2 var l_list_auth = 0x01;
3 var l_list_isol = 0x02;
4 var l_prefs_list_idx = new Array( 0x00, 0x01, 0x02 );
5 var l_prefs_list_id = new Array( "all", "auth", "isol" );
6 var l_comps_name = new Array('s_fg_r', 's_fg_g', 's_fg_b', 's_bg_r', 's_bg_g', 's_bg_b');
9 function client_prefs(old)
12 this.listen = old.listen;
13 this.supp_comp = old.supp_comp;
17 client_prefs.prototype = {
19 supp_comp: 'ff00ffff00'
22 function prefs_assign(content)
27 s = "prefs_new = " + content;
33 function prefs_apply(prefs_new, is_update, is_volat)
38 console.log('prefs_apply: begin');
40 if (typeof(g_prefs) == 'undefined')
42 /* listen management */
43 if (g_prefs.listen != prefs_new.listen || is_update) {
44 for (i = 0 ; i < l_prefs_list_idx.length ; i++) {
45 set_checked_value($('ra_listen_'+l_prefs_list_id[i]), prefs_new.listen);
46 if (prefs_new.listen == l_prefs_list_idx[i]) {
48 $('list_'+l_prefs_list_id[i]).style.color = 'red';
49 $('list_info').innerHTML = mlang_commons['tit_list'][i][g_lang];
53 $('list_'+l_prefs_list_id[i]).style.color = 'black';
60 // supporter component management
61 if (g_prefs.supp_comp != prefs_new.supp_comp || is_update) {
63 for (i = 0 ; i < 6 ; i++) {
64 $(l_comps_name[i]).value = parseInt(prefs_new.supp_comp.substr(i*2,2), 16);
66 $('s_img').src = 'suprend.php?comp='+prefs_new.supp_comp;
69 if (relo || !is_update) {
70 for (i = g_tables_appr_n ; i < g_tables_n ; i++) {
72 $('tr_noauth'+i).style.display = (prefs_new.listen == l_list_isol ? 'none' : '');
75 $('td_noauth'+i).style.display = (prefs_new.listen == l_list_isol ? 'none' : '');
77 if (prefs_new.listen == l_list_isol) {
85 // ricalculation of standup area
86 g_prefs.listen = prefs_new.listen;
88 console.log('here we are');
89 if (standup_data_old != null) {
90 console.log('here we are2');
91 standup_data = standup_data_old;
92 standup_data_old = null;
93 j_stand_cont(standup_data);
98 g_prefs.listen = prefs_new.listen;
99 g_prefs.supp_comp = prefs_new.supp_comp;
102 function prefs_load(content, is_update, is_volat)
106 // console.log('prefs_load('+content+')');
108 if ((prefs_new = prefs_assign(content)) == null)
111 return prefs_apply(prefs_new, is_update, is_volat);
114 function prefs_save()
118 if (typeof(g_prefs) == 'undefined')
121 ret = server_request('mesg', 'prefs|save','__POST__', 'prefs', JSON.stringify(g_prefs));
124 $('preferences').style.visibility = 'hidden';
131 function prefs_reset()
135 ret = server_request('mesg', 'prefs|reset');
138 function prefs_update(field)
143 // console.log("prefs_update("+field+")");
145 if (typeof(g_prefs) == 'undefined')
148 prefs_new = new client_prefs(g_prefs);
150 if (field == 'listen') {
151 /* listen management */
152 for (i = 0 ; i < l_prefs_list_idx.length ; i++) {
153 prefs_new.listen = get_checked_value($('ra_listen_'+l_prefs_list_id[i]));
154 if (prefs_new.listen != '')
158 else if (field == 'supp') {
159 for (i = 0 ; i < 6 ; i++) {
160 if (parseInt($(l_comps_name[i]).value) < 0 || parseInt($(l_comps_name[i]).value) > 255 ||
161 isNaN(parseInt($(l_comps_name[i]).value))) {
167 prefs_new.supp_comp = "";
168 for (i = 0 ; i < 6 ; i++) {
169 prefs_new.supp_comp += dec2hex(parseInt($(l_comps_name[i]).value), 2);
173 // console.log("prefs_update:: i break "+i+" ["+prefs_new.supp_comp+"]");
175 for (i = 0 ; i < 6 ; i++) {
176 $(l_comps_name[i]).value = parseInt(prefs_new.supp_comp.substr(i*2, 2), 16);
180 /* from form to struct */
181 prefs_apply(prefs_new, true, true);
184 function list_set(what, is_update, info)
188 var old_st = readCookie("CO_list");
190 if (what == 'auth') {
191 $('list_auth').style.color = 'red';
192 $('list_isol').style.color = 'black';
193 $('list_all').style.color = 'black';
194 if (old_st == 'isolation')
196 g_listen = l_list_auth;
198 else if (what == 'isolation') {
199 $('list_auth').style.color = 'black';
200 $('list_isol').style.color = 'red';
201 $('list_all').style.color = 'black';
202 if (old_st != 'isolation')
204 g_listen = l_list_isol;
207 $('list_auth').style.color = 'black';
208 $('list_isol').style.color = 'black';
209 $('list_all').style.color = 'red';
210 if (old_st == 'isolation')
212 g_listen = l_list_all;
215 set_checked_value($('ra_listen_auth'), what);
216 set_checked_value($('ra_listen_isol'), what);
217 set_checked_value($('ra_listen_all'), what);
219 $('list_info').innerHTML = info;
221 createCookie("CO_list", what, 24*365, cookiepath);
225 if (relo || !is_update) {
226 for (i = g_tables_appr_n ; i < g_tables_n ; i++) {
229 $('tr_noauth'+i).style.display = (what == 'isolation' ? 'none' : '');
232 $('td_noauth'+i).style.display = (what == 'isolation' ? 'none' : '');
234 if (what == 'isolation') {
242 // ricalculation of standup area
243 if (standup_data_old != null) {
244 standup_data = standup_data_old;
245 standup_data_old = null;
246 j_stand_cont(standup_data);