2 var l_list_isol = 0x02;
3 var l_prefs_list_idx = new Array( 0x00, 0x02 );
4 var l_prefs_list_id = new Array( "all", "isol" );
5 var l_comps_name = new Array('s_fg_r', 's_fg_g', 's_fg_b', 's_bg_r', 's_bg_g', 's_bg_b');
8 function client_prefs(old)
11 this.listen = old.listen;
12 this.supp_comp = old.supp_comp;
16 client_prefs.prototype = {
18 supp_comp: 'ff00ffff00'
21 function prefs_assign(content)
26 s = "prefs_new = " + content;
32 function prefs_apply(prefs_new, is_update, is_volat)
37 if (typeof(g_prefs) == 'undefined')
39 /* listen management */
40 if (g_prefs.listen != prefs_new.listen || is_update) {
41 for (i = 0 ; i < l_prefs_list_idx.length ; i++) {
42 set_checked_value($('ra_listen_'+l_prefs_list_id[i]), prefs_new.listen);
43 if (prefs_new.listen == l_prefs_list_idx[i]) {
45 $('list_'+l_prefs_list_id[i]).style.color = 'red';
46 $('list_info').innerHTML = mlang_commons['tit_list'][i][g_lang];
50 $('list_'+l_prefs_list_id[i]).style.color = 'black';
57 // supporter component management
58 if (g_prefs.supp_comp != prefs_new.supp_comp || is_update) {
60 for (i = 0 ; i < 6 ; i++) {
61 $(l_comps_name[i]).value = parseInt(prefs_new.supp_comp.substr(i*2,2), 16);
63 $('s_img').src = 'suprend.php?comp='+prefs_new.supp_comp;
66 if (relo || !is_update) {
67 for (i = g_tables_appr_n ; i < g_tables_n ; i++) {
69 $('tr_noauth'+i).style.display = (prefs_new.listen == l_list_isol ? 'none' : '');
72 $('td_noauth'+i).style.display = (prefs_new.listen == l_list_isol ? 'none' : '');
74 if (prefs_new.listen == l_list_isol) {
82 // ricalculation of standup area
83 if (standup_data_old != null) {
84 standup_data = standup_data_old;
85 standup_data_old = null;
86 j_stand_cont(standup_data);
91 g_prefs.listen = prefs_new.listen;
92 g_prefs.supp_comp = prefs_new.supp_comp;
95 function prefs_load(content, is_update, is_volat)
99 // console.log('prefs_load('+content+')');
101 if ((prefs_new = prefs_assign(content)) == null)
104 return prefs_apply(prefs_new, is_update, is_volat);
107 function prefs_save()
111 if (typeof(g_prefs) == 'undefined')
114 ret = server_request('mesg', 'prefs|save','__POST__', 'prefs', JSON.stringify(g_prefs));
117 $('preferences').style.visibility = 'hidden';
124 function prefs_reset()
128 ret = server_request('mesg', 'prefs|reset');
131 function prefs_update(field)
136 // console.log("prefs_update("+field+")");
138 if (typeof(g_prefs) == 'undefined')
141 prefs_new = new client_prefs(g_prefs);
143 if (field == 'listen') {
144 /* listen management */
145 for (i = 0 ; i < l_prefs_list_idx.length ; i++) {
146 prefs_new.listen = get_checked_value($('ra_listen_'+l_prefs_list_id[i]));
147 if (prefs_new.listen != '')
151 else if (field == 'supp') {
152 for (i = 0 ; i < 6 ; i++) {
153 if (parseInt($(l_comps_name[i]).value) < 0 || parseInt($(l_comps_name[i]).value) > 255 ||
154 isNaN(parseInt($(l_comps_name[i]).value))) {
160 prefs_new.supp_comp = "";
161 for (i = 0 ; i < 6 ; i++) {
162 prefs_new.supp_comp += dec2hex(parseInt($(l_comps_name[i]).value), 2);
166 // console.log("prefs_update:: i break "+i+" ["+prefs_new.supp_comp+"]");
168 for (i = 0 ; i < 6 ; i++) {
169 $(l_comps_name[i]).value = parseInt(prefs_new.supp_comp.substr(i*2, 2), 16);
173 /* from form to struct */
174 prefs_apply(prefs_new, true, true);
177 function list_set(what, is_update, info)
181 var old_st = readCookie("CO_list");
183 if (what == 'isolation') {
184 $('list_isol').style.color = 'red';
185 $('list_all').style.color = 'black';
186 if (old_st != 'isolation')
188 g_listen = l_list_isol;
191 $('list_isol').style.color = 'black';
192 $('list_all').style.color = 'red';
193 if (old_st == 'isolation')
195 g_listen = l_list_all;
198 set_checked_value($('ra_listen_isol'), what);
199 set_checked_value($('ra_listen_all'), what);
201 $('list_info').innerHTML = info;
203 createCookie("CO_list", what, 24*365, cookiepath);
207 if (relo || !is_update) {
208 for (i = g_tables_appr_n ; i < g_tables_n ; i++) {
211 $('tr_noauth'+i).style.display = (what == 'isolation' ? 'none' : '');
214 $('td_noauth'+i).style.display = (what == 'isolation' ? 'none' : '');
216 if (what == 'isolation') {
224 // ricalculation of standup area
225 if (standup_data_old != null) {
226 standup_data = standup_data_old;
227 standup_data_old = null;
228 j_stand_cont(standup_data);