reenabled all info items, and show calculated skills
authorMatteo Nastasi (mop) <nastasi@alternativeoutput.it>
Sun, 13 Dec 2015 10:07:53 +0000 (11:07 +0100)
committerMatteo Nastasi (mop) <nastasi@alternativeoutput.it>
Sun, 13 Dec 2015 10:52:39 +0000 (11:52 +0100)
TODO.txt
web/Obj/brisk.phh
web/Obj/dbase_pgsql.phh
web/fieldify.js
web/index.php
web/info.js
web/room.css

index 6f5fe62..3e7e637 100644 (file)
--- a/TODO.txt
+++ b/TODO.txt
@@ -21,8 +21,8 @@
      DONE - dbase API
      DONE - add apprentices tables
      - remove entry when set unknown
-     - enhance info interface
-       . SQL to show current evaluation
+     DONE - enhance info interface
+       DONE . SQL to show current evaluation
        . disable parts of interface
      <release>
      - minisplash at end of the match
index 0c1e5c9..5c951ef 100644 (file)
@@ -1694,7 +1694,9 @@ class Brisk
           $user_tos_vers = $user_item->tos_vers_get();
 
           $widefriend = $bdb->usersnet_widefriend($user->code, $user_item->code);
+          $widefriend['skill'] = $bdb->usersnet_wideskill($user->code, $user_item->code);
           $narrowfriend = $bdb->usersnet_narrowfriend($user->code, $user_item->code);
+          $narrowfriend['skill'] = $bdb->usersnet_narrowskill($user->code, $user_item->code);
 
           if (($usersnet_item = $bdb->usersnet_bycode($user->code, $user_item->code,
                                                       $widefriend, $narrowfriend)) == FALSE) {
index 520a4f0..c01bac9 100644 (file)
@@ -885,6 +885,27 @@ INSERT INTO %smails (code, ucode, type, tstamp, subj, body_txt, body_htm, hash)
         return ($widefriend);
     }
 
+    function usersnet_wideskill($owner, $target)
+    {
+        GLOBAL $G_dbpfx;
+
+        $wideskill = "//";
+
+        $wskl_sql = sprintf("SELECT * FROM %susersnet_wideskill WHERE owner = %d AND target = %d;",
+                            $G_dbpfx, $owner, $target);
+        if (($wskl_pg  = $this->query($wskl_sql)) == FALSE) {
+            return ($wideskill);
+        }
+
+        if (pg_numrows($wskl_pg) > 0) {
+            $wskl_obj = pg_fetch_object($wskl_pg, 0);
+            // TODO: UNCOMMENT IF THE NETWORK WORKS VERY WELL
+            // if ($wskl_obj->count >= 3)
+            $wideskill = sprintf("%3.2f", $wskl_obj->skill);
+        }
+        return ($wideskill);
+    }
+
     function usersnet_narrowfriend($owner, $target)
     {
         GLOBAL $G_dbpfx;
@@ -904,6 +925,27 @@ INSERT INTO %smails (code, ucode, type, tstamp, subj, body_txt, body_htm, hash)
         return ($narrowfriend);
     }
 
