summaryrefslogtreecommitdiffstats
path: root/extensions/BMO/web/js/sorttable.js
diff options
context:
space:
mode:
Diffstat (limited to 'extensions/BMO/web/js/sorttable.js')
-rw-r--r--extensions/BMO/web/js/sorttable.js52
1 files changed, 26 insertions, 26 deletions
diff --git a/extensions/BMO/web/js/sorttable.js b/extensions/BMO/web/js/sorttable.js
index 0873dc20a..c20f02647 100644
--- a/extensions/BMO/web/js/sorttable.js
+++ b/extensions/BMO/web/js/sorttable.js
@@ -3,13 +3,13 @@
version 2
7th April 2007
Stuart Langridge, http://www.kryogenix.org/code/browser/sorttable/
-
+
Instructions:
Download this file
Add <script src="sorttable.js"></script> to your HTML
Add class="sortable" to any table you'd like to make sortable
Click on the headers to sort
-
+
Thanks to many, many people for contributions and suggestions.
Licenced as X11: http://www.kryogenix.org/code/browser/licence.html
This basically means: do what you want with it.
@@ -25,20 +25,20 @@ sorttable = {
arguments.callee.done = true;
// kill the timer
if (_timer) clearInterval(_timer);
-
+
if (!document.createElement || !document.getElementsByTagName) return;
-
+
sorttable.DATE_RE = /^(\d\d?)[\/\.-](\d\d?)[\/\.-]((\d\d)?\d\d)$/;
-
+
forEach(document.getElementsByTagName('table'), function(table) {
if (table.className.search(/\bsortable\b/) != -1) {
sorttable.makeSortable(table);
}
});
-
+
},
- /*
+ /*
* Prepares the table so that it can be sorted
*
*/
@@ -53,9 +53,9 @@ sorttable = {
}
// Safari doesn't support table.tHead, sigh
if (table.tHead == null) table.tHead = table.getElementsByTagName('thead')[0];
-
+
//if (table.tHead.rows.length != 1) return; // can't cope with two header rows
-
+
// Sorttable v1 put rows with a class of "sortbottom" at the bottom (as
// "total" rows, for example). This is B&R, since what you're supposed
// to do is put them in a tfoot. So, if there are sortbottom rows,
@@ -106,7 +106,7 @@ sorttable = {
table.sorttable_rows = table_rows;
table.sorttable_body_size = body_size;
table.sorttable_bodies = bodies;
-
+
// work through each column and calculate its type
@@ -185,7 +185,7 @@ sorttable = {
_check_already_sorted: function(cell) {
if (cell.className.search(/\bsorttable_sorted\b/) != -1) {
- // if we're already sorted by this column, just
+ // if we're already sorted by this column, just
// reverse the table, which is quicker
sorttable.reverse_table(cell);
@@ -194,7 +194,7 @@ sorttable = {
}
if (cell.className.search(/\bsorttable_sorted_reverse\b/) != -1) {
- // if we're already sorted by this column in reverse, just
+ // if we're already sorted by this column in reverse, just
// re-reverse the table, which is quicker
sorttable.reverse_table(cell);
@@ -271,7 +271,7 @@ sorttable = {
return;
- // First, remove sorttable_sorted classes from the other header
+ // First, remove sorttable_sorted classes from the other header
// that is currently sorted and its marker (the simbol indicating
// that its sorted.
sorttable._remove_sorted_classes(this.table.tHead);
@@ -285,7 +285,7 @@ sorttable = {
sorttable._mark_column_as_sorted(this, '&#x25BC;', 0);
sorttable.sort_table(this);
-
+
},
sort_table: function(cell) {
@@ -312,7 +312,7 @@ sorttable = {
body_size = cell.table.sorttable_body_size;
body_index = 0;
- for (var j=0; j<rows.length; j++) {
+ for (var j=0; j<rows.length; j++) {
if (j % 2)
rows[j].className = rows[j].className.replace('bz_row_even',
'bz_row_odd');
@@ -336,7 +336,7 @@ sorttable = {
cell.table.sorttable_rows = rows;
},
-
+
reverse_table: function(cell) {
oldrows = cell.table.sorttable_rows;
newrows = [];
@@ -348,7 +348,7 @@ sorttable = {
tb = cell.table.sorttable_bodies[0];
body_size = cell.table.sorttable_body_size;
body_index = 0;
-
+
var BUGLIST = '';
cell.table.sorttable_rows = [];
@@ -379,17 +379,17 @@ sorttable = {
delete newrows;
},
-
+
guessType: function(table, column) {
// guess the type of a column based on its first non-blank row
sortfn = sorttable.sort_alpha;
for (var i=0; i<table.sorttable_bodies[0].rows.length; i++) {
text = sorttable.getInnerText(table.sorttable_bodies[0].rows[i].cells[column]);
if (text != '') {
- if (text.match(/^-?[£$¤]?[\d,.]+%?$/)) {
+ if (text.match(/^-?[£$¤]?[\d,.]+%?$/)) {
return sorttable.sort_numeric;
}
- // check for a date: dd/mm/yyyy or dd/mm/yy
+ // check for a date: dd/mm/yyyy or dd/mm/yy
// can have / or . or - as separator
// can be mm/dd as well
possdate = text.match(sorttable.DATE_RE)
@@ -412,7 +412,7 @@ sorttable = {
}
return sortfn;
},
-
+
getInnerText: function(node) {
// gets the text we want to use for sorting for a cell.
// strips leading and trailing whitespace.
@@ -422,7 +422,7 @@ sorttable = {
hasInputs = (typeof node.getElementsByTagName == 'function') &&
node.getElementsByTagName('input').length;
-
+
if (typeof node.getAttribute != 'undefined' && node.getAttribute("sorttable_customkey") != null) {
return node.getAttribute("sorttable_customkey");
}
@@ -457,14 +457,14 @@ sorttable = {
}
}
},
-
+
/* sort functions
each sort function takes two parameters, a and b
you are comparing a.sort_data and b.sort_data */
sort_numeric: function(a,b) {
aa = parseFloat(a.sort_data.replace(/[^0-9.-]/g,''));
if (isNaN(aa)) aa = 0;
- bb = parseFloat(b.sort_data.replace(/[^0-9.-]/g,''));
+ bb = parseFloat(b.sort_data.replace(/[^0-9.-]/g,''));
if (isNaN(bb)) bb = 0;
return aa-bb;
},
@@ -506,7 +506,7 @@ sorttable = {
if (dt1<dt2) return -1;
return 1;
},
-
+
shaker_sort: function(list, comp_func) {
// A stable sort function to allow multi-level sorting of data
// see: http://en.wikipedia.org/wiki/Cocktail_sort
@@ -536,7 +536,7 @@ sorttable = {
b++;
} // while(swap)
- }
+ }
}
/* ******************************************************************