1<!DOCTYPE HTML> 2<html> 3 4<!-- 5 pgn4web javascript chessboard 6 copyright (C) 2009-2014 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>Basic PGN viewer form</title> 14 15<link href="inputform.css" type="text/css" rel="stylesheet" /> 16 17<link rel="icon" sizes="16x16" href="pawn.ico" /> 18 19<script src="pgn4web.js" type="text/javascript"></script> 20<script src="engine.js" type="text/javascript"></script> 21 22<script type="text/javascript"> 23 "use strict"; 24 25 SetImagePath("images/merida/26"); 26 SetImageType("png"); 27 SetHighlightOption(false); 28 SetGameSelectorOptions(null, true, 8, 8, 0, 12, 12, 3, 10); // (head, num, chEvent, chSite, chRound, chWhite, chBlack, chResult, chDate); 29 SetAutoplayDelay(2000); // milliseconds 30 SetShortcutKeysEnabled(true); 31</script> 32 33</head> 34 35<body> 36 37<!-- paste your PGN below and make sure you dont specify an external source with SetPgnUrl() --> 38<form style="display: none;"><textarea style="display: none;" id="pgnText"> 39 40</textarea></form> 41<!-- paste your PGN above and make sure you dont specify an external source with SetPgnUrl() --> 42 43<table width="100%" cellpadding="0" cellspacing="0" border="0" style="border: solid 5px transparent; outline: solid 5px #E8E8E8;"> 44 45<tr> 46 47<td width="272" align="left" valign="top" style="background-color:#E8E8E8;"> 48<div id="GameBoard"></div> 49</td> 50 51<td align="left" valign="top" style="background-color:#E8E8E8;"> 52 53<div class="pgnheader"> </div> 54<div class="pgnheader"><span id="GameDate" title="date"></span> </div> 55<div class="pgnheader"><span id="GameSite" title="site"></span> </div> 56<div class="pgnheader"><span id="GameEvent" title="event"></span> </div> 57<div class="pgnheader"><span id="GameRound" title="round"></span> </div> 58<div class="pgnheader"> </div> 59<div class="pgnheader"><span id="GameWhite" title="white player"></span> </div> 60<div class="pgnheader"><span id="GameBlack" title="black player"></span> </div> 61<div class="pgnheader"><span id="GameResult" title="result"></span> </div> 62<div class="pgnheader"> </div> 63<div class="pgnheader"><span id="GameLastMove" title="last move"></span> <span id="GameLastVariations" title="last move alternatives"></span></div> 64<div class="pgnheader"><span id="GameNextMove" title="next move"></span> <span id="GameNextVariations" title="next move alternatives"></span></div> 65<div class="pgnheader" style="text-align:right; padding-right:10px;"><a class="pgnSubmit" href="javascript:loadPgnData();" onclick="this.blur();" title="submit PGN data; a flashing chessboard signals errors in the PGN data, click on the top left chessboard square for debug messages">click here to show chess games</a></div> 66 67</td> 68 69</tr> 70 71<tr height="34"> 72<td style="background-color:#E8E8E8;"> 73<div id="GameButtons"></div> 74</td> 75<td valign="bottom" style="padding-left:30px; background-color:#E8E8E8;"> 76<div id="GameSelector"></div> 77</td> 78</tr> 79 80<tr><td colspan="2" height="5" align="center"></td></tr> 81 82<tr><td colspan="2" align="center" style="background-color:#E8E8E8;"> 83<textarea id="pgnForm" style="padding:0px; border-style:none; width:100%; overflow:auto; background-color:#E8E8E8; scrollbar-base-color:#E8E8E8; resize:vertical;" rows="12" onFocus="disableShortcutKeysAndStoreStatus();" onBlur="restoreShortcutKeysStatus();" title="enter PGN data; a flashing chessboard signals errors in the PGN data, click on the top left chessboard square for debug messages"> 84 85 { enter PGN data here } 86</textarea> 87</td> 88</tr> 89 90</table> 91 92<script type="text/javascript"> 93"use strict"; 94 95function customFunctionOnAlert(message_string) { 96 stopAlertPrompt(); 97 alert(message_string); 98} 99 100// customShortcutKey_Shift_8 defined by engine.js 101// customShortcutKey_Shift_9 defined by engine.js 102// customShortcutKey_Shift_0 defined by engine.js 103 104function cleanPgnData(text) { 105 text = text.replace(/\[/g,'\n\n['); 106 text = text.replace(/\]/g,']\n\n'); 107 text = text.replace(/([012\*])(\s*)(\[)/g,'$1\n\n$3'); 108 text = text.replace(/\]\s*\[/g,']\n['); 109 text = text.replace(/^\s*\[/g,'['); 110 text = text.replace(/\n[\s*\n]+/g,'\n\n'); 111 return text; 112} 113 114function loadPgnData() { 115 firstStart = true; 116 document.getElementById('pgnText').value = simpleHtmlentities(cleanPgnData(document.getElementById('pgnForm').value)); 117 start_pgn4web(); 118} 119 120 121function gup(name) { 122 name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]"); 123 var regexS = "[\\?&]"+name+"=([^&#]*)"; 124 regexS = regexS+"(?!.*"+regexS+")"; // matches the LAST occurrence 125 var regex = new RegExp( regexS, "i" ); 126 var results = regex.exec( window.location.href ); 127 if (results === null) { return ""; } 128 else { return decodeURIComponent(results[1]); } 129} 130 131var newPgnText = gup("pgnText"); 132if (newPgnText === "") { newPgnText = gup("pt"); } 133if (newPgnText !== "") { 134 newPgnText = simpleHtmlentities(cleanPgnData(newPgnText)); 135 document.getElementById('pgnText').value = newPgnText; 136 document.getElementById('pgnForm').value = newPgnText; 137} 138 139</script> 140 141</body> 142 143</html> 144