Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | // -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
michael@0 | 2 | |
michael@0 | 3 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 4 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 5 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 6 | |
michael@0 | 7 | /*** =================== REJECTED SIGNONS CODE =================== ***/ |
michael@0 | 8 | |
michael@0 | 9 | function RejectsStartup() { |
michael@0 | 10 | LoadRejects(); |
michael@0 | 11 | } |
michael@0 | 12 | |
michael@0 | 13 | var rejectsTreeView = { |
michael@0 | 14 | rowCount : 0, |
michael@0 | 15 | setTree : function(tree){}, |
michael@0 | 16 | getImageSrc : function(row,column) {}, |
michael@0 | 17 | getProgressMode : function(row,column) {}, |
michael@0 | 18 | getCellValue : function(row,column) {}, |
michael@0 | 19 | getCellText : function(row,column){ |
michael@0 | 20 | var rv=""; |
michael@0 | 21 | if (column.id=="rejectCol") { |
michael@0 | 22 | rv = rejects[row].host; |
michael@0 | 23 | } |
michael@0 | 24 | return rv; |
michael@0 | 25 | }, |
michael@0 | 26 | isSeparator : function(index) {return false;}, |
michael@0 | 27 | isSorted: function() { return false; }, |
michael@0 | 28 | isContainer : function(index) {return false;}, |
michael@0 | 29 | cycleHeader : function(column) {}, |
michael@0 | 30 | getRowProperties : function(row){ return ""; }, |
michael@0 | 31 | getColumnProperties : function(column){ return ""; }, |
michael@0 | 32 | getCellProperties : function(row,column){ |
michael@0 | 33 | if (column.element.getAttribute("id") == "rejectCol") |
michael@0 | 34 | return "ltr"; |
michael@0 | 35 | |
michael@0 | 36 | return ""; |
michael@0 | 37 | } |
michael@0 | 38 | }; |
michael@0 | 39 | |
michael@0 | 40 | function Reject(number, host) { |
michael@0 | 41 | this.number = number; |
michael@0 | 42 | this.host = host; |
michael@0 | 43 | } |
michael@0 | 44 | |
michael@0 | 45 | function LoadRejects() { |
michael@0 | 46 | var hosts = passwordmanager.getAllDisabledHosts(); |
michael@0 | 47 | rejects = hosts.map(function(host, i) { return new Reject(i, host); }); |
michael@0 | 48 | rejectsTreeView.rowCount = rejects.length; |
michael@0 | 49 | |
michael@0 | 50 | // sort and display the table |
michael@0 | 51 | rejectsTree.treeBoxObject.view = rejectsTreeView; |
michael@0 | 52 | RejectColumnSort(lastRejectSortColumn); |
michael@0 | 53 | |
michael@0 | 54 | var element = document.getElementById("removeAllRejects"); |
michael@0 | 55 | if (rejects.length == 0) { |
michael@0 | 56 | element.setAttribute("disabled","true"); |
michael@0 | 57 | } else { |
michael@0 | 58 | element.removeAttribute("disabled"); |
michael@0 | 59 | } |
michael@0 | 60 | } |
michael@0 | 61 | |
michael@0 | 62 | function RejectSelected() { |
michael@0 | 63 | var selections = GetTreeSelections(rejectsTree); |
michael@0 | 64 | if (selections.length) { |
michael@0 | 65 | document.getElementById("removeReject").removeAttribute("disabled"); |
michael@0 | 66 | } |
michael@0 | 67 | } |
michael@0 | 68 | |
michael@0 | 69 | function DeleteReject() { |
michael@0 | 70 | DeleteSelectedItemFromTree(rejectsTree, rejectsTreeView, |
michael@0 | 71 | rejects, deletedRejects, |
michael@0 | 72 | "removeReject", "removeAllRejects"); |
michael@0 | 73 | FinalizeRejectDeletions(); |
michael@0 | 74 | } |
michael@0 | 75 | |
michael@0 | 76 | function DeleteAllRejects() { |
michael@0 | 77 | DeleteAllFromTree(rejectsTree, rejectsTreeView, |
michael@0 | 78 | rejects, deletedRejects, |
michael@0 | 79 | "removeReject", "removeAllRejects"); |
michael@0 | 80 | FinalizeRejectDeletions(); |
michael@0 | 81 | } |
michael@0 | 82 | |
michael@0 | 83 | function FinalizeRejectDeletions() { |
michael@0 | 84 | for (var r=0; r<deletedRejects.length; r++) { |
michael@0 | 85 | passwordmanager.setLoginSavingEnabled(deletedRejects[r].host, true); |
michael@0 | 86 | } |
michael@0 | 87 | deletedRejects.length = 0; |
michael@0 | 88 | } |
michael@0 | 89 | |
michael@0 | 90 | function HandleRejectKeyPress(e) { |
michael@0 | 91 | if (e.keyCode == 46) { |
michael@0 | 92 | DeleteRejectSelected(); |
michael@0 | 93 | } |
michael@0 | 94 | } |
michael@0 | 95 | |
michael@0 | 96 | var lastRejectSortColumn = "host"; |
michael@0 | 97 | var lastRejectSortAscending = false; |
michael@0 | 98 | |
michael@0 | 99 | function RejectColumnSort(column) { |
michael@0 | 100 | lastRejectSortAscending = |
michael@0 | 101 | SortTree(rejectsTree, rejectsTreeView, rejects, |
michael@0 | 102 | column, lastRejectSortColumn, lastRejectSortAscending); |
michael@0 | 103 | lastRejectSortColumn = column; |
michael@0 | 104 | |
michael@0 | 105 | // set the sortDirection attribute to get the styling going |
michael@0 | 106 | var sortedCol = document.getElementById("rejectCol"); |
michael@0 | 107 | sortedCol.setAttribute("sortDirection", lastRejectSortAscending ? |
michael@0 | 108 | "ascending" : "descending"); |
michael@0 | 109 | } |