-
Notifications
You must be signed in to change notification settings - Fork 3
/
inputform.html
143 lines (108 loc) · 4.95 KB
/
inputform.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
<!DOCTYPE HTML>
<html>
<!--
pgn4web javascript chessboard
copyright (C) 2009-2014 Paolo Casaschi
see README file and http://pgn4web.casaschi.net
for credits, license and more details
-->
<head>
<title>Basic PGN viewer form</title>
<link href="inputform.css" type="text/css" rel="stylesheet" />
<link rel="icon" sizes="16x16" href="pawn.ico" />
<script src="pgn4web.js" type="text/javascript"></script>
<script src="engine.js" type="text/javascript"></script>
<script type="text/javascript">
"use strict";
SetImagePath("images/merida/26");
SetImageType("png");
SetHighlightOption(false);
SetGameSelectorOptions(null, true, 8, 8, 0, 12, 12, 3, 10); // (head, num, chEvent, chSite, chRound, chWhite, chBlack, chResult, chDate);
SetAutoplayDelay(2000); // milliseconds
SetShortcutKeysEnabled(true);
</script>
</head>
<body>
<!-- paste your PGN below and make sure you dont specify an external source with SetPgnUrl() -->
<form style="display: none;"><textarea style="display: none;" id="pgnText">
</textarea></form>
<!-- paste your PGN above and make sure you dont specify an external source with SetPgnUrl() -->
<table width="100%" cellpadding="0" cellspacing="0" border="0" style="border: solid 5px transparent; outline: solid 5px #E8E8E8;">
<tr>
<td width="272" align="left" valign="top" style="background-color:#E8E8E8;">
<div id="GameBoard"></div>
</td>
<td align="left" valign="top" style="background-color:#E8E8E8;">
<div class="pgnheader"> </div>
<div class="pgnheader"><span id="GameDate" title="date"></span> </div>
<div class="pgnheader"><span id="GameSite" title="site"></span> </div>
<div class="pgnheader"><span id="GameEvent" title="event"></span> </div>
<div class="pgnheader"><span id="GameRound" title="round"></span> </div>
<div class="pgnheader"> </div>
<div class="pgnheader"><span id="GameWhite" title="white player"></span> </div>
<div class="pgnheader"><span id="GameBlack" title="black player"></span> </div>
<div class="pgnheader"><span id="GameResult" title="result"></span> </div>
<div class="pgnheader"> </div>
<div class="pgnheader"><span id="GameLastMove" title="last move"></span> <span id="GameLastVariations" title="last move alternatives"></span></div>
<div class="pgnheader"><span id="GameNextMove" title="next move"></span> <span id="GameNextVariations" title="next move alternatives"></span></div>
<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>
</td>
</tr>
<tr height="34">
<td style="background-color:#E8E8E8;">
<div id="GameButtons"></div>
</td>
<td valign="bottom" style="padding-left:30px; background-color:#E8E8E8;">
<div id="GameSelector"></div>
</td>
</tr>
<tr><td colspan="2" height="5" align="center"></td></tr>
<tr><td colspan="2" align="center" style="background-color:#E8E8E8;">
<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">
{ enter PGN data here }
</textarea>
</td>
</tr>
</table>
<script type="text/javascript">
"use strict";
function customFunctionOnAlert(message_string) {
stopAlertPrompt();
alert(message_string);
}
// customShortcutKey_Shift_8 defined by engine.js
// customShortcutKey_Shift_9 defined by engine.js
// customShortcutKey_Shift_0 defined by engine.js
function cleanPgnData(text) {
text = text.replace(/\[/g,'\n\n[');
text = text.replace(/\]/g,']\n\n');
text = text.replace(/([012\*])(\s*)(\[)/g,'$1\n\n$3');
text = text.replace(/\]\s*\[/g,']\n[');
text = text.replace(/^\s*\[/g,'[');
text = text.replace(/\n[\s*\n]+/g,'\n\n');
return text;
}
function loadPgnData() {
firstStart = true;
document.getElementById('pgnText').value = simpleHtmlentities(cleanPgnData(document.getElementById('pgnForm').value));
start_pgn4web();
}
function gup(name) {
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regexS = "[\\?&]"+name+"=([^&#]*)";
regexS = regexS+"(?!.*"+regexS+")"; // matches the LAST occurrence
var regex = new RegExp( regexS, "i" );
var results = regex.exec( window.location.href );
if (results === null) { return ""; }
else { return decodeURIComponent(results[1]); }
}
var newPgnText = gup("pgnText");
if (newPgnText === "") { newPgnText = gup("pt"); }
if (newPgnText !== "") {
newPgnText = simpleHtmlentities(cleanPgnData(newPgnText));
document.getElementById('pgnText').value = newPgnText;
document.getElementById('pgnForm').value = newPgnText;
}
</script>
</body>
</html>