Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: chrome/content/crawler.js

Issue 8402021: Crawler frontend (Closed)
Left Patch Set: Created Sept. 21, 2012, 1:16 p.m.
Right Patch Set: Created Sept. 26, 2012, 8:25 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « chrome.manifest ('k') | chrome/content/crawler.xul » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 /* 1 /*
2 * This Source Code is subject to the terms of the Mozilla Public License 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 3 * version 2.0 (the "License"). You can obtain a copy of the License at
4 * http://mozilla.org/MPL/2.0/. 4 * http://mozilla.org/MPL/2.0/.
5 */ 5 */
6 6
Wladimir Palant 2012/09/21 15:36:18 Site-note: I don't think that this manual UI will
7 const Cu = Components.utils; 7 const Cu = Components.utils;
8 8
9 Cu.import("resource://gre/modules/Services.jsm"); 9 Cu.import("resource://gre/modules/Services.jsm");
10 10
11 let crawling = false; 11 let crawling = false;
12 12
13 function require(module) 13 function require(module)
14 { 14 {
15 let result = {}; 15 let result = {};
16 result.wrappedJSObject = result; 16 result.wrappedJSObject = result;
17 Services.obs.notifyObservers(result, "abpcrawler-require", module); 17 Services.obs.notifyObservers(result, "abpcrawler-require", module);
18 return result.exports; 18 return result.exports;
19 } 19 }
20 20
21 let {Crawler} = require("crawler"); 21 let {Crawler} = require("crawler");
22 22
23 function onUnload() 23 function onUnload()
24 { 24 {
25 const fields = ["backend-url", "parallel-tabs"]; 25 const fields = ["backend-url", "parallel-tabs"];
26 fields.forEach(function(field) 26 fields.forEach(function(field)
27 { 27 {
28 let control = document.getElementById(field); 28 let control = document.getElementById(field);
29 control.setAttribute("value", control.value); 29 control.setAttribute("value", control.value);
Wladimir Palant 2012/09/21 15:36:18 Are you trying to make the field values persist? U
30 }); 30 });
31 } 31 }
32 32
33 function onClose()
34 {
35 return !crawling;
Wladimir Palant 2012/09/21 15:36:18 Maybe show a message why the window cannot be clos
36 }
37
38 function getBackendUrl() 33 function getBackendUrl()
39 { 34 {
40 let backendUrlTextBox = document.getElementById("backend-url"); 35 let backendUrlTextBox = document.getElementById("backend-url");
41 return backendUrlTextBox.value; 36 return backendUrlTextBox.value;
42 } 37 }
43 38
44 function getParallelTabs() 39 function getParallelTabs()
45 { 40 {
46 let parallelTabsTextBox = document.getElementById("parallel-tabs"); 41 let parallelTabsTextBox = document.getElementById("parallel-tabs");
47 return parseInt(parallelTabsTextBox.value); 42 return parseInt(parallelTabsTextBox.value);
48 } 43 }
49 44
50 function onAccept() 45 function onAccept()
51 { 46 {
52 let backendUrl = getBackendUrl(); 47 let backendUrl = getBackendUrl();
53 let parallelTabs = getParallelTabs(); 48 let parallelTabs = getParallelTabs();
54 let dialog = document.getElementById("abpcrawler-crawler"); 49 let dialog = document.documentElement;
Wladimir Palant 2012/09/21 15:36:18 How about using document.documentElement here?
55 let acceptButton = dialog.getButton("accept"); 50 let acceptButton = dialog.getButton("accept");
56 crawling = acceptButton.disabled = true; 51 crawling = acceptButton.disabled = true;
57 Crawler.crawl(backendUrl, parallelTabs, window.opener, function() 52
Wladimir Palant 2012/09/21 15:36:18 Of course we could have the condition that window.
53 let mainWindow = window.opener;
54 if (!mainWindow || mainWindow.closed)
58 { 55 {
56 alert( "Unable to find the main window, aborting.");
59 crawling = acceptButton.disabled = false; 57 crawling = acceptButton.disabled = false;
60 }); 58 }
59 else
60 Crawler.crawl(backendUrl, parallelTabs, mainWindow, function()
61 {
62 crawling = acceptButton.disabled = false;
63 });
64
61 return false; 65 return false;
62 } 66 }
67
68 function onCancel()
69 {
70 let closingPossible = !crawling;
71 if (!closingPossible)
72 alert("Crawling still in progress.");
73 return closingPossible;
74 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld