Permalink
Browse files

added set and get functionality for page

  • Loading branch information...
1 parent 96cd30e commit acddcb239d166decdc4de1638782d979fc20c8be @alexscheelmeyer committed Aug 20, 2012
Showing with 21 additions and 2 deletions.
  1. +2 −1 .gitignore
  2. +10 −1 bridge.js
  3. +9 −0 node-phantom.js
View
@@ -1 +1,2 @@
-node_modules
+node_modules
+.DS_Store
View
@@ -76,8 +76,17 @@ controlpage.onAlert=function(msg){
break;
case 'pageRender':
page.render(request[3]);
- respond([id,cmdId,'pageRendered',JSON.stringify(result)]);
+ respond([id,cmdId,'pageRendered']);
break;
+ case 'pageSet':
+ page[request[3]]=request[4];
+ respond([id,cmdId,'pageSetDone']);
+ break;
+ case 'pageGet':
+ var result=page[request[3]];
+ respond([id,cmdId,'pageGetDone',JSON.stringify(result)]);
+ break;
+
default:
console.error('unrecognized request:'+request);
break;
View
@@ -82,7 +82,14 @@ module.exports={
},
evaluate:function(evaluator,callback){
request(socket,[id,'pageEvaluate',evaluator.toString()],callbackOrDummy(callback));
+ },
+ set:function(name,value,callback){
+ request(socket,[id,'pageSet',name,value],callbackOrDummy(callback));
+ },
+ get:function(name,callback){
+ request(socket,[id,'pageGet',name],callbackOrDummy(callback));
}
+
};
cmds[cmdId].cb(null,pageProxy);
delete cmds[cmdId];
@@ -104,10 +111,12 @@ module.exports={
delete cmds[cmdId];
}
break;
+ case 'pageGetDone':
case 'pageEvaluated':
cmds[cmdId].cb(null,JSON.parse(response[3]));
delete cmds[cmdId];
break;
+ case 'pageSetDone':
case 'pageReleased':
case 'pageJsIncluded':
case 'pageRendered':

0 comments on commit acddcb2

Please sign in to comment.