$ret = sprintf('gst.st = %d; ', $user_step);
if ($user->is_auth()) {
- $ret .= sprintf('g_prefsn.load(\'%s\');', json_encode($user->prefsn_get()));
+ $ret .= sprintf('/* g_prefsn.load(\'%s\'); */', json_encode($user->prefsn_get()));
}
if(false) {
if ($user->flags & USER_FLAG_ISOLAUTH) {
<a href="#" title="'
// MLANG garantisci per un tuo conoscente
.$mlang_room['prefs_desc'][$G_lang].'"
- onmouseover="menu_hide(0,1);" onclick="g_prefsn.show(); menu_over(-1,this);">'
+ onmouseover="menu_hide(0,1);" onclick="g_prefsf.visible(true); 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_prefsn = null, g_prefsn_old = null;
+var g_prefsf = null;
var g_listen;
var g_withflash = false;
var g_is_spawn = 0;
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_prefsn = null, g_prefsn_old = null;
+ var g_prefsf = null;
var g_listen;
var g_is_spawn = 0;
var g_withflash = false;
// var nonunload = false;
var spo_slide, sup_slide;
+ function status_cb()
+ {
+ console.log("status_cb");
+ }
+
window.onload = function() {
g_brow = get_browser_agent();
g_prefs = new client_prefs(null);
- g_prefsn = new Prefsn($('prefsn'));
-
+ /* g_prefsn = new Prefsn($('prefsn')); */
+ g_prefsf = new Fieldify(null, null, null, {}, "prefsf", [$("prefsf")], status_cb);
spo_slide = new sideslide($('spon_caro'), 80, 20);
sup_slide = new sideslide($('supp_caro'), 80, 20);
-<!-- 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;">
+
+<!-- PREFSF -->
+<div id="prefsf" class="notify" style="z-index: 200; width: 600px; margin-left: -300px; height: 240px; top: 150px; visibility: hidden;">
+<div id="prefsf_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 style="text-align: center; margin: auto; border-collapse: collapse;"><tr><td style="vertical-align: top;">
<tr><td style="vertical-align: top; border: 1px solid black; border-width: 1px 0px 1px 0px;">
</div>
</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="g_prefsn.reset();" value="<?php echo $mlang_room['btn_reset'][$G_lang]; ?>"/>
+<input type="submit" class="input_sub" style="bottom: 4px;" onclick="g_prefsf.visible(false);" value="<?php echo $mlang_room['btn_close'][$G_lang]; ?>"/>
+<input type="submit" class="input_sub" style="bottom: 4px;" onclick="g_prefsf.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 -->
-
-
-
+</div> <!-- end prefsf -->
<script language="JavaScript">
<!--
$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->comm[$user->step % COMM_N] .= sprintf('prefs_load(\'%s\', true, %s);', json_encode($prefs),
+ 'false');
$user->step_inc();
if ($argz[1] == 'save') {
}
}
-Prefsn.supp_change_cb = function(field)
+function obj_clone(obj) // begin = {} or [] is optional
{
- var i;
- var prefs_new;
- var relo = false;
- console.log("prefs_update("+field+")");
- return;
- if (typeof(g_prefsn) == 'undefined')
- return false;
+ var ret, ty, begin;
+
+ if (arguments.length > 1)
+ begin = arguments[1];
+ else
+ begin = {};
- 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;
+ for (i in obj) {
+ ty = typeof(obj[i]);
+
+ if (ty == 'object') {
+ if (obj[i].constructor == Array) {
+ ret[i] = obj_clone(obj[i], []);
+ }
+ else {
+ ret[i] = obj_clone(obj[i], {});
+ }
+ }
+ else {
+ ret[i] = obj[i];
}
}
+ return ret;
+}
- 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);
+function obj_update(cur, delta)
+{
+ for (i in cur) {
+ if (i in delta) {
+ ty = typeof(cur[i]);
+ if (ty == 'object') {
+ obj_update(cur[i], delta[i]);
+ }
+ else {
+ cur[i] = delta[i];
+ }
}
}
+}
+
+Prefsn.supp_change_cb = function(field)
+{
+ var i;
+ var supp_new;
+ var relo = false;
- // console.log("prefs_update:: i break "+i+" ["+prefs_new.supp_comp+"]");
+ if (g_prefsn == null)
+ return false;
+
+ supp_new = Fieldify.item2tree([g_prefsn.obj], field);
+ supp_cur = {};
+ console.log(g_prefsn.data.fg);
+ supp_cur['fg'] = obj_clone(g_prefsn.data.fg);
+ supp_cur['bg'] = obj_clone(g_prefsn.data.bg);
- for (i = 0 ; i < 6 ; i++) {
- $(l_comps_name[i]).value = parseInt(prefs_new.supp_comp.substr(i*2, 2), 16);
+ for (i in ['fg', 'bg']) {
+ if (! i in supp_new) {
+ continue;
+ }
+ obj_update(supp_cur[i], supp_new[i]);
}
- /* from form to struct */
- // prefs_apply(prefs_new, true, true);
+ var col, ct = 0, s = "";
+ for (col in [ 'fg', 'bg' ]) {
+ for (cmp in [ 'r', 'g', 'b' ]) {
+ var val_s = supp_cur[col][cmp];
+ if (parseInt(val_s) < 0 || parseInt(val_s) > 255 || isNaN(parseInt(val_s)))
+ return false;
+ }
+ s += dec2hex(parseInt(val_s), 2);
+ }
+ $('s_img').src = 'suprend.php?comp=' + s;
};
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);
}