summaryrefslogtreecommitdiff
path: root/frontend/beta/js/Clipperz/Profile.js
Unidiff
Diffstat (limited to 'frontend/beta/js/Clipperz/Profile.js') (more/less context) (ignore whitespace changes)
-rw-r--r--frontend/beta/js/Clipperz/Profile.js15
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,120 +1,117 @@
1/* 1/*
2 2
3Copyright 2008-2011 Clipperz Srl 3Copyright 2008-2011 Clipperz Srl
4 4
5This file is part of Clipperz's Javascript Crypto Library. 5This file is part of Clipperz Community Edition.
6Javascript Crypto Library provides web developers with an extensive 6Clipperz Community Edition is an online password manager.
7and efficient set of cryptographic functions. The library aims to
8obtain maximum execution speed while preserving modularity and
9reusability.
10For further information about its features and functionalities please 7For further information about its features and functionalities please
11refer to http://www.clipperz.com 8refer 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
29addEvent(window, "load", sortables_init); 26addEvent(window, "load", sortables_init);
30 27
31var SORT_COLUMN_INDEX; 28var SORT_COLUMN_INDEX;
32 29
33function sortables_init() { 30function 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
46function ts_makeSortable(table) { 43function 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">&nbsp;&nbsp;&nbsp;</span></a>'; 55 txt+'<span class="sortarrow">&nbsp;&nbsp;&nbsp;</span></a>';
59 } 56 }
60} 57}
61 58
62function ts_getInnerText(el) { 59function 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
83function ts_resortTable(lnk,clid) { 80function 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);