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';
125 function prefs_reset()
129 ret = server_request('mesg', 'prefs|reset');
132 function prefs_update(field)
137 // console.log("prefs_update("+field+")");
139 if (typeof(g_prefs) == 'undefined')
142 prefs_new = new client_prefs(g_prefs);
144 if (field == 'listen') {
145 /* listen management */
146 for (i = 0 ; i < l_prefs_list_idx.length ; i++) {
147 prefs_new.listen = get_checked_value($('ra_listen_'+l_prefs_list_id[i]));
148 if (prefs_new.listen != '')
152 else if (field == 'supp') {
153 for (i = 0 ; i < 6 ; i++) {
154 if (parseInt($(l_comps_name[i]).value) < 0 || parseInt($(l_comps_name[i]).value) > 255 ||
155 isNaN(parseInt($(l_comps_name[i]).value))) {
161 prefs_new.supp_comp = "";
162 for (i = 0 ; i < 6 ; i++) {
163 prefs_new.supp_comp += dec2hex(parseInt($(l_comps_name[i]).value), 2);
167 // console.log("prefs_update:: i break "+i+" ["+prefs_new.supp_comp+"]");
169 for (i = 0 ; i < 6 ; i++) {
170 $(l_comps_name[i]).value = parseInt(prefs_new.supp_comp.substr(i*2, 2), 16);
174 /* from form to struct */
175 prefs_apply(prefs_new, true, true);
178 function list_set(what, is_update, info)
182 var old_st = readCookie("CO_list");
184 if (what == 'auth') {
185 $('list_auth').style.color = 'red';
186 $('list_isol').style.color = 'black';
187 $('list_all').style.color = 'black';
188 if (old_st == 'isolation')
190 g_listen = l_list_auth;
192 else if (what == 'isolation') {
193 $('list_auth').style.color = 'black';
194 $('list_isol').style.color = 'red';
195 $('list_all').style.color = 'black';
196 if (old_st != 'isolation')
198 g_listen = l_list_isol;
201 $('list_auth').style.color = 'black';
202 $('list_isol').style.color = 'black';
203 $('list_all').style.color = 'red';
204 if (old_st == 'isolation')
206 g_listen = l_list_all;
209 set_checked_value($('ra_listen_auth'), what);
210 set_checked_value($('ra_listen_isol'), what);
211 set_checked_value($('ra_listen_all'), what);
213 $('list_info').innerHTML = info;
215 createCookie("CO_list", what, 24*365, cookiepath);
219 if (relo || !is_update) {
220 for (i = g_tables_auth_n ; i < g_tables_n ; i++) {
223 $('tr_noauth'+i).style.display = (what == 'isolation' ? 'none' : '');
226 $('td_noauth'+i).style.display = (what == 'isolation' ? 'none' : '');
228 if (what == 'isolation') {
236 // ricalculation of standup area
237 if (standup_data_old != null) {
238 standup_data = standup_data_old;
239 standup_data_old = null;
240 j_stand_cont(standup_data);