[Toss-devel-svn] SF.net SVN: toss:[1495] trunk/Toss
Status: Beta
Brought to you by:
lukaszkaiser
|
From: <luk...@us...> - 2011-06-24 13:49:42
|
Revision: 1495
http://toss.svn.sourceforge.net/toss/?rev=1495&view=rev
Author: lukaszkaiser
Date: 2011-06-24 13:49:35 +0000 (Fri, 24 Jun 2011)
Log Message:
-----------
Plays list and stability corrections.
Modified Paths:
--------------
trunk/Toss/Server/DB.ml
trunk/Toss/Server/ReqHandler.ml
trunk/Toss/Server/Server.ml
trunk/Toss/WebClient/Main.js
trunk/Toss/WebClient/Style.css
trunk/Toss/WebClient/register.html
Modified: trunk/Toss/Server/DB.ml
===================================================================
--- trunk/Toss/Server/DB.ml 2011-06-22 22:37:37 UTC (rev 1494)
+++ trunk/Toss/Server/DB.ml 2011-06-24 13:49:35 UTC (rev 1495)
@@ -7,7 +7,9 @@
let tID = ref "toss_id_05174_"
-let dbFILE = ref ((Unix.getenv "HOME") ^ "/.tossdb.sqlite")
+let dbFILE = ref
+ ( try (Unix.getenv "HOME") ^ "/.tossdb.sqlite"
+ with _ -> "/tossdb.sqlite" )
let tGAMES = ref ["Breakthrough"; "Checkers"; "Chess"; "Connect4";
"Entanglement"; "Gomoku"; "Pawn-Whopping"; "Tic-Tac-Toe";
@@ -106,7 +108,7 @@
Printf.printf "DB busy or locked, retrying %i\n%!" retried;
ignore (Unix.select [] [] [] 0.1);
apply_cmd ~retried:(retried+1) dbfile select cmd
- | x -> raise (DBError (Sqlite3.Rc.to_string x))
+ | x -> raise (DBError ((Sqlite3.Rc.to_string x) ^ ":" ^ select_s))
let get_table dbfile ?(select="") tbl =
fst (apply_cmd dbfile select ("select * from " ^ tbl))
Modified: trunk/Toss/Server/ReqHandler.ml
===================================================================
--- trunk/Toss/Server/ReqHandler.ml 2011-06-22 22:37:37 UTC (rev 1494)
+++ trunk/Toss/Server/ReqHandler.ml 2011-06-24 13:49:35 UTC (rev 1495)
@@ -693,7 +693,7 @@
if line_in = "" || line_in = "\r" then
try nonempty () with End_of_file -> ""
else line_in in
- nonempty () in
+ try nonempty () with Sys_error _ -> "" in
let line_in_len = String.length line_in in
if line_in_len = 0 then ("", None) else
(* TODO: who needs escaping? *)
Modified: trunk/Toss/Server/Server.ml
===================================================================
--- trunk/Toss/Server/Server.ml 2011-06-22 22:37:37 UTC (rev 1494)
+++ trunk/Toss/Server/Server.ml 2011-06-24 13:49:35 UTC (rev 1495)
@@ -42,6 +42,7 @@
try
ignore (Unix.waitpid [Unix.WNOHANG] (-1));
ignore (Unix.waitpid [Unix.WNOHANG] (-1));
+ ignore (Unix.waitpid [Unix.WNOHANG] (-1));
with
Unix.Unix_error (e,_,_) -> if !debug_level > 1 then
Printf.printf "UNIX WAITPID: %s\n%!" (Unix.error_message e);
Modified: trunk/Toss/WebClient/Main.js
===================================================================
--- trunk/Toss/WebClient/Main.js 2011-06-22 22:37:37 UTC (rev 1494)
+++ trunk/Toss/WebClient/Main.js 2011-06-24 13:49:35 UTC (rev 1495)
@@ -64,7 +64,7 @@
function GamesPage(id, games){ // html tag id
this.games = games;
this.paragraphs = new Object();
- this.container = document.getElementById(id);
+ this.container = document.getElementById (id);
for (var i = 0; i < this.games.length; i++) {
var game = this.games[i];
@@ -74,35 +74,42 @@
var button = document.createElement("button");
paragraph.game_button = button;
- button.setAttribute("class", "boldobt");
+ button.setAttribute("class", "gamebt");
button.setAttribute("onclick", "new_play('" + game + "')");
button.innerHTML = game;
button.style.display = "block";
- this.container.appendChild(paragraph);
- paragraph.appendChild(button);
+ 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);
+ paragraph.appendChild (open_play_list);
+ var closed_plays = document.createElement("div");
+ paragraph.closed_plays = closed_plays;
+ closed_plays.setAttribute("id", "d-plays-div-" + game);
+
var completed_bt = document.createElement("button");
paragraph.completed_button = completed_bt;
completed_bt.setAttribute("class", "completedbt");
completed_bt.setAttribute("onclick",
- "GAMESPAGE.toggle_completed('" + game + "')");
+ "GAMESPAGE.toggle_completed ('" + game + "')");
completed_bt.innerHTML = "Completed games (Show)";
- this.container.appendChild(paragraph);
- paragraph.appendChild(completed_bt);
- paragraph.completed_shown = false;
+ closed_plays.appendChild (completed_bt);
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);
+ closed_plays.appendChild (closed_play_list);
+
+ closed_plays.style.display = "none";
+ paragraph.appendChild (closed_plays);
+ paragraph.completed_shown = false;
+ this.container.appendChild (paragraph);
}
return (this);
}
@@ -116,11 +123,11 @@
}
GamesPage.prototype.show_completed = function (game) {
- this.paragraphs[game].closed_play_list.style.display = "block";
+ this.paragraphs[game].closed_plays.style.display = "block";
}
GamesPage.prototype.hide_completed = function (game) {
- this.paragraphs[game].closed_play_list.style.display = "none";
+ this.paragraphs[game].closed_plays.style.display = "none";
}
GamesPage.prototype.toggle_completed = function (game) {
@@ -163,27 +170,23 @@
function list_plays_string (game, lst) {
PLAYS = parse_list ('##', lst);
- var a_plist = document.getElementById("a-plays-list-" + game);
- var d_plist = document.getElementById("d-plays-list-" + game);
+ 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);
+ a_plist.removeChild (a_plist.firstChild);
}
while (d_plist.childNodes.length > 0) {
- d_plist.removeChild(d_plist.firstChild);
+ 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));
+ a_plist.appendChild (new_play_item (game, i));
} else {
- d_plist.appendChild(new_play_item (game, i));
+ d_plist.appendChild (new_play_item (game, i));
}
}
- if (PLAYS.length == 0) {
- document.getElementById("a-plays-list-" + game).style.display = "none";
- } else {
- document.getElementById("a-plays-list-" + game).style.display = "block";
- }
+ if (d_plist.childNodes.length > 0) { GAMESPAGE.show_completed (game); }
}
function list_plays (game) {
@@ -193,19 +196,19 @@
function play_click (game, play_id, pi) {
- document.getElementById("opponents").style.display = "none";
+ document.getElementById ("opponents").style.display = "none";
list_plays (game);
- document.getElementById("welcome").style.display = "none";
- document.getElementById("game-disp").style.display = "none";
- document.getElementById("plays").style.display = "none";
+ document.getElementById ("welcome").style.display = "none";
+ document.getElementById ("game-disp").style.display = "none";
+ document.getElementById ("plays").style.display = "none";
GAME_NAME = game;
- var gd = document.getElementById("game-disp");
+ var gd = document.getElementById ("game-disp");
gd.style.display = "block";
gd.setAttribute ("class", "Game-" + game);
document.getElementById ("game-title").innerHTML = game;
- document.getElementById("game-disp").style.display = "block";
- document.getElementById("play-number").innerHTML = "" + play_id;
- document.getElementById("suggestions-toggle").style.display = "inline";
+ document.getElementById ("game-disp").style.display = "block";
+ document.getElementById ("play-number").innerHTML = "" + play_id;
+ document.getElementById ("suggestions-toggle").style.display = "inline";
CUR_PLAY_I = pi;
PLAYS[CUR_PLAY_I].redraw ();
}
@@ -232,12 +235,12 @@
}
function make_opnt_list () {
- var o = document.getElementById("opponents-list");
+ var o = document.getElementById ("opponents-list");
FULL_OPNT_LEN = FRIENDS.length + 1;
CUR_OPNT_START = 0;
- document.getElementById("opponents-prev").style.display = "none";
+ document.getElementById ("opponents-prev").style.display = "none";
if (MAX_OPNT_LEN > FULL_OPNT_LEN) {
- document.getElementById("opponents-next").style.display = "none"
+ document.getElementById ("opponents-next").style.display = "none"
}
var zeroli = document.createElement('li');
zeroli.setAttribute ("class", "opponents-list-elem");
@@ -250,55 +253,55 @@
if (i > MAX_OPNT_LEN - 2) { oi.style.display = "none"; }
o.appendChild (oi);
}
- document.getElementById("opponents").style.display = "block";
+ document.getElementById ("opponents").style.display = "block";
}
function new_play (game) {
if (UNAME == "") { alert ("Please log in to create plays"); return; }
GAME_NAME = game;
- var olist = document.getElementById("opponents-list");
- while (olist.childNodes.length > 0) { olist.removeChild(olist.firstChild); }
+ var olist = document.getElementById ("opponents-list");
+ while (olist.childNodes.length > 0) { olist.removeChild (olist.firstChild); }
make_opnt_list ();
}
function opponents_next () {
for (var i = CUR_OPNT_START; i < CUR_OPNT_START + MAX_OPNT_LEN; i++) {
- document.getElementById("opponent-" + "-" + i).style.display = "none";
+ document.getElementById ("opponent-" + "-" + i).style.display = "none";
}
CUR_OPNT_START += MAX_OPNT_LEN;
for (var i = CUR_OPNT_START; i < CUR_OPNT_START + MAX_OPNT_LEN; i++) {
if (i < FULL_OPNT_LEN) {
- document.getElementById("opponent-" + "-" + i).style.display = "list-item";
+ document.getElementById ("opponent-" + "-" + i).style.display = "list-item";
}
}
- document.getElementById("opponents-prev").style.display = "block"
+ document.getElementById ("opponents-prev").style.display = "block"
if (CUR_OPNT_START + MAX_OPNT_LEN > FULL_OPNT_LEN) {
- document.getElementById("opponents-next").style.display = "none"
+ document.getElementById ("opponents-next").style.display = "none"
}
}
function opponents_prev () {
for (var i = CUR_OPNT_START; i < CUR_OPNT_START + MAX_OPNT_LEN; i++) {
if (i < FULL_OPNT_LEN) {
- document.getElementById("opponent-" + "-" + i).style.display = "none";
+ document.getElementById ("opponent-" + "-" + i).style.display = "none";
}
}
CUR_OPNT_START -= MAX_OPNT_LEN;
for (var i = CUR_OPNT_START; i < CUR_OPNT_START + MAX_OPNT_LEN; i++) {
- document.getElementById("opponent-" + "-" + i).style.display = "list-item";
+ document.getElementById ("opponent-" + "-" + i).style.display = "list-item";
}
- document.getElementById("opponents-next").style.display = "block"
+ document.getElementById ("opponents-next").style.display = "block"
if (CUR_OPNT_START == 0) {
- document.getElementById("opponents-prev").style.display = "none"
+ document.getElementById ("opponents-prev").style.display = "none"
}
}
function show_chess_warning () {
- document.getElementById("chess-level-warning").style.display = "block";
+ document.getElementById ("chess-level-warning").style.display = "block";
}
function hide_chess_warning () {
- document.getElementById("chess-level-warning").style.display = "none";
+ document.getElementById ("chess-level-warning").style.display = "none";
}
function new_play_guest (game) {
@@ -309,17 +312,17 @@
if (game == "Pawn-Whopping") { wgame = "Pawn_(chess)" };
if (game == "Entanglement") { wgame = "Entanglement_(graph_measure)" };
wiki = "http://en.wikipedia.org/wiki/" + wgame;
- document.getElementById("topuser").innerHTML =
+ document.getElementById ("topuser").innerHTML =
game + ' (<a href="' + wiki + '">Move Rules</a>)';
- if (SIMPLE_SET) { document.getElementById("topuser").innerHTML = game };
- document.getElementById("pdescBack").style.display = "inline";
- document.getElementById("game-title").style.display = "none";
- document.getElementById("game-info-par").style.paddingBottom = "1em";
- document.getElementById("loginform").style.display = "none";
- document.getElementById("topright-register").style.display = "none";
- document.getElementById("topright").style.display = "inline";
- document.getElementById("logoutbt").style.display = "none";
- document.getElementById("welcome").style.display = "none";
+ if (SIMPLE_SET) { document.getElementById ("topuser").innerHTML = game };
+ document.getElementById ("pdescBack").style.display = "inline";
+ document.getElementById ("game-title").style.display = "none";
+ document.getElementById ("game-info-par").style.paddingBottom = "1em";
+ document.getElementById ("loginform").style.display = "none";
+ document.getElementById ("topright-register").style.display = "none";
+ document.getElementById ("topright").style.display = "inline";
+ document.getElementById ("logoutbt").style.display = "none";
+ document.getElementById ("welcome").style.display = "none";
if (game == "Chess") {
show_chess_warning ();
setTimeout("hide_chess_warning ()", 3000);
@@ -329,35 +332,35 @@
function new_play_do (opp_uid) {
list_plays (GAME_NAME);
- document.getElementById("welcome").style.display = "none";
- document.getElementById("game-disp").style.display = "none";
- document.getElementById("plays").style.display = "none";
- var gd = document.getElementById("game-disp");
+ document.getElementById ("welcome").style.display = "none";
+ document.getElementById ("game-disp").style.display = "none";
+ document.getElementById ("plays").style.display = "none";
+ var gd = document.getElementById ("game-disp");
gd.style.display = "block";
gd.setAttribute ("class", "Game-" + GAME_NAME);
document.getElementById ("game-title").innerHTML = GAME_NAME;
- document.getElementById("opponents").style.display = "none";
- var olist = document.getElementById("opponents-list");
- while (olist.childNodes.length > 0) { olist.removeChild(olist.firstChild); }
+ document.getElementById ("opponents").style.display = "none";
+ var olist = document.getElementById ("opponents-list");
+ while (olist.childNodes.length > 0) { olist.removeChild (olist.firstChild); }
if (opp_uid == -1) { opp_uid = UNAME; }
if (opp_uid == 0 || UNAME == "") { return; }
- //document.getElementById("plays-list-" + GAME_NAME).style.display = "block";
- document.getElementById("working").style.display = "block";
+ //document.getElementById ("plays-list-" + GAME_NAME).style.display = "block";
+ document.getElementById ("working").style.display = "block";
info_nbr = CONN.new_play (GAME_NAME, UNAME, opp_uid);
- document.getElementById("working").style.display = "none";
- document.getElementById("suggestions-toggle").style.display = "inline";
+ document.getElementById ("working").style.display = "none";
+ document.getElementById ("suggestions-toggle").style.display = "inline";
info_idx = info_nbr.indexOf('$');
FREE_PLAY_NO = parseInt(info_nbr.substring(0, info_idx));
- document.getElementById("play-number").innerHTML = "" + FREE_PLAY_NO;
+ document.getElementById ("play-number").innerHTML = "" + FREE_PLAY_NO;
CUR_PLAY_I = PLAYS.length;
- document.getElementById("game-disp").style.display = "block";
- document.getElementById("plays").style.left = "30em";
+ document.getElementById ("game-disp").style.display = "block";
+ document.getElementById ("plays").style.left = "30em";
var p = new Play (GAME_NAME, [0,1], [UNAME, opp_uid], FREE_PLAY_NO, 0,
info_nbr.substring(info_idx+1), UNAME);
PLAYS.push(p);
p.redraw ();
//li = new_play_item (GAME_NAME, CUR_PLAY_I);
- //document.getElementById("plays-list-" + GAME_NAME).appendChild(li);
+ //document.getElementById ("plays-list-" + GAME_NAME).appendChild (li);
}
function get_opponents () {
@@ -366,16 +369,16 @@
}
function play_anew (me_starts) {
- document.getElementById('payoffs').innerHTML = "Not Finished Yet";
- document.getElementById('payoffs').style.display = "none";
- document.getElementById('new-play-par').style.display = "none";
+ document.getElementById ('payoffs').innerHTML = "Not Finished Yet";
+ document.getElementById ('payoffs').style.display = "none";
+ document.getElementById ('new-play-par').style.display = "none";
if (UNAME == "guest") {
- document.getElementById("game-info-par").style.paddingBottom = "1em";
+ document.getElementById ("game-info-par").style.paddingBottom = "1em";
};
toggle_suggestions ();
toggle_suggestions ();
PLAYS[CUR_PLAY_I].clear ();
- document.getElementById('cur-move').innerHTML = "none";
+ document.getElementById ('cur-move').innerHTML = "none";
if (me_starts) {
var opp = PLAYS[CUR_PLAY_I].players[1];
if (PLAYS[CUR_PLAY_I].players[0] != UNAME) {
@@ -393,14 +396,14 @@
UNAME = me;
PLAYS[CUR_PLAY_I].cur_player_uid = UNAME;
if (opp == "computer") {
- var mv_time = document.getElementById("speed").value;
+ var mv_time = document.getElementById ("speed").value;
suggest_move_async (mv_time, make_move);
}
}
}
function decrease_moving (n) {
- document.getElementById("working").innerHTML = "Moving in " + n + "s ...";
+ document.getElementById ("working").innerHTML = "Moving in " + n + "s ...";
if (n > 0) {
setTimeout("decrease_moving(" + (n-1) + ")", 1000);
}
@@ -408,8 +411,8 @@
function show_moving_msg (n) {
if (n > 1) {
- document.getElementById("working").innerHTML = "Moving in "+ n+ "s ...";
- document.getElementById("working").style.display = "block";
+ document.getElementById ("working").innerHTML = "Moving in "+ n+ "s ...";
+ document.getElementById ("working").style.display = "block";
setTimeout("decrease_moving(" + (n-1) + ")", 1000);
}
}
@@ -417,8 +420,8 @@
function suggest_move_async (time, f) {
show_moving_msg (time);
var fm = function (m) {
- document.getElementById("working").style.display = "none";
- document.getElementById("working").innerHTML = "Working...";
+ document.getElementById ("working").style.display = "none";
+ document.getElementById ("working").innerHTML = "Working...";
if (m != "") { PLAYS[CUR_PLAY_I].show_move (new Move (m)); f() }
};
CONN.suggest (PLAYS[CUR_PLAY_I].cur_state.players[0]+1, time,
@@ -426,26 +429,26 @@
}
function suggest_move_click () {
- var mv_time = document.getElementById("speed").value;
+ var mv_time = document.getElementById ("speed").value;
suggest_move_async (mv_time, function () {});
}
function toggle_suggestions () {
- var txt = document.getElementById("suggestions-toggle").innerHTML;
+ var txt = document.getElementById ("suggestions-toggle").innerHTML;
if (txt.indexOf ("Before") == -1) {
SIMPLE_MOVES = true;
- document.getElementById("play-nbr-info").style.display = "none";
- document.getElementById("board").style.paddingTop = "1em";
- document.getElementById("suggestions-toggle").innerHTML =
+ document.getElementById ("play-nbr-info").style.display = "none";
+ document.getElementById ("board").style.paddingTop = "1em";
+ document.getElementById ("suggestions-toggle").innerHTML =
"Ask Before Move";
- document.getElementById("move-info-par").style.display = "none";
+ document.getElementById ("move-info-par").style.display = "none";
} else {
SIMPLE_MOVES = false;
- document.getElementById("play-nbr-info").style.display = "inline";
- document.getElementById("board").style.paddingTop = "0em";
- document.getElementById("suggestions-toggle").innerHTML =
+ document.getElementById ("play-nbr-info").style.display = "inline";
+ document.getElementById ("board").style.paddingTop = "0em";
+ document.getElementById ("suggestions-toggle").innerHTML =
"Move Without Asking";
- document.getElementById("move-info-par").style.display = "block";
+ document.getElementById ("move-info-par").style.display = "block";
}
}
Modified: trunk/Toss/WebClient/Style.css
===================================================================
--- trunk/Toss/WebClient/Style.css 2011-06-22 22:37:37 UTC (rev 1494)
+++ trunk/Toss/WebClient/Style.css 2011-06-24 13:49:35 UTC (rev 1495)
@@ -64,7 +64,7 @@
float: right;
}
-.obt, .boldobt {
+.obt, .boldobt, .gamebt {
text-align: left;
border-color: #260314;
border-radius: 4px;
@@ -81,17 +81,25 @@
text-decoration: underline;
}
-.boldobt {
+.boldobt, .gamebt {
font-weight: bold;
font-size: 1em;
}
-.boldobt:hover {
+.boldobt:hover, .gamebt:hover {
cursor: pointer;
text-decoration: underline;
}
+.gamebt {
+ margin-bottom: 1em;
+
+}
+
.completedbt {
+ position: relative;
+ top: -1em;
+ left: 1em;
text-align: left;
border-color: #260314;
border-radius: 4px;
@@ -730,15 +738,17 @@
}
.plays-list {
- margin-left: 1em;
- padding-left: 0px;
list-style: none;
margin: 0.5em;
+ margin-bottom: 0px;
+ margin-left: 0px;
+ padding-left: 0px;
+ padding-bottom: 1em;
border-bottom: 1px solid #260314;
}
.plays-list-elem {
- margin-left: 0em;
+ margin-left: 1em;
margin-bottom: 0em;
}
Modified: trunk/Toss/WebClient/register.html
===================================================================
--- trunk/Toss/WebClient/register.html 2011-06-22 22:37:37 UTC (rev 1494)
+++ trunk/Toss/WebClient/register.html 2011-06-24 13:49:35 UTC (rev 1495)
@@ -24,7 +24,7 @@
<h2>Register on tPlay</h2>
-<form id="registerform" action="">
+<div id="registerform">
<p> <span class="reglabel">Email:</span>
<input class="forminput" type="text" name="email"
id="email" onchange="register_email_change()" />
@@ -50,7 +50,7 @@
<p> <span class="reglabel">Surname:</span>
<input class="forminput" type="text" name="surname" id="surname" />
</p>
-</form>
+</div>
<p> </p>
<p> <span class="reglabel">Forgot your password?</span>
<button class="bt" id="forgotbt" type="button"
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|