forked from ornicar/pgn4web
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tactics.html
147 lines (116 loc) · 4.81 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
<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>Solve chess tactics!</title>
<link href="tactics.css" type="text/css" rel="stylesheet" />
<style type="text/css">
.newButton {
font-size: 9;
width: 80px;
vertical-align: middle;
text-align: center;
background-color: #f2d798;
border-color: #c9ad6f;
border-style: double;
border-width: 3;
}
</style>
<link rel="shortcut icon" href="pawn.ico" />
<script src="pgn4web.js" type="text/javascript"></script>
<script type="text/javascript">
SetPgnUrl("tactics.pgn"); // if set, this has precedence over the inline PGN in the HTML file
SetImagePath("uscf/24"); // use "" path if images are in the same folder as this javascript file
// SetImageType("png");
// SetHighlightOption(true); // true or false
// SetGameSelectorOptions(" ...", false, 0, 0, 0, 15, 15, 0, 10); // (head, num, chEvent, chSite, chRound, chWhite, chBlack, chResult, chDate);
// SetCommentsIntoMoveText(true);
// SetCommentsOnSeparateLines(false);
// SetAutoplayDelay(1000); // milliseconds
// SetAutostartAutoplay(false);
// SetAutoplayNextGame(false); // if set, move to the next game at the end of the current game during autoplay
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
// 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(false);
cols2clear="ABCDEFGH";
rows2clear="1234567";
for (c=0; c<cols2clear.length; c++) {
for (r=0; r<rows2clear.length; r++) {
boardShortcut(cols2clear.charAt(c)+rows2clear.charAt(r), "", function(){});
}
}
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]); }
}
if ((assignedInitialGame = gup('n')) !== '') { SetInitialGame(assignedInitialGame); }
</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: 14;">#<span id="GameRound"></span></div>
</td>
<td width=50%>
<div style="text-align: right;"> <span id="task" style="font-size: 14; background: yellow;"> <span id="GameSideToMove"></span> to move </span></div>
</td>
</tr>
</table>
</td>
<tr>
<td width=246 height=166 valign=middle>
<span id="solution" style="font-size: 14; text-align: left; visibility: hidden">
<span id="GameText"></span> <span id="GameResult"></span>
</span>
</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: MoveBackward(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:MoveForward(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>