Reviewers: jasvir,
Description:
* image uris were still referring to thinkfu. this makes image
uris relative to location of playground, which requires loosening
the uri policy to allow relative links.
* "restart" was broken. model.board is assigned to an object at
model creation time, which is the same as the local var 'board'.
model.reset() reassigns local var 'board' to a new object, but
model.board is still the old object. so internal to model we
have a new board, but external users of model still see the old board.
Please review this at http://codereview.appspot.com/4298056/
Affected files:
M src/com/google/caja/demos/playground/examples/unboxed/index.html
M src/com/google/caja/demos/playground/taming.js
Index: src/com/google/caja/demos/playground/taming.js
===================================================================
--- src/com/google/caja/demos/playground/taming.js (revision 4398)
+++ src/com/google/caja/demos/playground/taming.js (working copy)
@@ -34,7 +34,7 @@
var uriPolicy = {
rewrite: function (uri, uriEffect, loaderType, hints) {
- if (!/^https?:\/\//i.test(uri)) { return void 0; }
+ if (!/^https?:/i.test(uri)) { return void 0; }
if (uriEffect === html4.ueffects.NEW_DOCUMENT ||
(uriEffect === html4.ueffects.SAME_DOCUMENT &&
loaderType === html4.ltypes.SANDBOXED)) {
Index: src/com/google/caja/demos/playground/examples/unboxed/index.html
===================================================================
--- src/com/google/caja/demos/playground/examples/unboxed/index.html
(revision 4399)
+++ src/com/google/caja/demos/playground/examples/unboxed/index.html
(working copy)
@@ -17,9 +17,9 @@
var height = 8;
var logicBombs = 10;
var remaining = width*height - logicBombs;
- var bombs;
- var hints;
- var wrapped;
+ var bombs = [];
+ var hints = [];
+ var wrapped = [];
function plantBombs(bombs) {
for (var c=0; c < logicBombs; c++) {
@@ -84,10 +84,6 @@
function reset() {
debugger;
- bombs = [];
- hints = [];
- wrapped = [];
-
initialize(bombs, width, height, false);
initialize(hints, width, height, 0);
initialize(wrapped, width, height, true);
@@ -122,12 +118,13 @@
function clicked(i, j) {
if (controller) {
- controller.notifyCellClicked(i, j);
+ controller.openCell(i, j);
}
}
function displayWrapped(i, j) {
- document.getElementById('cell-' + i + '-' + j).src = 'wrapped.png';
+ document.getElementById('cell-' + i + '-' + j).src =
+ 'http:examples/unboxed/wrapped.png';
}
function displayLost() {
@@ -141,7 +138,7 @@
function displayUnwrapped(i, j) {
var img = document.getElementById('cell-' + i + '-' + j);
img.src = model.bombs[i][j] ? 'bomb.png' :
- "http://www.thinkfu.com/unboxed/" + model.hints[i][j]
+ '-unwrapped.png';
+ "http:examples/unboxed/" + model.hints[i][j] + '-unwrapped.png';
}
function configureDisplay(model, display) {
@@ -151,7 +148,7 @@
for (var j=0; j < model.width; j++) {
var td = document.createElement('td');
var img = document.createElement('img');
- img.src = 'http://www.thinkfu.com/unboxed/wrapped.png';
+ img.src = 'http:examples/unboxed/wrapped.png';
img.id = 'cell-' + i + '-' + j;
img.onclick = (function(i, j) {
return function () { clicked(i, j); };
@@ -196,7 +193,8 @@
};
var controllerMaker = function(model, view) {
- function clearCell(i, j) {
+ function openCell(i, j) {
+ debugger;
if (!model.inBounds(i, j) || !model.wrapped[i][j])
return;
view.displayUnwrapped(i, j);
@@ -208,14 +206,14 @@
view.displayWin();
}
if (model.hints[i][j] == 0) {
- clearCell(i-1, j-1);
- clearCell(i-1, j);
- clearCell(i-1, j+1);
- clearCell(i, j-1);
- clearCell(i, j+1);
- clearCell(i+1, j-1);
- clearCell(i+1, j);
- clearCell(i+1, j+1);
+ openCell(i-1, j-1);
+ openCell(i-1, j);
+ openCell(i-1, j+1);
+ openCell(i, j-1);
+ openCell(i, j+1);
+ openCell(i+1, j-1);
+ openCell(i+1, j);
+ openCell(i+1, j+1);
}
};
@@ -224,7 +222,7 @@
view.reset();
}
return {
- notifyCellClicked: clearCell,
+ openCell: openCell,
reset: reset
};
};