Permalink
Browse files

save level in the hash tag

  • Loading branch information...
1 parent c049372 commit 035ec39145d7bc53a3b0aeb5c7a26bd157940be9 @lacker committed Feb 12, 2012
Showing with 17 additions and 5 deletions.
  1. +1 −1 2012/tile.js
  2. +16 −4 2012/wordsquare.js
View
@@ -28,7 +28,7 @@ function unselectAll() {
console.log(GAME.answer.fragment);
if (GAME.answer.done()) {
- resetBoard(GAME.level + 1);
+ resetBoard(GAME.level + 1, true);
} else {
populateTarget();
}
View
@@ -6,7 +6,7 @@ var CANVAS_SIZE = 720;
var HINT_THRESHOLD = 4;
// How frustrated you can get before you get a really good hint
-var PERMAHINT_THRESHOLD = 10;
+var PERMAHINT_THRESHOLD = 8;
// Extra padding on each side of the canvas
var PADDING = 3;
@@ -234,7 +234,10 @@ function clear() {
}
// Resets the board for the given level.
-function resetBoard(level) {
+function resetBoard(level, updateHash) {
+ if (updateHash) {
+ window.location.hash = "#" + level;
+ }
GAME.level = level;
GAME.answer = new Answer(level);
GAME.permahint = null;
@@ -259,8 +262,17 @@ function main() {
$("canvas").mousemove(move);
$("canvas").mouseup(up);
- // TODO: read level from a hash tag
- resetBoard(1);
+ // read level from a hash tag
+ var level = 1;
+ var tag = window.location.hash.match(/[0-9]+$/);
+ if (tag) {
+ var num = parseInt(tag[0]);
+ if (num > 0) {
+ level = num;
+ setMessage("Level " + level);
+ }
+ }
+ resetBoard(level, false);
setInterval(tick, 1000 / FPS);
}

0 comments on commit 035ec39

Please sign in to comment.