reenabled all info items, and show calculated skills
[brisk.git] / web / info.js
index 8e30988..ec13833 100644 (file)
  *
  */
 
+var mlang_info = { 'btn_close' : { 'it' : 'Chiudi.',
+                                   'en' : 'Close.' }
+                 };
+
+
 function info_fld(dobj)
 {
     var fields = { login: { type: 'value' },
                    state: { type: 'value', perms: 'ro' },
                    guar: { type: 'value', perms: 'ro' },
+
+                   widefriend: { type: 'fields', fields: { skill: { type: 'value', perms: 'ro' },
+                                                           black: { type: 'value', perms: 'ro' },
+                                                           test: { type: 'value', perms: 'ro'},
+                                                           friend: { type: 'value', perms: 'ro'},
+                                                           bff: { type: 'value', perms: 'ro'}
+                                                         } },
+                   narrowfriend: { type: 'fields', fields: { skill: { type: 'value', perms: 'ro' },
+                                                             black: { type: 'value', perms: 'ro'},
+                                                             test: { type: 'value', perms: 'ro'},
+                                                             friend: { type: 'value', perms: 'ro'},
+                                                             bff: { type: 'value', perms: 'ro'}
+                                                         } },
                    match: { type: 'value', perms: 'ro' },
                    game: { type: 'value', perms: 'ro' },
                    friend: { type: 'radio' },
@@ -33,7 +51,9 @@ function info_fld(dobj)
                    trust: { type: 'radio' }
                  };
 
-    return (new Fieldify(dobj, fields));
+    var ret = new Fieldify([dobj], fields);
+    console.log(ret);
+    return (ret);
  }
 
 function info_show(username)
@@ -49,7 +69,7 @@ function info_show(username)
         info.visible(true);
         }
     else {
-        alert("error: open info window failed");
+        var noti = new notify(gst, info_in.mesg, 0, mlang_info['btn_close'][g_lang], 400, 150);
     }
 }
 
@@ -72,3 +92,20 @@ function info_reset()
     target = $('info').getElementsByClassName('login_id')[0].innerHTML;
     return info_show(target);
 }
+
+function info_save()
+{
+    var info, jinfo, ret;
+
+    info = info_fld($('info'));
+    jinfo = info.dom2json();
+
+    ret = server_request('mesg', 'info|save','__POST__', 'info', JSON.stringify(jinfo));
+
+    if (ret == 1) {
+        $('info').style.visibility = 'hidden';
+    }
+    else {
+        alert(ret);
+    }
+}