1 <?php include("header.phtml"); ?>
3 <script type="text/javascript" src="js/rsh.compressed.js"></script>
5 <div id="options"></div>
7 <div id="options-joseki" style="display: none">
8 <strong>Joseki Tutor:</strong>
9 <a href="/#kjd">Kogo's Joseki Dictionary</a> |
10 <a href="/#kombilo">Kombilo / Pro Game Database</a>
13 <div id="options-gnugo" style="display: none">
14 <strong>GNU Go</strong>
15 Board Size:
16 <a href="/#gnugo">19x19</a> |
17 <a href="/#gnugo-9">9x9</a> |
18 <a href="/#gnugo-13">13x13</a>
19 Your Color: <select id="human-color">
20 <option value="W">White</option>
21 <option value="B">Black</option>
23 Handicap: <select id="handicap">
24 <option value="0">None</option>
25 <option value="1">1 stone</option>
26 <option value="2">2 stones</option>
27 <option value="3">3 stones</option>
28 <option value="4">4 stones</option>
29 <option value="5">5 stones</option>
30 <option value="6">6 stones</option>
31 <option value="7">7 stones</option>
32 <option value="8">8 stones</option>
33 <option value="9">9 stones</option>
37 <div id="options-blank" style="display: none">
38 <strong>Blank Board:</strong>
39 <a href="/#blank">19x19</a> |
40 <a href="/#blank-9">9x9</a> |
41 <a href="/#blank-13">13x13</a>
44 <div id="player-container"></div>
46 <script type="text/javascript">
52 var byId = eidogo.util.byId,
53 hide = eidogo.util.hide,
54 show = eidogo.util.show,
55 addEvent = eidogo.util.addEvent;
57 // Provide handlers for frontend things (page title, permalinks) that
58 // aren't handled by Player directly
60 initGame: function() {
61 document.title = "EidoGo - " + this.getGameDescription();
63 showGameInfo: function(info) {
64 if (this.gameName == "kjd") {
65 ['KM', 'HA', 'CP', 'DT'].forEach(function(p) { delete info[p]; });
66 info.GC = "Available from " +
67 "<a href='http://waterfire.us/joseki.htm'>http://waterfire.us/joseki.htm</a><br><br>" +
68 "KJD Copyright 2006-2007 by Andre Ay. Copyright 1998-2005 " +
69 "by Gary Odom. Portions copyright 2000-2001 by Stefan " +
70 "Verstraeten. Used with permission.";
71 } else if (this.gameName == "kombilo") {
72 info.GN = "Kombilo / Pro Game Database";
73 info.GC = "Continuations derived from around 10,000 pro games.\n\n" +
74 "Since the continuations are computed automatically, there is a certain " +
75 "amount of spurious, non-fuseki moves included.";
78 setPermalink: function() {
79 if (!this.gameName || ['search', 'gnugo', 'url'].contains(this.gameName)) return;
80 var gn = this.gameName || "";
81 // Use move-based path for josekis to future-proof permalinks
82 var path = (gn == "kjd" || gn == "kombilo" ?
83 this.cursor.getPathMoves().join("") :
84 this.cursor.getPath().join(","));
85 var hash = gn + (path ? ":" + path : "");
88 searchRegion: function(params) {
89 this.hooks.initGame.call(this); // update title
90 var hash = "search:" + params.q + ":" + params.w + "x" + params.h +
91 ":" + this.compressPattern(params.p);
92 if (params.a && params.a != "corner") hash += ":" + params.a;
93 if (hash != location.hash.replace(/^#/, ""))
97 loadGame({gameName: gn, loadPath: [0,0]}, function() {
98 var url = location.href.replace(/#[^#]+$/, "") + "#" + this.gameName;
100 this.prependComment("Game saved to <a href='" + url + "'>" + url + "</a>");
105 // Load game data; create a Player instance if necessary
106 function loadGame(params, completeFn) {
107 params = params || {};
109 progressiveLoad: false,
111 markVariations: true,
114 showPlayerInfo: true,
120 for (var key in params) {
121 cfg[key] = params[key];
124 player = new eidogo.Player({
125 container: "player-container",
127 searchUrl: "backend/search.php",
128 saveUrl: "backend/save.php",
129 downloadUrl: "backend/download.php?id=",
130 scoreEstUrl: "backend/gnugo.php",
132 enableShortcuts: true
135 player.loadSgf(cfg, completeFn);
138 var notLoaded = true;
140 // Perform the appriate loading action depending on what hash is given
141 function loadState(hash) {
143 var hashParts = hash ? hash.replace(/^#/, "").split(/:/) : [];
144 var gameName = hashParts[0] || "";
145 var loadPath = hashParts[1] ? hashParts[1].split(",") : null;
146 var rest = hashParts.slice(1);
150 if (!gameName || gameName == "kjd" || gameName == "kombilo")
151 loadJoseki(gameName, loadPath);
152 else if (gameName == "url")
153 loadUrl(hash.replace(/^#?url:/, ""));
154 else if (gameName == "search")
156 else if (gameName.indexOf("gnugo") === 0)
158 else if (gameName.indexOf("blank") === 0)
161 loadGame({gameName: gameName, loadPath: loadPath});
164 function loadJoseki(gameName, loadPath) {
165 byId("options").innerHTML = byId("options-joseki").innerHTML;
168 // Parse moves out of string like "aepqnctt"
172 while (coord = s.substring(0, 2)) {
173 loadPath.push(coord);
178 gameName: gameName || "kjd",
179 progressiveUrl: gameName == "kombilo" ? "backend/search.php" : "backend/kjd_progressive.php",
181 progressiveLoad: true,
182 progressiveMode: gameName == "kombilo" ? "pattern" : "id",
184 showPlayerInfo: false,
185 showOptions: false});
188 function loadSearch(args) {
190 loadGame({showOptions: false});
191 player.loadSearch.apply(player, args);
200 function loadUrl(url) {
203 sgfUrl: "backend/fetch.php?url=" + url});
206 function loadGnuGo(gameName) {
207 byId("options").innerHTML = byId("options-gnugo").innerHTML;
211 opponentUrl: "backend/gnugo.php",
216 var parts = gameName.split("-");
218 params.boardSize = parts[1];
219 var inputColor = byId("human-color"),
220 inputHandi = byId("handicap");
221 var changeHandler = function() {
222 params.opponentColor = inputColor.value == "W" ? "B" : "W";
223 params.handicap = inputHandi.value;
226 addEvent(inputColor, "change", changeHandler);
227 addEvent(inputHandi, "change", changeHandler);
231 function loadBlank(gameName) {
232 byId("options").innerHTML = byId("options-blank").innerHTML;
234 loadGame({gameName: gameName});
237 function addHistory(hash) {
239 if (dhtmlHistory.isSafari)
240 location.hash = hash;
242 dhtmlHistory.add(hash);
246 window.dhtmlHistory.create({
247 toJSON: function(o) { return ''; },
248 fromJSON: function(s) { return {}; }});
251 addEvent(document, "click", function(evt) {
252 var target = eidogo.util.getTarget(evt)
253 if (target.nodeName.toUpperCase() != "A" || target.href.indexOf("#") == -1) return true;
254 var hash = target.href.replace(/^.*#/, "");
256 player.closeSearch();
258 eidogo.util.stopEvent(evt);
261 dhtmlHistory.initialize();
262 dhtmlHistory.addListener(loadState);
264 // Make sure we load our state on first page load (RSH quirk)
266 loadState(location.hash.replace(/^#/, ""));
272 <?php include("footer.phtml"); ?>