// for test: $prefs = new Client_prefs(USER_FLAG_LISTAUTH >> 2);
$prefs = new Client_prefs(($user->flags & USER_FLAG_MAP_AUTH) >> 2);
- $ret .= sprintf('prefs_load(\'%s\');', json_encode($prefs));
+ $ret .= sprintf('prefs_load(\'%s\', false, false);', json_encode($prefs));
if(false) {
if ($user->flags & USER_FLAG_ISOLAUTH) {
}
/*
- request to server
+ sync request to server
server_request([arg0=arg1[, arg2=arg3[, ...]]])
+ if var name == '__POST__' than all other vars will be managed as POST content
+ and the call will be a POST
*/
function server_request()
{
var xhr_wr = createXMLHttpRequest();
- var i, collect = "";
+ var i, collect = "", post_collect = null, is_post = false;
if (arguments.length > 0) {
for (i = 0 ; i < arguments.length ; i+= 2) {
- collect += (i == 0 ? "" : "&") + arguments[i] + "=" + encodeURIComponent(arguments[i+1]);
+ if (arguments[i] == "__POST__") {
+ is_post = true;
+ post_collect = "";
+ i -= 1;
+ continue;
+ }
+ if (is_post)
+ post_collect += (post_collect == "" ? "" : "&") + arguments[i] + "=" + encodeURIComponent(arguments[i+1]);
+ else
+ collect += (i == 0 ? "" : "&") + arguments[i] + "=" + encodeURIComponent(arguments[i+1]);
}
}
// alert("Args: "+arguments.length);
// console.log("server_request:preresp: "+xhr_wr.responseText);
- xhr_wr.open('GET', 'index_wr.php?'+(is_conn ? 'sess='+sess+'&' : '')+collect, false);
+ if (is_post) {
+ xhr_wr.open('POST', 'index_wr.php?'+(is_conn ? 'sess='+sess+'&' : '')+collect, false);
+ xhr_wr.setRequestHeader("Content-type","application/x-www-form-urlencoded");
+ }
+ else {
+ xhr_wr.open('GET', 'index_wr.php?'+(is_conn ? 'sess='+sess+'&' : '')+collect, false);
+ }
xhr_wr.onreadystatechange = function() { return; };
- xhr_wr.send(null);
+ xhr_wr.send(post_collect);
if (xhr_wr.responseText != null) {
// console.log("server_request:resp: "+xhr_wr.responseText);
'en' => 'back to tables'),
'btn_exit' => array('it' => 'Esco.',
'en' => 'Exit.'),
- 'btn_prefs_update' => array('it' => 'Salva.',
+ 'btn_prefs_save' => array('it' => 'Salva.',
'en' => 'Save.'),
'btn_prefs_close' => array('it' => 'Chiudi.',
'en' => 'Close.'),
<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="0" onclick="act_chatt(\'/listen all\');" title="'
+<tr><td><input style="vertical-align: bottom;" id="ra_listen_all" type="radio" name="listen" value="0" onclick="prefs_update();" 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="1" onclick="act_chatt(\'/listen auth\');" title="'
+<tr><td><input style="vertical-align: bottom;" id="ra_listen_auth" type="radio" name="listen" value="1" onclick="prefs_update();" 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="2" onclick="act_chatt(\'/listen isolation\');" title="'
+<tr><td><input style="vertical-align: bottom;" id="ra_listen_isol" type="radio" name="listen" value="2" onclick="prefs_update();" title="'
<?php echo $mlang_room['listisol_desc'][$G_lang];?>
'"><span id="list_isol">
<?php echo $mlang_room['tit_listisol'][$G_lang];?>
</div>
-<div class="notify_clo"><input type="submit" class="input_sub" style="bottom: 4px;" onclick="$('preferences').style.visibility = 'hidden';" value="<?php echo $mlang_room['btn_prefs_close'][$G_lang]; ?>"/> <input type="submit" class="input_sub" style="bottom: 4px;" onclick="act_preferences_update();" value="<?php echo $mlang_room['btn_prefs_update'][$G_lang]; ?>"/></div>
+<div class="notify_clo"><input type="submit" class="input_sub" style="bottom: 4px;" onclick="$('preferences').style.visibility = 'hidden';" value="<?php echo $mlang_room['btn_prefs_close'][$G_lang]; ?>"/> <input type="submit" class="input_sub" style="bottom: 4px;" onclick="prefs_save();" value="<?php echo $mlang_room['btn_prefs_save'][$G_lang]; ?>"/></div>
</div>
</body>
</html>
else if ($argz[0] == 'whysupport') {
echo show_notify(str_replace("\n", " ", $G_room_whysupport[$G_lang]), 0, $mlang_indwr['btn_close'][$G_lng], 400, 200);
}
-
+ else if ($argz[0] == 'prefs') {
+ fprintf(STDERR, "\n\n PREFS \n\n");
+ }
else {
log_wr("Get User Error");
echo "Get User Error:" + $argz[0];
var prefs_list_idx = new Array( 0x00, 0x01, 0x02 );
var prefs_list_id = new Array( "all", "auth", "isol" );
-function prefs_apply(prefs_new)
+function prefs_apply(prefs_new, is_update, is_volat)
{
+ var i;
+ var relo = false;
+
if (typeof(g_prefs) == 'undefined')
return false;
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';
+ if (!is_volat)
+ $('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';
+ if (!is_volat)
+ $('list_'+prefs_list_id[i]).style.color = 'black';
}
}
- g_prefs.listen = prefs_new.listen;
relo = true;
}
+
+
+ // TO BE ANALYZED !!!
+ // if (is_update) {
+ // createCookie("CO_list", what, 24*365, cookiepath);
+ // }
+
+
+ if (relo || !is_update) {
+ for (i = g_tables_auth_n ; i < g_tables_n ; i++) {
+ if (i % 4 == 0) {
+ $('tr_noauth'+i).style.display = (prefs_new.listen == l_list_isol ? 'none' : '');
+ }
+
+ $('td_noauth'+i).style.display = (prefs_new.listen == l_list_isol ? 'none' : '');
+ }
+ if (prefs_new.listen == l_list_isol) {
+ tra.hide_noauth();
+ }
+ else {
+ tra.show_noauth();
+ }
+
+ if (false) {
+ // ricalculation of standup area
+ if (standup_data_old != null) {
+ standup_data = standup_data_old;
+ standup_data_old = null;
+ j_stand_cont(standup_data);
+ }
+ }
+ }
+
+ g_prefs.listen = prefs_new.listen;
}
-function prefs_load(content)
+function prefs_load(content, is_update, is_volat)
{
var prefs_new;
if ((prefs_new = prefs_assign(content)) == null)
return false;
- return prefs_apply(prefs_new);
+ return prefs_apply(prefs_new, is_update, is_volat);
+}
+
+function prefs_save()
+{
+ if (typeof(g_prefs) == 'undefined')
+ return false;
+
+ console.log(server_request('mesg', 'prefs', '__POST__', 'prefs', JSON.stringify(g_prefs)));
+ // close the win:
+ // $('preferences').style.visibility = 'hidden';
+}
+
+function prefs_update()
+{
+ var i;
+ var prefs_new;
+ var relo = false;
+
+ if (typeof(g_prefs) == 'undefined')
+ return false;
+
+ prefs_new = new client_prefs();
+
+ /* listen management */
+ for (i = 0 ; i < prefs_list_idx.length ; i++) {
+ prefs_new.listen = get_checked_value($('ra_listen_'+prefs_list_id[i]));
+ if (prefs_new.listen != '')
+ break;
+ }
+
+ /* TODO SAVE TEMPORARY */
+ /* from form to struct */
+ console.log("Prefs_update");
+ prefs_apply(prefs_new, true, true);
}
function list_set(what, is_update, info)