partial implementation of new fieldified preferences system
[brisk.git] / web / prefs.js
index afddd09..1bee269 100644 (file)
  *
  */
 
+var mlang_prefsf = { '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 mlang_prefsn = { 'btn_close' : { 'it' : 'Chiudi.',
                                      'en' : 'Close.' },
                      'tit_list'  : { '0'  : { 'it' : '',
@@ -455,3 +465,51 @@ function list_set(what, is_update, info)
         }
     }
 }
+
+var g_prefsf = null;
+function g_prefsf_listen_cb(item)
+{
+    var whats = [ 'all', 'auth', 'isolation' ];
+    var what = whats[item.value];
+
+    console.log("change listen", item.value);
+
+    $('list_info').innerHTML = mlang_prefsf.tit_list[item.value][g_lang];
+
+    for (i = g_tables_cert_n + 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') {
+        tra.hide_noauth();
+    }
+    else {
+        tra.show_noauth();
+    }
+}
+
+function prefsf_status_cb(st)
+{
+    // console.log('status_show HERE ' + st);
+    switch(st) {
+    case Fieldify.STATUS_OK:
+        $('prefsf-status-flag').src = 'img/light-green.png';
+        break;
+    case Fieldify.STATUS_PROC:
+        $('prefsf-status-flag').src = 'img/light-orange.png';
+        break;
+    default:  // Fieldify.STATUS_ERR
+        $('prefsf-status-flag').src = 'img/light-red.png';
+        break;
+    }
+}
+
+
+
+function prefsf_initialize()
+{
+    clie_cb = { 'listen': { cb: g_prefsf_listen_cb, type: "fast" } };
+    g_prefsf = new Fieldify(null, null, null, clie_cb, "prefsf", [$("prefsf")], prefsf_status_cb);
+}