1 <?php include("header.phtml"); ?>
3 <script type="text/javascript" src="js/rsh.compressed.js"></script>
5 <div id="player-container"></div>
7 <script type="text/javascript">
13 // Provide handlers for frontend things (page title, permalinks) that
14 // aren't handled by Player directly
16 initGame: function() {
17 document.title = "EidoGo - " + this.getGameDescription();
19 setPermalink: function() {
20 if (!this.gameName || ['search', 'gnugo', 'url'].contains(this.gameName)) return;
21 var gn = this.gameName || "";
22 // use move-based path for KJD to future-proof permalinks
23 var path = (gn == "kjd" ?
24 this.cursor.getPathMoves().join("") :
25 this.cursor.getPath().join(","));
26 var hash = gn + (path ? ":" + path : "");
29 searchRegion: function(params) {
30 this.hooks.initGame.call(this); // update title
31 var hash = "search:" + params.q + ":" + params.w + "x" + params.h +
32 ":" + this.compressPattern(params.p);
33 if (params.a && params.a != "corner") hash += ":" + params.a;
34 if (hash != location.hash.replace(/^#/, "")) {
39 loadGame({gameName: gn, loadPath: [0,0]}, function() {
40 var url = location.href.replace(/#[^#]+$/, "") + "#" + this.gameName;
42 this.prependComment("Game saved to <a href='" + url + "'>" + url + "</a>");
47 // Load game data; create a Player instance if necessary
48 function loadGame(params, completeFn) {
49 params = params || {};
51 progressiveLoad: false,
61 for (var key in params) {
62 cfg[key] = params[key];
65 player = new eidogo.Player({
66 container: "player-container",
68 searchUrl: "php/search.php",
69 saveUrl: "php/save.php",
70 downloadUrl: "php/download.php?id=",
71 scoreEstUrl: "php/gnugo.php",
76 player.loadSgf(cfg, completeFn);
81 function loadState(hash) {
83 var hashParts = hash ? hash.replace(/^#/, "").split(/:/) : [];
84 var gameName = hashParts[0] || "";
85 var loadPath = hashParts[1] ? hashParts[1].split(",") : null;
86 var rest = hashParts.slice(1);
87 if (!gameName || gameName == "kjd") {
92 while (coord = s.substring(0, 2)) {
99 sgfUrl: "php/ojd_progressive.php",
100 commitUrl: "php/ojd_commit.php",
102 progressiveLoad: true,
104 showPlayerInfo: false,
109 if (gameName == "url") {
112 sgfUrl: "php/fetch.php?url=" + hash.replace(/^#?url:/, "")
116 if (gameName == "search") {
118 loadGame({showOptions: false});
119 player.loadSearch.apply(player, rest);
129 if (gameName.indexOf("gnugo") === 0) {
132 opponentUrl: "php/gnugo.php",
135 var parts = gameName.split("-");
137 params.boardSize = parts[1];
148 function addHistory(hash) {
149 if (dhtmlHistory.isSafari) {
151 location.hash = hash;
153 dhtmlHistory.add(hash);
158 window.dhtmlHistory.create({
159 toJSON: function(o) { return ''; },
160 fromJSON: function(s) { return {}; }
165 eidogo.util.addEvent(document, "click", function(evt) {
166 var target = eidogo.util.getTarget(evt)
167 if (target.nodeName.toUpperCase() != "A" || target.href.indexOf("#") == -1) return true;
168 var hash = target.href.replace(/^.*#/, "");
170 player.closeSearch();
172 eidogo.util.stopEvent(evt);
175 dhtmlHistory.initialize();
176 dhtmlHistory.addListener(loadState);
179 // make sure we load our state on first page load (RSH quirk)
180 loadState(location.hash.replace(/^#/, ""));
187 <?php include("footer.phtml"); ?>