+/* 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', cb: Prefsn.supp_change_cb },
+ g: { type: 'value', cb: Prefsn.supp_change_cb },
+ b: { type: 'value', cb: Prefsn.supp_change_cb }
+ }
+ };
+ fields.bg = {
+ type: 'fields', fields: { r: { type: 'value', cb: Prefsn.supp_change_cb },
+ g: { type: 'value', cb: Prefsn.supp_change_cb },
+ b: { type: 'value', cb: Prefsn.supp_change_cb }
+ }
+ };
+ }
+
+ 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_cert_n + 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();
+ }
+ }
+}
+
+function obj_clone(obj) // begin = {} or [] is optional
+{
+ var ret, ty, begin;
+
+ if (arguments.length > 1)
+ begin = arguments[1];
+ else
+ begin = {};
+
+ 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;
+}
+
+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;
+
+ 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 in ['fg', 'bg']) {
+ if (! i in supp_new) {
+ continue;
+ }
+ obj_update(supp_cur[i], supp_new[i]);
+ }
+
+ 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.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'));
+}
+
+
+
+
+
+