Skip to content

Commit

Permalink
Bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
weikinhuang committed Oct 16, 2012
1 parent a382377 commit d5940f1
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions phantom-bridge.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ controller.onAlert = function(msg) {
break;

case "evaluate": // (function, arg1, arg2, ...)` {object}
var args = data.args[1].slice(0);
var args = (data.args[1] || []).slice(0);
args.unshift((new Function("return " + data.args[0]))());
send(data, [ page.evaluate.apply(page, args) ]);
break;
Expand All @@ -133,8 +133,9 @@ controller.onAlert = function(msg) {
break;

case "open": // (url, callback)` {void}
page.open(data.args[0], function() {
send(data);
page.open(data.args[0], function(status) {
// console.log("opening page...");
send(data, [ status ]);
});
break;

Expand All @@ -151,12 +152,24 @@ controller.onAlert = function(msg) {
break;

case "set":
var k;
var k, j;
if (typeof data.args[0] === "string") {
page[data.args[0]] = data.args[1];
if (data.args[0] === "settings") {
for (k in data.args[1]) {
page.settings[k] = data.args[1][k];
}
} else {
page[data.args[0]] = data.args[1];
}
} else {
for (k in data.args[0]) {
page[k] = data.args[0][k];
if (k === "settings") {
for (l in data.args[0][k]) {
page.settings[l] = data.args[k][l];
}
} else {
page[k] = data.args[0][k];
}
}
}
send(data);
Expand Down

0 comments on commit d5940f1

Please sign in to comment.