!import
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 *
3 * ***** BEGIN LICENSE BLOCK *****
4 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 *
6 * The contents of this file are subject to the Mozilla Public License Version
7 * 1.1 (the "License"); you may not use this file except in compliance with
8 * the License. You may obtain a copy of the License at
9 * http://www.mozilla.org/MPL/
10 *
11 * Software distributed under the License is distributed on an "AS IS" basis,
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 * for the specific language governing rights and limitations under the
14 * License.
15 *
16 * The Original Code is Mozilla Communicator client code, released
17 * March 31, 1998.
18 *
19 * The Initial Developer of the Original Code is
20 * Netscape Communications Corporation.
21 * Portions created by the Initial Developer are Copyright (C) 1998
22 * the Initial Developer. All Rights Reserved.
23 *
24 * Contributor(s):
25 * Ben "Count XULula" Goodger
26 * Mike Calmus
27 *
28 * Alternatively, the contents of this file may be used under the terms of
29 * either the GNU General Public License Version 2 or later (the "GPL"), or
30 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
31 * in which case the provisions of the GPL or the LGPL are applicable instead
32 * of those above. If you wish to allow use of your version of this file only
33 * under the terms of either the GPL or the LGPL, and not to allow others to
34 * use your version of this file under the terms of the MPL, indicate your
35 * decision by deleting the provisions above and replace them with the notice
36 * and other provisions required by the GPL or the LGPL. If you do not delete
37 * the provisions above, a recipient may use your version of this file under
38 * the terms of any one of the MPL, the GPL or the LGPL.
39 *
40 * ***** END LICENSE BLOCK ***** */
41
42 /*** =================== INITIALISATION CODE =================== ***/
43
44 var kObserverService;
45 var kSignonBundle;
46 var gSelectUserInUse = false;
47
48 // interface variables
49 var signonviewer = null;
50 var passwordmanager = null;
51
52 // password-manager lists
53 var signons = [];
54 var rejects = [];
55 var deletedSignons = [];
56 var deletedRejects = [];
57
58 // form-manager lists
59 var nopreviews = [];
60 var nocaptures = [];
61 var deletedNopreviews = [];
62 var deletedNocaptures = [];
63
64 // delete the following lines !!!!!
65 var goneNP = ""; // nopreview
66 var goneNC = ""; // nocapture
67
68 // differentiate between password manager and form manager
69 var isPasswordManager = (window.arguments[0] == "S");
70
71 // variables for encryption
72 var encrypted = "";
73 var showingPasswords = false;
74
Startup
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
75 function Startup() {
76
77 // xpconnect to password manager interfaces
78 signonviewer = Components.classes["@mozilla.org/signonviewer/signonviewer-world;1"].createInstance();
79 signonviewer = signonviewer.QueryInterface(Components.interfaces.nsISignonViewer);
80 passwordmanager = Components.classes["@mozilla.org/passwordmanager;1"].getService();
81 passwordmanager = passwordmanager.QueryInterface(Components.interfaces.nsIPasswordManager);
82
83 // determine if database is encrypted
84 try {
85 var pref = Components.classes["@mozilla.org/preferences-service;1"]
86 .getService(Components.interfaces.nsIPrefBranch);
87 try {
88 encrypted = pref.getBoolPref("wallet.crypto");
89 } catch(e) {
90 dump("wallet.crypto pref is missing from all.js");
91 }
92
93 } catch (ex) {
94 dump("failed to get prefs service!\n");
95 pref = null;
96 }
97
98 // determine whether to run in password-manager mode or form-manager mode
99 var tabBox = document.getElementById("tabbox");
100 kSignonBundle = document.getElementById("signonBundle");
101 var element;
102 if (isPasswordManager) {
103
104 // be prepared to reload the display if anything changes
105 kObserverService = Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService);
106 kObserverService.addObserver(signonReloadDisplay, "signonChanged", false);
107
108 // be prepared to disable the buttons when selectuser dialog is in use
109 kObserverService.addObserver(signonReloadDisplay, "signonSelectUser", false);
110
111 signonsTree = document.getElementById("signonsTree");
112 rejectsTree = document.getElementById("rejectsTree");
113
114 // set initial password-manager tab
115 element = document.getElementById("signonsTab");
116 tabBox.selectedTab = element;
117
118 // hide form-manager tabs
119 element = document.getElementById("nopreviewsTab");
120 element.hidden = "true";
121 element = document.getElementById("nocapturesTab");
122 element.hidden = "true"
123
124 // load password manager items
125 if (!LoadSignons()) {
126 return; /* user failed to unlock the database */
127 }
128 LoadRejects();
129
130 // label the show/hide password button
131 document.getElementById("togglePasswords").label = kSignonBundle.getString(showingPasswords ? "hidePasswords" : "showPasswords");
132 } else {
133
134 nopreviewsTree = document.getElementById("nopreviewsTree");
135 nocapturesTree = document.getElementById("nocapturesTree");
136
137 // change title on window
138 var wind = document.getElementById("signonviewer");
139 document.title = wind.getAttribute("alttitle");
140
141 // set initial form-manager tab
142 element = document.getElementById("nopreviewsTab");
143 tabBox.selectedTab = element;
144
145 // hide password-manager tabs
146 element = document.getElementById("signonsTab");
147 element.hidden = "true";
148 element = document.getElementById("signonsitesTab");
149 element.hidden = "true";
150
151 // load form manager items
152 LoadNopreview();
153 LoadNocapture();
154 }
155
156 // label the close button
157 document.documentElement.getButton("accept").label = kSignonBundle.getString("close");
158 }
159
Shutdown
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
160 function Shutdown() {
161 if (isPasswordManager) {
162 kObserverService.removeObserver(signonReloadDisplay, "signonChanged");
163 kObserverService.removeObserver(signonReloadDisplay, "signonSelectUser");
164 }
165 }
166
167 var signonReloadDisplay = {
observe
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
168 observe: function(subject, topic, state) {
169 if (topic == "signonChanged") {
170 if (state == "signons") {
171 signons.length = 0;
172 if (lastSignonSortColumn == "host") {
173 lastSignonSortAscending = !lastSignonSortAscending; // prevents sort from being reversed
174 }
175 LoadSignons();
176 } else if (state == "rejects") {
177 rejects.length = 0;
178 if (lastRejectSortColumn == "host") {
179 lastRejectSortAscending = !lastRejectSortAscending; // prevents sort from being reversed
180 }
181 LoadRejects();
182 } else if (state == "nocaptures") {
183 nocaptures.length = 0;
184 if (lastNocaptureSortColumn == "host") {
185 lastNocaptureSortAscending = !lastNocaptureSortAscending; // prevents sort from being reversed
186 }
187 LoadNocapture();
188 } else if (state == "nopreviews") {
189 nopreviews.length = 0;
190 if (lastNopreviewSortColumn == "host") {
191 lastNopreviewSortAscending = !lastNopreviewSortAscending; // prevents sort from being reversed
192 }
193 LoadNopreview();
194 }
195 } else if (topic == "signonSelectUser") {
196 if (state == "suspend") {
197 gSelectUserInUse = true;
198 document.getElementById("removeSignon").disabled = true;
199 document.getElementById("removeAllSignons").disabled = true;
200 document.getElementById("togglePasswords").disabled = true;
201 } else if (state == "resume") {
202 gSelectUserInUse = false;
203 var selections = GetTreeSelections(signonsTree);
204 if (selections.length > 0) {
205 document.getElementById("removeSignon").disabled = false;
206 }
207 if (signons.length > 0) {
208 document.getElementById("removeAllSignons").disabled = false;
209 document.getElementById("togglePasswords").disabled = false;
210 }
211 } else if (state == "inUse") {
212 gSelectUserInUse = true;
213 }
214 }
215 }
216 }
217
218 /*** =================== SAVED SIGNONS CODE =================== ***/
219
220 var signonsTreeView = {
221 rowCount : 0,
setTree
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
222 setTree : function(tree) {},
getImageSrc
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
223 getImageSrc : function(row,column) {},
getProgressMode
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
224 getProgressMode : function(row,column) {},
getCellValue
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
225 getCellValue : function(row,column) {},
getCellText
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
226 getCellText : function(row,column) {
227 var rv="";
228 if (column.id=="siteCol") {
229 rv = signons[row].host;
230 } else if (column.id=="userCol") {
231 rv = signons[row].user;
232 } else if (column.id=="passwordCol") {
233 rv = signons[row].password;
234 }
235 return rv;
236 },
isSeparator
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
237 isSeparator : function(index) { return false; },
isSorted
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
238 isSorted : function() { return false; },
isContainer
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
239 isContainer : function(index) { return false; },
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
240 cycleHeader : function(column) {},
getRowProperties
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
241 getRowProperties : function(row,prop) {},
getColumnProperties
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
242 getColumnProperties : function(column,prop) {},
getCellProperties
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
243 getCellProperties : function(row,column,prop) {}
244 };
245 var signonsTree;
246
Signon
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
247 function Signon(id, host, user, rawuser, password) {
248 this.id = id;
249 this.host = host;
250 this.user = user;
251 this.rawuser = rawuser;
252 this.password = password;
253 }
254
LoadSignons
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
255 function LoadSignons() {
256 // loads signons into table
257 var enumerator = passwordmanager.enumerator;
258 var count = 0;
259
260 while (enumerator.hasMoreElements()) {
261 var nextPassword;
262 try {
263 nextPassword = enumerator.getNext();
264
265 nextPassword = nextPassword.QueryInterface(Components.interfaces.nsIPassword);
266 var host = nextPassword.host;
267 var user = nextPassword.user;
268 var password = nextPassword.password;
269 var rawuser = user;
270
271 // if no username supplied, try to parse it out of the url
272 if (user == "") {
273 var ioService = Components.classes["@mozilla.org/network/io-service;1"]
274 .getService(Components.interfaces.nsIIOService);
275 try {
276 user = ioService.newURI(host, null, null).username;
277 if (user == "") {
278 user = "<>";
279 }
280 } catch(e) {
281 user = "<>";
282 }
283 }
284
285 if (encrypted) {
286 user = kSignonBundle.getFormattedString("encrypted", [user], 1);
287 }
288
289 signons[count] = new Signon(count++, host, user, rawuser, password);
290 } catch(e) {
291 /* The user cancelled the master password dialog */
292 if (e.result==Components.results.NS_ERROR_NOT_AVAILABLE) {
293 window.close();
294 return false;
295 }
296 /* Otherwise an entry is corrupt. Go to next element. */
297 }
298 }
299 signonsTreeView.rowCount = signons.length;
300
301 // sort and display the table
302 signonsTree.treeBoxObject.view = signonsTreeView;
303 SignonColumnSort('host');
304
305 // disable "remove all signons" button if there are no signons
306 var element = document.getElementById("removeAllSignons");
307 var toggle = document.getElementById("togglePasswords")
308 if (signons.length == 0 || gSelectUserInUse) {
309 element.setAttribute("disabled","true");
310 toggle.setAttribute("disabled","true");
311 } else {
312 element.removeAttribute("disabled");
313 toggle.removeAttribute("disabled");
314 }
315
316 return true;
317 }
318
SignonSelected
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
319 function SignonSelected() {
320 var selections = GetTreeSelections(signonsTree);
321 if (selections.length && !gSelectUserInUse) {
322 document.getElementById("removeSignon").removeAttribute("disabled");
323 }
324 }
325
DeleteSignon
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
326 function DeleteSignon() {
327 DeleteSelectedItemFromTree(signonsTree, signonsTreeView,
328 signons, deletedSignons,
329 "removeSignon", "removeAllSignons");
330 FinalizeSignonDeletions();
331 }
332
DeleteAllSignons
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
333 function DeleteAllSignons() {
334 var prompter = Components.classes["@mozilla.org/embedcomp/prompt-service;1"]
335 .getService(Components.interfaces.nsIPromptService);
336
337 // Confirm the user wants to remove all passwords
338 var dummy = { value: false };
339 if (prompter.confirmEx(window,
340 kSignonBundle.getString("removeAllPasswordsTitle"),
341 kSignonBundle.getString("removeAllPasswordsPrompt"),
342 prompter.STD_YES_NO_BUTTONS + prompter.BUTTON_POS_1_DEFAULT,
343 null, null, null, null, dummy) == 1) // 1 == "No" button
344 return;
345
346 DeleteAllFromTree(signonsTree, signonsTreeView,
347 signons, deletedSignons,
348 "removeSignon", "removeAllSignons");
349 FinalizeSignonDeletions();
350 }
351
TogglePasswordVisible
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
352 function TogglePasswordVisible() {
353 if (!showingPasswords && !ConfirmShowPasswords())
354 return;
355
356 showingPasswords = !showingPasswords;
357 document.getElementById("togglePasswords").label = kSignonBundle.getString(showingPasswords ? "hidePasswords" : "showPasswords");
358 document.getElementById("passwordCol").hidden = !showingPasswords;
359 }
360
AskUserShowPasswords
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
361 function AskUserShowPasswords() {
362 var prompter = Components.classes["@mozilla.org/embedcomp/prompt-service;1"].getService(Components.interfaces.nsIPromptService);
363 var dummy = { value: false };
364
365 // Confirm the user wants to display passwords
366 return prompter.confirmEx(window,
367 null,
368 kSignonBundle.getString("noMasterPasswordPrompt"),
369 prompter.STD_YES_NO_BUTTONS,
370 null, null, null, null, dummy) == 0; // 0=="Yes" button
371 }
372
ConfirmShowPasswords
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
373 function ConfirmShowPasswords() {
374 if (encrypted) {
375 // If signons are encrypted, force prompted login into Software Security Device
376 var tokendb = Components.classes["@mozilla.org/security/pk11tokendb;1"]
377 .createInstance(Components.interfaces.nsIPK11TokenDB);
378 var token = tokendb.getInternalKeyToken();
379
380 try {
381 // If signons are encrypted but there is no master password (it could have been changed to an empty string),
382 // still give the user a chance to opt-out of displaying passwords (like in the non-encrypted case).
383 // Regardless of whether the check succeeds or not, we still login to make sure we're properly authenticated.
384 // This is all right since login() will succeed without prompting the user for the (empty) master password.
385 if (token.checkPassword("") && !AskUserShowPasswords())
386 return false;
387
388 token.login(true); // 'true' means always prompt for token password. User will be prompted until
389 // clicking 'Cancel' or entering the correct password.
390 } catch (e) {
391 // An exception will be thrown if the user cancels the login prompt dialog.
392 // User is also logged out of Software Security Device.
393 ;
394 }
395
396 return token.isLoggedIn();
397 } else {
398 // signons not encrypted, confirm the user wants to display passwords
399 return AskUserShowPasswords();
400 }
401 }
402
FinalizeSignonDeletions
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
403 function FinalizeSignonDeletions() {
404 for (var s=0; s<deletedSignons.length; s++) {
405 passwordmanager.removeUser(deletedSignons[s].host, deletedSignons[s].rawuser);
406 }
407 deletedSignons.length = 0;
408 }
409
HandleSignonKeyPress
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
410 function HandleSignonKeyPress(e) {
411 if (e.keyCode == 46) {
412 DeleteSignonSelected();
413 }
414 }
415
416 var lastSignonSortColumn = "";
417 var lastSignonSortAscending = false;
418
SignonColumnSort
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
419 function SignonColumnSort(column) {
420 lastSignonSortAscending =
421 SortTree(signonsTree, signonsTreeView, signons,
422 column, lastSignonSortColumn, lastSignonSortAscending);
423 lastSignonSortColumn = column;
424 }
425
426 /*** =================== REJECTED SIGNONS CODE =================== ***/
427
428 var rejectsTreeView = {
429 rowCount : 0,
setTree
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
430 setTree : function(tree){},
getImageSrc
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
431 getImageSrc : function(row,column) {},
getProgressMode
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
432 getProgressMode : function(row,column) {},
getCellValue
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
433 getCellValue : function(row,column) {},
getCellText
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
434 getCellText : function(row,column){
435 var rv="";
436 if (column.id=="rejectCol") {
437 rv = rejects[row].host;
438 }
439 return rv;
440 },
isSeparator
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
441 isSeparator : function(index) {return false;},
isSorted
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
442 isSorted: function() { return false; },
isContainer
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
443 isContainer : function(index) {return false;},
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
444 cycleHeader : function(column) {},
getRowProperties
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
445 getRowProperties : function(row,prop) {},
getColumnProperties
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
446 getColumnProperties : function(column,prop) {},
getCellProperties
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
447 getCellProperties : function(row,column,prop) {}
448 };
449 var rejectsTree;
450
Reject
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
451 function Reject(id, host) {
452 this.id = id;
453 this.host = host;
454 }
455
LoadRejects
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
456 function LoadRejects() {
457 var enumerator = passwordmanager.rejectEnumerator;
458 var count = 0;
459 while (enumerator.hasMoreElements()) {
460 var nextReject = enumerator.getNext();
461 nextReject = nextReject.QueryInterface(Components.interfaces.nsIPassword);
462 var host = nextReject.host;
463 rejects[count] = new Reject(count++, host);
464 }
465 rejectsTreeView.rowCount = rejects.length;
466
467 // sort and display the table
468 rejectsTree.treeBoxObject.view = rejectsTreeView;
469 RejectColumnSort('host');
470
471 var element = document.getElementById("removeAllRejects");
472 if (rejects.length == 0) {
473 element.setAttribute("disabled","true");
474 } else {
475 element.removeAttribute("disabled");
476 }
477 }
478
RejectSelected
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
479 function RejectSelected() {
480 var selections = GetTreeSelections(rejectsTree);
481 if (selections.length) {
482 document.getElementById("removeReject").removeAttribute("disabled");
483 }
484 }
485
DeleteReject
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
486 function DeleteReject() {
487 DeleteSelectedItemFromTree(rejectsTree, rejectsTreeView,
488 rejects, deletedRejects,
489 "removeReject", "removeAllRejects");
490 FinalizeRejectDeletions();
491 }
492
DeleteAllRejects
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
493 function DeleteAllRejects() {
494 DeleteAllFromTree(rejectsTree, rejectsTreeView,
495 rejects, deletedRejects,
496 "removeReject", "removeAllRejects");
497 FinalizeRejectDeletions();
498 }
499
FinalizeRejectDeletions
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
500 function FinalizeRejectDeletions() {
501 for (var r=0; r<deletedRejects.length; r++) {
502 passwordmanager.removeReject(deletedRejects[r].host);
503 }
504 deletedRejects.length = 0;
505 }
506
HandleRejectKeyPress
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
507 function HandleRejectKeyPress(e) {
508 if (e.keyCode == 46) {
509 DeleteRejectSelected();
510 }
511 }
512
513 var lastRejectSortColumn = "";
514 var lastRejectSortAscending = false;
515
RejectColumnSort
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
516 function RejectColumnSort(column) {
517 lastRejectSortAscending =
518 SortTree(rejectsTree, rejectsTreeView, rejects,
519 column, lastRejectSortColumn, lastRejectSortAscending);
520 lastRejectSortColumn = column;
521 }
522
523 /*** =================== NO PREVIEW FORMS CODE =================== ***/
524
525 var nopreviewsTreeView = {
526 rowCount : 0,
setTree
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
527 setTree : function(tree){},
getImageSrc
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
528 getImageSrc : function(row,column) {},
getProgressMode
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
529 getProgressMode : function(row,column) {},
getCellValue
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
530 getCellValue : function(row,column) {},
getCellText
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
531 getCellText : function(row,column){
532 var rv="";
533 if (column.id=="nopreviewCol") {
534 rv = nopreviews[row].host;
535 }
536 return rv;
537 },
isSeparator
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
538 isSeparator : function(index) {return false;},
isSorted
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
539 isSorted: function() { return false; },
isContainer
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
540 isContainer : function(index) {return false;},
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
541 cycleHeader : function(column) {},
getRowProperties
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
542 getRowProperties : function(row,prop) {},
getColumnProperties
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
543 getColumnProperties : function(column,prop) {},
getCellProperties
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
544 getCellProperties : function(row,column,prop) {}
545 };
546 var nopreviewsTree;
547
Nopreview
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
548 function Nopreview(id, host) {
549 this.id = id;
550 this.host = host;
551 }
552
LoadNopreview
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
553 function LoadNopreview() {
554 var list = signonviewer.getNopreviewValue();
555 var count = 0;
556 if (list.length > 0) {
557 var delim = list[0];
558 list = list.split(delim);
559 }
560 for (var i = 1; i < list.length; i++) {
561 var host = TrimString(list[i]);
562 nopreviews[count] = new Nopreview(count++, host);
563 }
564 nopreviewsTreeView.rowCount = nopreviews.length;
565
566 // sort and display the table
567 nopreviewsTree.treeBoxObject.view = nopreviewsTreeView;
568 NopreviewColumnSort('host');
569
570 var element = document.getElementById("removeAllNopreviews");
571 if (nopreviews.length == 0) {
572 element.setAttribute("disabled","true");
573 } else {
574 element.removeAttribute("disabled");
575 }
576 }
577
NopreviewSelected
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
578 function NopreviewSelected() {
579 var selections = GetTreeSelections(nopreviewsTree);
580 if (selections.length) {
581 document.getElementById("removeNopreview").removeAttribute("disabled");
582 }
583 }
584
DeleteNopreview
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
585 function DeleteNopreview() {
586 DeleteSelectedItemFromTree(nopreviewsTree, nopreviewsTreeView,
587 nopreviews, deletedNopreviews,
588 "removeNopreview", "removeAllNopreviews");
589 FinalizeNopreviewDeletions();
590 }
591
DeleteAllNopreviews
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
592 function DeleteAllNopreviews() {
593 DeleteAllFromTree(nopreviewsTree, nopreviewsTreeView,
594 nopreviews, deletedNopreviews,
595 "removeNopreview", "removeAllNopreviews");
596 FinalizeNopreviewDeletions();
597 }
598
FinalizeNopreviewDeletions
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
599 function FinalizeNopreviewDeletions() {
600 var i;
601 var result = "|goneP|";
602 for (i=0; i<deletedNopreviews.length; i++) {
603 result += deletedNopreviews[i].id;
604 result += ",";
605 }
606 result += "|";
607 signonviewer.setValue(result, window);
608 deletedNoPreviews.length = 0;
609 }
610
HandleNopreviewKeyPress
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
611 function HandleNopreviewKeyPress(e) {
612 if (e.keyCode == 46) {
613 DeleteNopreviewSelected();
614 }
615 }
616
617 var lastNopreviewSortColumn = "";
618 var lastNopreviewSortAscending = false;
619
NopreviewColumnSort
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
620 function NopreviewColumnSort(column) {
621 lastNopreviewSortAscending =
622 SortTree(nopreviewsTree, nopreviewsTreeView, nopreviews,
623 column, lastNopreviewSortColumn, lastNopreviewSortAscending);
624 lastNopreviewSortColumn = column;
625 }
626
627 /*** =================== NO CAPTURE FORMS CODE =================== ***/
628
629
630 var nocapturesTreeView = {
631 rowCount : 0,
setTree
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
632 setTree : function(tree){},
getImageSrc
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
633 getImageSrc : function(row,column) {},
getProgressMode
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
634 getProgressMode : function(row,column) {},
getCellValue
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
635 getCellValue : function(row,column) {},
getCellText
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
636 getCellText : function(row,column){
637 var rv="";
638 if (column.id=="nocaptureCol") {
639 rv = nocaptures[row].host;
640 }
641 return rv;
642 },
isSeparator
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
643 isSeparator : function(index) {return false;},
isSorted
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
644 isSorted: function() { return false; },
isContainer
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
645 isContainer : function(index) {return false;},
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
646 cycleHeader : function(column) {},
getRowProperties
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
647 getRowProperties : function(row,prop) {},
getColumnProperties
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
648 getColumnProperties : function(column,prop) {},
getCellProperties
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
649 getCellProperties : function(row,column,prop) {}
650 };
651 var nocapturesTree;
652
Nocapture
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
653 function Nocapture(id, host) {
654 this.id = id;
655 this.host = host;
656 }
657
LoadNocapture
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
658 function LoadNocapture() {
659 var list = signonviewer.getNocaptureValue();
660 var count = 0;
661 if (list.length > 0) {
662 var delim = list[0];
663 list = list.split(delim);
664 }
665 for (var i = 1; i < list.length; i++) {
666 var host = TrimString(list[i]);
667 nocaptures[count] = new Nocapture(count++, host);
668 }
669 nocapturesTreeView.rowCount = nocaptures.length;
670
671 // sort and display the table
672 nocapturesTree.treeBoxObject.view = nocapturesTreeView;
673 NocaptureColumnSort('host');
674
675 var element = document.getElementById("removeAllNocaptures");
676 if (nocaptures.length == 0) {
677 element.setAttribute("disabled","true");
678 } else {
679 element.removeAttribute("disabled");
680 }
681 }
682
NocaptureSelected
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
683 function NocaptureSelected() {
684 var selections = GetTreeSelections(nocapturesTree);
685 if (selections.length) {
686 document.getElementById("removeNocapture").removeAttribute("disabled");
687 }
688 }
689
DeleteNocapture
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
690 function DeleteNocapture() {
691 DeleteSelectedItemFromTree(nocapturesTree, nocapturesTreeView,
692 nocaptures, deletedNocaptures,
693 "removeNocapture", "removeAllNocaptures");
694 FinalizeNocaptureDeletions();
695 }
696
DeleteAllNocaptures
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
697 function DeleteAllNocaptures() {
698 DeleteAllFromTree(nocapturesTree, nocapturesTreeView,
699 nocaptures, deletedNocaptures,
700 "removeNocapture", "removeAllNocaptures");
701 FinalizeNocaptureDeletions();
702 }
703
FinalizeNocaptureDeletions
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
704 function FinalizeNocaptureDeletions() {
705 var i;
706 var result = "|goneC|";
707 for (i=0; i<deletedNocaptures.length; i++) {
708 result += deletedNocaptures[i].id;
709 result += ",";
710 }
711 result += "|";
712 signonviewer.setValue(result, window);
713 deletedNoCaptures.length = 0;
714 }
715
HandleNocaptureKeyPress
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
716 function HandleNocaptureKeyPress(e) {
717 if (e.keyCode == 46) {
718 DeleteNocaptureSelected();
719 }
720 }
721
722 var lastNocaptureSortColumn = "";
723 var lastNocaptureSortAscending = false;
724
NocaptureColumnSort
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
725 function NocaptureColumnSort(column) {
726 lastNocaptureSortAscending =
727 SortTree(nocapturesTree, nocapturesTreeView, nocaptures,
728 column, lastNocaptureSortColumn, lastNocaptureSortAscending);
729 lastNocaptureSortColumn = column;
730 }
731
732 /*** =================== GENERAL CODE =================== ***/
733
734 // Remove whitespace from both ends of a string
TrimString
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
735 function TrimString(string)
736 {
737 if (!string) {
738 return "";
739 }
740 return string.replace(/(^\s+)|(\s+$)/g, '')
741 }
742
doHelpButton
(0 calls, 0 incl. v-uS, 0 excl. v-uS)
743 function doHelpButton() {
744 if (isPasswordManager) {
745 openHelp("password_mgr");
746 } else {
747 openHelp("forms_sites");
748 }
749 }