| Index: chrome/content/crawler.js |
| =================================================================== |
| new file mode 100644 |
| --- /dev/null |
| +++ b/chrome/content/crawler.js |
| @@ -0,0 +1,62 @@ |
| +/* |
| + * This Source Code is subject to the terms of the Mozilla Public License |
| + * version 2.0 (the "License"). You can obtain a copy of the License at |
| + * http://mozilla.org/MPL/2.0/. |
| + */ |
| + |
|
Wladimir Palant
2012/09/21 15:36:18
Site-note: I don't think that this manual UI will
|
| +const Cu = Components.utils; |
| + |
| +Cu.import("resource://gre/modules/Services.jsm"); |
| + |
| +let crawling = false; |
| + |
| +function require(module) |
| +{ |
| + let result = {}; |
| + result.wrappedJSObject = result; |
| + Services.obs.notifyObservers(result, "abpcrawler-require", module); |
| + return result.exports; |
| +} |
| + |
| +let {Crawler} = require("crawler"); |
| + |
| +function onUnload() |
| +{ |
| + const fields = ["backend-url", "parallel-tabs"]; |
| + fields.forEach(function(field) |
| + { |
| + let control = document.getElementById(field); |
| + control.setAttribute("value", control.value); |
|
Wladimir Palant
2012/09/21 15:36:18
Are you trying to make the field values persist? U
|
| + }); |
| +} |
| + |
| +function onClose() |
| +{ |
| + return !crawling; |
|
Wladimir Palant
2012/09/21 15:36:18
Maybe show a message why the window cannot be clos
|
| +} |
| + |
| +function getBackendUrl() |
| +{ |
| + let backendUrlTextBox = document.getElementById("backend-url"); |
| + return backendUrlTextBox.value; |
| +} |
| + |
| +function getParallelTabs() |
| +{ |
| + let parallelTabsTextBox = document.getElementById("parallel-tabs"); |
| + return parseInt(parallelTabsTextBox.value); |
| +} |
| + |
| +function onAccept() |
| +{ |
| + let backendUrl = getBackendUrl(); |
| + let parallelTabs = getParallelTabs(); |
| + let dialog = document.getElementById("abpcrawler-crawler"); |
|
Wladimir Palant
2012/09/21 15:36:18
How about using document.documentElement here?
|
| + let acceptButton = dialog.getButton("accept"); |
| + crawling = acceptButton.disabled = true; |
| + Crawler.crawl(backendUrl, parallelTabs, window.opener, function() |
|
Wladimir Palant
2012/09/21 15:36:18
Of course we could have the condition that window.
|
| + { |
| + crawling = acceptButton.disabled = false; |
| + }); |
| + return false; |
| +} |