+    function usersnet_narrowskill($owner, $target)
+    {
+        GLOBAL $G_dbpfx;
+
+        $narrowskill = "//";
+
+        $nskl_sql = sprintf("SELECT * FROM %susersnet_narrowskill WHERE owner = %d AND target = %d;",
+                            $G_dbpfx, $owner, $target);
+        if (($nskl_pg = $this->query($nskl_sql)) == FALSE) {
+            return ($narrowskill);
+        }
+
+        if (pg_numrows($nskl_pg) > 0) {
+            $nskl_obj = pg_fetch_object($nskl_pg, 0);
+            // TODO: UNCOMMENT IF THE NETWORK WORKS VERY WELL
+            // if ($nskl_obj->count >= 3)
+            $narrowskill = sprintf("%3.2f", $nskl_obj->skill);
+        }
+        return ($narrowskill);
+    }
+
     function usersnet_bycode($owner, $target, $widefriend, $narrowfriend)
     {
         GLOBAL $G_dbpfx;
index 1447d41..f6bfb58 100644 (file)
@@ -1,6 +1,9 @@
-function __fieldify_findfirst(objarr, name)
+function __fieldify_find_ancestors(objarr, name)
 {
-    for (var i = 0, obj = objarr[i] ; i < objarr.length ; i++) {
+    var obj;
+
+    for (var i = 0 ; i < objarr.length ; i++) {
+        obj = objarr[i];
         var item = obj.getElementsByClassName(name + '_id');
         if (item.length > 0) {
             return (item);
@@ -12,13 +15,14 @@ function __fieldify_findfirst(objarr, name)
 // fieldsdescr = { name: { type: 'typename' }, ... }
 function Fieldify(ancestors, fieldsdescr)
 {
+    var item;
+
     this.ancestors = ancestors;
     this.field = new Array();
     for (k in fieldsdescr) {
         this.field[k] = fieldsdescr[k];
         if (this.field[k].type == 'fields') {
-            var item = __fieldify_findfirst(this.ancestors, k);
-            if (item) {
+            if (item = __fieldify_find_ancestors(this.ancestors, k)) {
                 this.field[k].obj = new Fieldify(item, this.field[k].fields);
             }
         }
@@ -70,7 +74,7 @@ Fieldify.prototype = {
 
     fld_value_set: function(name, value)
     {
-        var item = __fieldify_findfirst(this.ancestors, name);
+        var item = __fieldify_find_ancestors(this.ancestors, name);
         if (item) {
             item[0].innerHTML = value;
         }
@@ -78,7 +82,7 @@ Fieldify.prototype = {
 
     fld_value_get: function(name)
     {
-        var item = __fieldify_findfirst(this.ancestors, name);
+        var item = __fieldify_find_ancestors(this.ancestors, name);
         if (item) {
             return (item[0].innerHTML);
         }
@@ -87,7 +91,7 @@ Fieldify.prototype = {
 
     fld_radio_set: function(name, value)
     {
-        var arr = __fieldify_findfirst(this.ancestors, name);
+        var arr = __fieldify_find_ancestors(this.ancestors, name);
         if (arr) {
             for (k in arr) {
                 if (arr[k].value == value)
@@ -101,7 +105,7 @@ Fieldify.prototype = {
     fld_radio_get: function(name)
     {
         var ret = null;
-        var arr = __fieldify_findfirst(this.ancestors, name);
+        var arr = __fieldify_find_ancestors(this.ancestors, name);
         if (arr) {
             for (k in arr) {
                 if (arr[k].checked == true) {
index 1e1b09d..b67b0a4 100644 (file)
@@ -1378,39 +1378,38 @@ type="submit" class="button" onclick="this.form.elements['realsub'].value = 'chi
 <div id="xhrdeltalog"></div>
 </div>
 
-<div id="info" class="notify" style="z-index: 200; width: 400px; margin-left: -200px; height: 340px; top: 150px; visibility: hidden;">
+<div id="info" class="notify" style="z-index: 200; width: 500px; margin-left: -250px; height: 340px; top: 150px; visibility: hidden;">
 <table class="info">
-<tr><td><b><?php echo $mlang_room['info_login'][$G_lang]; ?></b></td><td class="ri"><span class="login_id"></span></td>
-<td><b><?php echo $mlang_room['info_state'][$G_lang]; ?></b></td><td class="ri"><span class="state_id"></span></td></tr>
-<tr><td><b><?php echo $mlang_room['info_guar'][$G_lang]; ?></b></td><td class="ri"><span class="guar_id"></span></td><td></td><td></td></tr>
-<tr><td><b><?php echo $mlang_room['info_match'][$G_lang]; ?></b></td><td class="ri"><span class="match_id"></span></td>
-<td><b><?php echo $mlang_room['info_game'][$G_lang]; ?></b></td><td class="ri"><span class="game_id"></span></td></tr>
-<!-- <tr class="widefriendh_id"><td colspan="3"><b>Cosa ne pensano gli amici.</b></td>
-<td class="le info-opt">Bravura: <span class="skill_id"></span></td></tr> -->
-<tr><td colspan="4"><b>Cosa ne pensano gli amici.</b></td></tr>
-
-<tr class="widefriend_id"><td class="le info-opt">Da evitare: <span class="black_id"></span></td>
-<td class="le info-opt">In prova: <span class="test_id"></span></td>
-<td class="le info-opt">Amico: <span class="friend_id"></span></td>
-<td class="le info-opt">Fidato: <span class="bff_id"></span></td></tr>
-
-<!-- <tr class="narrowfriendh_id"><td colspan="3"><b>Cosa ne pensano gli amici fidati:</b></td>
-<td class="le info-opt">Bravura: <span class="skill_id"></span></td></tr> -->
-<tr><td colspan="4"><b>Cosa ne pensano gli amici fidati:</b></td></tr>
-
-<tr class="narrowfriend_id"><td class="le info-opt">Da evitare: <span class="black_id"></span></td>
-<td class="le info-opt">In prova: <span class="test_id"></span></td>
-<td class="le info-opt">Amico: <span class="friend_id"></span></td>
-<td class="le info-opt">Fidato: <span class="bff_id"></span></td></tr>
-<!-- 
-<tr><td class="le ri" colspan="2"><b><?php echo $mlang_room['info_frie'][$G_lang]; ?></b></td></tr>
-<tr><td class="le info-opt"><input type="radio" name="friend" class="friend_id" value="black">Da evitare</td>
-    <td class="ri info-opt"><input type="radio" name="friend" class="friend_id" value="friend">Amico</td></tr>
-<tr><td class="le info-opt"><input type="radio" name="friend" class="friend_id" value="unknown">Sconosciuto</td>
-<td class="ri info-opt"><input type="radio" name="friend" class="friend_id" value="bff">Amico fidato</td></tr>
-<tr><td class="le info-opt"><input type="radio" name="friend" class="friend_id" value="test">In prova</td></tr>
-<tr><td class="le"><b>Bravura:</b></td><td class="le"><b>Credibilità:</b></td></tr>
-<tr><td class="info-opt">
+<tr><td><b><?php echo $mlang_room['info_login'][$G_lang]; ?></b></td><td class="ri b-right data"><span class="login_id"></span></td>
+<td><b><?php echo $mlang_room['info_state'][$G_lang]; ?></b></td><td class="ri data"><span class="state_id"></span></td></tr>
+<tr><td><b><?php echo $mlang_room['info_guar'][$G_lang]; ?></b></td><td class="ri b-right data"><span class="guar_id"></span></td><td></td><td></td></tr>
+<tr><td><b><?php echo $mlang_room['info_match'][$G_lang]; ?></b></td><td class="ri b-right data"><span class="match_id"></span></td>
+<td><b><?php echo $mlang_room['info_game'][$G_lang]; ?></b></td><td class="ri data"><span class="game_id"></span></td></tr>
+<tr class="widefriend_id"><td colspan="3"><b>Cosa ne pensano gli amici:</b></td>
+<td class="le data">Bravura: <span class="skill_id"></span></td></tr>
+
+<tr class="widefriend_id"><td class="le info-opt data">Da evitare: <span class="black_id"></span></td>
+<td class="le info-opt data">In prova: <span class="test_id"></span></td>
+<td class="le info-opt data">Amico: <span class="friend_id"></span></td>
+<td class="le data">Fidato: <span class="bff_id"></span></td></tr>
+
+<tr class="narrowfriend_id"><td colspan="3"><b>Cosa ne pensano gli amici fidati:</b></td>
+<td class="le data">Bravura: <span class="skill_id"></span></td></tr>
+
+<tr class="narrowfriend_id"><td class="le info-opt data">Da evitare: <span class="black_id"></span></td>
+<td class="le info-opt data">In prova: <span class="test_id"></span></td>
+<td class="le info-opt data">Amico: <span class="friend_id"></span></td>
+<td class="le data">Fidato: <span class="bff_id"></span></td></tr>
+<tr><td class="le ri triple" colspan="3"><b><?php echo $mlang_room['info_frie'][$G_lang]; ?></b></td>
+<td class="le data triple"><input type="radio" name="friend" class="friend_id" value="black">Da evitare</td></tr>
+<tr>
+<td class="le info-opt data"><input type="radio" name="friend" class="friend_id" value="unknown">Sconosciuto</td>
+<td class="le info-opt data"><input type="radio" name="friend" class="friend_id" value="test">In prova</td>
+<td class="ri info-opt data"><input type="radio" name="friend" class="friend_id" value="friend">Amico</td>
+<td class="ri info-opt data"><input type="radio" name="friend" class="friend_id" value="bff">Amico fidato</td>
+</tr>
+<tr><td class="le"><b>Bravura:</b></td>
+<td class="data">
     <table class="fiverank" style="margin: auto;">
        <tr><td class="c1t">1</td>
            <td class="c2t">2</td>
@@ -1424,7 +1423,9 @@ type="submit" class="button" onclick="this.form.elements['realsub'].value = 'chi
            <td class="c5b"><input type="radio" name="skill" class="skill_id" value="5"></td>
        </tr>
     </table>
-</td><td class="info-opt">
+</td>
+<td class="le"><b>Credibilità:</b></td>
+<td class="data">
     <table class="fiverank" style="margin: auto;">
        <tr><td class="c1t">1</td>
            <td class="c2t">2</td>
@@ -1439,8 +1440,7 @@ type="submit" class="button" onclick="this.form.elements['realsub'].value = 'chi
        </tr>
     </table>
 </td></tr>
--->
-<tr><td colspan="4" style="background-color: pink;">di seguito le opzioni che verranno attivate successivamente:</td></tr>
+<!-- <tr><td colspan="4" style="background-color: pink;">di seguito le opzioni che verranno attivate successivamente:</td></tr> -->
 </table>
 <div style="position: absolute; bottom: 8px; margin: auto; width: 100%;">
 <input type="submit" class="input_sub" style="bottom: 4px;" onclick="$('info').style.visibility = 'hidden';" value="<?php echo $mlang_room['btn_close'][$G_lang]; ?>"/>
index 499a7e1..ec13833 100644 (file)
@@ -32,12 +32,14 @@ function info_fld(dobj)
                    state: { type: 'value', perms: 'ro' },
                    guar: { type: 'value', perms: 'ro' },
 
-                   widefriend: { type: 'fields', fields: { black: { 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: { black: { 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'}
@@ -48,7 +50,10 @@ function info_fld(dobj)
                    skill: { type: 'radio' },
                    trust: { type: 'radio' }
                  };
-    return (new Fieldify([dobj], fields));
+
+    var ret = new Fieldify([dobj], fields);
+    console.log(ret);
+    return (ret);
  }
 
 function info_show(username)
index 5eef67e..a3c17bf 100644 (file)
@@ -510,10 +510,21 @@ table.info {
 
 table.info td {
     border-top: 1px solid grey;
-    padding: 4px;
+    padding: 6px;
     width: 25%;
 }
 
+table.info td.triple {
+    border-top: 2px solid #000000;
+}
+
+table.info td.data {
+    background-color: white;
+}
+table.info span {
+    text-align: left;
+    font-style: italic;
+}
 
 table.info table.fiverank {
     border-collapse: collapse;
@@ -575,16 +586,20 @@ table.info td.info-opt {
     padding: 0px 4px 4px 4px;
     }
 
+table.info td.b-right {
+    border-right: 1px solid grey;
+    }
+
 table.info td.noborder {
     border-top: 0px;
     }
 
 table.info td.le {
-    padding-left: 16px;
+    padding-left: 8px;
     }
 
 table.info td.ro {
-    padding-right: 16px;
+    padding-right: 8px;
     }
 
 body.explain h1 {