$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;
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));
--- /dev/null
+
+// 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
+}
'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");
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="shortcut icon" href="img/brisk_ico.png">
<script type="text/javascript" src="commons.js"></script>
+<script type="text/javascript" src="fieldify.js"></script>
<script type="text/javascript" src="prefs.js"></script>
<!-- <script type="text/javascript" src="myconsole.js"></script> -->
<script type="text/javascript" src="menu.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="shortcut icon" href="img/brisk_ico.png">
<script type="text/javascript" src="commons.js"></script>
+<script type="text/javascript" src="fieldify.js"></script>
<script type="text/javascript" src="prefs.js"></script>
<!-- <script type="text/javascript" src="myconsole.js"></script> -->
<script type="text/javascript" src="menu.js"></script>
<div id="xhrlog"></div>
<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;">
+<table class="info">
+<tr><td class="le"><?php echo $mlang_room['info_login'][$G_lang]; ?></td><td class="ri"><span class="login_id"></span></td></tr>
+<tr><td class="le"><?php echo $mlang_room['info_state'][$G_lang]; ?></td><td class="ri"><span class="state_id"></span></td></tr>
+<tr><td class="le"><?php echo $mlang_room['info_guar'][$G_lang]; ?></td><td class="ri"><span class="guar_id"></span></td></tr>
+<tr><td class="le"><?php echo $mlang_room['info_match'][$G_lang]; ?></td><td class="ri"><span class="match_id"></span></td></tr>
+<tr><td class="le"><?php echo $mlang_room['info_game'][$G_lang]; ?></td><td class="ri"><span class="game_id"></span></td></tr>
+<tr><td class="le ri" colspan="2"><?php echo $mlang_room['info_frie'][$G_lang]; ?></td></tr>
+<tr><td class="le"><input type="radio" name="friend" class="friend_id" value="black">Da evitare</td>
+ <td class="ri noborder"><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>
+</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]; ?>"/>
+<!-- <input type="submit" class="input_sub" style="bottom: 4px;" onclick="prefs_reset();" value="<?php echo $mlang_room['btn_reset'][$G_lang]; ?>"/>
+<input type="submit" class="input_sub" style="bottom: 4px;" onclick="prefs_save();" value="<?php echo $mlang_room['btn_save'][$G_lang]; ?>"/> -->
+</div>
+
+</div>
+
<div id="preferences" class="notify" style="z-index: 200; width: 600px; margin-left: -300px; height: 240px; top: 150px; visibility: hidden;">
<div id="preferences_child" style="border-bottom: 1px solid gray; overflow: auto; height: 370px;">
span.id_usr {
cursor: pointer;
-}
\ No newline at end of file
+}
+
+table.info {
+ margin: auto;
+ border-collapse: collapse;
+}
+
+table.info td {
+ border-top: 1px solid grey;
+ padding: 4px;
+ width: 50%;
+}
+
+table.info td.info-opt {
+ border-top: 0px;
+ padding: 0px 4px 4px 4px;
+ }
+
+table.info td.noborder {
+ border-top: 0px;
+ }
+
+table.info td.le {
+ padding-left: 16px;
+ }
+
+table.info td.ro {
+ padding-right: 16px;
+ }
+
function info_show(username)
{
// ret = server_request('mesg', 'prefs|save','__POST__', 'prefs', JSON.stringify(g_prefs));
- var udata = server_request('mesg', 'chatt|/info ' + username);
+ var info_in = JSON.parse(server_request('mesg', 'chatt|/info ' + username));
+ var info = null;
+ if (info_in.ret == 0) {
+ var fields = { login: { type: 'value' },
+ state: { type: 'value' },
+ guar: { type: 'value' },
+ match: { type: 'value' },
+ game: { type: 'value' },
+ friend: { type: 'radio' } };
+
+ info = new Fieldify($('info'), fields);
+ info.populate(info_in);
+ info.visible(true);
+ }
+ else {
+ console.log("some error: open a dialog");
+ }
// FIXME: just to be finished
- console.log(udata);
+ console.log(info);
}
function click_update_cb(e)