Diffstat (limited to 'frontend/beta/js/Clipperz/Profile.js') (more/less context) (ignore whitespace changes)
-rw-r--r-- | frontend/beta/js/Clipperz/Profile.js | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/frontend/beta/js/Clipperz/Profile.js b/frontend/beta/js/Clipperz/Profile.js index 31888a9..fb12417 100644 --- a/frontend/beta/js/Clipperz/Profile.js +++ b/frontend/beta/js/Clipperz/Profile.js | |||
@@ -1,216 +1,213 @@ | |||
1 | /* | 1 | /* |
2 | 2 | ||
3 | Copyright 2008-2011 Clipperz Srl | 3 | Copyright 2008-2011 Clipperz Srl |
4 | 4 | ||
5 | This file is part of Clipperz's Javascript Crypto Library. | 5 | This file is part of Clipperz Community Edition. |
6 | Javascript Crypto Library provides web developers with an extensive | 6 | Clipperz Community Edition is an online password manager. |
7 | and efficient set of cryptographic functions. The library aims to | ||
8 | obtain maximum execution speed while preserving modularity and | ||
9 | reusability. | ||
10 | For further information about its features and functionalities please | 7 | For further information about its features and functionalities please |
11 | refer to http://www.clipperz.com | 8 | refer to http://www.clipperz.com. |
12 | 9 | ||
13 | * Javascript Crypto Library is free software: you can redistribute | 10 | * Clipperz Community Edition is free software: you can redistribute |
14 | it and/or modify it under the terms of the GNU Affero General Public | 11 | it and/or modify it under the terms of the GNU Affero General Public |
15 | License as published by the Free Software Foundation, either version | 12 | License as published by the Free Software Foundation, either version |
16 | 3 of the License, or (at your option) any later version. | 13 | 3 of the License, or (at your option) any later version. |
17 | 14 | ||
18 | * Javascript Crypto Library is distributed in the hope that it will | 15 | * Clipperz Community Edition is distributed in the hope that it will |
19 | be useful, but WITHOUT ANY WARRANTY; without even the implied | 16 | be useful, but WITHOUT ANY WARRANTY; without even the implied |
20 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | 17 | warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
21 | See the GNU Affero General Public License for more details. | 18 | See the GNU Affero General Public License for more details. |
22 | 19 | ||
23 | * You should have received a copy of the GNU Affero General Public | 20 | * You should have received a copy of the GNU Affero General Public |
24 | License along with Javascript Crypto Library. If not, see | 21 | License along with Clipperz Community Edition. If not, see |
25 | <http://www.gnu.org/licenses/>. | 22 | <http://www.gnu.org/licenses/>. |
26 | 23 | ||
27 | */ | 24 | */ |
28 | 25 | ||
29 | addEvent(window, "load", sortables_init); | 26 | addEvent(window, "load", sortables_init); |
30 | 27 | ||
31 | var SORT_COLUMN_INDEX; | 28 | var SORT_COLUMN_INDEX; |
32 | 29 | ||
33 | function sortables_init() { | 30 | function sortables_init() { |
34 | // Find all tables with class sortable and make them sortable | 31 | // Find all tables with class sortable and make them sortable |
35 | if (!document.getElementsByTagName) return; | 32 | if (!document.getElementsByTagName) return; |
36 | tbls = document.getElementsByTagName("table"); | 33 | tbls = document.getElementsByTagName("table"); |
37 | for (ti=0;ti<tbls.length;ti++) { | 34 | for (ti=0;ti<tbls.length;ti++) { |
38 | thisTbl = tbls[ti]; | 35 | thisTbl = tbls[ti]; |
39 | if (((' '+thisTbl.className+' ').indexOf("sortable") != -1) && (thisTbl.id)) { | 36 | if (((' '+thisTbl.className+' ').indexOf("sortable") != -1) && (thisTbl.id)) { |
40 | //initTable(thisTbl.id); | 37 | //initTable(thisTbl.id); |
41 | ts_makeSortable(thisTbl); | 38 | ts_makeSortable(thisTbl); |
42 | } | 39 | } |
43 | } | 40 | } |
44 | } | 41 | } |
45 | 42 | ||
46 | function ts_makeSortable(table) { | 43 | function ts_makeSortable(table) { |
47 | if (table.rows && table.rows.length > 0) { | 44 | if (table.rows && table.rows.length > 0) { |
48 | var firstRow = table.rows[0]; | 45 | var firstRow = table.rows[0]; |
49 | } | 46 | } |
50 | if (!firstRow) return; | 47 | if (!firstRow) return; |
51 | 48 | ||
52 | // We have a first row: assume it's the header, and make its contents clickable links | 49 | // We have a first row: assume it's the header, and make its contents clickable links |
53 | for (var i=0;i<firstRow.cells.length;i++) { | 50 | for (var i=0;i<firstRow.cells.length;i++) { |
54 | var cell = firstRow.cells[i]; | 51 | var cell = firstRow.cells[i]; |
55 | var txt = ts_getInnerText(cell); | 52 | var txt = ts_getInnerText(cell); |
56 | cell.innerHTML = '<a href="#" class="sortheader" '+ | 53 | cell.innerHTML = '<a href="#" class="sortheader" '+ |
57 | 'onclick="ts_resortTable(this, '+i+');return false;">' + | 54 | 'onclick="ts_resortTable(this, '+i+');return false;">' + |
58 | txt+'<span class="sortarrow"> </span></a>'; | 55 | txt+'<span class="sortarrow"> </span></a>'; |
59 | } | 56 | } |
60 | } | 57 | } |
61 | 58 | ||
62 | function ts_getInnerText(el) { | 59 | function ts_getInnerText(el) { |
63 | if (typeof el == "string") return el; | 60 | if (typeof el == "string") return el; |
64 | if (typeof el == "undefined") { return el }; | 61 | if (typeof el == "undefined") { return el }; |
65 | if (el.innerText) return el.innerText;//Not needed but it is faster | 62 | if (el.innerText) return el.innerText;//Not needed but it is faster |
66 | var str = ""; | 63 | var str = ""; |
67 | 64 | ||
68 | var cs = el.childNodes; | 65 | var cs = el.childNodes; |
69 | var l = cs.length; | 66 | var l = cs.length; |
70 | for (var i = 0; i < l; i++) { | 67 | for (var i = 0; i < l; i++) { |
71 | switch (cs[i].nodeType) { | 68 | switch (cs[i].nodeType) { |
72 | case 1: //ELEMENT_NODE | 69 | case 1: //ELEMENT_NODE |
73 | str += ts_getInnerText(cs[i]); | 70 | str += ts_getInnerText(cs[i]); |
74 | break; | 71 | break; |
75 | case 3://TEXT_NODE | 72 | case 3://TEXT_NODE |
76 | str += cs[i].nodeValue; | 73 | str += cs[i].nodeValue; |
77 | break; | 74 | break; |
78 | } | 75 | } |
79 | } | 76 | } |
80 | return str; | 77 | return str; |
81 | } | 78 | } |
82 | 79 | ||
83 | function ts_resortTable(lnk,clid) { | 80 | function ts_resortTable(lnk,clid) { |
84 | // get the span | 81 | // get the span |
85 | var span; | 82 | var span; |
86 | for (var ci=0;ci<lnk.childNodes.length;ci++) { | 83 | for (var ci=0;ci<lnk.childNodes.length;ci++) { |
87 | if (lnk.childNodes[ci].tagName && lnk.childNodes[ci].tagName.toLowerCase() == 'span') span = lnk.childNodes[ci]; | 84 | if (lnk.childNodes[ci].tagName && lnk.childNodes[ci].tagName.toLowerCase() == 'span') span = lnk.childNodes[ci]; |
88 | } | 85 | } |
89 | var spantext = ts_getInnerText(span); | 86 | var spantext = ts_getInnerText(span); |
90 | var td = lnk.parentNode; | 87 | var td = lnk.parentNode; |
91 | var column = clid || td.cellIndex; | 88 | var column = clid || td.cellIndex; |
92 | var table = getParent(td,'TABLE'); | 89 | var table = getParent(td,'TABLE'); |
93 | 90 | ||
94 | // Work out a type for the column | 91 | // Work out a type for the column |
95 | if (table.rows.length <= 1) return; | 92 | if (table.rows.length <= 1) return; |
96 | var itm = ts_getInnerText(table.rows[1].cells[column]); | 93 | var itm = ts_getInnerText(table.rows[1].cells[column]); |
97 | sortfn = ts_sort_caseinsensitive; | 94 | sortfn = ts_sort_caseinsensitive; |
98 | if (itm.match(/^\d\d[\/-]\d\d[\/-]\d\d\d\d$/)) { | 95 | if (itm.match(/^\d\d[\/-]\d\d[\/-]\d\d\d\d$/)) { |
99 | sortfn = ts_sort_date; | 96 | sortfn = ts_sort_date; |
100 | } | 97 | } |
101 | if (itm.match(/^\d\d[\/-]\d\d[\/-]\d\d$/)) { | 98 | if (itm.match(/^\d\d[\/-]\d\d[\/-]\d\d$/)) { |
102 | sortfn = ts_sort_date; | 99 | sortfn = ts_sort_date; |
103 | } | 100 | } |
104 | if (itm.match(/^[£$]/)) { | 101 | if (itm.match(/^[£$]/)) { |
105 | sortfn = ts_sort_currency; | 102 | sortfn = ts_sort_currency; |
106 | } | 103 | } |
107 | if (itm.match(/^[\d\.]+$/)) { | 104 | if (itm.match(/^[\d\.]+$/)) { |
108 | sortfn = ts_sort_numeric; | 105 | sortfn = ts_sort_numeric; |
109 | } | 106 | } |
110 | SORT_COLUMN_INDEX = column; | 107 | SORT_COLUMN_INDEX = column; |
111 | var firstRow = new Array(); | 108 | var firstRow = new Array(); |
112 | var newRows = new Array(); | 109 | var newRows = new Array(); |
113 | for (i=0;i<table.rows[0].length;i++) { | 110 | for (i=0;i<table.rows[0].length;i++) { |
114 | firstRow[i] = table.rows[0][i]; | 111 | firstRow[i] = table.rows[0][i]; |
115 | } | 112 | } |
116 | 113 | ||
117 | for (j=1;j<table.rows.length;j++) { | 114 | for (j=1;j<table.rows.length;j++) { |
118 | newRows[j-1] = table.rows[j]; | 115 | newRows[j-1] = table.rows[j]; |
119 | } | 116 | } |
120 | newRows.sort(sortfn); | 117 | newRows.sort(sortfn); |
121 | 118 | ||
122 | if (span.getAttribute("sortdir") == 'down') { | 119 | if (span.getAttribute("sortdir") == 'down') { |
123 | ARROW = ' ↑'; | 120 | ARROW = ' ↑'; |
124 | newRows.reverse(); | 121 | newRows.reverse(); |
125 | span.setAttribute('sortdir','up'); | 122 | span.setAttribute('sortdir','up'); |
126 | } else { | 123 | } else { |
127 | ARROW = ' ↓'; | 124 | ARROW = ' ↓'; |
128 | span.setAttribute('sortdir','down'); | 125 | span.setAttribute('sortdir','down'); |
129 | } | 126 | } |
130 | 127 | ||
131 | // We appendChild rows that already exist to the tbody, so it moves them rather than creating new ones | 128 | // We appendChild rows that already exist to the tbody, so it moves them rather than creating new ones |
132 | // don't do sortbottom rows | 129 | // don't do sortbottom rows |
133 | for (i=0;i<newRows.length;i++) { | 130 | for (i=0;i<newRows.length;i++) { |
134 | if (!newRows[i].className || (newRows[i].className && (newRows[i].className.indexOf('sortbottom') == -1))) { | 131 | if (!newRows[i].className || (newRows[i].className && (newRows[i].className.indexOf('sortbottom') == -1))) { |
135 | table.tBodies[0].appendChild(newRows[i]); | 132 | table.tBodies[0].appendChild(newRows[i]); |
136 | } | 133 | } |
137 | } | 134 | } |
138 | // do sortbottom rows only | 135 | // do sortbottom rows only |
139 | for (i=0;i<newRows.length;i++) { | 136 | for (i=0;i<newRows.length;i++) { |
140 | if (newRows[i].className && (newRows[i].className.indexOf('sortbottom') != -1)) { | 137 | if (newRows[i].className && (newRows[i].className.indexOf('sortbottom') != -1)) { |
141 | table.tBodies[0].appendChild(newRows[i]); | 138 | table.tBodies[0].appendChild(newRows[i]); |
142 | } | 139 | } |
143 | } | 140 | } |
144 | 141 | ||
145 | // Delete any other arrows there may be showing | 142 | // Delete any other arrows there may be showing |
146 | var allspans = document.getElementsByTagName("span"); | 143 | var allspans = document.getElementsByTagName("span"); |
147 | for (var ci=0;ci<allspans.length;ci++) { | 144 | for (var ci=0;ci<allspans.length;ci++) { |
148 | if (allspans[ci].className == 'sortarrow') { | 145 | if (allspans[ci].className == 'sortarrow') { |
149 | if (getParent(allspans[ci],"table") == getParent(lnk,"table")) { // in the same table as us? | 146 | if (getParent(allspans[ci],"table") == getParent(lnk,"table")) { // in the same table as us? |
150 | allspans[ci].innerHTML = ' '; | 147 | allspans[ci].innerHTML = ' '; |
151 | } | 148 | } |
152 | } | 149 | } |
153 | } | 150 | } |
154 | 151 | ||
155 | span.innerHTML = ARROW; | 152 | span.innerHTML = ARROW; |
156 | } | 153 | } |
157 | 154 | ||
158 | function getParent(el, pTagName) { | 155 | function getParent(el, pTagName) { |
159 | if (el == null) return null; | 156 | if (el == null) return null; |
160 | else if (el.nodeType == 1 && el.tagName.toLowerCase() == pTagName.toLowerCase())// Gecko bug, supposed to be uppercase | 157 | else if (el.nodeType == 1 && el.tagName.toLowerCase() == pTagName.toLowerCase())// Gecko bug, supposed to be uppercase |
161 | return el; | 158 | return el; |
162 | else | 159 | else |
163 | return getParent(el.parentNode, pTagName); | 160 | return getParent(el.parentNode, pTagName); |
164 | } | 161 | } |
165 | function ts_sort_date(a,b) { | 162 | function ts_sort_date(a,b) { |
166 | // y2k notes: two digit years less than 50 are treated as 20XX, greater than 50 are treated as 19XX | 163 | // y2k notes: two digit years less than 50 are treated as 20XX, greater than 50 are treated as 19XX |
167 | aa = ts_getInnerText(a.cells[SORT_COLUMN_INDEX]); | 164 | aa = ts_getInnerText(a.cells[SORT_COLUMN_INDEX]); |
168 | bb = ts_getInnerText(b.cells[SORT_COLUMN_INDEX]); | 165 | bb = ts_getInnerText(b.cells[SORT_COLUMN_INDEX]); |
169 | if (aa.length == 10) { | 166 | if (aa.length == 10) { |
170 | dt1 = aa.substr(6,4)+aa.substr(3,2)+aa.substr(0,2); | 167 | dt1 = aa.substr(6,4)+aa.substr(3,2)+aa.substr(0,2); |
171 | } else { | 168 | } else { |
172 | yr = aa.substr(6,2); | 169 | yr = aa.substr(6,2); |
173 | if (parseInt(yr) < 50) { yr = '20'+yr; } else { yr = '19'+yr; } | 170 | if (parseInt(yr) < 50) { yr = '20'+yr; } else { yr = '19'+yr; } |
174 | dt1 = yr+aa.substr(3,2)+aa.substr(0,2); | 171 | dt1 = yr+aa.substr(3,2)+aa.substr(0,2); |
175 | } | 172 | } |
176 | if (bb.length == 10) { | 173 | if (bb.length == 10) { |
177 | dt2 = bb.substr(6,4)+bb.substr(3,2)+bb.substr(0,2); | 174 | dt2 = bb.substr(6,4)+bb.substr(3,2)+bb.substr(0,2); |
178 | } else { | 175 | } else { |
179 | yr = bb.substr(6,2); | 176 | yr = bb.substr(6,2); |
180 | if (parseInt(yr) < 50) { yr = '20'+yr; } else { yr = '19'+yr; } | 177 | if (parseInt(yr) < 50) { yr = '20'+yr; } else { yr = '19'+yr; } |
181 | dt2 = yr+bb.substr(3,2)+bb.substr(0,2); | 178 | dt2 = yr+bb.substr(3,2)+bb.substr(0,2); |
182 | } | 179 | } |
183 | if (dt1==dt2) return 0; | 180 | if (dt1==dt2) return 0; |
184 | if (dt1<dt2) return -1; | 181 | if (dt1<dt2) return -1; |
185 | return 1; | 182 | return 1; |
186 | } | 183 | } |
187 | 184 | ||
188 | function ts_sort_currency(a,b) { | 185 | function ts_sort_currency(a,b) { |
189 | aa = ts_getInnerText(a.cells[SORT_COLUMN_INDEX]).replace(/[^0-9.]/g,''); | 186 | aa = ts_getInnerText(a.cells[SORT_COLUMN_INDEX]).replace(/[^0-9.]/g,''); |
190 | bb = ts_getInnerText(b.cells[SORT_COLUMN_INDEX]).replace(/[^0-9.]/g,''); | 187 | bb = ts_getInnerText(b.cells[SORT_COLUMN_INDEX]).replace(/[^0-9.]/g,''); |
191 | return parseFloat(aa) - parseFloat(bb); | 188 | return parseFloat(aa) - parseFloat(bb); |
192 | } | 189 | } |
193 | 190 | ||
194 | function ts_sort_numeric(a,b) { | 191 | function ts_sort_numeric(a,b) { |
195 | aa = parseFloat(ts_getInnerText(a.cells[SORT_COLUMN_INDEX])); | 192 | aa = parseFloat(ts_getInnerText(a.cells[SORT_COLUMN_INDEX])); |
196 | if (isNaN(aa)) aa = 0; | 193 | if (isNaN(aa)) aa = 0; |
197 | bb = parseFloat(ts_getInnerText(b.cells[SORT_COLUMN_INDEX])); | 194 | bb = parseFloat(ts_getInnerText(b.cells[SORT_COLUMN_INDEX])); |
198 | if (isNaN(bb)) bb = 0; | 195 | if (isNaN(bb)) bb = 0; |
199 | return aa-bb; | 196 | return aa-bb; |
200 | } | 197 | } |
201 | 198 | ||
202 | function ts_sort_caseinsensitive(a,b) { | 199 | function ts_sort_caseinsensitive(a,b) { |
203 | aa = ts_getInnerText(a.cells[SORT_COLUMN_INDEX]).toLowerCase(); | 200 | aa = ts_getInnerText(a.cells[SORT_COLUMN_INDEX]).toLowerCase(); |
204 | bb = ts_getInnerText(b.cells[SORT_COLUMN_INDEX]).toLowerCase(); | 201 | bb = ts_getInnerText(b.cells[SORT_COLUMN_INDEX]).toLowerCase(); |
205 | if (aa==bb) return 0; | 202 | if (aa==bb) return 0; |
206 | if (aa<bb) return -1; | 203 | if (aa<bb) return -1; |
207 | return 1; | 204 | return 1; |
208 | } | 205 | } |
209 | 206 | ||
210 | function ts_sort_default(a,b) { | 207 | function ts_sort_default(a,b) { |
211 | aa = ts_getInnerText(a.cells[SORT_COLUMN_INDEX]); | 208 | aa = ts_getInnerText(a.cells[SORT_COLUMN_INDEX]); |
212 | bb = ts_getInnerText(b.cells[SORT_COLUMN_INDEX]); | 209 | bb = ts_getInnerText(b.cells[SORT_COLUMN_INDEX]); |
213 | if (aa==bb) return 0; | 210 | if (aa==bb) return 0; |
214 | if (aa<bb) return -1; | 211 | if (aa<bb) return -1; |
215 | return 1; | 212 | return 1; |
216 | } | 213 | } |