-
Notifications
You must be signed in to change notification settings - Fork 6
/
inputform.html
144 lines (112 loc) · 5.64 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
<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>Basic PGN viewer form</title>
<link href="inputform.css" type="text/css" rel="stylesheet" />
<link rel="shortcut icon" href="pawn.ico" />
<script src="pgn4web.js" type="text/javascript"></script>
<script type="text/javascript">
// SetPgnUrl(""); // if set, this has precedence over the inline PGN below
SetImagePath("merida/26"); // use "" path if images are in the same folder as this javascript file
SetImageType("png");
SetHighlightOption(false); // true or false
SetGameSelectorOptions(" ...", true, 8, 8, 0, 12, 12, 3, 10); // (head, num, chEvent, chSite, chRound, chWhite, chBlack, chResult, chDate);
// SetCommentsIntoMoveText(true);
// SetCommentsOnSeparateLinesa(true);
SetAutoplayDelay(2000); // milliseconds
// SetAutostartAutoplay(false);
// SetAutoplayNextGame(false); // if set, move to the next game at the end of the current game during autoplay
// SetInitialGame(1); // number of game to be shown at load, from 1 (default); values (keep the quotes) of "first", "last", "random" are accepted; other string values assumed as PGN search string
// SetInitialHalfmove(0,false); // halfmove number to be shown at load, 0 (default) for start position; values (keep the quotes) of "start", "end", "random" and "comment" (go to first comment) are also accepted. Second parameter if true applies the setting to every selected game instead of startup only (default)
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="10" style="background-color:#E8E8E8;">
<tr>
<td width="272" align="left" valign="top">
<div style="width:272px;" id="GameBoard"></div>
</td>
<td width="100%" align="left" valign="top">
<div class="pgnheader"><span id="GameDate"></span> </div>
<div class="pgnheader"><span id="GameSite"></span> </div>
<div class="pgnheader"><span id="GameEvent"></span> </div>
<div class="pgnheader"><span id="GameRound"></span> </div>
<div class="pgnheader"> </div>
<div class="pgnheader"><span id="GameWhite"></span> </div>
<div class="pgnheader"><span id="GameBlack"></span> </div>
<div class="pgnheader"><span id="GameResult"></span> </div>
<div class="pgnheader"> </div>
<div class="pgnheader"><span id="GameLastMove"></span> </div>
</td>
</tr>
<tr>
<td>
<div id="GameButtons"></div>
</td>
<td style="padding-left:40px;">
<div id="GameSelector"></div>
</td>
</tr>
<tr><td colspan="2" width="100%" align="center">
<!--
padding-left = (8 * square-width) + (2 * table-cellpadding) + (pgnheader-padding) =
322 = (8 * 34) + (2 * 10) + (30)
-->
<div style="text-align:left; padding-left:322px; padding-bottom:5px;">
<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>
<textarea id="pgnForm" style="padding:10px; border-style:none; width:100%; overflow:auto; scrollbar-base-color:white;" 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"></textarea>
</td>
</tr>
</table>
<script type="text/javascript">
function customFunctionOnAlert(message_string) {
stopAlertPrompt();
alert(message_string);
}
function loadPgnData() {
firstStart = true;
document.getElementById('pgnText').value = document.getElementById('pgnForm').value;
document.getElementById('pgnText').value = document.getElementById('pgnText').value.replace(/\[/g,'\n\n[');
document.getElementById('pgnText').value = document.getElementById('pgnText').value.replace(/\]/g,']\n\n');
document.getElementById('pgnText').value = document.getElementById('pgnText').value.replace(/([012\*])(\s*)(\[)/g,'$1\n\n$3');
document.getElementById('pgnText').value = document.getElementById('pgnText').value.replace(/\]\s*\[/g,']\n[');
document.getElementById('pgnText').value = document.getElementById('pgnText').value.replace(/^\s*\[/g,'[');
document.getElementById('pgnText').value = document.getElementById('pgnText').value.replace(/\n[\s*\n]+/g,'\n\n');
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]); }
}
newPgnText = gup("pgnText");
if (newPgnText === "") { newPgnText = gup("pt"); }
if (newPgnText !== "") {
// cleans the PGN text
newPgnText = newPgnText.replace(/\[/g,"\n\n[");
newPgnText = newPgnText.replace(/\]/g,"]\n\n");
newPgnText = newPgnText.replace(/([012\*])(\s*)(\[)/g,"$1\n\n$3");
newPgnText = newPgnText.replace(/\]\s*\[/g,"]\n[");
newPgnText = newPgnText.replace(/^\s*\[/g,"[");
newPgnText = newPgnText.replace(/\n[\s*\n]+/g,'\n\n');
document.getElementById('pgnText').value = newPgnText;
document.getElementById('pgnForm').value = newPgnText;
}
</script>
</body>
</html>