summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--css/standard025.css (renamed from css/standard024.css)51
-rw-r--r--include/output.php15
-rw-r--r--include/user.php198
3 files changed, 201 insertions, 63 deletions
diff --git a/css/standard024.css b/css/standard025.css
index ac8aaff..5a5d22f 100644
--- a/css/standard024.css
+++ b/css/standard025.css
@@ -509,7 +509,47 @@ ul.tricks li div div span.comment span{
}
.user { margin-left:25%;margin-right:5%; }
-.user td.usergames { width:50%; }
+
+div.user ul {
+ list-style:none;
+}
+
+div.user ul li {
+ position: relative;
+ padding:3px;
+ margin: 0px;
+ width: 80%;
+ min-height: 1.2em;
+ border-left: 2px solid #babdb6 ;
+ border-right: 2px solid #babdb6 ;
+ border-bottom: 2px solid #babdb6 ;
+}
+
+div.user ul li:first-child {
+ border-top: 2px solid #babdb6 ;
+}
+.gamessession {
+ display:none;
+}
+.link {
+ text-decoration:underline;
+ color: blue;
+}
+
+.user .gameid {
+ float: left;
+ width: 5em;
+}
+.user .turn {
+ padding-left: 1em;
+ float: left;
+ width: 20em;
+}
+.user .gameshidesession {
+ float:right;
+ width: 10em;
+}
+
.wide { margin-left:5%;margin-right:5%; }
.over {
@@ -532,19 +572,18 @@ div span img.tinybutton { width: 1.4em;}
.gamestatuspre {
padding: 0 0.3em;
- background-color: #fd8901;
+ background-color: #f57900;
}
.gamestatusover {
padding:0 0.3em;
- background-color: #f82c20 ;
+ background-color: #e9b96e ;
+ color: #fff;
}
.gamestatusplay {
padding:0 0.3em;
- background-color: #15de26;
+ background-color: #8ae234;
}
-.multi a{ color: #fff;}
-
.bigger{ font-size:larger;}
diff --git a/include/output.php b/include/output.php
index 03e6ced..a4b84a0 100644
--- a/include/output.php
+++ b/include/output.php
@@ -376,7 +376,7 @@ function output_header()
<title>e-Doko</title>
<meta content="text/html; charset=ISO-8859-1" http-equiv="content-type" />
<link rel="shortcut icon" type="image/x-icon" href="pics/edoko-favicon.png" />
- <link rel="stylesheet" type="text/css" href="css/standard024.css" />
+ <link rel="stylesheet" type="text/css" href="css/standard025.css" />
<script type="text/javascript" src="include/game.js"> </script>
<script type="text/javascript" src="include/jquery.js"> </script>
<script type="text/javascript" src="include/jquery.tablesorter.js"></script>
@@ -384,6 +384,19 @@ function output_header()
$(document).ready(function()
{
$("#ScoreTable").tablesorter({ widgets: ['zebra']});
+
+ $(".gameshidesession").click( function () {
+ $(this).parent().children(".gamessession").toggle(300);
+ });
+
+ $(".gameshowall").click( function () {
+ $(".gamessession").show(300);
+ });
+ $(".gamehideall").click( function () {
+ $(".gamessession").hide(300);
+ });
+
+
});
</script>
</head>
diff --git a/include/user.php b/include/user.php
index 1f2ae74..eb4f6c4 100644
--- a/include/user.php
+++ b/include/user.php
@@ -138,81 +138,167 @@ else
echo "<h4>These are all your games:</h4>\n";
/* output legend */
- echo "<p>Session: <br />\n";
- echo "<span class=\"gamestatuspre\"> p </span> = pre-game phase ";
- echo "<span class=\"gamestatusplay\">P </span> = game in progess ";
- echo "<span class=\"gamestatusover\">E </span> = game ended ";
- echo "<span class=\"gamestatusover multi\"><a>N</a> </span> = N games with same hand <br />";
+ echo "<p>Games: \n";
+ echo "<span class=\"gamestatuspre\"> &nbsp; </span> = pre-game phase ";
+ echo "<span class=\"gamestatusplay\"> &nbsp; </span> = game in progess ";
+ echo "<span class=\"gamestatusover \"><a>N</a> </span> = game over (N people played the same hand) <br />";
+ echo " Reminder: canceling a game can't be reversed!";
echo "</p>\n";
+ /* get all games */
$output = array();
$result = DB_query("SELECT Hand.hash,Hand.game_id,G.mod_date,G.player,G.status, ".
- " (SELECT count(H.randomnumbers) FROM Game H WHERE H.randomnumbers=G.randomnumbers) AS count ".
+ " (SELECT count(H.randomnumbers) FROM Game H WHERE H.randomnumbers=G.randomnumbers) AS count, ".
+ " G.session".
" FROM Hand".
" LEFT JOIN Game G ON G.id=Hand.game_id".
" WHERE user_id='$myid'".
" ORDER BY G.session,G.create_date" );
- $gamenrold = -1;
- $count = 0;
- echo "<table>\n <tr><td>\n";
- while( $r = DB_fetch_array($result))
+ /* sort into active and passive sessions */
+ $count = 0; /* count number of games to check for beginner status */
+ $session = -1;
+ $maxgame = 0;
+ $output_active = "";
+ $output_inactive = "";
+ $sessionoutput = "";
+ $gameoutput = "";
+ $keep_going = 2;
+ while( $keep_going )
{
- $count++;
- $game = DB_format_gameid($r[1]);
- $gamenr = (int) $game;
- if($gamenrold < $gamenr)
+ /* get next element */
+ $r = DB_fetch_array($result);
+
+ if($r)
+ $count++;
+ else
{
- if($gamenrold!=-1)
- echo "</td></tr>\n <tr> <td>$gamenr:</td>\n";
- else
- echo "$gamenr:</td>\n";
- $gamenrold = $gamenr;
- echo "<td class=\"usergames\">\n";
+ /* need to run the while loop one more time when we run out of elements in the database */
+ $keep_going--;
+ $r[0] = NULL;
+ $r[1] = NULL;
+ $r[2] = NULL;
+ $r[3] = NULL;
+ $r[4] = NULL;
+ $r[5] = NULL;
+ $r[6] = -2;
}
- $Multi = ($r[5]>1) ? "multi" : "";
- if($r[4]=='pre')
- echo " <span class=\"gamestatuspre $Multi\"><a href=\"".$INDEX."?action=game&amp;me=".$r[0]."\">p </a></span>\n";
- else if (in_array($r[4],array('gameover','cancel-timedout','cancel-nines','cancel-noplay','cancel-trump')))
- {
- echo " <span class=\"gamestatusover $Multi\"><a href=\"".$INDEX."?action=game&amp;me=".$r[0]."\">";
- if($r[5]<2)
- echo "E ";
- else
- echo $r[5];
- echo "</a></span>\n";
- }
- else
- echo " <span class=\"gamestatusplay $Multi\"><a href=\"".$INDEX."?action=game&amp;me=".$r[0]."\">P </a></span>\n";
- if($r[4] == 'pre' || $r[4] == 'play')
+ if( $r[6]==$session )
{
- echo "</td>\n<td>\n ";
- if($r[3]==$myid || !$r[3])
- echo "(it's <strong>your</strong> turn)\n";
- else
+ /* same session, update information */
+ $maxgame++;
+ $myhash = $r[0];
+ $gameid = $r[1];
+ $gamemoddate = $r[2];
+ $userid = $r[3];
+ $gamestatus = $r[4];
+ $gamefrequence = $r[5];
+
+ /* create output */
+ $sessionoutput .= $gameoutput;
+ $gameoutput = " <span class=\"gamestatusover \"><a href=\"".$INDEX."?action=game&amp;me=".$myhash."\">"
+ .$gamefrequence."</a></span>\n";
+ }
+ else
+ { /* new session */
+
+ /* output old session if available */
+ if($maxgame)
{
- $name = DB_get_name('userid',$r[3]);
- $gameid = $r[1];
- /* check if we need to send out a reminder */
- if(DB_get_reminder($r[3],$gameid)==0)
- if(time()-strtotime($r[2]) > 60*60*24*7)
- echo "<a href=\"$INDEX?action=reminder&amp;me=".$r[0]."\">Send a reminder.</a>";
-
- /* check vacaction status of this user */
- if($vacation=check_vacation($r[3]))
+ /* is session active? */
+ if($gamestatus == 'pre' || $gamestatus== 'play' || time()-strtotime($gamemoddate) < 60*60*24*5 )
{
- $stop = substr($vacation[1],0,10);
- $title = 'begin:'.substr($vacation[0],0,10).' end:'.$vacation[1].' '.$vacation[2];
- echo "(it's <span class=\"vacation\" title=\"$title\">$name's (on vacation until $stop)</span> turn)\n";
+ $output_active .= "<li> ";
+ if($gamestatus == 'pre')
+ $output_active .= '<span class="gamestatuspre gameid">';
+ else if($gamestatus == 'play')
+ $output_active .= '<span class="gamestatusplay gameid">';
+ else
+ $output_active .= '<span class="gamestatusover gameid">';
+ $output_active .= "<a href=\"$INDEX?action=game&amp;me=$myhash\">".
+ DB_format_gameid($gameid).'</a></span>&nbsp;&nbsp;&nbsp;';
+
+
+
+ /* who's turn is it? */
+ if( $gamestatus == 'pre' || $gamestatus == 'play')
+ {
+ $output_active .= '<span class="turn">';
+ if($userid==$myid || !$userid)
+ $output_active .= " <strong>your</strong> turn\n";
+ else
+ {
+ $name = DB_get_name('userid',$userid);
+
+ /* check vacaction status of this user */
+ if($vacation=check_vacation($userid))
+ {
+ $stop = substr($vacation[1],0,10);
+ $title = 'begin:'.substr($vacation[0],0,10).' end:'.$vacation[1].' '.$vacation[2];
+ $output_active .= " <span class=\"vacation\" title=\"$title\">$name's (on vacation until $stop)</span> turn\n";
+ }
+ else
+ $output_active .= "$name's turn\n";
+
+ /* check if we need to send out a reminder */
+ if(DB_get_reminder($userid,$gameid)==0)
+ if(time()-strtotime($gamemoddate) > 60*60*24*7)
+ $output_active .= "<a href=\"$INDEX?action=reminder&amp;me=".$myhash."\">Send a reminder?</a> ";
+
+ };
+ $output_active .= '</span>';
+
+ if(time()-strtotime($gamemoddate) > 60*60*24*30)
+ $output_active .= "<a href=\"$INDEX?action=cancel&amp;me=".$myhash."\">Cancel?</a> ";
+ }
+
+ if($maxgame>1)
+ {
+ $output_active .= ' <span class="gameshidesession link">(hide/show) old</span><br />'."\n";
+ $output_active .= ' <span class="gamessession">'.$sessionoutput.'</span>';
+ }
+
+ $output_active .= "</li>\n";
+
}
else
- echo "(it's $name's turn)\n";
- };
- if(time()-strtotime($r[2]) > 60*60*24*30)
- echo "<a href=\"$INDEX?action=cancel&amp;me=".$r[0]."\">Cancel?</a> ";
+ {
+ /* session is not active anymore */
+ $output_inactive .= "<li> $session:" ;
+ $output_inactive .= $sessionoutput.$gameoutput ;
+ $output_inactive .= "</li>\n";
+ }
+
+ /* reset all session variables */
+ $maxgame = 0;
+ $sessionoutput = "";
+ $gameoutput = "";
+
+ }
+
+ /* save game information */
+ $maxgame++;
+ $myhash = $r[0];
+ $gameid = $r[1];
+ $gamemoddate = $r[2];
+ $userid = $r[3];
+ $gamestatus = $r[4];
+ $gamefrequence = $r[5];
+ $session = $r[6];
+
+ /* create output */
+ $sessionoutput .= $gameoutput;
+ $gameoutput = " <span class=\"gamestatusover \"><a href=\"".$INDEX."?action=game&amp;me=".$myhash."\">"
+ .$gamefrequence."</a></span>\n";
+
}
}
- echo "</td></tr>\n</table>\n";
+
+ echo "<ul>\n ";
+ echo " <li><span class=\"gameshowall link\">show all</span> <span class=\"gamehideall link\">hide all</span></li>\n";
+ echo $output_active;
+ echo " <li><span class=\"gameshidesession link\">hide/show inactive</span><ul class=\"gamessession\">$output_inactive </ul></li>";
+ echo "</ul>\n";
/* give a hint for new players */
if($count<10)