1<!DOCTYPE HTML>
2<html>
3
4<!--
5  pgn4web javascript chessboard
6  copyright (C) 2009-2015 Paolo Casaschi
7  see README file and http://pgn4web.casaschi.net
8  for credits, license and more details
9-->
10
11<head>
12
13<title>pgn4web live chessboard</title>
14
15<link rel="icon" sizes="16x16" href="pawn.ico" />
16
17<script src="pgn4web.js" type="text/javascript"></script>
18<script src="engine.js" type="text/javascript"></script>
19
20<script src="fide-lookup.js" type="text/javascript"></script>
21
22<script type="text/javascript">
23  "use strict";
24
25  var thisRegExp;
26
27  var readyToReceivePgn = false;
28
29  var useTextarea = false;
30  thisRegExp = /(&|\?)(useTextarea|ut)=([^&]*)(&|$)/i;
31  if (window.location.search.match(thisRegExp) !== null) {
32    var useTextareaValue = unescape(window.location.search.match(thisRegExp)[3]);
33    if ((useTextareaValue == "true") || (useTextareaValue == "t")) { useTextarea = true; }
34  }
35
36  var pgnFile_default = location.protocol + "//" + location.hostname +
37    location.pathname.replace(/\/[^\/]*$/, "/live/live.pgn");
38  var pgnFile = pgnFile_default;
39  thisRegExp = /(&|\?)(pgnData|pd)=([^&]*)(&|$)/i;
40  if (window.location.search.match(thisRegExp) !== null) {
41    pgnFile = unescape(window.location.search.match(thisRegExp)[3]);
42  } else {
43    // accepts pgnData as alias for pgnFile for consistency with board.html
44    thisRegExp = /(&|\?)(pgnFile|pf)=([^&]*)(&|$)/i;
45    if (window.location.search.match(thisRegExp) !== null) {
46      pgnFile = unescape(window.location.search.match(thisRegExp)[3]);
47    }
48  }
49
50  var alertFlag = false;
51  var demoFlag = false;
52  thisRegExp = /(&|\?)(refreshDemo|rd|demo|d)=([^&]*)(&|$)/i;
53  if (window.location.search.match(thisRegExp) !== null) {
54    var refreshDemo = unescape(window.location.search.match(thisRegExp)[3]);
55    if ((refreshDemo == "true") || (refreshDemo == "t")) { alertFlag = demoFlag = true; }
56  }
57
58  var refreshMinutes_default = 1;
59  var refreshMinutes = refreshMinutes_default;
60  var stepFlag = true;
61  thisRegExp = /(&|\?)(refreshMinutes|rm)=([^&]*)(&|$)/i;
62  if (window.location.search.match(thisRegExp) !== null) {
63    refreshMinutes = parseFloat(unescape(window.location.search.match(thisRegExp)[3]));
64    if (isNaN(refreshMinutes)) { refreshMinutes = refreshMinutes_default; }
65    if (refreshMinutes <= 0) { refreshMinutes = refreshMinutes_default; }
66  }
67
68  var iniGame_default = 1;
69  var iniGame = iniGame_default;
70  thisRegExp = /(&|\?)(initialGame|ig)=([^&]*)(&|$)/i;
71  if (window.location.search.match(thisRegExp) !== null) {
72    iniGame = unescape(window.location.search.match(thisRegExp)[3]);
73  }
74
75  // set hideFinishedGamesClocks to true/false to hide/show the clocks of finished games
76  var hideFinishedGamesClocks = true;
77
78  thisRegExp = /(&|\?)(help|h)=(true|t)(&|$)/i;
79  if (window.location.search.match(thisRegExp) !== null) {
80    alert("pgn4web live-mosaic-tile.html parameters" + "\n" +
81      " - useTextarea = " + useTextarea + "; if set true uses textarea as PGN input (default false = use pgnData)" + "\n" +
82      " - pgnData = " + pgnFile + "; PGN file to load (default " + pgnFile_default + ")" + "\n" +
83      " - refreshMinutes = " + refreshMinutes + "; refresh interval in minutes, decimals allowed (default " + refreshMinutes_default + ")" + "\n" +
84      " - refreshDemo = " + demoFlag + "; sets live demo mode (default false)" + "\n" +
85      " - initialGame = " + iniGame + "; initial game number or search string" + "\n" +
86      " - help = true");
87  }
88
89  if (!useTextarea) { SetPgnUrl(pgnFile); }
90  SetImagePath("images/alpha/24");
91  SetImageType("png");
92  SetHighlightOption(true); // true or false
93  SetCommentsIntoMoveText(false);
94  SetCommentsOnSeparateLines(false);
95  SetAutoplayDelay(1000); // milliseconds
96  SetAutostartAutoplay(false);
97  SetAutoplayNextGame(false);
98  SetInitialGame(iniGame);
99  SetInitialVariation(0);
100  SetInitialHalfmove("end", true);
101  SetShortcutKeysEnabled(false);
102  SetLiveBroadcast(refreshMinutes, demoFlag, alertFlag, stepFlag);
103
104  clearShortcutSquares("G", "8");
105  clearShortcutSquares("BCEFG", "7");
106  clearShortcutSquares("CDEF", "6");
107  clearShortcutSquares("ABCDEFGH", "345");
108
109  try {
110    var pcscsfcf, cscs;
111    if (parent && (parent !== window) && (pcscsfcf = parent.pgn4webClearShortCutSquaresForChildFrames)) {
112      for (cscs in pcscsfcf) { clearShortcutSquares(pcscsfcf[cscs][0], pcscsfcf[cscs][1]); }
113    }
114    if (parent && (parent !== window) && parent.displayPgnData && parent.savePgnData) {
115      boardShortcut("D8", "show full PGN source data", function(t,e){ if (e.shiftKey) { parent.savePgnData(); } else { parent.displayPgnData(); } });
116    }
117  } catch(e) { myAlert("warning: failed accessing frame's parent for shortcut squares to clear", false); }
118
119  function addTagToTitle(tagLabel, tagValue, object) {
120    if (!tagValue || tagValue[1] == "?" || !object) { return; }
121    object.title += ((object.title && tagLabel) ? "\n" : (object.title ? "  " : "")) + simpleHtmlentitiesDecode(tagLabel + tagValue);
122  }
123
124  function hideThisGame() {
125    try {
126      if (parent && (parent !== window) && parent.pgn4webHideChildFrameGame) {
127        parent.pgn4webHideChildFrameGame(gameEvent[currentGame], gameSite[currentGame], gameDate[currentGame], gameRound[currentGame], gameWhite[currentGame], gameBlack[currentGame]);
128      }
129    } catch(e) { myAlert("error: failed accessing frame's parent for hiding game", true); }
130  }
131
132  function customFunctionOnPgnTextLoad() {
133    var thisCurrentGame = currentGame;
134
135    // force reloading iniGame each time
136    SetInitialGame(iniGame);
137    setCurrentGameFromInitialGame();
138    if (currentGame != thisCurrentGame) {
139      SetInitialVariation(0);
140      SetInitialHalfmove("end",true);
141      Init();
142      GoToInitialHalfmove();
143    }
144
145  }
146
147  var old_gameKey = "";
148  var old_PlyNumber = -1;
149  function customFunctionOnPgnGameLoad() {
150    var theObj;
151
152    theObj = document.getElementById("GameWhiteClock");
153    if (theObj) { theObj.style.visibility = ((hideFinishedGamesClocks) && (gameResult[currentGame] != "*")) ? "hidden" : ""; }
154    theObj = document.getElementById("GameBlackClock");
155    if (theObj) { theObj.style.visibility = ((hideFinishedGamesClocks) && (gameResult[currentGame] != "*")) ? "hidden" : ""; }
156
157    theObj = document.getElementById("bottomContainer");
158    if (theObj) {
159      theObj.title = numberOfGames > 1 ? "game " + (currentGame+1) + " of " + numberOfGames : "";
160      addTagToTitle("event:  ", gameEvent[currentGame], theObj);
161      addTagToTitle("", customPgnHeaderTag("Section"), theObj);
162      addTagToTitle("", customPgnHeaderTag("Stage"), theObj);
163      addTagToTitle("site:  ", gameSite[currentGame], theObj);
164      addTagToTitle("date:  ", gameDate[currentGame], theObj);
165      addTagToTitle("round:  ", gameRound[currentGame], theObj);
166      addTagToTitle("white:  ", gameWhite[currentGame], theObj);
167      addTagToTitle("", customPgnHeaderTag("WhiteTitle"), theObj);
168      addTagToTitle("", customPgnHeaderTag("WhiteElo"), theObj);
169      addTagToTitle("", customPgnHeaderTag("WhiteTeam"), theObj);
170      addTagToTitle("black:  ", gameBlack[currentGame], theObj);
171      addTagToTitle("", customPgnHeaderTag("BlackTitle"), theObj);
172      addTagToTitle("", customPgnHeaderTag("BlackElo"), theObj);
173      addTagToTitle("", customPgnHeaderTag("BlackTeam"), theObj);
174      addTagToTitle("result:  ", gameResult[currentGame], theObj);
175      addTagToTitle("termination:  ", customPgnHeaderTag("Termination"), theObj);
176      addTagToTitle("timecontrol:  ", customPgnHeaderTag("TimeControl"), theObj);
177    }
178
179    try {
180      if (parent && (parent !== window) && parent.pgn4webHideChildFrameGame) {
181        if (parent.barePadding === "") {
182          if (parent.pgn4webHideChildFrameGame(gameEvent[currentGame], gameSite[currentGame], gameDate[currentGame], gameRound[currentGame], gameWhite[currentGame], gameBlack[currentGame], true)) {
183            boardShortcut("A6", "hide this game", function(t,e){ hideThisGame(); });
184          } else {
185            boardShortcut("A6", "hiding option unavailable for this game", function(t,e){} );
186          }
187        }
188      }
189    } catch(e) { myAlert("warning: failed accessing frame's parent for hiding game option", false); }
190
191    var this_gameKey = gameKey(gameEvent[currentGame], gameSite[currentGame], gameDate[currentGame], gameRound[currentGame], gameWhite[currentGame], gameBlack[currentGame]);
192    newMovesFlag((old_gameKey === this_gameKey) && (old_PlyNumber !== PlyNumber));
193    old_gameKey = this_gameKey;
194    old_PlyNumber = PlyNumber;
195  }
196
197  var newMovesFlagTimeout = null;
198  function newMovesFlag(onOff) {
199    if (newMovesFlagTimeout) {
200      clearTimeout(newMovesFlagTimeout);
201      newMovesFlagTimeout = null;
202    }
203    var theObj = document.getElementById("GameNewMoves");
204    if (theObj) { theObj.innerHTML = onOff ? "^" : ""; }
205    if (onOff) { newMovesFlagTimeout = setTimeout("newMovesFlag(false);", refreshMinutes * 60000 + 2000); }
206  }
207
208  function gameKey(event, site, date, round, white, black) {
209    var key = "";
210    key += "[" + (typeof(event) == "string" ? event : "") + "]";
211    key += "[" + (typeof(site) == "string" ? site : "") + "]";
212    key += "[" + (typeof(round) == "string" ? round : "") + "]";
213    key += "[" + (typeof(white) == "string" ? white : "") + "]";
214    key += "[" + (typeof(black) == "string" ? black : "") + "]";
215    return key;
216  }
217
218  function replayPreviousMovesMosaic(force) {
219    if (force || newMovesFlagTimeout) { replayPreviousMoves(1); }
220  }
221
222  function customShortcutKey_Shift_0() { try { if (parent && (parent !== window) && parent.customShortcutKey_Shift_0) { parent.customShortcutKey_Shift_0(); } } catch(e) { myAlert("error: failed accessing frame's parent custom shortcut key function"); } }
223
224  // customShortcutKey_Shift_1 defined by fide-lookup.js
225  // customShortcutKey_Shift_2 defined by fide-lookup.js
226
227  function customShortcutKey_Shift_3() { try { if (parent && (parent !== window) && parent.customShortcutKey_Shift_3) { parent.customShortcutKey_Shift_3(); } } catch(e) { myAlert("error: failed accessing frame's parent custom shortcut key function"); } }
228  function customShortcutKey_Shift_4() { try { if (parent && (parent !== window) && parent.customShortcutKey_Shift_4) { parent.customShortcutKey_Shift_4(); } } catch(e) { myAlert("error: failed accessing frame's parent custom shortcut key function"); } }
229  function customShortcutKey_Shift_5() { try { if (parent && (parent !== window) && parent.customShortcutKey_Shift_5) { parent.customShortcutKey_Shift_5(); } } catch(e) { myAlert("error: failed accessing frame's parent custom shortcut key function"); } }
230  function customShortcutKey_Shift_6() { try { if (parent && (parent !== window) && parent.customShortcutKey_Shift_6) { parent.customShortcutKey_Shift_6(); } } catch(e) { myAlert("error: failed accessing frame's parent custom shortcut key function"); } }
231  function customShortcutKey_Shift_7() { try { if (parent && (parent !== window) && parent.customShortcutKey_Shift_7) { parent.customShortcutKey_Shift_7(); } } catch(e) { myAlert("error: failed accessing frame's parent custom shortcut key function"); } }
232
233  // overwriting engine.js definitions of customShortcutKey_Shift_8 9 0
234  function customShortcutKey_Shift_8() { try { if (parent && (parent !== window) && parent.customShortcutKey_Shift_8) { parent.customShortcutKey_Shift_8(); } } catch(e) { myAlert("error: failed accessing frame's parent custom shortcut key function"); } }
235  function customShortcutKey_Shift_9() { try { if (parent && (parent !== window) && parent.customShortcutKey_Shift_9) { parent.customShortcutKey_Shift_9(); } } catch(e) { myAlert("error: failed accessing frame's parent custom shortcut key function"); } }
236
237
238  function pgn4web_onload(e) {
239    start_pgn4web();
240    readyToReceivePgn = true;
241    try {
242      if (parent && (parent !== window)) {
243        if (parent.readyToSendPgn) {
244          var boardId = parseInt(window.name.substr(5), 10);
245          if (!isNaN(boardId)) { parent.updateBoard(boardId); }
246          else { myAlert("warning: failed detecting board id", false); }
247        }
248        if (parent.document.body.style.backgroundColor) {
249          var RGB;
250          if (RGB = parent.document.body.style.backgroundColor.match(/^rgb\((\d+), (\d+), (\d+)\)$/)) {
251            // RGB to Luma conversion: Photometric/digital ITU-R
252            if ((0.2126 * parseInt(RGB[1],10) + 0.7152 * parseInt(RGB[2],10) + 0.0722 * parseInt(RGB[3],10)) < (256 * 0.45)) {
253              if (theObj = document.body) { theObj.style.color = "white"; }
254              if (theObj = document.getElementById("GameWhiteFlag")) { theObj.style.borderColor = "white"; }
255              if (theObj = document.getElementById("GameBlackFlag")) { theObj.style.borderColor = "white"; }
256            }
257          }
258        }
259      } else { myAlert("warning: parent not avalable", false); }
260    } catch(e) { myAlert("warning: failed accessing parent", false); }
261  }
262
263</script>
264
265<style type="text/css">
266
267@import url("fonts/pgn4web-font-LiberationSans.css");
268
269html,
270body {
271  margin: 0px;
272  padding: 0px;
273}
274
275body {
276  background: transparent;
277  color: black;
278  font-family: 'pgn4web Liberation Sans', sans-serif;
279  font-size: 12px;
280  font-weight: bold;
281  padding: 13px;
282
283  -webkit-user-select: none;
284  -moz-user-select: none;
285  -ms-user-select: none;
286  -o-user-select: none;
287  user-select: none;
288  -webkit-text-size-adjust: none;
289  -moz-text-size-adjust: none;
290  -ms-text-size-adjust: none;
291  -o-text-size-adjust: none;
292  text-size-adjust: none;
293  -webkit-touch-callout: none;
294}
295
296a {
297  color: inherit;
298  text-decoration: none;
299}
300
301.boardTable {
302  border-style: solid;
303  border-color: #663300;
304  border-width: 3px;
305  background: #CC9966;
306  box-shadow: 0px 0px 13px #663300;
307  width: 230px;
308  height: 230px;
309}
310
311.pieceImage {
312  width: 24px;
313  height: 24px;
314}
315
316.whiteSquare,
317.blackSquare,
318.highlightWhiteSquare,
319.highlightBlackSquare {
320  width: 26px;
321  height: 26px;
322  border-style: solid;
323  border-width: 1px;
324}
325
326.whiteSquare,
327.highlightWhiteSquare {
328  border-color: #FFCC99;
329  background: #FFCC99;
330}
331
332.blackSquare,
333.highlightBlackSquare {
334  border-color: #CC9966;
335  background: #CC9966;
336}
337
338.highlightWhiteSquare,
339.highlightBlackSquare {
340  border-style: inset;
341  border-color: #CC9966;
342}
343
344.move,
345.variation,
346.comment {
347}
348
349.bottomContainer {
350  width: 230px;
351  margin-top: 10px;
352}
353
354.leftHeaderItem,
355.rightHeaderItem {
356  white-space: nowrap;
357  overflow: hidden;
358  width: 103px;
359}
360
361.leftHeaderItem {
362  float: left;
363  text-align: left;
364}
365
366.rightHeaderItem {
367  float: right;
368  text-align: right;
369}
370
371</style>
372
373</head>
374
375<body>
376
377<!-- paste your PGN below and make sure you dont specify an external source with SetPgnUrl() -->
378<form style="display: none;"><textarea style="display: none;" id="pgnText">
379
380[Result "*"]
381
382</textarea></form>
383<!-- paste your PGN above and make sure you dont specify an external source with SetPgnUrl() -->
384
385<center>
386
387<div id="GameBoard"></div>
388
389<div id="bottomContainer" class="bottomContainer">
390
391<div class="leftHeaderItem"><span id="GameLastMove"></span>&nbsp;</div>
392<div class="rightHeaderItem">&nbsp;<span id="GameNextMove"></span></div>
393<div>&nbsp;<a href="javascript:void(0);" onclick="newMovesFlag(false); this.blur();" title="new moves received" id="GameNewMoves"></a>&nbsp;</div>
394
395<div class="leftHeaderItem"><a href="javascript:void(0);" onclick="if (typeof(openFidePlayerUrl) == 'function') { openFidePlayerUrl(gameWhite[currentGame], customPgnHeaderTag('WhiteFideId')); } this.blur();" id="GameWhite" class="notranslate"></a>&nbsp;</div>
396<div class="rightHeaderItem">&nbsp;<a href="javascript:void(0);" onclick="if (typeof(openFidePlayerUrl) == 'function') { openFidePlayerUrl(gameBlack[currentGame], customPgnHeaderTag('BlackFideId')); } this.blur();" id="GameBlack" class="notranslate"></a></div>
397
398<div class="leftHeaderItem"><span id="GameWhiteClock"></span>&nbsp;</div>
399<div class="rightHeaderItem">&nbsp;<span id="GameBlackClock"></span></div>
400
401</div>
402
403</center>
404
405</body>
406
407</html>
408