-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathanalysis.html
More file actions
409 lines (349 loc) · 18.6 KB
/
analysis.html
File metadata and controls
409 lines (349 loc) · 18.6 KB
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
<!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>0.</title>
<!-- use viewport settings when body.onresize adapts the chessboard to the available space -->
<meta name="viewport" content="initial-scale=1, maximum-scale=1">
<link rel="icon" sizes="16x16" href="pawn.ico" />
<link href="analysis.css" type="text/css" rel="stylesheet" />
<script src="pgn4web.js" type="text/javascript"></script>
<script src="fonts/chess-informant-NAG-symbols.js" type="text/javascript"></script>
<script src="engine.js" type="text/javascript"></script>
<script src="fide-lookup.js" type="text/javascript"></script>
<script type="text/javascript">
"use strict";
var pgn4web_engineWindowUrlParameters = "as=66&ss=36&ps=29&pf=m&fms=14&fcs=22&lch=FFFFFF&dch=DDDDDD&hch=AAAAAA&ctch=808080&fpr=0";
var pgn4web_engineWindowTarget = "pgn4webAnalysisBoardForAnalysis";
var pgn4web_engineWindowHeight = "";
var pgn4web_engineWindowWidth = "";
var thisRegExp;
thisRegExp = /(&|\?)(help|h)=(true|t)(&|$)/i;
if (window.location.search.match(thisRegExp) !== null) {
alert("pgn4web analysis.html parameters" + "\n" +
" - pgnFile = filename.pgn" + "\n" +
" - initialGame = first | last | random | a number | a search expression (default first)" + "\n" +
" - initialVariation = a number (default 0)" + "\n" +
" - initialHalfmove = start | end | random | comment | variation | a number (default start)" + "\n" +
" - showPrevNext = true | false (default false)" + "\n" +
" - showGamesList = true | false (default false)" + "\n" +
" - beautifyTags = true | false (default true)" + "\n" +
" - help = true");
}
var pgnFilename = "";
thisRegExp = /(&|\?)(pgnFile|pf)=([^&]*)(&|$)/i;
if (window.location.search.match(thisRegExp) !== null) {
pgnFilename = unescape(window.location.search.match(thisRegExp)[3]);
} else {
// accepts pgnData as alias for pgnFile for consistency with board.html
thisRegExp = /(&|\?)(pgnData|pd)=([^&]*)(&|$)/i;
if (window.location.search.match(thisRegExp) !== null) {
pgnFilename = unescape(window.location.search.match(thisRegExp)[3]);
}
}
if (pgnFilename !== "") { SetPgnUrl(pgnFilename); }
thisRegExp = /(&|\?)(initialGame|ig)=([^&]*)(&|$)/i;
if (window.location.search.match(thisRegExp) !== null) {
SetInitialGame(unescape(window.location.search.match(thisRegExp)[3]));
}
thisRegExp = /(&|\?)(initialVariation|iv)=([^&]*)(&|$)/i;
if (window.location.search.match(thisRegExp) !== null) {
SetInitialVariation(unescape(window.location.search.match(thisRegExp)[3]));
}
thisRegExp = /(&|\?)(initialHalfmove|ih)=([^&]*)(&|$)/i;
if (window.location.search.match(thisRegExp) !== null) {
SetInitialHalfmove(unescape(window.location.search.match(thisRegExp)[3]), false);
}
thisRegExp = /(&|\?)(showLastNext|sln)=(true|t)(&|$)/i;
var showLastNext = (window.location.search.match(thisRegExp) !== null);
thisRegExp = /(&|\?)(showGamesList|sgl)=(true|t)(&|$)/i;
var showGamesList = (window.location.search.match(thisRegExp) !== null);
thisRegExp = /(&|\?)(beautifyTags|bt)=(false|f)(&|$)/i;
var beautifyTags = (window.location.search.match(thisRegExp) === null);
SetImagePath("images/merida/39");
SetImageType("png");
SetHighlightOption(true);
SetGameSelectorOptions(null, true, 12, 12, 2, 15, 15, 3, 10); // (head, num, chEvent, chSite, chRound, chWhite, chBlack, chResult, chDate);
SetCommentsIntoMoveText(true);
SetCommentsOnSeparateLines(false);
SetAutoplayDelay(1000); // milliseconds
SetAutostartAutoplay(false);
SetAutoplayNextGame(false);
SetShortcutKeysEnabled(true);
// customShortcutKey_Shift_1 defined by fide-lookup.js
// customShortcutKey_Shift_2 defined by fide-lookup.js
function customShortcutKey_Shift_3() { toggleLastNext(); }
function customShortcutKey_Shift_4() { toggleGamesList(); }
function customShortcutKey_Shift_5() { toggleBeautifyTags(); }
// overwriting engine.js definitions
function customShortcutKey_Shift_8() { showAnalysisBoard(true); }
function customShortcutKey_Shift_9() { showAnalysisBoard(false); }
function customShortcutKey_Shift_0() { showAnalysisBoard(); }
if (!pgn4web_engineWindowDisableAnalysisBoard) {
boardShortcut("E8", "open/update analysis board", function(t,e){ showAnalysisBoard(e.shiftKey); });
boardShortcut("F8", "close/pause analysis board", function(t,e){ if (!e.shiftKey) { hideAnalysisBoard(); } });
}
boardShortcut("E7", "toggle last/next moves information", function(t,e){ toggleLastNext(); });
boardShortcut("G7", "toggle show comments on separate lines", function(t,e){ if (e.shiftKey) { SetCommentsIntoMoveText(!commentsIntoMoveText); } else { SetCommentsOnSeparateLines(!commentsOnSeparateLines); } var oldPly = CurrentPly; var oldVar = CurrentVar; Init(); GoToMove(oldPly, oldVar); });
boardShortcut("G6", "search next annotator", function(t,e){ searchAnnotator(e.shiftKey); });
boardShortcut("H6", "scroll moves text to top", function(t,e){ document.getElementById("GameTextResult").scrollTop = 0; });
boardShortcut("F5", "toggle games list", function(t,e){ toggleGamesList(); });
boardShortcut("G5", "scroll moves text to current move", function(t,e){ autoScrollToCurrentMoveIfEnabled(); });
boardShortcut("H5", "scroll moves text to bottom", function(t,e){ document.getElementById("GameTextResult").scrollTop = document.getElementById("GameTextResult").scrollHeight; });
function FlipBoard() {}
var firstCustomFunctionOnPgnTextLoad = true;
function customFunctionOnPgnTextLoad() {
myOnResize();
if (firstCustomFunctionOnPgnTextLoad) {
firstCustomFunctionOnPgnTextLoad = false;
showEngineAnalysisBoard(true, true); // prepare analysis frame with an idle board
}
}
function customFunctionOnPgnGameLoad() {
var theObj, theOther, theThird, theMatch, newTitle, newTitleBlock;
if ((theObj = document.getElementById('GameEvent')) && (theMatch = gameRound[currentGame].match(/^\d+/))) { theObj.innerHTML += ' (' + theMatch[0] + ')'; }
fixObjInnerHTML('GameEvent');
fixObjInnerHTML('GameSite');
if (theObj = document.getElementById('GameDate')) { theObj.innerHTML = (theMatch = gameDate[currentGame].match(/^\d+/)) ? theMatch[0] : ''; }
fixObjInnerHTML('GameDate');
fixObjInnerHTML('GameWhite');
fixObjInnerHTML('GameBlack');
fixObjInnerHTML('GameResult');
if (theObj = document.getElementById('GameNum')) { theObj.innerHTML = (currentGame + 1); }
fixObjInnerHTML('GameNum');
customPgnHeaderTag('WhiteElo', 'GameWhiteElo');
fixObjInnerHTML('GameWhiteElo');
customPgnHeaderTag('BlackElo', 'GameBlackElo');
fixObjInnerHTML('GameBlackElo');
customPgnHeaderTag('ECO', 'GameECO');
fixObjInnerHTML('GameECO');
customPgnHeaderTag('Annotator', 'GameAnnotator');
fixObjInnerHTML('GameAnnotator');
theObj = document.getElementById('GameWhite');
theOther = document.getElementById('GameWhiteElo');
if (theObj && theObj.innerHTML && theOther && theOther.innerHTML) { theOther.style.marginLeft = '1ex'; }
theObj = document.getElementById('GameBlack');
theOther = document.getElementById('GameBlackElo');
if (theObj && theObj.innerHTML && theOther && theOther.innerHTML) { theOther.style.marginLeft = '1ex'; }
theObj = document.getElementById('GameSite');
theOther = document.getElementById('GameEvent');
if (theObj && theObj.innerHTML && theOther && theOther.innerHTML) { theOther.style.marginLeft = '1ex'; }
theThird = document.getElementById('GameDate');
if (((theObj && theObj.innerHTML) || (theOther && theOther.innerHTML)) && (theThird && theThird.innerHTML)) { theThird.style.marginLeft = '1ex'; }
newTitle = (currentGame + 1) + '.';
if ((theObj = document.getElementById('GameWhite')) && (theObj.innerHTML)) { newTitle += '\u00a0 ' + theObj.innerHTML; }
if ((theObj = document.getElementById('GameBlack')) && (theObj.innerHTML)) { newTitle += '\u00a0 ' + theObj.innerHTML; }
if ((theObj = document.getElementById('GameResult')) && (theObj.innerHTML)) { newTitle += '\u00a0 ' + theObj.innerHTML; }
if ((theObj = document.getElementById('GameSite')) && (theObj.innerHTML)) { newTitle += '\u00a0 ' + theObj.innerHTML; }
if ((theObj = document.getElementById('GameEvent')) && (theObj.innerHTML)) { newTitle += '\u00a0 ' + theObj.innerHTML; }
if ((theObj = document.getElementById('GameDate')) && (theObj.innerHTML)) { newTitle += '\u00a0 ' + theObj.innerHTML; }
document.title = simpleHtmlentitiesDecode(newTitle);
newTitle = (currentGame + 1) + '.';
newTitleBlock = '';
if ((theObj = document.getElementById('GameWhite')) && (theObj.innerHTML)) { newTitleBlock += theObj.innerHTML; }
if ((theObj = document.getElementById('GameWhiteElo')) && (theObj.innerHTML)) { newTitleBlock += (newTitleBlock ? ' ' : '') + theObj.innerHTML; }
if (newTitleBlock) { newTitle += '\n' + newTitleBlock; }
newTitleBlock = '';
if ((theObj = document.getElementById('GameBlack')) && (theObj.innerHTML)) { newTitleBlock += theObj.innerHTML; }
if ((theObj = document.getElementById('GameBlackElo')) && (theObj.innerHTML)) { newTitleBlock += (newTitleBlock ? ' ' : '') + theObj.innerHTML; }
if (newTitleBlock) { newTitle += '\n' + newTitleBlock; }
newTitleBlock = '';
if ((theObj = document.getElementById('GameSite')) && (theObj.innerHTML)) { newTitleBlock += theObj.innerHTML; }
if ((theObj = document.getElementById('GameEvent')) && (theObj.innerHTML)) { newTitleBlock += theObj.innerHTML; }
if ((theObj = document.getElementById('GameDate')) && (theObj.innerHTML)) { newTitleBlock += (newTitleBlock ? ' ' : '') + theObj.innerHTML; }
if (newTitleBlock) { newTitle += '\n' + newTitleBlock; }
newTitleBlock = '';
if ((theObj = document.getElementById('GameECO')) && (theObj.innerHTML)) { newTitleBlock += theObj.innerHTML; }
if (newTitleBlock) { newTitle += '\n' + newTitleBlock; }
if (theObj = document.getElementById('boardHeaderInfo')) { theObj.title = simpleHtmlentitiesDecode(newTitle); }
}
function fixObjInnerHTML(id) {
if (!beautifyTags) { return; }
var theObj = document.getElementById(id);
if (theObj) {
theObj.innerHTML = theObj.innerHTML.replace(/\.?\?[.?]*/, "").replace(/,(\w)/g, ", $1");
}
}
function searchPlayer(name, FideId) {
if (typeof(openFidePlayerUrl) == "function") { openFidePlayerUrl(name, FideId); }
}
function searchAnnotator(same) {
var fixedAnnotator = fixRegExp(customPgnHeaderTag("Annotator"));
searchPgnGame(same ? '\\[\\s*Annotator\\s*"' + fixedAnnotator + '"\\s*\\]' : '\\[\\s*Annotator\\s*"(?!' + fixedAnnotator + '"\\s*\\])', false);
document.getElementById("GameTextResult").scrollTop = document.getElementById("GameTextResult").scrollHeight;
}
function myOnResize() {
var ww, wh, theObj;
if (window.innerWidth && window.innerHeight) { ww = window.innerWidth; wh = window.innerHeight; }
else if (document.documentElement && document.documentElement.clientWidth) { ww = document.documentElement.clientWidth; wh = document.documentElement.clientHeight; }
else if (document.body && document.body.clientWidth) { ww = document.body.clientWidth; wh = document.body.clientHeight; }
else { return; }
if (theObj = document.getElementById("GameTextResult")) { theObj.style.height = (wh - 60) + "px"; }
autoScrollToCurrentMoveIfEnabled();
}
enableAutoScrollToCurrentMove("GameTextResult");
var thisEngineWin;
var thisEngineWinShown = false;
function showAnalysisBoard(de) {
if (pgn4web_engineWindowDisableAnalysisBoard) { return; }
var theObj;
if ((thisEngineWin = showEngineAnalysisBoard(de)) && (!thisEngineWinShown)) {
if (theObj = document.getElementById('analysisHeader')) {
theObj.style.left = "451px"; // 436px boardheaderDiv.width + 15px gametextresultDiv.paddingLeft
}
if (theObj = document.getElementById('GameTextResult')) {
theObj.style.marginLeft = "769px"; // 451px analysisHeader.left + 288px analysisHeader.width + 30px padding
}
setTimeout(autoScrollToCurrentMoveIfEnabled, 2100);
thisEngineWinShown = true;
}
}
function hideAnalysisBoard() {
if (pgn4web_engineWindowDisableAnalysisBoard) { return; }
var theObj;
if (thisEngineWinShown) {
if (theObj = document.getElementById('analysisHeader')) {
theObj.style.left = "";
}
if (theObj = document.getElementById('GameTextResult')) {
theObj.style.marginLeft = "";
}
setTimeout(autoScrollToCurrentMoveIfEnabled, 2100);
thisEngineWinShown = false;
}
if (typeof(thisEngineWin) != "undefined") {
if (typeof(thisEngineWin.StopBackgroundEngine) == "function") { thisEngineWin.StopBackgroundEngine(); }
if (typeof(thisEngineWin.autoUpdate) != "undefined") { thisEngineWin.autoUpdate = false; }
}
}
function toggleLastNext(sln) {
showLastNext = (typeof(sln) == "undefined") ? !showLastNext : sln;
var theObj = document.getElementById("GameLastNext");
if (theObj) {
theObj.style.display = showLastNext ? "" : "none";
}
if (theObj = document.getElementById("GameSelector")) {
theObj.style.top = showLastNext ? "0" : "30px";
}
}
function toggleGamesList(sgl) {
showGamesList = (typeof(sgl) == "undefined") ? !showGamesList : sgl;
var theObj = document.getElementById("GamesList");
if (theObj) {
theObj.style.display = showGamesList ? "" : "none";
}
}
function toggleBeautifyTags(bt) {
beautifyTags = (typeof(bt) == "undefined") ? !beautifyTags : bt;
Init(currentGame);
}
</script>
</head>
<body onResize="myOnResize();">
<!-- 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() -->
<div class="analysisheaderDiv" id="analysisHeader">
<iframe class="gameAnalysisFrame" id="GameAnalysisFrame" name="pgn4webAnalysisBoardForAnalysis" src="./blank.html" frameborder="0" scrolling="no" marginheight="0" marginwidth="0">your web browser and/or your host do not support iframes as required</iframe>
</div>
<div class="boardheaderDiv" id="boardHeader">
<div id="boardHeaderInfo">
<table cellspacing=0 cellpadding=0 border=0><tr>
<td><div class="headerLine gameNum"><span id="GameNum">1</span>.</div></td>
<td><div class="headerLine gameECO"><span id="GameECO"></span></div></td>
</tr></table>
<div class="shortRowSpace"> </div>
<div class="headerLine"><a id="GameWhite" href="javascript:void(0);" onclick="searchPlayer(this.innerHTML, customPgnHeaderTag('WhiteFideId')); this.blur();"></a><span id="GameWhiteElo"></span></div>
<div class="headerLine"><a id="GameBlack" href="javascript:void(0);" onclick="searchPlayer(this.innerHTML, customPgnHeaderTag('BlackFideId')); this.blur();"></a><span id="GameBlackElo"></span></div>
<div class="shortRowSpace"> </div>
<div class="headerLine gameSiteEventDate"><span id="GameSite"></span><span id="GameEvent"></span><span id="GameDate"></span></div>
<div class="shortRowSpace"> </div>
</div>
<div class="shortRowSpace"> </div>
<div id="GameBoard"></div>
<div id="GameLastNext" style="display: none;">
<div class="shortRowSpace"> </div>
<div class="shortRowSpace"> </div>
<div class="gameLastMove">
<span id="GameLastMove" title="last move"></span> <span id="GameLastVariations" title="last move alternatives"></span>
</div>
<div class="shortRowSpace"> </div>
<div class="gameNextMove">
<span id="GameNextMove" title="next move"></span> <span id="GameNextVariations" title="next move alternatives"></span>
</div>
</div>
<div class="gameList" id="GamesList" style="display: none;">
<div class="shortRowSpace"> </div>
<div class="shortRowSpace"> </div>
<div class="gameSelector" id="GameSelector"></div>
</div>
</div>
<div class="topSpacer"> </div>
<div class="gametextresultDiv" id="GameTextResult">
<div id="GameText"></div>
<div class="comment" style="line-height: 33%;"> </div>
<a class="gameAnnotator" id="GameAnnotator" href="javascript:void(0);" onclick="searchAnnotator(!event.shiftKey); this.blur();"></a>
<div id="GameResult"></div>
</div>
<a class="helpLink" title="pgn4web help" href="javascript:void(0);" onclick="displayHelp(); this.blur();">?</a>
<script type="text/javascript">
"use strict";
toggleLastNext(showLastNext);
toggleGamesList(showGamesList);
function pgn4web_handleTouchEnd_Header(e) {
e.stopPropagation();
var jj, deltaX, deltaY;
for (var ii = 0; ii < e.changedTouches.length; ii++) {
if ((jj = pgn4webOngoingTouchIndexById(e.changedTouches[ii].identifier)) != -1) {
if (pgn4webOngoingTouches.length == 1) {
deltaX = e.changedTouches[ii].clientX - pgn4webOngoingTouches[jj].clientX;
deltaY = e.changedTouches[ii].clientY - pgn4webOngoingTouches[jj].clientY;
if (Math.max(Math.abs(deltaX), Math.abs(deltaY)) >= 13) {
if (Math.abs(deltaX) > 1.5 * Math.abs(deltaY)) {
if (deltaX > 0) { // horizontal right
showAnalysisBoard(false);
} else { // horizontal left
hideAnalysisBoard();
}
} else if (Math.abs(deltaY) > 1.5 * Math.abs(deltaX)) { // vertical up or down
SetCommentsIntoMoveText(!commentsIntoMoveText);
var oldPly = CurrentPly;
var oldVar = CurrentVar;
Init();
GoToMove(oldPly, oldVar);
}
}
pgn4webMaxTouches = 0;
}
pgn4webOngoingTouches.splice(jj, 1);
}
}
clearSelectedText();
}
if (touchEventEnabled) {
var theObj = document.getElementById("boardHeader");
if (theObj) {
simpleAddEvent(theObj, "touchstart", pgn4web_handleTouchStart);
simpleAddEvent(theObj, "touchmove", pgn4web_handleTouchMove);
simpleAddEvent(theObj, "touchend", pgn4web_handleTouchEnd_Header);
simpleAddEvent(theObj, "touchleave", pgn4web_handleTouchEnd_Header);
simpleAddEvent(theObj, "touchcancel", pgn4web_handleTouchCancel);
}
theObj = document.getElementById("analysisHeader");
if (theObj) {
simpleAddEvent(theObj, "touchstart", pgn4web_handleTouchStart);
simpleAddEvent(theObj, "touchmove", pgn4web_handleTouchMove);
simpleAddEvent(theObj, "touchend", pgn4web_handleTouchEnd_Header);
simpleAddEvent(theObj, "touchleave", pgn4web_handleTouchEnd_Header);
simpleAddEvent(theObj, "touchcancel", pgn4web_handleTouchCancel);
}
}
</script>
</body>
</html>