-
Notifications
You must be signed in to change notification settings - Fork 3
/
tactics.html
148 lines (115 loc) · 4.2 KB
/
tactics.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
144
145
146
147
148
<!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>Solve chess tactics!</title>
<link href="tactics.css" type="text/css" rel="stylesheet" />
<style type="text/css">
.newButton {
-webkit-appearance: none;
font-size: 9px;
width: 80px;
vertical-align: middle;
text-align: center;
background-color: #f2d798;
border-color: #c9ad6f;
border-style: double;
border-width: 3px;
border-radius: 0px;
}
</style>
<link rel="icon" sizes="16x16" href="pawn.ico" />
<script src="pgn4web.js" type="text/javascript"></script>
<script type="text/javascript">
"use strict";
SetPgnUrl("tactics.pgn");
SetImagePath("images/uscf/24");
SetInitialGame("random"); // 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
SetShortcutKeysEnabled(false);
clearShortcutSquares("BCDEFGH", "1234567");
clearShortcutSquares("A", "123456");
boardShortcut("H8", "hint", function(t,e){ hint(); });
function hint() {
alert("hint: the solution's main line is " + PlyNumber + " ply long");
}
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 assignedInitialGame = gup('n');
if (assignedInitialGame) { SetInitialGame(assignedInitialGame); }
function customFunctionOnPgnGameLoad() {
var theObj = document.getElementById('GameNumber');
if (theObj) { theObj.innerHTML = (currentGame+1); }
}
</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() -->
<center>
<table width=508 cellspacing=0 cellpadding=0 border=0>
<tr>
<td width=246 rowspan=3 valign=top>
<div id="GameBoard"></div>
</td>
<td width=16 rowspan=3>
</td>
<td width=246 height=40 valign=top>
<table width=246 cellspacing=0 cellpadding=0 border=0>
<tr>
<td width=50%>
<div style="text-align: left; font-size: 14px;">#<span id="GameNumber"></span></div>
</td>
<td width=50%>
<div style="text-align: right;"> <span id="task" style="font-size: 14px; background: yellow;"> <span id="GameSideToMove"></span> to move </span></div>
</td>
</tr>
</table>
</td>
<tr>
<td width=246 height=166 valign=middle>
<div id="solution" style="font-size: 14px; text-align: left; visibility: hidden">
<span id="GameText"></span> <span class="move" id="GameResult"></span>
</div>
</td>
</tr>
<tr>
<td width=246 height=40 valign=bottom>
<form style="display: inline">
<table cellspacing=0 cellpadding=0 border=0>
<tr>
<td width=80px valign=top>
<input type=button value="move back" title="click here to move back one ply when looking at the solution" class="newButton" onClick="javascript: GoToMove(CurrentPly - 1); if (StartPly == CurrentPly) {document.getElementById('task').style.visibility = 'visible';}" onFocus="this.blur()">
</td>
<td width=4px>
</td>
<td width=80px valign=top>
<input type=button value="show solution" title="click here to show the solution and step through the main line" class="newButton" onClick="javascript:GoToMove(CurrentPly + 1); document.getElementById('solution').style.visibility = 'visible';document.getElementById('task').style.visibility = 'hidden';" onFocus="this.blur()">
</td>
<td width=4px>
</td>
<td width=80px valign=top>
<input type=button value="next puzzle" title="click here to load the next puzzle" class="newButton" onClick="javascript: document.getElementById('solution').style.visibility = 'hidden'; document.getElementById('task').style.visibility = 'visible'; Init(Math.floor(Math.random()*numberOfGames));" onFocus="this.blur()">
</td>
</tr>
</table>
</form>
</td>
</tr>
</table>
</center>
</body>
</html>