FEATURES |
----------+
- prefs API:
+ . prefs_assign(content): assign json content as output var
+ . prefs_apply(prefs_new): apply new content to g_prefs and system
+ . prefs_load(content): load json content and apply to g_prefs and system
+
. prefs_save (save to the server the new prefs)
- . prefs_load (load prefs structure with a json)
- . prefs_apply (from server, and after prefs_save if success)
- preferences (listen into preferences)
. update values
$ret = sprintf('gst.st = %d; ', $user_step);
+ // for test: $prefs = new Client_prefs(USER_FLAG_LISTAUTH >> 2);
$prefs = new Client_prefs(($user->flags & USER_FLAG_MAP_AUTH) >> 2);
- $ret .= sprintf('var prefs_new = prefs_load(\'%s\'); console.log(prefs_new);', json_encode($prefs));
+ $ret .= sprintf('prefs_load(\'%s\');', json_encode($prefs));
- if ($user->flags & USER_FLAG_ISOLAUTH) {
- $ret .= 'list_set(\'isolation\', false, \''.$mlang_brisk['tit_onisol'][$G_lang].'\' ); ';
- }
- else if ($user->flags & USER_FLAG_LISTAUTH) {
- $ret .= 'list_set(\'auth\', false, \''.$mlang_brisk['tit_onauth'][$G_lang].'\' ); ';
- }
- else {
- $ret .= 'list_set(\'all\', false, \'\' ); ';
+ if(false) {
+ if ($user->flags & USER_FLAG_ISOLAUTH) {
+ $ret .= 'list_set(\'isolation\', false, \''.$mlang_brisk['tit_onisol'][$G_lang].'\' ); ';
+ }
+ else if ($user->flags & USER_FLAG_LISTAUTH) {
+ $ret .= 'list_set(\'auth\', false, \''.$mlang_brisk['tit_onauth'][$G_lang].'\' ); ';
+ }
+ else {
+ $ret .= 'list_set(\'all\', false, \'\' ); ';
+ }
}
if ($user->subst == 'standup')
'btn_sit' : { 'it' : 'Mi siedo.',
'en' : 'Sit down.' },
'btn_exit' : { 'it' : 'Esco.',
- 'en' : 'Exit.' }
-
- };
+ 'en' : 'Exit.' },
+ 'tit_list' : { '0' : { 'it' : '',
+ 'en' : '' },
+ '1' : { 'it' : '(solo aut.)',
+ 'en' : '(only aut.)' },
+ '2' : { 'it' : '(isolam.to)',
+ 'en' : '(isolation)' } }
+ };
function $(id) { return document.getElementById(id); }
var g_lng = "<? echo $G_lng; ?>";
var g_tables_n = <? echo TABLES_N; ?>;
var g_tables_auth_n = <? echo TABLES_AUTH_N; ?>;
+ var g_prefs, g_prefs_new = null;
var g_listen;
var g_withflash = false;
var g_is_spawn = 0;
window.onload = function() {
// alert(window.onbeforeunload);
g_brow = get_browser_agent();
+
+ g_prefs = new client_prefs();
+
spo_slide = new sideslide($('spon_caro'), 80, 20);
sup_slide = new sideslide($('supp_caro'), 80, 20);
var g_lng = "<? echo $G_lng; ?>";
var g_tables_n = <? echo TABLES_N; ?>;
var g_tables_auth_n = <? echo TABLES_AUTH_N; ?>;
+ var g_prefs, g_prefs_new = null;
var g_listen;
var tra = null;
var stat = "";
var topbanner_sfx, topbanner_dx;
// var nonunload = false;
var g_withflash = false;
- var g_imgct= 0;
+ var g_imgct = 0;
var g_imgtot = g_preload_img_arr.length;
var g_brow = null;
var spo_slide, sup_slide;
window.onload = function() {
g_brow = get_browser_agent();
+
+ g_prefs = new client_prefs();
+
spo_slide = new sideslide($('spon_caro'), 80, 20);
sup_slide = new sideslide($('supp_caro'), 80, 20);
<table style="border: 1px solid gray;"><tr><th style="background-color: #cccccc;">
<?php echo $mlang_room['itm_list'][$G_lang];?>
</th></tr>
-<tr><td><input style="vertical-align: bottom;" id="ra_listen_all" type="radio" name="listen" value="all" onclick="act_chatt(\'/listen all\');" title="'
+<tr><td><input style="vertical-align: bottom;" id="ra_listen_all" type="radio" name="listen" value="0" onclick="act_chatt(\'/listen all\');" title="'
<?php echo $mlang_room['listall_desc'][$G_lang];?>
'"><span id="list_all">
<?php echo $mlang_room['tit_listall'][$G_lang];?>
</span></td></tr>
-<tr><td><input style="vertical-align: bottom;" id="ra_listen_auth" type="radio" name="listen" value="auth" onclick="act_chatt(\'/listen auth\');" title="'
+<tr><td><input style="vertical-align: bottom;" id="ra_listen_auth" type="radio" name="listen" value="1" onclick="act_chatt(\'/listen auth\');" title="'
<?php echo $mlang_room['listaut_desc'][$G_lang];?>
'"><span id="list_auth">
<?php echo $mlang_room['tit_listaut'][$G_lang];?>
</span></td></tr>
-<tr><td><input style="vertical-align: bottom;" id="ra_listen_isol" type="radio" name="listen" value="isolation" onclick="act_chatt(\'/listen isolation\');" title="'
+<tr><td><input style="vertical-align: bottom;" id="ra_listen_isol" type="radio" name="listen" value="2" onclick="act_chatt(\'/listen isolation\');" title="'
<?php echo $mlang_room['listisol_desc'][$G_lang];?>
'"><span id="list_isol">
<?php echo $mlang_room['tit_listisol'][$G_lang];?>
/*
+
data = [ [ flags, name ], ... ]
*/
+
var l_list_all = 0x00;
var l_list_auth = 0x01;
var l_list_isol = 0x02;
+function client_prefs()
+{
+}
+
+client_prefs.prototype = {
+ listen: -1
+}
+
function state_add(flags)
{
var content = "", supercont = "";
return (false);
}
-function prefs_load(content)
+function prefs_assign(content)
{
var prefs_new;
var s;
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)
+{
+ if (typeof(g_prefs) == 'undefined')
+ return false;
+
+ /* listen management */
+ if (g_prefs.listen != prefs_new.listen) {
+ 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]) {
+ $('list_'+prefs_list_id[i]).style.color = 'red';
+ $('list_info').innerHTML = mlang_commons['tit_list'][i][g_lang];
+ }
+ else {
+ $('list_'+prefs_list_id[i]).style.color = 'black';
+ }
+ }
+
+ g_prefs.listen = prefs_new.listen;
+ relo = true;
+ }
+}
+
+function prefs_load(content)
+{
+ var prefs_new;
+
+ if ((prefs_new = prefs_assign(content)) == null)
+ return false;
+
+ return prefs_apply(prefs_new);
+}
function list_set(what, is_update, info)
{
- // console.log(what);
var i;
var relo = false;
var old_st = readCookie("CO_list");