$ret = sprintf('gst.st = %d; ', $user_step);
if ($user->is_auth()) {
- $model = '{ "listen": { "__type": "radio" } }';
- $content = array('listen' => array('val' => ($user->flags & USER_FLAG_ISOLAUTH ? "2" :
- ($user->flags & USER_FLAG_LISTAUTH ? "1" : "0")),
- 'cur' => ($user->flags_cur & USER_FLAG_ISOLAUTH ? "2" :
- ($user->flags_cur & USER_FLAG_LISTAUTH ? "1" : "0"))));
-
- $ret .= sprintf('g_prefsf.fields_descr_set(JSON.parse(\'%s\'));', $model);
+ $model = array('listen' => array('__type' => 'radio'));
+ $content = array('listen' => array('val' => ($user->flags_db & USER_FLAG_ISOLAUTH ? "2" :
+ ($user->flags_db & USER_FLAG_LISTAUTH ? "1" : "0")),
+ 'cur' => ($user->flags & USER_FLAG_ISOLAUTH ? "2" :
+ ($user->flags & USER_FLAG_LISTAUTH ? "1" : "0"))));
+ if ($user->is_supp_custom()) {
+ $comps = $user->rec->supp_comp_get_array();
+ $model['fg'] = array('__type' => 'fields', 'r' => array('__type' => 'value'),
+ 'g' => array('__type' => 'value'), 'b' => array('__type' => 'value'));
+ $model['bg'] = array('__type' => 'fields', 'r' => array('__type' => 'value'),
+ 'g' => array('__type' => 'value'), 'b' => array('__type' => 'value'));
+ $content['fg'] = array('r' => array('val' => $comps['fg']['r'], 'cur' => $comps['fg']['r']),
+ 'g' => array('val' => $comps['fg']['g'], 'cur' => $comps['fg']['g']),
+ 'b' => array('val' => $comps['fg']['b'], 'cur' => $comps['fg']['b']));
+ $content['bg'] = array('r' => array('val' => $comps['bg']['r'], 'cur' => $comps['bg']['r']),
+ 'g' => array('val' => $comps['bg']['g'], 'cur' => $comps['bg']['g']),
+ 'b' => array('val' => $comps['bg']['b'], 'cur' => $comps['bg']['b']));
+ }
+
+ $ret .= sprintf('g_prefsf.fields_descr_set(JSON.parse(\'%s\'));', json_encode($model));
$ret .= sprintf('g_prefsf.json2dom(JSON.parse(\'%s\'));', json_encode($content));
}
$this->user[$idx]->ip = $ip;
$this->user[$idx]->rec = $authenticate;
- $this->user[$idx]->flags = $user_type;
- $this->user[$idx]->flags |= ($authenticate != FALSE ? USER_FLAG_AUTH : 0x00);
- $this->user[$idx]->flags |= ( ($pass != FALSE && $bdb == FALSE) ? USER_FLAG_DBFAILED : 0x00);
- log_auth("XXX", sprintf("FLAGS: [%x]", $this->user[$idx]->flags));
- $this->user[$idx]->flags_cur = $this->user[$idx]->flags;
+ $this->user[$idx]->flags_db = $user_type;
+ $this->user[$idx]->flags_db |= ($authenticate != FALSE ? USER_FLAG_AUTH : 0x00);
+ $this->user[$idx]->flags_db |= ( ($pass != FALSE && $bdb == FALSE) ? USER_FLAG_DBFAILED : 0x00);
+ log_auth("XXX", sprintf("FLAGS: [%x]", $this->user[$idx]->flags_db));
+ $this->user[$idx]->flags = $this->user[$idx]->flags_db;
if ($authenticate != FALSE) {
$this->user[$idx]->code = $authenticate->code_get();
}
return ($ret_arr);
}
+ function supp_comp_set_array($supp_comp_in)
+ {
+ $group_id = array("fg", "bg");
+ $comp_id = array("r", "g", "b");
+ $supp_comp = "";
+
+ for ($i = 0 ; $i < 2 ; $i++) {
+ for ($e = 0 ; $e < 3 ; $e++) {
+ $supp_comp += sprintf("%02x", $supp_comp_in[$group_id[$i]][$comp_id[$e]]);
+ }
+ }
+ $this->supp_comp = $supp_comp;
+ }
+
function supp_comp_set($supp_comp)
{
$this->supp_comp = $supp_comp;
$thiz->handpt = -1;
$thiz->exitislock = TRUE;
+ $thiz->flags_db = 0x00;
$thiz->flags = 0x00;
- $thiz->flags_cur = 0x00;
$thiz->rec = FALSE;
$thiz->chattime = array_fill(0, CHAT_N, 0);
$this->handpt = $from->handpt;
$this->exitislock = $from->exitislock;
+ $this->flags_db = $from->flags_db;
$this->flags = $from->flags;
- $this->flags_cur = $from->flags_cur;
$this->rec = $from->rec;
$this->chattime = array();
$thiz->exitislock = $from->exitislock;
$thiz->the_end = $from->the_end;
+ $thiz->flags_db = $from->flags_db;
$thiz->flags = $from->flags;
- $thiz->flags_cur = $from->flags_cur;
$thiz->rec = $from->rec;
$thiz->chattime = array_fill(0, CHAT_N, 0);
return FALSE;
}
- function flags_set($flags, $mask)
+ function flags_db_get($mask)
{
- $flags_old = $this->flags & (~$mask);
- $this->flags = ($flags_old | ($flags & $mask));
+ return ($this->flags_db & $mask);
+ }
- return ($flags_old);
+ function flags_db_set($flags_db, $mask)
+ {
+ $flags_db_old = $this->flags_db & (~$mask);
+ $this->flags_db = ($flags_db_old | ($flags_db & $mask));
+
+ return ($flags_db_old);
}
- function flags_cur_set($flags_cur, $mask)
+ function flags_get($mask)
{
- $flags_cur_old = $this->flags_cur & (~$mask);
- $this->flags_cur = ($flags_cur_old | ($flags_cur & $mask));
+ return ($this->flags & $mask);
+ }
- return ($flags_cur_old);
+ function flags_set($flags, $mask)
+ {
+ $flags_old = $this->flags & (~$mask);
+ $this->flags = ($flags_old | ($flags & $mask));
+
+ return ($flags_old);
}
function prefs_store()
if (($bdb = BriskDB::create()) == FALSE) {
return FALSE;
}
- return ($bdb->user_prefs_update($this->code, ($this->flags & (USER_FLAG_TY_ALL | USER_FLAG_MAP_AUTH)),
+ if ($this->flags_db == $this->flags)
+ return TRUE;
+
+ $this->flags_db = $this->flags;
+ return ($bdb->user_prefs_update($this->code, ($this->flags_db & (USER_FLAG_TY_ALL | USER_FLAG_MAP_AUTH)),
$this->rec->supp_comp_get()));
}
function state_store()
{
- if (($bdb = BriskDB::create()) == FALSE) {
+ if (($bdb = BriskDB::create()) == FALSE) {
return FALSE;
}
- return ($bdb->user_state_update($this->code, ($this->flags & (USER_FLAG_TY_ALL | USER_FLAG_MAP_AUTH)),
+ $this->flags_db = $this->flags;
+ return ($bdb->user_state_update($this->code, ($this->flags_db & (USER_FLAG_TY_ALL | USER_FLAG_MAP_AUTH)),
$this->rec->disa_reas_get()));
}
function $(id) { return document.getElementById(id); }
+function $C(cls) { return document.getElementsByClassName(cls); }
+
function dec2hex(d, padding)
{
var hex = Number(d).toString(16);
<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">
+<img id="s_imgxx" class="nobo" src="img/noimg.png">
</td></tr>
</table>
</div>
<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"
+<input class="r_id fg_r" 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"
+<input class="g_id fg_g" 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"
+<input class="b_id fg_b" 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>
<span style="font-weight: bold;">
<?php echo $mlang_room['suppcomp_bg'][$G_lang];?>:</span>
</td><td>
-<input class="r_id" style="width: 3em;" type="text" maxlength="3" size="3" value="255"
+<input class="r_id bg_r" 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"
+<input class="g_id bg_g" 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"
+<input class="b_id bg_b" 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>
[json] => {"listen":{"act":"1"}}
*/
if ($post['model_name'] == 'prefsf') {
- fprintf(STDERR, "INFO: prefsf preset [%x]\n", $user->flags_cur);
- $cont = json_decode($post['json']);
- $new_flags_cur = $user->flags_cur & ~(USER_FLAG_ISOLAUTH | USER_FLAG_LISTAUTH);
- if ($cont->listen->cur == '1') {
- $new_flags_cur |= USER_FLAG_LISTAUTH;
+ if ($post['F_act'] == 'update' || $post['F_act'] == 'store') {
+ $cont = json_decode($post['json']);
+ $leaf = ($post['F_act'] == 'update' ? 'cur' : 'val');
+
+ $listen_flags = (($cont->listen->$leaf == '1' ? USER_FLAG_LISTAUTH : 0) |
+ ($cont->listen->$leaf == '2' ? USER_FLAG_ISOLAUTH : 0));
+ $user->flags_set($listen_flags, USER_FLAG_MAP_AUTH);
+ if ($post['F_act'] == 'store'
+ && $user->flags_db_get(USER_FLAG_MAP_AUTH) != $user->flags_get(USER_FLAG_MAP_AUTH)) {
+ $user->prefs_store();
+ }
+ }
+ if ($user->stat == 'room' && $user->subst == 'standup') {
+ $brisk->standup_update($user);
}
- else if ($cont->listen->cur == '2') {
- $new_flags_cur |= USER_FLAG_ISOLAUTH;
+ else if ($user->stat == 'room' && $user->subst == 'sitdown') {
+ $brisk->table_update($user);
}
- $user->flags_cur = $new_flags_cur;
- fprintf(STDERR, "INFO: prefsf postset [%x]\n", $user->flags_cur);
+ echo "1";
+ return TRUE;
}
}
else if ($argz[0] == 'prefs') {
}
}
+function g_prefsf_comps_cb(item)
+{
+ console.log(item);
+ console.log(g_prefsf);
+
+ var col, ct = 0, s = "";
+ var col_arr = [ 'fg', 'bg' ];
+ var cmp_arr = [ 'r', 'g', 'b' ];
+ for (col in col_arr) {
+ for (cmp in cmp_arr) {
+ console.log(g_prefsf.bsk_comps[col_arr[col]][cmp_arr[cmp]].value);
+ var val_s = g_prefsf.bsk_comps[col_arr[col]][cmp_arr[cmp]].value;
+ if (parseInt(val_s) < 0 || parseInt(val_s) > 255 || isNaN(parseInt(val_s)))
+ return false;
+ s += dec2hex(parseInt(val_s), 2);
+ }
+ console.log("sub: [" + s + "]");
+ }
+ $('s_img').src = 'suprend.php?comp=' + s;
+}
+
function prefsf_status_cb(st)
{
// console.log('status_show HERE ' + st);
}
}
-
-
function prefsf_initialize()
{
- clie_cb = { 'listen': { cb: g_prefsf_listen_cb, type: "fast" } };
+ clie_cb = { 'listen': { cb: g_prefsf_listen_cb, type: "fast" },
+ 'fg': { 'r': { cb: g_prefsf_comps_cb, type: "fast"},
+ 'g': { cb: g_prefsf_comps_cb, type: "fast"},
+ 'b': { cb: g_prefsf_comps_cb, type: "fast"}},
+ 'bg': { 'r': { cb: g_prefsf_comps_cb, type: "fast"},
+ 'g': { cb: g_prefsf_comps_cb, type: "fast"},
+ 'b': { cb: g_prefsf_comps_cb, type: "fast"}}};
g_prefsf = new Fieldify(null, null, null, clie_cb, "prefsf", [$("prefsf")], prefsf_status_cb);
+ g_prefsf.bsk_comps = { 'bg': { 'r': $C('bg_r') != undefined ? $C('bg_r')[0] : null,
+ 'g': $C('bg_g') != undefined ? $C('bg_g')[0] : null,
+ 'b': $C('bg_b') != undefined ? $C('bg_b')[0] : null },
+ 'fg': { 'r': $C('fg_r') != undefined ? $C('fg_r')[0] : null,
+ 'g': $C('fg_g') != undefined ? $C('fg_g')[0] : null,
+ 'b': $C('fg_b') != undefined ? $C('fg_b')[0] : null} };
}