/*
* This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
*/
var cat_count=0;
var cat_active=-1;
var info_cats=[];
var tmpids;
var kv_count=0;
function print()
{
var x = "[";
var i;
for(i=0; i');
o.append($('
'+text+'
'));
info_cats.push({ "title" : text, "id" : n, "content" : val});
$('#input_1_cat_list').append(o);
$('#input_1_cat').val("");
}
function info_cat_rename()
{
if(cat_active<0) return;
var cat = info_get_active_cat_index(cat_active);
var text = $('#input_1_cat_rename').val();
$("#input_1_cat_"+cat_active).html($('
'+text+'
'));
info_cats[cat].title=text;
}
// [index, key, value]
function info_get_kv_index(icat, kv)
{
if(icat<0) return;
var i;
for( i=0; i
'+key+'
'));
vp.append($('
'+value+'
'));
$('#input_1_kv_valid_'+index).removeClass('glyphicon-ok');
$('#input_1_kv_valid_'+index).addClass('glyphicon-pencil');
}else
{
kp.append($(''));
vp.append($(''));
$('#input_1_kv_valid_'+index).removeClass('glyphicon-pencil');
$('#input_1_kv_valid_'+index).addClass('glyphicon-ok');
}
console.log("KV Valid: val='"+JSON.stringify(info_cats[cat].content)+"'");
}
function info_kv_del(index)
{
if(cat_active<0) return;
var cat = info_get_active_cat_index(cat_active);
var kv = info_get_kv_index(cat, index);
if(kv<0)
{
$('#input_1_kv_'+index).remove();
return;
}
$('#input_1_kv_'+info_cats[cat].content[kv][0]).remove();
info_cats[cat].content.splice(kv, 1);
}
function info_kv_add(i, k, v)
{
i = (typeof i === 'undefined') ? -1 : i;
k = (typeof k === 'undefined') ? '' : k;
v = (typeof v === 'undefined') ? '' : v;
console.log("i="+i+", v="+k+", v="+v);
if(cat_active<0) return;
var nb;
if(i<0) nb=(kv_count++);
else
{
if(i>kv_count) kv_count=i;
nb=i;
}
console.log("N="+nb);
var disable=(i==-1)?"":"disabled=true";
var o = $("");
if(i==-1)o.append($(''));
else o.append($('
'+k+'
'));
if(i==-1)o.append($(''));
else o.append($('
'+v+'
'));
if(i==-1) o.append($(''));
else o.append($(''));
o.append($(''));
$('#input_1_kv_list').append(o);
}
function info_kv_show()
{
var cat = info_get_active_cat_index(cat_active);
var i;
$('#input_1_kv_list').empty();
$('#input_1_cat_rename').val($($("#input_1_cat_"+cat_active).html()).html());
for(i=0; i