1
Fork 0
lorchess.ru/_assets/vendor/pgn4web/live-results-template.html

124 lines
3.9 KiB
HTML

<!DOCTYPE HTML>
<html>
<!--
pgn4web javascript chessboard
copyright (C) 2009-2013 Paolo Casaschi
see README file and http://pgn4web.casaschi.net
for credits, license and more details
-->
<head>
<title>pgn4web live broadcast</title>
<link rel="shortcut icon" href="pawn.ico" />
<script src="pgn4web.js" type="text/javascript"></script>
<script type="text/javascript">
"use strict";
var pgnFile;
var pgnFile_default = detectBaseLocation() ?
location.protocol + "//" + location.hostname + location.pathname.replace(/\/[^\/]*$/, "/live/live.pgn") :
"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;
}
}
var demoFlag = false;
var alertFlag = false;
if ((gup("demo") == "true") || (gup("demo") == "t") ||
(gup("refreshDemo") == "true") || (gup("refreshDemo") == "t")) {
demoFlag = true; alertFlag = true;
}
var refreshMinutes;
if ((refreshMinutes = gup("refreshMinutes")) === "") {
refreshMinutes = 1;
} else {
var testMinutes = refreshMinutes + "";
if ((testMinutes.match(/[^0-9\.]/)) || (refreshMinutes === 0)) {
if (alertFlag) {
alert("ERROR: refreshMinutes parameter must be a positive number.\n" +
"Supplied " + testMinutes + "; defaulting to 1.");
}
refreshMinutes = 1;
}
}
SetPgnUrl(pgnFile);
SetShortcutKeysEnabled(true);
SetLiveBroadcast(refreshMinutes, alertFlag, demoFlag, false);
function customFunctionOnPgnTextLoad() {
var resultObject = document.getElementById("results");
if (resultObject) {
var resultString = "";
resultString += fillWithBlanks("white", 15) + " ";
resultString += fillWithBlanks("black", 15) + " ";
resultString += fillWithBlanks("result", 7) + " ";
resultString += "\n \n";
for (var gg = 0; gg < numberOfGames; gg++) {
resultString += fillWithBlanks(gameWhite[gg], 15) + " ";
resultString += fillWithBlanks(gameBlack[gg], 15) + " ";
resultString += fillWithBlanks(gameResult[gg], 7) + " ";
resultString += "\n";
}
resultObject.innerText = resultString;
}
}
var blanks = " ";
function fillWithBlanks(str, num) {
if (str.length >= num) { return str.substr(0, num); }
else { return str + blanks.substr(0, num - str.length); }
}
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
var compact_name = name.charAt(0);
for (var 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 "";
}
</script>
</head>
<body style="margin:0px; padding:1.75em; font-family:monospace; color:black; font-size:16px;">
<pre id="results" style="font-size:16px;"></pre>
<a id="GameLiveStatus" style="text-decoration:none; color:black;" href="javascript:void(0);" onclick="refreshPgnSource(); this.blur();"></a>
</body>
</html>