$ret = sprintf('gst.st = %d; ', $user_step);
- $prefs = Client_prefs::from_user($user);
- $ret .= sprintf('prefs_load(\'%s\', false, false);', json_encode($prefs));
-
+ if ($user->is_auth()) {
+ $ret .= sprintf('g_prefsn.load(\'%s\');', json_encode($user->prefsn_get()));
+ }
if(false) {
if ($user->flags & USER_FLAG_ISOLAUTH) {
$ret .= 'list_set(\'isolation\', false, \''.$mlang_brisk['tit_onisol'][$G_lang].'\' ); ';
echo $this->info_show($user, urldecode($info_user), $dt);
} while(0);
}
+ else if (strncmp($msg, "/prefsn", 7) == 0) {
+ do {
+ if (! $user->is_auth()) {
+ if ($mlang_indwr) {
+ $to_user = nickserv_msg($dt, $mlang_indwr['info_auth'][$G_lang]);
+ }
+ else {
+ $to_user = nickserv_msg($dt, "error");
+ }
+ break;
+ }
+ echo $this->prefsn_show($user, $dt);
+ } while(0);
+ }
else if (strncmp($msg, "/st ", 4) == 0) {
log_main("chatt_send BEGIN");
{
return $this->supp_comp;
}
+ function supp_comp_get_array()
+ {
+ $ret = array();
+ $group_id = array("fg", "bg");
+ $comp_id = array("r", "g", "b");
+ $ret_arr = array();
+ $supp_comp = $this->supp_comp;
+
+ for ($i = 0 ; $i < 2 ; $i++) {
+ $group_cur = $group_id[$i];
+ $ret_arr[$group_cur] = array();
+ for ($e = 0 ; $e < 3 ; $e++) {
+ $ret_arr[$group_cur][$comp_id[$e]] = base_convert(substr($supp_comp, $i*3 + $e, 2), 16, 10);
+ }
+ }
+
+ return ($ret_arr);
+ }
+
function supp_comp_set($supp_comp)
{
$this->supp_comp = $supp_comp;
return sprintf("0\r\n");
}
+function prefsn_get()
+{
+ GLOBAL $G_lang, $mlang_brisk, $G_base;
+
+ $mesg = "";
+ $user_code = -1;
+
+ $listen = ($this->flags & USER_FLAG_MAP_AUTH) >> 2;
+ if ($this->rec != FALSE) {
+ $ret = $this->rec->supp_comp_get_array();
+ }
+ else {
+ $ret = array(
+ "fg" => array("r" => 0, "g" => 0, "b" => 0),
+ "bg" => array("r" => 0, "g" => 0, "b" => 0)
+ );
+ }
+
+ return (array("ret" => 0,
+ "listen" => $listen,
+ "fg" => $ret["fg"],
+ "bg" => $ret["bg"]));
+}
+
} // end class User
<a href="#" title="'
// MLANG garantisci per un tuo conoscente
.$mlang_room['prefs_desc'][$G_lang].'"
- onmouseover="menu_hide(0,1);" onclick="$(\'prefsn\').style.visibility = \'visible\'; menu_over(-1,this);">'
+ onmouseover="menu_hide(0,1);" onclick="g_prefsn.show(); menu_over(-1,this);">'
// MLANG garantisci
.$mlang_room['tit_prefs'][$G_lang].'</a><br>' : '').'
var g_tables_auth_n = <? echo TABLES_AUTH_N; ?>;
var g_tables_cert_n = <? echo TABLES_CERT_N; ?>;
var g_prefs, g_prefs_new = null;
+var g_prefsn, g_prefsn_old = null;
var g_listen;
var g_withflash = false;
var g_is_spawn = 0;
// alert(window.onbeforeunload);
g_brow = get_browser_agent();
- g_prefs = new client_prefs(null);
-
spo_slide = new sideslide($('spon_caro'), 80, 20);
sup_slide = new sideslide($('supp_caro'), 80, 20);
var g_tables_auth_n = <? echo TABLES_AUTH_N; ?>;
var g_tables_cert_n = <? echo TABLES_CERT_N; ?>;
var g_prefs, g_prefs_new = null;
+ var g_prefsn, g_prefsn_old = null;
var g_listen;
var g_is_spawn = 0;
var g_withflash = false;
g_brow = get_browser_agent();
g_prefs = new client_prefs(null);
+ g_prefsn = new Prefsn($('prefsn'));
spo_slide = new sideslide($('spon_caro'), 80, 20);
sup_slide = new sideslide($('supp_caro'), 80, 20);
</div>
+
+
+<!-- PREFERENCES -->
<div id="preferences" class="notify" style="z-index: 200; width: 600px; margin-left: -300px; height: 240px; top: 150px; visibility: hidden;">
<div id="preferences_child" style="border-bottom: 1px solid gray; overflow: auto; height: 370px;">
<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="prefs_update('listen');" title="'
-<?php echo $mlang_room['listall_desc'][$G_lang];?>
-'"><span id="list_all">
+<tr><td><input style="vertical-align: bottom;" id="ra_listen_all" type="radio" name="listen" value="0" onclick="prefs_update('listen');" 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="prefs_update('listen');" title="'
-<?php echo $mlang_room['listaut_desc'][$G_lang];?>
-'"><span id="list_auth">
+<tr><td><input style="vertical-align: bottom;" id="ra_listen_auth" type="radio" name="listen" value="1" onclick="prefs_update('listen');" 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="prefs_update('listen');" title="'
-<?php echo $mlang_room['listisol_desc'][$G_lang];?>
-'"><span id="list_isol">
+<tr><td><input style="vertical-align: bottom;" id="ra_listen_isol" type="radio" name="listen" value="2" onclick="prefs_update('listen');" title="<?php echo $mlang_room['listisol_desc'][$G_lang];?>"><span id="list_isol">
<?php echo $mlang_room['tit_listisol'][$G_lang];?>
</span></td></tr>
</table>
-
+<!-- PREFSN -->
<div id="prefsn" class="notify" style="z-index: 200; width: 600px; margin-left: -300px; height: 240px; top: 150px; visibility: hidden;">
<div id="prefsn_child" style="background-color: text-align: left; border-bottom: 1px solid gray; overflow: auto; height: 370px;">
<h4 style="text-align: left;"><?php echo $mlang_room['tit_prefs'][$G_lang]; ?></h4>
<table><tr><td>
<span style="font-weight: bold;"><?php echo $mlang_room['itm_list'][$G_lang];?>:</span>
</td></tr>
-<tr><td><input style="vertical-align: bottom;" id="ra_listen_all" type="radio" name="listen" value="0" onclick="prefs_update('listen');" 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="prefs_update('listen');" 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="prefs_update('listen');" title="'
-<?php echo $mlang_room['listisol_desc'][$G_lang];?>
-'"><span id="list_isol">
-<?php echo $mlang_room['tit_listisol'][$G_lang];?>
-</span></td></tr>
+<tr><td>
+<input class="listen_id" style="vertical-align: bottom;" type="radio" name="listen" value="0" onclick="prefs_update('listen');" title="<?php echo $mlang_room['listall_desc'][$G_lang];?>">
+<span class="listen_t_id" data-ffy-value="0"><?php echo $mlang_room['tit_listall'][$G_lang];?></span>
+</td></tr><tr><td>
+<input class="listen_id" style="vertical-align: bottom;" type="radio" name="listen" value="1" onclick="prefs_update('listen');" title="<?php echo $mlang_room['listaut_desc'][$G_lang];?>">
+<span class="listen_t_id" data-ffy-value="1"><?php echo $mlang_room['tit_listaut'][$G_lang];?></span>
+</td></tr><tr><td>
+<input class="listen_id" style="vertical-align: bottom;" type="radio" name="listen" value="2" onclick="prefs_update('listen');" title="<?php echo $mlang_room['listisol_desc'][$G_lang];?>">
+<span class="listen_t_id" data-ffy-value="2"><?php echo $mlang_room['tit_listisol'][$G_lang];?></span>
+</td></tr>
</table>
</td>
<?php
<tr><td colspan="4">
<span style="font-weight: bold;"><?php echo $mlang_room['suppcomp_tit'][$G_lang];?>:
</span></td></tr>
-<tr>
-<td style="border: 0px solid black; border-width: 0px 0px 1px 0px;"><span style="font-weight: bold;">
-<?php echo $mlang_room['suppcomp_fg'][$G_lang];?>:</span>
-</td><td style="border: 0px solid black; border-width: 0px 0px 1px 0px;"><input style="width: 3em;" id="s_fg_r" type="text" maxlength="3" size="3" name="s_fg_r"
- onchange="prefs_update('supp');" value="255"
- title="'<?php echo $mlang_room['suppcomp_range'][$G_lang];?>'">
- <span id="list_all"><?php echo $mlang_room['suppcomp_r'][$G_lang];?></span></td>
-<td style="border: 0px solid black; border-width: 0px 0px 1px 0px;"><input style="width: 3em;" id="s_fg_g" type="text" maxlength="3" size="3" name="s_fg_g"
- onchange="prefs_update('supp');" value="255"
- title="'<?php echo $mlang_room['suppcomp_range'][$G_lang];?>'">
- <span id="list_all"><?php echo $mlang_room['suppcomp_g'][$G_lang];?></span></td>
-<td style="border: 0px solid black; border-width: 0px 0px 1px 0px;"><input style="width: 3em;" id="s_fg_b" type="text" maxlength="3" size="3" name="s_fg_b"
- onchange="prefs_update('supp');" value="255"
- title="'<?php echo $mlang_room['suppcomp_range'][$G_lang];?>'">
- <span id="list_all"><?php echo $mlang_room['suppcomp_b'][$G_lang];?></span></td>
-</tr>
-<tr>
-<td><span style="font-weight: bold;">
+<tr class="fg_id"><td style="border: 0px solid black; border-width: 0px 0px 1px 0px;">
+<span style="font-weight: bold;"><?php echo $mlang_room['suppcomp_fg'][$G_lang];?>:</span>
+</td><td style="border: 0px solid black; border-width: 0px 0px 1px 0px;">
+<input class="r_id" style="width: 3em;" type="text" maxlength="3" size="3" value="255"
+title="<?php echo $mlang_room['suppcomp_range'][$G_lang];?>">
+<span id="list_all"><?php echo $mlang_room['suppcomp_r'][$G_lang];?></span>
+</td><td style="border: 0px solid black; border-width: 0px 0px 1px 0px;">
+<input class="g_id" style="width: 3em;" type="text" maxlength="3" size="3" value="255"
+title="<?php echo $mlang_room['suppcomp_range'][$G_lang];?>">
+<span id="list_all"><?php echo $mlang_room['suppcomp_g'][$G_lang];?></span>
+</td><td style="border: 0px solid black; border-width: 0px 0px 1px 0px;">
+<input class="b_id" style="width: 3em;" type="text" maxlength="3" size="3" value="255"
+title="<?php echo $mlang_room['suppcomp_range'][$G_lang];?>">
+<span id="list_all"><?php echo $mlang_room['suppcomp_b'][$G_lang];?></span>
+</td></tr>
+<tr class="bg_id"><td>
+<span style="font-weight: bold;">
<?php echo $mlang_room['suppcomp_bg'][$G_lang];?>:</span>
-</td>
-<td><input style="width: 3em;" id="s_bg_r" type="text" maxlength="3" size="3" name="s_bg_r"
- onchange="prefs_update('supp');" value="255"
- title="'<?php echo $mlang_room['suppcomp_range'][$G_lang];?>'">
- <span id="list_all"><?php echo $mlang_room['suppcomp_r'][$G_lang];?></span></td>
-<td><input style="width: 3em;" id="s_bg_g" type="text" maxlength="3" size="3" name="s_bg_g"
- onchange="prefs_update('supp');" value="255"
- title="'<?php echo $mlang_room['suppcomp_range'][$G_lang];?>'">
- <span id="list_all"><?php echo $mlang_room['suppcomp_g'][$G_lang];?></span></td>
-<td><input style="width: 3em;" id="s_bg_b" type="text" maxlength="3" size="3" name="s_bg_b"
- onchange="prefs_update('supp');" value="255"
- title="'<?php echo $mlang_room['suppcomp_range'][$G_lang];?>'">
- <span id="list_all"><?php echo $mlang_room['suppcomp_b'][$G_lang];?></span></td>
-</tr>
+</td><td>
+<input class="r_id" style="width: 3em;" type="text" maxlength="3" size="3" value="255"
+ title="<?php echo $mlang_room['suppcomp_range'][$G_lang];?>">
+ <span id="list_all"><?php echo $mlang_room['suppcomp_r'][$G_lang];?></span>
+</td><td>
+<input class="g_id" style="width: 3em;" type="text" maxlength="3" size="3" value="255"
+ title="<?php echo $mlang_room['suppcomp_range'][$G_lang];?>">
+ <span id="list_all"><?php echo $mlang_room['suppcomp_g'][$G_lang];?></span>
+</td><td>
+<input class="b_id" style="width: 3em;" type="text" maxlength="3" size="3" value="255"
+ title="<?php echo $mlang_room['suppcomp_range'][$G_lang];?>">
+ <span id="list_all"><?php echo $mlang_room['suppcomp_b'][$G_lang];?></span>
+</td></tr>
<tr><td colspan="4" style="text-align: center;">
<img id="s_img" class="nobo" src="img/noimg.png">
</td></tr>
</table>
</td></tr></table>
-<?php
- }
- else {
-?>
-</tr></table>
-<input id="s_fg_r" type="hidden" name="s_fg_r">
-<input id="s_fg_g" type="hidden" name="s_fg_g">
-<input id="s_fg_b" type="hidden" name="s_fg_b">
-<input id="s_bg_r" type="hidden" name="s_bg_r">
-<input id="s_bg_g" type="hidden" name="s_bg_g">
-<input id="s_bg_b" type="hidden" name="s_bg_b">
-<input id="s_img" type="hidden" name="s_bg_b">
<?php
}
?>
</div>
<div class="notify_clo">
<input type="submit" class="input_sub" style="bottom: 4px;" onclick="$('prefsn').style.visibility = 'hidden';" value="<?php echo $mlang_room['btn_close'][$G_lang]; ?>"/>
-<input type="submit" class="input_sub" style="bottom: 4px;" onclick="prefs_reset();" value="<?php echo $mlang_room['btn_reset'][$G_lang]; ?>"/>
+<input type="submit" class="input_sub" style="bottom: 4px;" onclick="g_prefsn.reset();" value="<?php echo $mlang_room['btn_reset'][$G_lang]; ?>"/>
<input type="submit" class="input_sub" style="bottom: 4px;" onclick="prefs_save();" value="<?php echo $mlang_room['btn_save'][$G_lang]; ?>"/>
</div>
</div> <!-- end prefsn -->
echo "1";
return TRUE;
}
+ else if ($argz[0] == 'prefsn') {
+ if ($argz[1] == 'save') {
+ if (!isset($post['prefs'])) {
+ return FALSE;
+ }
+
+ if (($prefs = Client_prefs::from_json($post['prefs'])) == FALSE) {
+ $prefs = Client_prefs::from_user($user);
+ }
+ $prefs->store($user, TRUE);
+ }
+ else { // reset case as default
+ $prefs = Client_prefs::from_user($user);
+ }
+ $user->comm[$user->step % COMM_N] = "gst.st = ".($user->step+1)."; ";
+ $user->comm[$user->step % COMM_N] .= sprintf('prefs_load(\'%s\', true, %s);', json_encode($prefs),
+ 'false');
+ $user->step_inc();
+
+ if ($argz[1] == 'save') {
+ if ($user->stat == 'room' && $user->subst == 'standup') {
+ $brisk->standup_update($user);
+ }
+ else if ($user->stat == 'room' && $user->subst == 'sitdown') {
+ log_main("chatt_send pre table update");
+ $brisk->table_update($user);
+ log_main("chatt_send post table update");
+ }
+ }
+ echo "1";
+ return TRUE;
+ }
else if ($argz[0] == 'shutdown') {
log_auth($user->sess, "Shutdown session.");
trust: { type: 'radio' }
};
- var ret = new Fieldify([dobj], fields);
- return (ret);
+ return (new Fieldify([dobj], fields));
}
function info_show(username)
+/*
+ * brisk - prefs.js
+ *
+ * Copyright (C) 2015 Matteo Nastasi
+ * mailto: nastasi@alternativeoutput.it
+ * matteo.nastasi@milug.org
+ * web: http://www.alternativeoutput.it
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABLILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details. You should have received a
+ * copy of the GNU General Public License along with this program; if
+ * not, write to the Free Software Foundation, Inc, 59 Temple Place -
+ * Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+var mlang_prefsn = { 'btn_close' : { 'it' : 'Chiudi.',
+ 'en' : 'Close.' },
+ 'tit_list' : { '0' : { 'it' : '',
+ 'en' : '' },
+ '1' : { 'it' : '(solo aut.)',
+ 'en' : '(only aut.)' },
+ '2' : { 'it' : '(isolam.to)',
+ 'en' : '(isolation)' } }
+ };
+
var l_list_all = 0x00;
var l_list_auth = 0x01;
var l_list_isol = 0x02;
var l_prefs_list_id = new Array( "all", "auth", "isol" );
var l_comps_name = new Array('s_fg_r', 's_fg_g', 's_fg_b', 's_bg_r', 's_bg_g', 's_bg_b');
+/* FIXME: move to html page with dynamic valorization */
+var is_supp_custom = true;
+
+function Prefsn(obj)
+{
+ var fields = { listen: { type: 'radio', cb: Prefsn.listen_change_cb } };
+ if (is_supp_custom) {
+ fields.fg = {
+ type: 'fields', fields: { r: { type: 'value' },
+ g: { type: 'value' },
+ b: { type: 'value' }
+ }
+ };
+ fields.bg = {
+ type: 'fields', fields: { r: { type: 'value' },
+ g: { type: 'value' },
+ b: { type: 'value' }
+ }
+ };
+ }
+
+ this.fieldify = new Fieldify([obj], fields);
+ this.obj = obj;
+ this.data = null;
+}
+
+Prefsn.listen_change_cb = function(field)
+{
+ var i;
+ var prefs_new;
+ var relo = false;
+
+ console.log("listen_change_cb:" + field.value);
+ console.log("xx" + g_prefsn.data);
+
+ /* listen management */
+ if (g_prefsn.data == null || g_prefsn.data.listen != field.value) {
+ $('list_info').innerHTML = mlang_prefsn['tit_list'][field.value][g_lang];
+ console.log('update listen');
+ for (i = g_tables_auth_n ; i < g_tables_n ; i++) {
+ if (i % 4 == 0) {
+ $('tr_noauth'+i).style.display = (field.value == l_list_isol ? 'none' : '');
+ }
+
+ $('td_noauth'+i).style.display = (field.value == l_list_isol ? 'none' : '');
+ }
+ if (field.value == l_list_isol) {
+ tra.hide_noauth();
+ }
+ else {
+ tra.show_noauth();
+ }
+ }
+}
+
+Prefsn.supp_change_cb = function(field)
+{
+ var i;
+ var prefs_new;
+ var relo = false;
+ // console.log("prefs_update("+field+")");
+
+ if (typeof(g_prefsn) == 'undefined')
+ return false;
+
+ for (i = 0 ; i < 6 ; i++) {
+ if (parseInt($(l_comps_name[i]).value) < 0 || parseInt($(l_comps_name[i]).value) > 255 ||
+ isNaN(parseInt($(l_comps_name[i]).value))) {
+ break;
+ }
+ }
+
+ if (i == 6) {
+ prefs_new.supp_comp = "";
+ for (i = 0 ; i < 6 ; i++) {
+ prefs_new.supp_comp += dec2hex(parseInt($(l_comps_name[i]).value), 2);
+ }
+ }
+
+ // console.log("prefs_update:: i break "+i+" ["+prefs_new.supp_comp+"]");
+
+ for (i = 0 ; i < 6 ; i++) {
+ $(l_comps_name[i]).value = parseInt(prefs_new.supp_comp.substr(i*2, 2), 16);
+ }
+
+ /* from form to struct */
+ // prefs_apply(prefs_new, true, true);
+};
+
+
+
+Prefsn.prototype = {
+ obj: null,
+ fieldify: null,
+ data: null,
+
+ load: function(data) {
+ var in_data = JSON.parse(data);
+ this.fieldify.json2dom(in_data);
+ this.data = in_data;
+ },
+
+ reset: function() {
+ console.log('here');
+ Fieldify.reset(this.obj);
+ },
+
+ show: function() {
+ this.fieldify.visible(true);
+ }
+}
+
+function prefsn_show(username)
+{
+ var prefsn_in_in = server_request('index_wr.php', sess, 'mesg', 'chatt|/prefsn');
+ var prefsn_in = JSON.parse(prefsn_in_in);
+ var prefsn = null;
+
+ if (prefsn_in.ret == 0) {
+ prefsn = prefsn_fld($('prefsn'));
+ prefsn.json2dom(prefsn_in);
+ prefsn.visible(true);
+ }
+ else {
+ var noti = new notify(gst, prefsn_in.mesg, 0, mlang_prefsn['btn_close'][g_lang], 400, 150);
+ }
+}
+
+function prefsn_reset()
+{
+ Fieldify.reset($('prefsn'));
+}
+
+
+
+
+
+
function client_prefs(old)
{
if (prefs_new.listen == l_prefs_list_idx[i]) {
if (!is_volat)
$('list_'+l_prefs_list_id[i]).style.color = 'red';
- $('list_info').innerHTML = mlang_commons['tit_list'][i][g_lang];
+ $('list_info').innerHTML = mlang_prefsn['tit_list'][i][g_lang];
}
else {
if (!is_volat)
var i;
var relo = false;
var old_st = readCookie("CO_list");
-
+
if (what == 'auth') {
$('list_auth').style.color = 'red';
$('list_isol').style.color = 'black';
if (relo || !is_update) {
for (i = g_tables_auth_n ; i < g_tables_n ; i++) {
-
+
if (i % 4 == 0) {
$('tr_noauth'+i).style.display = (what == 'isolation' ? 'none' : '');
}
-
+
$('td_noauth'+i).style.display = (what == 'isolation' ? 'none' : '');
}
if (what == 'isolation') {
else {
tra.show_noauth();
}
-
+
if (false) {
// ricalculation of standup area
if (standup_data_old != null) {