this.downloadpage = function(link){
- var url = File.read(__script_path__+"/downloadqueue/"+link);
- TabbedBrowser.browser.current_tab().get_web_view().execute_script(
- "downloadpage("+url+");");
+ //var url = File.read(__script_path__+"/downloadqueue/"+link);
+ //TabbedBrowser.browser.current_tab().get_web_view().execute_script(
+ //"gatherlinks();");
};
this.signal.console_message.connect(function(wv, msg, line, sid) {
//print('BrowserView.js got ' + msg);
+ var methodname;
+ myData = JSON.parse(msg, function (key, value) {
+ if (key=='method'){ methodname = value;}
- if (msg.indexOf('html')){
+ return value;
+ });
+
+ /*if (msg.indexOf('html')){
File.write(__script_path__+"/parsequeue/"+Math.random(), msg);
}
File.write(__script_path__+"/downloadqueue/"+Math.random(), msg);
-
+ */
+
+ if (methodname == 'gatherlinks'){
+ File.write(__script_path__+"/downloadqueue/"+Math.random(), msg);
+ }
+
+ if (methodname == 'downloadpage'){
+ File.write(__script_path__+"/parsequeue/"+Math.random(), msg);
+ }
this.queuerun();
return true;
var urls= [];
for (var i= document.links.length; i-->0;){
urls.push(document.links[i].href);
- console.log(document.links[i].href);
+
}
+ console.log(JSON.stringify( { method: 'gatherlinks' , data : urls }));
+ print('gatherlinks');
return urls;
}
xmlhttp.open("HEAD", url,true);
xmlhttp.onreadystatechange=function() {
if (xmlhttp.readyState==4) {
- console.log(xmlhttp.getAllResponseHeaders());
- console.log(xmlhttp.responseText);
-
+ console.log( JSON.stringify ({method: 'downloadpage', headers:xmlhttp.getAllResponseHeaders(), data:xmlhttp.responseText}));
}
xmlhttp.send(null);