include ERB::Util
def show_date(time)
- time.strftime("%Y-%m-%d")
+ if (Time.now - time < 30*60)
+ return "on line"
+ elsif (Time.now - time < 24*60*60)
+ return time.strftime("%Y-%m-%d")
+ # return "%d hours ago" % [(Time.now - time)/3600]
+ else
+ return time.strftime("%Y-%m-%d")
+ end
end
def usage
player_decoration = "default"
- case (Time.now - last_modified)/(60*60*24)
- when (0..1) then player_decoration = "today"
- when (0..7) then player_decoration = "this_week"
+ case (Time.now - last_modified)/60 # minutes
+ when (0..30) then player_decoration = "current"
+ when (0..(1*60*24)) then player_decoration = "today"
+ when (0..(7*60*24)) then player_decoration = "this_week"
end
case key
%>
<tr class="<%=player_decoration%>">
<td class="name">
- <a id="popup<%=popup_id+=1%>" href="http://wdoor.c.u-tokyo.ac.jp/shogi/tools/view/show-player.cgi?event=LATEST&filter=floodgate&show_self_play=1&user=<%= h yaml[key]['name'] %>"><%= h yaml[key]['name'] %></a>
+ <a id="popup<%=popup_id+=1%>" href="http://wdoor.c.u-tokyo.ac.jp/shogi/tools/view/show-player.cgi?event=LATEST&filter=floodgate&show_self_play=1&user=<%=u key%>"><%= h yaml[key]['name'] %></a>
<script type="text/javascript">
var tooltip<%=popup_id%> = new YAHOO.widget.Tooltip("myTooltip", {
context:"popup<%=popup_id%>",
<%= "%.3f" % [win_rate] %> </td>
<td class="last_modified">
<%= show_date(last_modified) %> </td>
-% if $wdoor & yss_rate
+% if $wdoor
<td class="rate">
- <%= rate != 0 ? "%5d" % [ 2300 - yss_rate + rate ] : "N/A" %> </td>
+ <%= rate != 0 && yss_rate > 0 ? ("%5d" % [2300 - yss_rate + rate]) : "N/A" %> </td>
% end
</tr>
% end
.rate, .ngames, .win_rate {text-align: right;}
.last_modified {text-align: center;}
.gps, .yowai_gps {background-color: lightgreen;}
- .today {background-color: #FFD700;}
- .this_week {background-color: #FFDAB9;}
+ .current {background-color: #FFD700;}
+ .today {background-color: #FFFF00;}
+ .this_week {background-color: #FFFFAA;}
#bd {text-align: center;}
#ft {text-align: right;}