[Toss-devel-svn] SF.net SVN: toss:[1494] trunk/Toss
Status: Beta
Brought to you by:
lukaszkaiser
|
From: <luk...@us...> - 2011-06-22 22:37:44
|
Revision: 1494
http://toss.svn.sourceforge.net/toss/?rev=1494&view=rev
Author: lukaszkaiser
Date: 2011-06-22 22:37:37 +0000 (Wed, 22 Jun 2011)
Log Message:
-----------
Lists of plays in JavaScript.
Modified Paths:
--------------
trunk/Toss/Toss.py
trunk/Toss/WebClient/Login.js
trunk/Toss/WebClient/Main.js
trunk/Toss/WebClient/Style.css
trunk/Toss/WebClient/index.html
Modified: trunk/Toss/Toss.py
===================================================================
--- trunk/Toss/Toss.py 2011-06-22 07:34:03 UTC (rev 1493)
+++ trunk/Toss/Toss.py 2011-06-22 22:37:37 UTC (rev 1494)
@@ -35,7 +35,7 @@
app_win.show()
sys.exit(app.exec_())
else:
- args = [toss_dir + "/TossServer", "-s", host, "-p", str(port), "-d", log_level]
+ args = [toss_dir + "/TossServer", "-nocache", "-s", host, "-p", str(port), "-d", log_level]
# gather exception backtrace information
os.environ['OCAMLRUNPARAM'] = 'b'
server_proc = subprocess.Popen(args)
Modified: trunk/Toss/WebClient/Login.js
===================================================================
--- trunk/Toss/WebClient/Login.js 2011-06-22 07:34:03 UTC (rev 1493)
+++ trunk/Toss/WebClient/Login.js 2011-06-22 22:37:37 UTC (rev 1494)
@@ -30,7 +30,7 @@
list_plays_string ("Gomoku", udata[7]);
list_plays_string ("Pawn-Whopping", udata[8]);
list_plays_string ("Tic-Tac-Toe", udata[9]);
- list_plays_string ("Concurrent-Tic-Tac-Toe", udata[10]);
+ /* list_plays_string ("Concurrent-Tic-Tac-Toe", udata[10]); */
get_opponents ();
}
@@ -48,6 +48,7 @@
// Onload handler
function startup (game) {
+ GAMESPAGE = new GamesPage ("plays", GAMES);
if (navigator.userAgent.indexOf('MSIE') != -1 &&
navigator.userAgent.indexOf('MSIE 9') == -1) {
document.getElementById("nosvg").style.display = "block";
Modified: trunk/Toss/WebClient/Main.js
===================================================================
--- trunk/Toss/WebClient/Main.js 2011-06-22 07:34:03 UTC (rev 1493)
+++ trunk/Toss/WebClient/Main.js 2011-06-22 22:37:37 UTC (rev 1494)
@@ -45,6 +45,98 @@
PLAYS[CUR_PLAY_I].next_move ();
}
+
+var GAMES = new Array(
+ /* "Concurrent-Tic-Tac-Toe" */
+ "Breakthrough",
+ "Checkers",
+ "Chess",
+ "Connect4",
+ "Entanglement",
+ "Gomoku",
+ "Pawn-Whopping",
+ "Tic-Tac-Toe"
+);
+
+var GAMESPAGE = undefined;
+
+
+function GamesPage(id, games){ // html tag id
+ this.games = games;
+ this.paragraphs = new Object();
+ this.container = document.getElementById(id);
+ for (var i = 0; i < this.games.length; i++) {
+ var game = this.games[i];
+
+ var paragraph = document.createElement("p");
+ this.paragraphs[game] = paragraph;
+ paragraph.setAttribute("class", "game-par");
+
+ var button = document.createElement("button");
+ paragraph.game_button = button;
+ button.setAttribute("class", "boldobt");
+ button.setAttribute("onclick", "new_play('" + game + "')");
+ button.innerHTML = game;
+ button.style.display = "block";
+ this.container.appendChild(paragraph);
+ paragraph.appendChild(button);
+
+ var open_play_list = document.createElement("ul");
+ paragraph.open_play_list = open_play_list;
+ open_play_list.setAttribute("class", "plays-list");
+ open_play_list.setAttribute("id", "a-plays-list-" + game);
+ paragraph.appendChild(open_play_list);
+
+ var completed_bt = document.createElement("button");
+ paragraph.completed_button = completed_bt;
+ completed_bt.setAttribute("class", "completedbt");
+ completed_bt.setAttribute("onclick",
+ "GAMESPAGE.toggle_completed('" + game + "')");
+ completed_bt.innerHTML = "Completed games (Show)";
+ this.container.appendChild(paragraph);
+ paragraph.appendChild(completed_bt);
+ paragraph.completed_shown = false;
+
+ var closed_play_list = document.createElement("ul");
+ paragraph.closed_play_list = closed_play_list;
+ closed_play_list.setAttribute("class", "plays-list");
+ closed_play_list.setAttribute("id", "d-plays-list-" + game);
+ closed_play_list.style.display = "none";
+ paragraph.appendChild(closed_play_list);
+ }
+ return (this);
+}
+
+GamesPage.prototype.show = function () {
+ this.container.style.display = "block";
+}
+
+GamesPage.prototype.hide = function () {
+ this.container.style.display = "none";
+}
+
+GamesPage.prototype.show_completed = function (game) {
+ this.paragraphs[game].closed_play_list.style.display = "block";
+}
+
+GamesPage.prototype.hide_completed = function (game) {
+ this.paragraphs[game].closed_play_list.style.display = "none";
+}
+
+GamesPage.prototype.toggle_completed = function (game) {
+ var par = this.paragraphs[game];
+ if (par.completed_shown) {
+ par.closed_play_list.style.display = "none";
+ par.completed_button.innerHTML = "Completed games (Show)";
+ par.completed_shown = false;
+ } else {
+ par.closed_play_list.style.display = "block";
+ par.completed_button.innerHTML = "Completed games (Hide)";
+ par.completed_shown = true;
+ }
+}
+
+
function play_from_string (game, s) {
var p = s.substring(game.length + 1);
var lst = parse_list ('#', p);
@@ -73,14 +165,18 @@
PLAYS = parse_list ('##', lst);
var a_plist = document.getElementById("a-plays-list-" + game);
var d_plist = document.getElementById("d-plays-list-" + game);
- while (a_plist.childNodes.length > 0) { a_plist.removeChild(a_plist.firstChild); }
- while (d_plist.childNodes.length > 0) { d_plist.removeChild(d_plist.firstChild); }
+ while (a_plist.childNodes.length > 0) {
+ a_plist.removeChild(a_plist.firstChild);
+ }
+ while (d_plist.childNodes.length > 0) {
+ d_plist.removeChild(d_plist.firstChild);
+ }
for (var i = 0; i < PLAYS.length; i++) {
PLAYS[i] = play_from_string (game, PLAYS[i]);
- if (PLAYS[i].cur_state.payoff == "") a_plist.appendChild(new_play_item (game, i));
- else
- {
- d_plist.appendChild(new_play_item (game, i));
+ if (PLAYS[i].cur_state.payoff == "") {
+ a_plist.appendChild(new_play_item (game, i));
+ } else {
+ d_plist.appendChild(new_play_item (game, i));
}
}
if (PLAYS.length == 0) {
Modified: trunk/Toss/WebClient/Style.css
===================================================================
--- trunk/Toss/WebClient/Style.css 2011-06-22 07:34:03 UTC (rev 1493)
+++ trunk/Toss/WebClient/Style.css 2011-06-22 22:37:37 UTC (rev 1494)
@@ -91,6 +91,23 @@
text-decoration: underline;
}
+.completedbt {
+ text-align: left;
+ border-color: #260314;
+ border-radius: 4px;
+ -moz-border-radius: 4px;
+ border-width: 0px;
+ color: #260314;
+ background-color: #fff1d4;
+ font-size: 0.8em;
+ font-family: Verdana, 'TeXGyreHerosRegular', sans;
+}
+
+.completedbt:hover {
+ cursor: pointer;
+ text-decoration: underline;
+}
+
.dbt {
border-color: #fff1d4;
border-radius: 4px;
@@ -716,8 +733,8 @@
margin-left: 1em;
padding-left: 0px;
list-style: none;
- margin-top: 0em;
- border-top: 1px solid #260314;
+ margin: 0.5em;
+ border-bottom: 1px solid #260314;
}
.plays-list-elem {
Modified: trunk/Toss/WebClient/index.html
===================================================================
--- trunk/Toss/WebClient/index.html 2011-06-22 07:34:03 UTC (rev 1493)
+++ trunk/Toss/WebClient/index.html 2011-06-22 22:37:37 UTC (rev 1494)
@@ -179,6 +179,7 @@
<div id="news">
<h3>News</h3>
<ul id="welcome-list-news" class="welcome-list">
+<li><b>22/06/11</b> Better organized lists of plays</li>
<li><b>19/06/11</b> News section on the front page of tPlay</li>
<li><b>15/06/11</b> Bug with underscores in user names corrected</li>
<li><b>10/06/11</b> New register site handles forgotten passwords</li>
@@ -211,96 +212,6 @@
</div>
<div id="plays">
- <p class="game-par">
- <button onclick="new_play('Breakthrough')"
- class="boldobt">Breakthrough</button>
- </p>
- <ul class="plays-list" id="a-plays-list-Breakthrough">
- <li style="display: none;"/>
- </ul>
- <ul class="plays-list" id="d-plays-list-Breakthrough">
- <li style="display: none;"/>
- </ul>
- <p class="game-par">
- <button onclick="new_play('Checkers')"
- class="boldobt">Checkers</button>
- </p>
- <ul class="plays-list" id="a-plays-list-Checkers">
- <li style="display: none;"/>
- </ul>
- <ul class="plays-list" id="d-plays-list-Checkers">
- <li style="display: none;"/>
- </ul>
- <p class="game-par">
- <button onclick="new_play('Chess')"
- class="boldobt">Chess</button>
- </p>
- <ul class="plays-list" id="a-plays-list-Chess">
- <li style="display: none;"/>
- </ul>
- <ul class="plays-list" id="d-plays-list-Chess">
- <li style="display: none;"/>
- </ul>
- <p class="game-par">
- <button onclick="new_play('Connect4')"
- class="boldobt">Connect4</button>
- </p>
- <ul class="plays-list" id="a-plays-list-Connect4">
- <li style="display: none;"/>
- </ul>
- <ul class="plays-list" id="d-plays-list-Connect4">
- <li style="display: none;"/>
- </ul>
- <p class="game-par">
- <button onclick="new_play('Entanglement')"
- class="boldobt">Entanglement</button>
- </p>
- <ul class="plays-list" id="a-plays-list-Entanglement">
- <li style="display: none;"/>
- </ul>
- <ul class="plays-list" id="d-plays-list-Entanglement">
- <li style="display: none;"/>
- </ul>
- <p class="game-par">
- <button onclick="new_play('Gomoku')"
- class="boldobt">Gomoku</button>
- </p>
- <ul class="plays-list" id="a-plays-list-Gomoku">
- <li style="display: none;"/>
- </ul>
- <ul class="plays-list" id="d-plays-list-Gomoku">
- <li style="display: none;"/>
- </ul>
- <p class="game-par">
- <button onclick="new_play('Pawn-Whopping')"
- class="boldobt">Pawn-Whopping</button>
- </p>
- <ul class="plays-list" id="a-plays-list-Pawn-Whopping">
- <li style="display: none;"/>
- </ul>
- <ul class="plays-list" id="d-plays-list-Pawn-Whopping">
- <li style="display: none;"/>
- </ul>
- <p class="game-par">
- <button onclick="new_play('Tic-Tac-Toe')"
- class="boldobt">Tic-Tac-Toe</button>
- </p>
- <ul class="plays-list" id="a-plays-list-Tic-Tac-Toe">
- <li style="display: none;"/>
- </ul>
- <ul class="plays-list" id="d-plays-list-Tic-Tac-Toe">
- <li style="display: none;"/>
- </ul>
- <p class="game-par">
- <button onclick="new_play('Concurrent-Tic-Tac-Toe')"
- class="boldobt">Concurrent-Tic-Tac-Toe</button>
- </p>
- <ul class="plays-list" id="a-plays-list-Concurrent-Tic-Tac-Toe">
- <li style="display: none;"/>
- </ul>
- <ul class="plays-list" id="d-plays-list-Concurrent-Tic-Tac-Toe">
- <li style="display: none;"/>
- </ul>
</div>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|