OLD | NEW |
(Empty) | |
| 1 /* |
| 2 * This Source Code is subject to the terms of the Mozilla Public License |
| 3 * version 2.0 (the "License"). You can obtain a copy of the License at |
| 4 * http://mozilla.org/MPL/2.0/. |
| 5 */ |
| 6 |
| 7 const Cu = Components.utils; |
| 8 |
| 9 Cu.import("resource://gre/modules/Services.jsm"); |
| 10 |
| 11 let crawling = false; |
| 12 |
| 13 function require(module) |
| 14 { |
| 15 let result = {}; |
| 16 result.wrappedJSObject = result; |
| 17 Services.obs.notifyObservers(result, "abpcrawler-require", module); |
| 18 return result.exports; |
| 19 } |
| 20 |
| 21 let {Crawler} = require("crawler"); |
| 22 |
| 23 function onUnload() |
| 24 { |
| 25 const fields = ["backend-url", "parallel-tabs"]; |
| 26 fields.forEach(function(field) |
| 27 { |
| 28 let control = document.getElementById(field); |
| 29 control.setAttribute("value", control.value); |
| 30 }); |
| 31 } |
| 32 |
| 33 function getBackendUrl() |
| 34 { |
| 35 let backendUrlTextBox = document.getElementById("backend-url"); |
| 36 return backendUrlTextBox.value; |
| 37 } |
| 38 |
| 39 function getParallelTabs() |
| 40 { |
| 41 let parallelTabsTextBox = document.getElementById("parallel-tabs"); |
| 42 return parseInt(parallelTabsTextBox.value); |
| 43 } |
| 44 |
| 45 function onAccept() |
| 46 { |
| 47 let backendUrl = getBackendUrl(); |
| 48 let parallelTabs = getParallelTabs(); |
| 49 let dialog = document.documentElement; |
| 50 let acceptButton = dialog.getButton("accept"); |
| 51 crawling = acceptButton.disabled = true; |
| 52 |
| 53 let mainWindow = window.opener; |
| 54 if (!mainWindow || mainWindow.closed) |
| 55 { |
| 56 alert( "Unable to find the main window, aborting."); |
| 57 crawling = acceptButton.disabled = false; |
| 58 } |
| 59 else |
| 60 Crawler.crawl(backendUrl, parallelTabs, mainWindow, function() |
| 61 { |
| 62 crawling = acceptButton.disabled = false; |
| 63 }); |
| 64 |
| 65 return false; |
| 66 } |
| 67 |
| 68 function onCancel() |
| 69 { |
| 70 let closingPossible = !crawling; |
| 71 if (!closingPossible) |
| 72 alert("Crawling still in progress."); |
| 73 return closingPossible; |
| 74 } |
OLD | NEW |