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 if (typeof(g_prefs) == 'undefined')
40 /* listen management */
41 if (g_prefs.listen != prefs_new.listen || is_update) {
42 for (i = 0 ; i < l_prefs_list_idx.length ; i++) {
43 set_checked_value($('ra_listen_'+l_prefs_list_id[i]), prefs_new.listen);
44 if (prefs_new.listen == l_prefs_list_idx[i]) {
46 $('list_'+l_prefs_list_id[i]).style.color = 'red';
47 $('list_info').innerHTML = mlang_commons['tit_list'][i][g_lang];
51 $('list_'+l_prefs_list_id[i]).style.color = 'black';
58 // supporter component management
59 if (g_prefs.supp_comp != prefs_new.supp_comp || is_update) {
61 for (i = 0 ; i < 6 ; i++) {
62 $(l_comps_name[i]).value = parseInt(prefs_new.supp_comp.substr(i*2,2), 16);
64 $('s_img').src = 'suprend.php?comp='+prefs_new.supp_comp;
67 if (relo || !is_update) {
68 for (i = g_tables_auth_n ; i < g_tables_n ; i++) {
70 $('tr_noauth'+i).style.display = (prefs_new.listen == l_list_isol ? 'none' : '');
73 $('td_noauth'+i).style.display = (prefs_new.listen == l_list_isol ? 'none' : '');
75 if (prefs_new.listen == l_list_isol) {
83 // ricalculation of standup area
84 if (standup_data_old != null) {
85 standup_data = standup_data_old;
86 standup_data_old = null;
87 j_stand_cont(standup_data);
92 g_prefs.listen = prefs_new.listen;
93 g_prefs.supp_comp = prefs_new.supp_comp;
96 function prefs_load(content, is_update, is_volat)
100 // console.log('prefs_load('+content+')');
102 if ((prefs_new = prefs_assign(content)) == null)
105 return prefs_apply(prefs_new, is_update, is_volat);
108 function prefs_save()
112 if (typeof(g_prefs) == 'undefined')
115 ret = server_request('mesg', 'prefs|save','__POST__', 'prefs', JSON.stringify(g_prefs));
118 $('preferences').style.visibility = 'hidden';
121 function prefs_reset()
125 ret = server_request('mesg', 'prefs|reset');
128 function prefs_update(field)
133 // console.log("prefs_update("+field+")");
135 if (typeof(g_prefs) == 'undefined')
138 prefs_new = new client_prefs(g_prefs);
140 if (field == 'listen') {
141 /* listen management */
142 for (i = 0 ; i < l_prefs_list_idx.length ; i++) {
143 prefs_new.listen = get_checked_value($('ra_listen_'+l_prefs_list_id[i]));
144 if (prefs_new.listen != '')
148 else if (field == 'supp') {
149 for (i = 0 ; i < 6 ; i++) {
150 if (parseInt($(l_comps_name[i]).value) < 0 || parseInt($(l_comps_name[i]).value) > 255 ||
151 isNaN(parseInt($(l_comps_name[i]).value))) {
157 prefs_new.supp_comp = "";
158 for (i = 0 ; i < 6 ; i++) {
159 prefs_new.supp_comp += dec2hex(parseInt($(l_comps_name[i]).value), 2);
163 // console.log("prefs_update:: i break "+i+" ["+prefs_new.supp_comp+"]");
165 for (i = 0 ; i < 6 ; i++) {
166 $(l_comps_name[i]).value = parseInt(prefs_new.supp_comp.substr(i*2, 2), 16);
170 /* from form to struct */
171 prefs_apply(prefs_new, true, true);
174 function list_set(what, is_update, info)
178 var old_st = readCookie("CO_list");
180 if (what == 'auth') {
181 $('list_auth').style.color = 'red';
182 $('list_isol').style.color = 'black';
183 $('list_all').style.color = 'black';
184 if (old_st == 'isolation')
186 g_listen = l_list_auth;
188 else if (what == 'isolation') {
189 $('list_auth').style.color = 'black';
190 $('list_isol').style.color = 'red';
191 $('list_all').style.color = 'black';
192 if (old_st != 'isolation')
194 g_listen = l_list_isol;
197 $('list_auth').style.color = 'black';
198 $('list_isol').style.color = 'black';
199 $('list_all').style.color = 'red';
200 if (old_st == 'isolation')
202 g_listen = l_list_all;
205 set_checked_value($('ra_listen_auth'), what);
206 set_checked_value($('ra_listen_isol'), what);
207 set_checked_value($('ra_listen_all'), what);
209 $('list_info').innerHTML = info;
211 createCookie("CO_list", what, 24*365, cookiepath);
215 if (relo || !is_update) {
216 for (i = g_tables_auth_n ; i < g_tables_n ; i++) {
219 $('tr_noauth'+i).style.display = (what == 'isolation' ? 'none' : '');
222 $('td_noauth'+i).style.display = (what == 'isolation' ? 'none' : '');
224 if (what == 'isolation') {
232 // ricalculation of standup area
233 if (standup_data_old != null) {
234 standup_data = standup_data_old;
235 standup_data_old = null;
236 j_stand_cont(standup_data);