-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathlive-multi.html
176 lines (140 loc) · 7.22 KB
/
live-multi.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
<html>
<!--
pgn4web javascript chessboard
copyright (C) 2009, 2010 Paolo Casaschi
see README file and http://pgn4web.casaschi.net
for credits, license and more details
-->
<head>
<title>pgn4web multiple live chessboards</title>
<link rel="shortcut icon" href="pawn.ico" />
<script type="text/javascript">
pgnFile_default = location.protocol + "//" + location.hostname + location.pathname.replace(/\/[^\/]*$/, "/live/live.pgn");
// accepts pgnData as alias for pgnFile for consistency with board.html
if ((pgnFile = gup("pgnData")) === "") {
if ((pgnFile = gup("pgnFile")) === "") {
pgnFile = pgnFile_default;
}
}
if ((refreshMinutes = gup("refreshMinutes")) === "") {
refreshMinutes = 1;
} else {
testMinutes = refreshMinutes + "";
if (testMinutes.match(/[^0-9\.]/)) {
alert("ERROR: refreshMinutes parameter must be a positive number.\n" +
"Supplied " + testMinutes + "; defaulting to 1.");
refreshMinutes = 1;
}
}
if ((boards = gup("boards")) === "") {
boards = 2;
} else {
testBoards = boards + "";
if ((testBoards.match(/[^0-9]/)) || (boards == 0) || (boards > 32)) {
alert("ERROR: boards parameter must be a positive integer, max 32.\n" +
"Supplied " + testBoards + "; defaulting to 2.");
boards = 2;
}
}
boards = parseInt(boards, 10);
if ((columns = gup("columns")) === "") {
columns = 2;
} else {
testColumns = columns + "";
if ((testColumns.match(/[^0-9]/)) || (columns == 0) || (columns > 8)) {
alert("ERROR: columns parameter must be a positive integer, max 8.\n" +
"Supplied " + testColumns + "; defaulting to 2.");
columns = 2;
}
}
columns = parseInt(columns, 10);
if ((displayOrder = gup("displayOrder")) === "") {
displayOrder = "sequential";
} else {
if ( (displayOrder != "reverse") && (displayOrder != "r") &&
(displayOrder != "sequential") && (displayOrder != "s") ) {
alert("ERROR: displayOrder must be either 'sequential' or 'reverse'.\n" +
"Supplied '" + displayOrder + "'; defaulting to 'sequential'.");
displayOrder = "sequential";
}
}
if ((gup("help") == "true") || (gup("help") == "t")) { developer_help(); }
function gup( name ){
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regexS = "[\\?&]"+name+"=([^&#]*)";
// commented below to match first occurrence (to avoid users overruling setting)
// regexS = regexS+"(?!.*"+regexS+")"; // matches the LAST occurrence
var regex = new RegExp( regexS, "i" );
var results = regex.exec( window.location.href );
if( results !== null ) { return decodeURIComponent(results[1]); }
// allows for short version of the URL parameters, for instance sC matches squareColor
compact_name = name.charAt(0);
for(i=1; i<name.length; i++){
if (name.charAt(i).match(/[A-Z]/)) { compact_name = compact_name + name.charAt(i).toLowerCase(); }
}
name = compact_name;
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
regexS = "[\\?&]"+name+"=([^&#]*)";
// commented below to match first occurrence (to avoid users overruling setting)
// regexS = regexS+"(?!.*"+regexS+")"; // matches the LAST occurrence
regex = new RegExp( regexS, "i" );
results = regex.exec( window.location.href );
if( results !== null ) { return decodeURIComponent(results[1]); }
return "";
}
function developer_help() {
alert("pgn4web live-multi.html parameters" + "\n" +
" - pgnData = " + pgnFile + "; PGN file to load (default " + pgnFile_default + ")" + "\n" +
" - refreshMinutes = " + refreshMinutes + "; refresh interval in minutes, decimals allowed (default 1)" + "\n" +
" - boards = " + boards + "; number of boards to display (default 2)" + "\n" +
" - columns = " + columns + "; number of columns to arrange the display (default 2)" + "\n" +
" - displayOrder = " + displayOrder + "; order of game display, 'sequential' (default) or 'reverse'" + "\n" +
" - help = true; prints this help (default false)");
}
buildUrl_one = location.protocol + "//" + location.host + location.pathname + "?";
buildUrl_two = "&do=" + displayOrder.charAt(0) + "&rm=" + refreshMinutes + "&pd=" + pgnFile;
oneMoreBoardUrl = buildUrl_one + "&b=" + (boards < 32 ? (boards + 1) : 32) + "&c=" + columns + buildUrl_two;
oneLessBoardUrl = buildUrl_one + "&b=" + (boards > 1 ? (boards - 1) : 1) + "&c=" + columns + buildUrl_two;
oneMoreColumnUrl = buildUrl_one + "&b=" + boards + "&c=" + (columns < 8 ? (columns + 1) : 8) + buildUrl_two;
oneLessColumnUrl = buildUrl_one + "&b=" + boards + "&c=" + (columns > 1 ? (columns - 1) : 1) + buildUrl_two;
</script>
<style type="text/css">
body
{ color: #DDDDDD; background: white; font-family: sans-serif; padding: 20px 20px 10px 20px; }
a:link, a:visited, a:hover, a:active
{ color: #DDDDDD; text-decoration: none; }
</style>
</head>
<body>
<h1 name='top'><a href='#row2'>pgn4web</a> <a href='#row3'>multiple</a> <a href='#row4'>live</a> <a href='#row5'>chessboards</a></h1>
<script type="text/javascript">
rows = Math.ceil(boards / columns);
document.write("<center><table cellspacing='5' cellpadding='0'>");
for (r = 0; r < rows; r++) {
document.write("<tr>");
for (c = 0; c < columns; c++) {
document.write("<td align='center' width='260'>");
if ((r * columns + c) < boards) {
initialGame = (r * columns + c + 1);
rm = Math.floor(1000 * (refreshMinutes * (1 + 0.1 * Math.random()))) / 1000;
if (displayOrder.charAt(0) == "r") { initialGame = -initialGame; }
document.write("<a style='color:white; font-size:x-small;' name='row" + (r+1) + "' href='#row" + (r+1) + "'>chessboard row:" + (r+1) + " col:" + (c+1) + "</a><br>");
document.write("<iframe width='240' height='313' frameborder='0' scrolling='no' marginheight='0' marginwidth='0' src='board.html?am=n&d=5000&ih=e&ss=26&ps=d&pf=d&lcs=VdyD&dcs=LHCg&bbcs=LHCg&bscs=b&hm=b&hcs=x7y_&bd=h&cbcs=VdyD&ctcs=yU1n&hd=j&md=h&tm=0&fhcs=7jdn&fhs=67p&bcs=____&fp=13&hl=f&fh=313&fw=b&pd=" + pgnFile + "&ig=" + initialGame + "&rm=" + rm + "'>your web browser and/or your host do not support iframes as required to display the chessboard</iframe>");
}
document.write("</td>");
}
document.write("</tr>");
}
document.write("</table></center>");
document.write("<table width='100%' cellspacing='5' cellpadding='0'><tr><td>");
document.write("<p style='text-align: left; font-size:small; color:white;'>refreshMinutes: " + refreshMinutes + "</p>");
document.write("</td><td>");
document.write("<p style='text-align: right; font-size:small; color:white;'><a style='color:white;' href='" + pgnFile + "'>" + pgnFile + "</a></p>");
document.write("</td></tr><tr><td>");
document.write("<p style='text-align: left; font-size:small; font-weight:bold;'><a href='" + oneLessColumnUrl + "'>less</a> / <a href='" + oneMoreColumnUrl + "'>more</a> columns<br/><a href='" + oneLessBoardUrl + "'>less</a> / <a href='" + oneMoreBoardUrl + "'>more</a> boards</p>");
document.write("</td><td>");
document.write("<p style='text-align: right; font-size:small; font-weight:bold;'>control the <a href='#top'>chessboards</a> by clicking their squares<br>hover the mouse on each square for help</p>");
document.write("</td></tr></table>");
</script>
</body>
</html>