-var l_list_all = 0x00;
+/*
+ * brisk - prefs.js
+ *
+ * Copyright (C) 2015 Matteo Nastasi
+ * mailto: nastasi@alternativeoutput.it
+ * matteo.nastasi@milug.org
+ * web: http://www.alternativeoutput.it
+ *
+ * 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 2 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
+ * MERCHANTABLILITY 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, write to the Free Software Foundation, Inc, 59 Temple Place -
+ * Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+var mlang_prefsn = { '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 l_list_all = 0x00;
var l_list_auth = 0x01;
var l_list_isol = 0x02;
+var l_prefs_list_idx = new Array( 0x00, 0x01, 0x02 );
+var l_prefs_list_id = new Array( "all", "auth", "isol" );
+var l_comps_name = new Array('s_fg_r', 's_fg_g', 's_fg_b', 's_bg_r', 's_bg_g', 's_bg_b');
+
+/* FIXME: move to html page with dynamic valorization */
+var is_supp_custom = true;
+
+function Prefsn(obj)
+{
+ var fields = { listen: { type: 'radio', cb: Prefsn.listen_change_cb } };
+ if (is_supp_custom) {
+ fields.fg = {
+ type: 'fields', fields: { r: { type: 'value' },
+ g: { type: 'value' },
+ b: { type: 'value' }
+ }
+ };
+ fields.bg = {
+ type: 'fields', fields: { r: { type: 'value' },
+ g: { type: 'value' },
+ b: { type: 'value' }
+ }
+ };
+ }
+
+ this.fieldify = new Fieldify([obj], fields);
+ this.obj = obj;
+ this.data = null;
+}
+
+Prefsn.listen_change_cb = function(field)
+{
+ var i;
+ var prefs_new;
+ var relo = false;
+
+ console.log("listen_change_cb:" + field.value);
+ console.log("xx" + g_prefsn.data);
+
+ /* listen management */
+ 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++) {
+ if (i % 4 == 0) {
+ $('tr_noauth'+i).style.display = (field.value == l_list_isol ? 'none' : '');
+ }
+
+ $('td_noauth'+i).style.display = (field.value == l_list_isol ? 'none' : '');
+ }
+ if (field.value == l_list_isol) {
+ tra.hide_noauth();
+ }
+ else {
+ tra.show_noauth();
+ }
+ }
+}
+
+Prefsn.supp_change_cb = function(field)
+{
+ var i;
+ var prefs_new;
+ var relo = false;
+ // console.log("prefs_update("+field+")");
+
+ if (typeof(g_prefsn) == 'undefined')
+ return false;
+
+ 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 (i == 6) {
+ prefs_new.supp_comp = "";
+ for (i = 0 ; i < 6 ; i++) {
+ prefs_new.supp_comp += dec2hex(parseInt($(l_comps_name[i]).value), 2);
+ }
+ }
+
+ // console.log("prefs_update:: i break "+i+" ["+prefs_new.supp_comp+"]");
+
+ for (i = 0 ; i < 6 ; i++) {
+ $(l_comps_name[i]).value = parseInt(prefs_new.supp_comp.substr(i*2, 2), 16);
+ }
+
+ /* from form to struct */
+ // prefs_apply(prefs_new, true, true);
+};
+
+
+
+Prefsn.prototype = {
+ obj: null,
+ fieldify: null,
+ data: null,
+
+ load: function(data) {
+ var in_data = JSON.parse(data);
+ this.fieldify.json2dom(in_data);
+ this.data = in_data;
+ },
+
+ reset: function() {
+ console.log('here');
+ Fieldify.reset(this.obj);
+ },
+
+ show: function() {
+ this.fieldify.visible(true);
+ }
+}
+
+function prefsn_show(username)
+{
+ var prefsn_in_in = server_request('index_wr.php', sess, 'mesg', 'chatt|/prefsn');
+ var prefsn_in = JSON.parse(prefsn_in_in);
+ var prefsn = null;
+
+ if (prefsn_in.ret == 0) {
+ 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);
+ }
+}
+
+function prefsn_reset()
+{
+ Fieldify.reset($('prefsn'));
+}
+
+
+
+
+
+
function client_prefs(old)
{
return (prefs_new);
}
-var prefs_list_idx = new Array( 0x00, 0x01, 0x02 );
-var prefs_list_id = new Array( "all", "auth", "isol" );
-
function prefs_apply(prefs_new, is_update, is_volat)
{
var i;
return false;
/* listen management */
if (g_prefs.listen != prefs_new.listen || is_update) {
- for (i = 0 ; i < prefs_list_idx.length ; i++) {
- set_checked_value($('ra_listen_'+prefs_list_id[i]), prefs_new.listen);
- if (prefs_new.listen == prefs_list_idx[i]) {
+ for (i = 0 ; i < l_prefs_list_idx.length ; i++) {
+ set_checked_value($('ra_listen_'+l_prefs_list_id[i]), prefs_new.listen);
+ if (prefs_new.listen == l_prefs_list_idx[i]) {
if (!is_volat)
- $('list_'+prefs_list_id[i]).style.color = 'red';
- $('list_info').innerHTML = mlang_commons['tit_list'][i][g_lang];
+ $('list_'+l_prefs_list_id[i]).style.color = 'red';
+ $('list_info').innerHTML = mlang_prefsn['tit_list'][i][g_lang];
}
else {
if (!is_volat)
- $('list_'+prefs_list_id[i]).style.color = 'black';
+ $('list_'+l_prefs_list_id[i]).style.color = 'black';
}
}
// supporter component management
if (g_prefs.supp_comp != prefs_new.supp_comp || is_update) {
+
+ for (i = 0 ; i < 6 ; i++) {
+ $(l_comps_name[i]).value = parseInt(prefs_new.supp_comp.substr(i*2,2), 16);
+ }
$('s_img').src = 'suprend.php?comp='+prefs_new.supp_comp;
}
if (typeof(g_prefs) == 'undefined')
return false;
- ret = server_request('mesg', 'prefs','__POST__', 'prefs', JSON.stringify(g_prefs));
+ ret = server_request('index_wr.php', sess, 'mesg', 'prefs|save','__POST__', 'prefs', JSON.stringify(g_prefs));
- if (ret == 1)
+ if (ret == 1) {
$('preferences').style.visibility = 'hidden';
+ }
+ else {
+ alert(ret);
+ }
+}
+
+function prefs_reset()
+{
+ var ret;
+
+ ret = server_request('index_wr.php', sess, 'mesg', 'prefs|reset');
}
function prefs_update(field)
var i;
var prefs_new;
var relo = false;
-
// console.log("prefs_update("+field+")");
if (typeof(g_prefs) == 'undefined')
if (field == 'listen') {
/* listen management */
- for (i = 0 ; i < prefs_list_idx.length ; i++) {
- prefs_new.listen = get_checked_value($('ra_listen_'+prefs_list_id[i]));
+ for (i = 0 ; i < l_prefs_list_idx.length ; i++) {
+ prefs_new.listen = get_checked_value($('ra_listen_'+l_prefs_list_id[i]));
if (prefs_new.listen != '')
break;
}
}
else if (field == 'supp') {
- prefs_new.supp_comp = "" + dec2hex($('s_fg_r').value, 2) + dec2hex($('s_fg_g').value, 2) + dec2hex($('s_fg_b').value, 2) + dec2hex($('s_bg_r').value, 2) + dec2hex($('s_bg_g').value, 2) + dec2hex($('s_bg_b').value, 2);
+ 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 (i == 6) {
+ prefs_new.supp_comp = "";
+ for (i = 0 ; i < 6 ; i++) {
+ prefs_new.supp_comp += dec2hex(parseInt($(l_comps_name[i]).value), 2);
+ }
+ }
+
+ // console.log("prefs_update:: i break "+i+" ["+prefs_new.supp_comp+"]");
+
+ for (i = 0 ; i < 6 ; i++) {
+ $(l_comps_name[i]).value = parseInt(prefs_new.supp_comp.substr(i*2, 2), 16);
+ }
}
/* from form to struct */
var i;
var relo = false;
var old_st = readCookie("CO_list");
-
+
if (what == 'auth') {
$('list_auth').style.color = 'red';
$('list_isol').style.color = 'black';
if (relo || !is_update) {
for (i = 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') {
else {
tra.show_noauth();
}
-
+
if (false) {
// ricalculation of standup area
if (standup_data_old != null) {