From 22d489aa1f47bfaec201d561c773d4649bbdae84 Mon Sep 17 00:00:00 2001 From: "Matteo Nastasi (mop)" Date: Sun, 13 Dec 2015 11:07:53 +0100 Subject: [PATCH] reenabled all info items, and show calculated skills --- TODO.txt | 4 +-- web/Obj/brisk.phh | 2 ++ web/Obj/dbase_pgsql.phh | 42 +++++++++++++++++++++++++ web/fieldify.js | 20 +++++++----- web/index.php | 70 ++++++++++++++++++++--------------------- web/info.js | 11 +++++-- web/room.css | 21 +++++++++++-- 7 files changed, 119 insertions(+), 51 deletions(-) diff --git a/TODO.txt b/TODO.txt index 6f5fe62..3e7e637 100644 --- 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 - minisplash at end of the match diff --git a/web/Obj/brisk.phh b/web/Obj/brisk.phh index 0c1e5c9..5c951ef 100644 --- a/web/Obj/brisk.phh +++ b/web/Obj/brisk.phh @@ -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) { diff --git a/web/Obj/dbase_pgsql.phh b/web/Obj/dbase_pgsql.phh index 520a4f0..c01bac9 100644 --- a/web/Obj/dbase_pgsql.phh +++ b/web/Obj/dbase_pgsql.phh @@ -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; diff --git a/web/fieldify.js b/web/fieldify.js index 1447d41..f6bfb58 100644 --- a/web/fieldify.js +++ b/web/fieldify.js @@ -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) { diff --git a/web/index.php b/web/index.php index 1e1b09d..b67b0a4 100644 --- a/web/index.php +++ b/web/index.php @@ -1378,39 +1378,38 @@ type="submit" class="button" onclick="this.form.elements['realsub'].value = 'chi
-