From 43038b6a6a2edc22b573ccc0abac9374499154a6 Mon Sep 17 00:00:00 2001 From: "Matteo Nastasi (mop)" Date: Wed, 30 Nov 2011 09:09:30 +0100 Subject: [PATCH] function to decorate user name refactored --- web/Obj/brisk.phh | 22 +++++++++++----------- web/briskin5/Obj/briskin5.phh | 10 ++-------- 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/web/Obj/brisk.phh b/web/Obj/brisk.phh index 4dd36c9..bd80e1f 100644 --- a/web/Obj/brisk.phh +++ b/web/Obj/brisk.phh @@ -1087,6 +1087,13 @@ class User { return (FALSE); } + function myname_innerHTML() + { + $class_id = ($this->flags & USER_FLAG_AUTH) + 1; + + return (sprintf('$("myname").innerHTML = "%s";', $class_id, + xcape($this->name,ENT_COMPAT,"UTF-8"))); + } } // end class User @@ -1335,9 +1342,8 @@ class Room { } $ret .= sprintf('subst = "%s";', $user->subst); - $itin = ($user->flags & USER_FLAG_AUTH ? "" : ""); - $itou = ($user->flags & USER_FLAG_AUTH ? "" : ""); - $ret .= sprintf('$("myname").innerHTML = "%s%s%s";', $itin, xcape($user->name), $itou); + $ret .= $user->myname_innerHTML(); + for ($i = 0 ; $i < TABLES_N ; $i++) { $ret .= $this->table_content($user, $i); @@ -1578,9 +1584,7 @@ class Room { $ret .= $this->table_content($user_cur, $table_idx); if ($user->idx_get() == $i) { - $itin = ($user->flags & USER_FLAG_AUTH ? "" : ""); - $itou = ($user->flags & USER_FLAG_AUTH ? "" : ""); - $ret .= sprintf('$("myname").innerHTML = "%s%s%s: ";', $itin, xcape($user->name), $itou); + $ret .= $user->myname_innerHTML(); } $user_cur->comm[$user_cur->step % COMM_N] = $ret; $user_cur->step_inc(); @@ -2301,11 +2305,7 @@ class Room { if ($user_cur->stat == 'room') { $user_cur->comm[$user_cur->step % COMM_N] = "gst.st = ".($user_cur->step+1)."; ".$this->standup_content($user_cur); if ($user->idx_get() == $i) { - $itin = ($user->flags & USER_FLAG_AUTH ? "" : ""); - $itou = ($user->flags & USER_FLAG_AUTH ? "" : ""); - - $user_cur->comm[$user_cur->step % COMM_N] .= sprintf('$("myname").innerHTML = "%s%s%s: ";', - $itin, xcape($user->name), $itou); + $user_cur->comm[$user_cur->step % COMM_N] .= $user->myname_innerHTML(); } log_main("FROM STANDUP: NAME: ".$user_cur->name." SENDED: ".$user_cur->comm[$user_cur->step % COMM_N]); diff --git a/web/briskin5/Obj/briskin5.phh b/web/briskin5/Obj/briskin5.phh index b7c703b..41cacfd 100644 --- a/web/briskin5/Obj/briskin5.phh +++ b/web/briskin5/Obj/briskin5.phh @@ -1105,10 +1105,7 @@ class Bin5 { (BIN5_PLAYERS_N == 3 ? 0: $this->user[$table->player[($user_cur->table_pos+4) % BIN5_PLAYERS_N]]->flags), (BIN5_PLAYERS_N == 3 ? "" : xcape($this->user[$table->player[($user_cur->table_pos+4) % BIN5_PLAYERS_N]]->name))); if ($user_cur == $user) { - $itin = ($user->flags & USER_FLAG_AUTH ? "" : ""); - $itou = ($user->flags & USER_FLAG_AUTH ? "" : ""); - $user_cur->comm[$user_cur->step % COMM_N] .= sprintf('$("myname").innerHTML = "%s%s%s";', - $itin, xcape($user->name), $itou); + $user_cur->comm[$user_cur->step % COMM_N] .= $user_cur->myname_innerHTML(); } $user_cur->step_inc(); } @@ -1372,10 +1369,7 @@ function show_table(&$room, &$user, $sendstep, $is_transition, $is_again) $ret .= "background_set();"; /* USERS INFO */ - $itin = ($user->flags & USER_FLAG_AUTH ? "" : ""); - $itou = ($user->flags & USER_FLAG_AUTH ? "" : ""); - - $ret .= sprintf('$("myname").innerHTML = "%s%s%s";', $itin, xcape($user->name), $itou); + $ret .= $user->myname_innerHTML(); $ret .= sprintf('set_names([%d, "%s"], [%d, "%s"], [%d, "%s"], [%d, "%s"], [%d, "%s"]); ', $room->user[$table->player[($table_pos) % BIN5_PLAYERS_N]]->flags, xcape($room->user[$table->player[($table_pos) % BIN5_PLAYERS_N]]->name), -- 2.17.1