*
*/
+var mlang_prefsf = { 'btn_close' : { 'it' : 'Chiudi.',
+ 'en' : 'Close.' },
+ 'tit_list' : { '0' : { 'it' : '',
+ 'en' : '' },
+ '1' : { 'it' : '(solo aut.)',
+ 'en' : '(only aut.)' },
+ '2' : { 'it' : '(isolam.to)',
+ 'en' : '(isolation)' } }
+ };
+
var mlang_prefsn = { 'btn_close' : { 'it' : 'Chiudi.',
'en' : 'Close.' },
'tit_list' : { '0' : { 'it' : '',
if (g_prefsn.data == null || g_prefsn.data.listen != field.value) {
$('list_info').innerHTML = mlang_prefsn['tit_list'][field.value][g_lang];
console.log('update listen');
- for (i = g_tables_auth_n ; i < g_tables_n ; i++) {
+ for (i = g_tables_cert_n + g_tables_auth_n ; i < g_tables_n ; i++) {
if (i % 4 == 0) {
$('tr_noauth'+i).style.display = (field.value == l_list_isol ? 'none' : '');
}
}
}
-Prefsn.supp_change_cb = function(field)
+function obj_clone(obj) // begin = {} or [] is optional
{
- var i;
- var prefs_new;
- var relo = false;
- console.log("prefs_update("+field+")");
- return;
- if (typeof(g_prefsn) == 'undefined')
- return false;
+ var ret, ty, begin;
+
+ if (arguments.length > 1)
+ begin = arguments[1];
+ else
+ begin = {};
+
+ for (i in obj) {
+ ty = typeof(obj[i]);
- for (i = 0 ; i < 6 ; i++) {
- if (parseInt($(l_comps_name[i]).value) < 0 || parseInt($(l_comps_name[i]).value) > 255 ||
- isNaN(parseInt($(l_comps_name[i]).value))) {
- break;
+ if (ty == 'object') {
+ if (obj[i].constructor == Array) {
+ ret[i] = obj_clone(obj[i], []);
+ }
+ else {
+ ret[i] = obj_clone(obj[i], {});
+ }
+ }
+ else {
+ ret[i] = obj[i];
}
}
+ return ret;
+}
- if (i == 6) {
- prefs_new.supp_comp = "";
- for (i = 0 ; i < 6 ; i++) {
- prefs_new.supp_comp += dec2hex(parseInt($(l_comps_name[i]).value), 2);
+function obj_update(cur, delta)
+{
+ for (i in cur) {
+ if (i in delta) {
+ ty = typeof(cur[i]);
+ if (ty == 'object') {
+ obj_update(cur[i], delta[i]);
+ }
+ else {
+ cur[i] = delta[i];
+ }
}
}
+}
- // console.log("prefs_update:: i break "+i+" ["+prefs_new.supp_comp+"]");
+Prefsn.supp_change_cb = function(field)
+{
+ var i;
+ var supp_new;
+ var relo = false;
- for (i = 0 ; i < 6 ; i++) {
- $(l_comps_name[i]).value = parseInt(prefs_new.supp_comp.substr(i*2, 2), 16);
+ if (g_prefsn == null)
+ return false;
+
+ supp_new = Fieldify.item2tree([g_prefsn.obj], field);
+ supp_cur = {};
+ console.log(g_prefsn.data.fg);
+ supp_cur['fg'] = obj_clone(g_prefsn.data.fg);
+ supp_cur['bg'] = obj_clone(g_prefsn.data.bg);
+
+ for (i in ['fg', 'bg']) {
+ if (! i in supp_new) {
+ continue;
+ }
+ obj_update(supp_cur[i], supp_new[i]);
}
- /* from form to struct */
- // prefs_apply(prefs_new, true, true);
+ var col, ct = 0, s = "";
+ for (col in [ 'fg', 'bg' ]) {
+ for (cmp in [ 'r', 'g', 'b' ]) {
+ var val_s = supp_cur[col][cmp];
+ if (parseInt(val_s) < 0 || parseInt(val_s) > 255 || isNaN(parseInt(val_s)))
+ return false;
+ }
+ s += dec2hex(parseInt(val_s), 2);
+ }
+ $('s_img').src = 'suprend.php?comp=' + s;
};
prefsn = prefsn_fld($('prefsn'));
prefsn.json2dom(prefsn_in);
prefsn.visible(true);
- }
+ }
else {
var noti = new notify(gst, prefsn_in.mesg, 0, mlang_prefsn['btn_close'][g_lang], 400, 150);
}
}
}
}
+
+var g_prefsf = null;
+function g_prefsf_listen_cb(item)
+{
+ var whats = [ 'all', 'auth', 'isolation' ];
+ var what = whats[item.value];
+
+ console.log("change listen", item.value);
+
+ $('list_info').innerHTML = mlang_prefsf.tit_list[item.value][g_lang];
+
+ for (i = g_tables_cert_n + g_tables_auth_n ; i < g_tables_n ; i++) {
+ if (i % 4 == 0) {
+ $('tr_noauth'+i).style.display = (what == 'isolation' ? 'none' : '');
+ }
+ $('td_noauth'+i).style.display = (what == 'isolation' ? 'none' : '');
+ }
+ if (what == 'isolation') {
+ tra.hide_noauth();
+ }
+ else {
+ tra.show_noauth();
+ }
+}
+
+function g_prefsf_comps_cb(item, type)
+{
+ console.log(item);
+ console.log(g_prefsf);
+
+ var col, ct = 0, s = "";
+ var col_arr = [ 'fg', 'bg' ];
+ var cmp_arr = [ 'r', 'g', 'b' ];
+ for (col in col_arr) {
+ for (cmp in cmp_arr) {
+ console.log(g_prefsf.bsk_comps[col_arr[col]][cmp_arr[cmp]].value);
+ var val_s = g_prefsf.bsk_comps[col_arr[col]][cmp_arr[cmp]].value;
+ if (parseInt(val_s) < 0 || parseInt(val_s) > 255 || isNaN(parseInt(val_s)))
+ return false;
+ s += dec2hex(parseInt(val_s), 2);
+ }
+ console.log("sub: [" + s + "]");
+ }
+ $('s_img').src = 'suprend.php?comp=' + s;
+}
+
+function prefsf_status_cb(st)
+{
+ // console.log('status_show HERE ' + st);
+ switch(st) {
+ case Fieldify.STATUS_OK:
+ $('prefsf-status-flag').src = 'img/light-green.png';
+ break;
+ case Fieldify.STATUS_PROC:
+ $('prefsf-status-flag').src = 'img/light-orange.png';
+ break;
+ default: // Fieldify.STATUS_ERR
+ $('prefsf-status-flag').src = 'img/light-red.png';
+ break;
+ }
+}
+
+function prefsf_initialize()
+{
+ clie_cb = { 'listen': { cb: g_prefsf_listen_cb, type: "fast" },
+ 'fg': { 'r': { cb: g_prefsf_comps_cb, type: "fast"},
+ 'g': { cb: g_prefsf_comps_cb, type: "fast"},
+ 'b': { cb: g_prefsf_comps_cb, type: "fast"}},
+ 'bg': { 'r': { cb: g_prefsf_comps_cb, type: "fast"},
+ 'g': { cb: g_prefsf_comps_cb, type: "fast"},
+ 'b': { cb: g_prefsf_comps_cb, type: "fast"}}};
+ g_prefsf = new Fieldify(null, null, null, clie_cb, "prefsf", [$("prefsf")], prefsf_status_cb);
+ g_prefsf.bsk_comps = { 'bg': { 'r': $C('bg_r') != undefined ? $C('bg_r')[0] : null,
+ 'g': $C('bg_g') != undefined ? $C('bg_g')[0] : null,
+ 'b': $C('bg_b') != undefined ? $C('bg_b')[0] : null },
+ 'fg': { 'r': $C('fg_r') != undefined ? $C('fg_r')[0] : null,
+ 'g': $C('fg_g') != undefined ? $C('fg_g')[0] : null,
+ 'b': $C('fg_b') != undefined ? $C('fg_b')[0] : null} };
+}