From: Matteo Nastasi (mop) Date: Fri, 23 Oct 2015 16:58:27 +0000 (+0200) Subject: add new Fieldfy class to manage forms (minimal), new user 'info' form X-Git-Tag: v5.0.0~7 X-Git-Url: http://mop.ddnsfree.com/gitweb/?a=commitdiff_plain;h=29386faba01ac22d3d47e5f467412dc63b4e22cf;p=brisk.git add new Fieldfy class to manage forms (minimal), new user 'info' form --- diff --git a/web/Obj/brisk.phh b/web/Obj/brisk.phh index a171273..f044b4a 100644 --- a/web/Obj/brisk.phh +++ b/web/Obj/brisk.phh @@ -1693,7 +1693,20 @@ class Brisk $jret = json_encode(array("ret" => $ret, "mesg" => $mesg)); } else { - $jret = json_encode(array("ret" => 0, "mesg" => "", "guar" => $guar_login)); + $jret = json_encode(array("ret" => 0, + "mesg" => "", + "login" => $user_login, + // FIXME: state internationalization + "state" => + ($user_item->type & USER_FLAG_TY_APPR ? "Apprendista" : + ($user_item->type & USER_FLAG_TY_CERT ? "Certificato" : + ($user_item->type & (USER_FLAG_TY_NORM | USER_FLAG_TY_SUPER) ? + "Normale" : "Stato sconosciuto"))), + "guar" => ($user_item->type & USER_FLAG_TY_APPR ? + "" : $guar_login), + "match" => $user_item->match_cnt, + "game" => $user_item->game_cnt, + "friend" => "unknown")); } return $jret; diff --git a/web/commons.js b/web/commons.js index 463169d..c317957 100644 --- a/web/commons.js +++ b/web/commons.js @@ -359,7 +359,7 @@ function chatt_checksend(obj,e) function act_chatt(value) { if (value.substring(0, 6) == "/info ") { - show_user_info(value.substring(6)); + info_show(value.substring(6)); } else { send_mesg("chatt|"+encodeURIComponent(value)); diff --git a/web/fieldify.js b/web/fieldify.js new file mode 100644 index 0000000..254dd0d --- /dev/null +++ b/web/fieldify.js @@ -0,0 +1,54 @@ + +// fieldsdescr = { name: { type: 'typename' }, ... } +function Fieldify(ancestor, fieldsdescr) +{ + this.ancestor = ancestor; + + this.field = new Array(); + for (k in fieldsdescr) { + this.field[k] = fieldsdescr[k]; + } +} + +Fieldify.prototype = { + ancestor: null, + field: null, + + visible: function(is_visible) { + this.ancestor.style.visibility = (is_visible ? "visible" : "hidden" ); + }, + + // { 'name': 'value' } + populate: function(field_values) + { + for (k in this.field) { + if (this.field[k].type == 'value') { + this.fld_value_set(k, field_values[k]); + } + else if (this.field[k].type == 'radio') { + this.fld_radio_set(k, field_values[k]); + } + } + }, + + fld_value_set: function(name, value) + { + console.log(name + "=" + value); + this.ancestor.getElementsByClassName(name + '_id')[0].innerHTML = value; + }, + + fld_radio_set: function(name, value) + { + var arr = this.ancestor.getElementsByClassName(name + '_id'); + + console.log(name + "=" + value); + + for (k in arr) { + if (arr[k].value == value) + arr[k].checked = true; + else + arr[k].checked = false; + } + }, + tap: null +} diff --git a/web/index.php b/web/index.php index a3be749..26f12f3 100644 --- a/web/index.php +++ b/web/index.php @@ -228,6 +228,18 @@ $mlang_room = array( 'userpassuse' => array('it' => 'Il tuo nickname è g 'en' => 'Send a message to the administrator:'), 'mesgtoadm_sub'=> array('it' => 'soggetto:', 'en' => 'subject:'), + 'info_login' => array('it' => 'Utente:', + 'en' => 'User:'), + 'info_state' => array('it' => 'Stato:', + 'en' => 'State:'), + 'info_guar' => array('it' => 'Garante:', + 'en' => 'Guarantee:'), + 'info_match' => array('it' => 'Partite:', + 'en' => 'Matches:'), + 'info_game' => array('it' => 'Mani:', + 'en' => 'Hands:'), + 'info_frie' => array('it' => 'Conoscenza:', + 'en' => 'Friendship:'), ); require_once("briskin5/Obj/briskin5.phh"); @@ -989,6 +1001,7 @@ supported by:
+ @@ -1156,6 +1169,7 @@ cookie_law(null); + @@ -1359,6 +1373,29 @@ type="submit" class="button" onclick="this.form.elements['realsub'].value = 'chi
+ + +