ositah 25.6.dev1__py3-none-any.whl → 25.9.dev2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of ositah might be problematic. Click here for more details.

Files changed (42) hide show
  1. ositah/app.py +17 -17
  2. ositah/apps/analysis.py +785 -785
  3. ositah/apps/configuration/callbacks.py +916 -916
  4. ositah/apps/configuration/main.py +546 -546
  5. ositah/apps/configuration/parameters.py +74 -74
  6. ositah/apps/configuration/tools.py +112 -112
  7. ositah/apps/export.py +1209 -1191
  8. ositah/apps/validation/callbacks.py +240 -240
  9. ositah/apps/validation/main.py +89 -89
  10. ositah/apps/validation/parameters.py +25 -25
  11. ositah/apps/validation/tables.py +646 -646
  12. ositah/apps/validation/tools.py +552 -552
  13. ositah/assets/arrow_down_up.svg +3 -3
  14. ositah/assets/ositah.css +53 -53
  15. ositah/assets/sort_ascending.svg +4 -4
  16. ositah/assets/sort_descending.svg +5 -5
  17. ositah/assets/sorttable.js +499 -499
  18. ositah/main.py +449 -449
  19. ositah/ositah.example.cfg +229 -229
  20. ositah/static/style.css +53 -53
  21. ositah/templates/base.html +22 -22
  22. ositah/templates/bootstrap_login.html +38 -38
  23. ositah/templates/login_form.html +26 -26
  24. ositah/utils/agents.py +124 -124
  25. ositah/utils/authentication.py +287 -287
  26. ositah/utils/cache.py +19 -19
  27. ositah/utils/core.py +13 -13
  28. ositah/utils/exceptions.py +64 -64
  29. ositah/utils/hito_db.py +51 -51
  30. ositah/utils/hito_db_model.py +253 -253
  31. ositah/utils/menus.py +339 -339
  32. ositah/utils/period.py +139 -139
  33. ositah/utils/projects.py +1179 -1178
  34. ositah/utils/teams.py +42 -42
  35. ositah/utils/utils.py +474 -474
  36. {ositah-25.6.dev1.dist-info → ositah-25.9.dev2.dist-info}/METADATA +149 -150
  37. ositah-25.9.dev2.dist-info/RECORD +46 -0
  38. {ositah-25.6.dev1.dist-info → ositah-25.9.dev2.dist-info}/licenses/LICENSE +29 -29
  39. ositah-25.6.dev1.dist-info/RECORD +0 -46
  40. {ositah-25.6.dev1.dist-info → ositah-25.9.dev2.dist-info}/WHEEL +0 -0
  41. {ositah-25.6.dev1.dist-info → ositah-25.9.dev2.dist-info}/entry_points.txt +0 -0
  42. {ositah-25.6.dev1.dist-info → ositah-25.9.dev2.dist-info}/top_level.txt +0 -0
@@ -1,499 +1,499 @@
1
- /*
2
- SortTable
3
- version 2
4
- 7th April 2007
5
- Stuart Langridge, http://www.kryogenix.org/code/browser/sorttable/
6
-
7
- Instructions:
8
- Download this file
9
- Add <script src="sorttable.js"></script> to your HTML
10
- Add class="sortable" to any table you'd like to make sortable
11
- Click on the headers to sort
12
-
13
- Thanks to many, many people for contributions and suggestions.
14
- Licenced as X11: http://www.kryogenix.org/code/browser/licence.html
15
- This basically means: do what you want with it.
16
- */
17
-
18
-
19
- /* alert('DEBUG: sorttable.js run') */
20
-
21
- var stIsIE = /*@cc_on!@*/false;
22
-
23
- sorttable = {
24
- init: function() {
25
- // quit if this function has already been called
26
- if (arguments.callee.done) return;
27
- // flag this function so we don't do the same thing twice
28
- arguments.callee.done = true;
29
- // kill the timer
30
- if (_timer) clearInterval(_timer);
31
-
32
- if (!document.createElement || !document.getElementsByTagName) return;
33
-
34
- sorttable.DATE_RE = /^(\d\d?)[\/\.-](\d\d?)[\/\.-]((\d\d)?\d\d)$/;
35
-
36
- forEach(document.getElementsByTagName('table'), function(table) {
37
- if (table.className.search(/\bsortable\b/) != -1) {
38
- sorttable.makeSortable(table);
39
- }
40
- });
41
-
42
- },
43
-
44
- makeSortable: function(table) {
45
- if (table.getElementsByTagName('thead').length == 0) {
46
- // table doesn't have a tHead. Since it should have, create one and
47
- // put the first table row in it.
48
- the = document.createElement('thead');
49
- the.appendChild(table.rows[0]);
50
- table.insertBefore(the,table.firstChild);
51
- }
52
- // Safari doesn't support table.tHead, sigh
53
- if (table.tHead == null) table.tHead = table.getElementsByTagName('thead')[0];
54
-
55
- if (table.tHead.rows.length != 1) return; // can't cope with two header rows
56
-
57
- // Sorttable v1 put rows with a class of "sortbottom" at the bottom (as
58
- // "total" rows, for example). This is B&R, since what you're supposed
59
- // to do is put them in a tfoot. So, if there are sortbottom rows,
60
- // for backwards compatibility, move them to tfoot (creating it if needed).
61
- sortbottomrows = [];
62
- for (var i=0; i<table.rows.length; i++) {
63
- if (table.rows[i].className.search(/\bsortbottom\b/) != -1) {
64
- sortbottomrows[sortbottomrows.length] = table.rows[i];
65
- }
66
- }
67
- if (sortbottomrows) {
68
- if (table.tFoot == null) {
69
- // table doesn't have a tfoot. Create one.
70
- tfo = document.createElement('tfoot');
71
- table.appendChild(tfo);
72
- }
73
- for (var i=0; i<sortbottomrows.length; i++) {
74
- tfo.appendChild(sortbottomrows[i]);
75
- }
76
- delete sortbottomrows;
77
- }
78
-
79
- // work through each column and calculate its type
80
- headrow = table.tHead.rows[0].cells;
81
- for (var i=0; i<headrow.length; i++) {
82
- // manually override the type with a sorttable_type attribute
83
- if (!headrow[i].className.match(/\bsorttable_nosort\b/)) { // skip this col
84
- mtch = headrow[i].className.match(/\bsorttable_([a-z0-9]+)\b/);
85
- if (mtch) { override = mtch[1]; }
86
- if (mtch && typeof sorttable["sort_"+override] == 'function') {
87
- headrow[i].sorttable_sortfunction = sorttable["sort_"+override];
88
- } else {
89
- headrow[i].sorttable_sortfunction = sorttable.guessType(table,i);
90
- }
91
- // make it clickable to sort
92
- headrow[i].sorttable_columnindex = i;
93
- headrow[i].sorttable_tbody = table.tBodies[0];
94
- dean_addEvent(headrow[i],"click", sorttable.innerSortFunction = function(e) {
95
-
96
- if (this.className.search(/\bsorttable_sorted\b/) != -1) {
97
- // if we're already sorted by this column, just
98
- // reverse the table, which is quicker
99
- sorttable.reverse(this.sorttable_tbody);
100
- this.className = this.className.replace('sorttable_sorted',
101
- 'sorttable_sorted_reverse');
102
- this.removeChild(document.getElementById('sorttable_sortfwdind'));
103
- sortrevind = document.createElement('span');
104
- sortrevind.id = "sorttable_sortrevind";
105
- sortrevind.innerHTML = stIsIE ? '&nbsp<font face="webdings">5</font>' : '&nbsp;&#x25B4;';
106
- this.appendChild(sortrevind);
107
- return;
108
- }
109
- if (this.className.search(/\bsorttable_sorted_reverse\b/) != -1) {
110
- // if we're already sorted by this column in reverse, just
111
- // re-reverse the table, which is quicker
112
- sorttable.reverse(this.sorttable_tbody);
113
- this.className = this.className.replace('sorttable_sorted_reverse',
114
- 'sorttable_sorted');
115
- this.removeChild(document.getElementById('sorttable_sortrevind'));
116
- sortfwdind = document.createElement('span');
117
- sortfwdind.id = "sorttable_sortfwdind";
118
- sortfwdind.innerHTML = stIsIE ? '&nbsp<font face="webdings">6</font>' : '&nbsp;&#x25BE;';
119
- this.appendChild(sortfwdind);
120
- return;
121
- }
122
-
123
- // remove sorttable_sorted classes
124
- theadrow = this.parentNode;
125
- forEach(theadrow.childNodes, function(cell) {
126
- if (cell.nodeType == 1) { // an element
127
- cell.className = cell.className.replace('sorttable_sorted_reverse','');
128
- cell.className = cell.className.replace('sorttable_sorted','');
129
- }
130
- });
131
- sortfwdind = document.getElementById('sorttable_sortfwdind');
132
- if (sortfwdind) { sortfwdind.parentNode.removeChild(sortfwdind); }
133
- sortrevind = document.getElementById('sorttable_sortrevind');
134
- if (sortrevind) { sortrevind.parentNode.removeChild(sortrevind); }
135
-
136
- this.className += ' sorttable_sorted';
137
- sortfwdind = document.createElement('span');
138
- sortfwdind.id = "sorttable_sortfwdind";
139
- sortfwdind.innerHTML = stIsIE ? '&nbsp<font face="webdings">6</font>' : '&nbsp;&#x25BE;';
140
- this.appendChild(sortfwdind);
141
-
142
- // build an array to sort. This is a Schwartzian transform thing,
143
- // i.e., we "decorate" each row with the actual sort key,
144
- // sort based on the sort keys, and then put the rows back in order
145
- // which is a lot faster because you only do getInnerText once per row
146
- row_array = [];
147
- col = this.sorttable_columnindex;
148
- rows = this.sorttable_tbody.rows;
149
- for (var j=0; j<rows.length; j++) {
150
- row_array[row_array.length] = [sorttable.getInnerText(rows[j].cells[col]), rows[j]];
151
- }
152
- /* If you want a stable sort, uncomment the following line */
153
- //sorttable.shaker_sort(row_array, this.sorttable_sortfunction);
154
- /* and comment out this one */
155
- row_array.sort(this.sorttable_sortfunction);
156
-
157
- tb = this.sorttable_tbody;
158
- for (var j=0; j<row_array.length; j++) {
159
- tb.appendChild(row_array[j][1]);
160
- }
161
-
162
- delete row_array;
163
- });
164
- }
165
- }
166
- },
167
-
168
- guessType: function(table, column) {
169
- // guess the type of a column based on its first non-blank row
170
- sortfn = sorttable.sort_alpha;
171
- for (var i=0; i<table.tBodies[0].rows.length; i++) {
172
- text = sorttable.getInnerText(table.tBodies[0].rows[i].cells[column]);
173
- if (text != '') {
174
- if (text.match(/^-?[£$¤]?[\d,.]+%?$/)) {
175
- return sorttable.sort_numeric;
176
- }
177
- // check for a date: dd/mm/yyyy or dd/mm/yy
178
- // can have / or . or - as separator
179
- // can be mm/dd as well
180
- possdate = text.match(sorttable.DATE_RE)
181
- if (possdate) {
182
- // looks like a date
183
- first = parseInt(possdate[1]);
184
- second = parseInt(possdate[2]);
185
- if (first > 12) {
186
- // definitely dd/mm
187
- return sorttable.sort_ddmm;
188
- } else if (second > 12) {
189
- return sorttable.sort_mmdd;
190
- } else {
191
- // looks like a date, but we can't tell which, so assume
192
- // that it's dd/mm (English imperialism!) and keep looking
193
- sortfn = sorttable.sort_ddmm;
194
- }
195
- }
196
- }
197
- }
198
- return sortfn;
199
- },
200
-
201
- getInnerText: function(node) {
202
- // gets the text we want to use for sorting for a cell.
203
- // strips leading and trailing whitespace.
204
- // this is *not* a generic getInnerText function; it's special to sorttable.
205
- // for example, you can override the cell text with a customkey attribute.
206
- // it also gets .value for <input> fields.
207
-
208
- if (!node) return "";
209
-
210
- hasInputs = (typeof node.getElementsByTagName == 'function') &&
211
- node.getElementsByTagName('input').length;
212
-
213
- if (node.getAttribute("sorttable_customkey") != null) {
214
- return node.getAttribute("sorttable_customkey");
215
- }
216
- else if (typeof node.textContent != 'undefined' && !hasInputs) {
217
- return node.textContent.replace(/^\s+|\s+$/g, '');
218
- }
219
- else if (typeof node.innerText != 'undefined' && !hasInputs) {
220
- return node.innerText.replace(/^\s+|\s+$/g, '');
221
- }
222
- else if (typeof node.text != 'undefined' && !hasInputs) {
223
- return node.text.replace(/^\s+|\s+$/g, '');
224
- }
225
- else {
226
- switch (node.nodeType) {
227
- case 3:
228
- if (node.nodeName.toLowerCase() == 'input') {
229
- return node.value.replace(/^\s+|\s+$/g, '');
230
- }
231
- case 4:
232
- return node.nodeValue.replace(/^\s+|\s+$/g, '');
233
- break;
234
- case 1:
235
- case 11:
236
- var innerText = '';
237
- for (var i = 0; i < node.childNodes.length; i++) {
238
- innerText += sorttable.getInnerText(node.childNodes[i]);
239
- }
240
- return innerText.replace(/^\s+|\s+$/g, '');
241
- break;
242
- default:
243
- return '';
244
- }
245
- }
246
- },
247
-
248
- reverse: function(tbody) {
249
- // reverse the rows in a tbody
250
- newrows = [];
251
- for (var i=0; i<tbody.rows.length; i++) {
252
- newrows[newrows.length] = tbody.rows[i];
253
- }
254
- for (var i=newrows.length-1; i>=0; i--) {
255
- tbody.appendChild(newrows[i]);
256
- }
257
- delete newrows;
258
- },
259
-
260
- /* sort functions
261
- each sort function takes two parameters, a and b
262
- you are comparing a[0] and b[0] */
263
- sort_numeric: function(a,b) {
264
- aa = parseFloat(a[0].replace(/[^0-9.-]/g,''));
265
- if (isNaN(aa)) aa = 0;
266
- bb = parseFloat(b[0].replace(/[^0-9.-]/g,''));
267
- if (isNaN(bb)) bb = 0;
268
- return aa-bb;
269
- },
270
- sort_alpha: function(a,b) {
271
- a_lc = a[0].toLowerCase()
272
- b_lc = b[0].toLowerCase()
273
- if (a_lc==b_lc) return 0;
274
- if (a_lc<b_lc) return -1;
275
- return 1;
276
- },
277
- sort_ddmm: function(a,b) {
278
- mtch = a[0].match(sorttable.DATE_RE);
279
- y = mtch[3]; m = mtch[2]; d = mtch[1];
280
- if (m.length == 1) m = '0'+m;
281
- if (d.length == 1) d = '0'+d;
282
- dt1 = y+m+d;
283
- mtch = b[0].match(sorttable.DATE_RE);
284
- y = mtch[3]; m = mtch[2]; d = mtch[1];
285
- if (m.length == 1) m = '0'+m;
286
- if (d.length == 1) d = '0'+d;
287
- dt2 = y+m+d;
288
- if (dt1==dt2) return 0;
289
- if (dt1<dt2) return -1;
290
- return 1;
291
- },
292
- sort_mmdd: function(a,b) {
293
- mtch = a[0].match(sorttable.DATE_RE);
294
- y = mtch[3]; d = mtch[2]; m = mtch[1];
295
- if (m.length == 1) m = '0'+m;
296
- if (d.length == 1) d = '0'+d;
297
- dt1 = y+m+d;
298
- mtch = b[0].match(sorttable.DATE_RE);
299
- y = mtch[3]; d = mtch[2]; m = mtch[1];
300
- if (m.length == 1) m = '0'+m;
301
- if (d.length == 1) d = '0'+d;
302
- dt2 = y+m+d;
303
- if (dt1==dt2) return 0;
304
- if (dt1<dt2) return -1;
305
- return 1;
306
- },
307
-
308
- shaker_sort: function(list, comp_func) {
309
- // A stable sort function to allow multi-level sorting of data
310
- // see: http://en.wikipedia.org/wiki/Cocktail_sort
311
- // thanks to Joseph Nahmias
312
- var b = 0;
313
- var t = list.length - 1;
314
- var swap = true;
315
-
316
- while(swap) {
317
- swap = false;
318
- for(var i = b; i < t; ++i) {
319
- if ( comp_func(list[i], list[i+1]) > 0 ) {
320
- var q = list[i]; list[i] = list[i+1]; list[i+1] = q;
321
- swap = true;
322
- }
323
- } // for
324
- t--;
325
-
326
- if (!swap) break;
327
-
328
- for(var i = t; i > b; --i) {
329
- if ( comp_func(list[i], list[i-1]) < 0 ) {
330
- var q = list[i]; list[i] = list[i-1]; list[i-1] = q;
331
- swap = true;
332
- }
333
- } // for
334
- b++;
335
-
336
- } // while(swap)
337
- }
338
- }
339
-
340
- /* ******************************************************************
341
- Supporting functions: bundled here to avoid depending on a library
342
- ****************************************************************** */
343
-
344
- // Dean Edwards/Matthias Miller/John Resig
345
-
346
- /* for Mozilla/Opera9 */
347
- if (document.addEventListener) {
348
- document.addEventListener("DOMContentLoaded", sorttable.init, false);
349
- }
350
-
351
- /* for Internet Explorer */
352
- /*@cc_on @*/
353
- /*@if (@_win32)
354
- document.write("<script id=__ie_onload defer src=javascript:void(0)><\/script>");
355
- var script = document.getElementById("__ie_onload");
356
- script.onreadystatechange = function() {
357
- if (this.readyState == "complete") {
358
- sorttable.init(); // call the onload handler
359
- }
360
- };
361
- /*@end @*/
362
-
363
- /* for Safari */
364
- if (/WebKit/i.test(navigator.userAgent)) { // sniff
365
- var _timer = setInterval(function() {
366
- if (/loaded|complete/.test(document.readyState)) {
367
- sorttable.init(); // call the onload handler
368
- }
369
- }, 10);
370
- }
371
-
372
- /* for other browsers */
373
- window.onload = sorttable.init;
374
-
375
- // written by Dean Edwards, 2005
376
- // with input from Tino Zijdel, Matthias Miller, Diego Perini
377
-
378
- // http://dean.edwards.name/weblog/2005/10/add-event/
379
-
380
- function dean_addEvent(element, type, handler) {
381
- if (element.addEventListener) {
382
- element.addEventListener(type, handler, false);
383
- } else {
384
- // assign each event handler a unique ID
385
- if (!handler.$$guid) handler.$$guid = dean_addEvent.guid++;
386
- // create a hash table of event types for the element
387
- if (!element.events) element.events = {};
388
- // create a hash table of event handlers for each element/event pair
389
- var handlers = element.events[type];
390
- if (!handlers) {
391
- handlers = element.events[type] = {};
392
- // store the existing event handler (if there is one)
393
- if (element["on" + type]) {
394
- handlers[0] = element["on" + type];
395
- }
396
- }
397
- // store the event handler in the hash table
398
- handlers[handler.$$guid] = handler;
399
- // assign a global event handler to do all the work
400
- element["on" + type] = handleEvent;
401
- }
402
- };
403
- // a counter used to create unique IDs
404
- dean_addEvent.guid = 1;
405
-
406
- function removeEvent(element, type, handler) {
407
- if (element.removeEventListener) {
408
- element.removeEventListener(type, handler, false);
409
- } else {
410
- // delete the event handler from the hash table
411
- if (element.events && element.events[type]) {
412
- delete element.events[type][handler.$$guid];
413
- }
414
- }
415
- };
416
-
417
- function handleEvent(event) {
418
- var returnValue = true;
419
- // grab the event object (IE uses a global event object)
420
- event = event || fixEvent(((this.ownerDocument || this.document || this).parentWindow || window).event);
421
- // get a reference to the hash table of event handlers
422
- var handlers = this.events[event.type];
423
- // execute each event handler
424
- for (var i in handlers) {
425
- this.$$handleEvent = handlers[i];
426
- if (this.$$handleEvent(event) === false) {
427
- returnValue = false;
428
- }
429
- }
430
- return returnValue;
431
- };
432
-
433
- function fixEvent(event) {
434
- // add W3C standard event methods
435
- event.preventDefault = fixEvent.preventDefault;
436
- event.stopPropagation = fixEvent.stopPropagation;
437
- return event;
438
- };
439
- fixEvent.preventDefault = function() {
440
- this.returnValue = false;
441
- };
442
- fixEvent.stopPropagation = function() {
443
- this.cancelBubble = true;
444
- }
445
-
446
- // Dean's forEach: http://dean.edwards.name/base/forEach.js
447
- /*
448
- forEach, version 1.0
449
- Copyright 2006, Dean Edwards
450
- License: http://www.opensource.org/licenses/mit-license.php
451
- */
452
-
453
- // array-like enumeration
454
- if (!Array.forEach) { // mozilla already supports this
455
- Array.forEach = function(array, block, context) {
456
- for (var i = 0; i < array.length; i++) {
457
- block.call(context, array[i], i, array);
458
- }
459
- };
460
- }
461
-
462
- // generic enumeration
463
- Function.prototype.forEach = function(object, block, context) {
464
- for (var key in object) {
465
- if (typeof this.prototype[key] == "undefined") {
466
- block.call(context, object[key], key, object);
467
- }
468
- }
469
- };
470
-
471
- // character enumeration
472
- String.forEach = function(string, block, context) {
473
- Array.forEach(string.split(""), function(chr, index) {
474
- block.call(context, chr, index, string);
475
- });
476
- };
477
-
478
- // globally resolve forEach enumeration
479
- var forEach = function(object, block, context) {
480
- if (object) {
481
- var resolve = Object; // default
482
- if (object instanceof Function) {
483
- // functions have a "length" property
484
- resolve = Function;
485
- } else if (object.forEach instanceof Function) {
486
- // the object implements a custom forEach method so use that
487
- object.forEach(block, context);
488
- return;
489
- } else if (typeof object == "string") {
490
- // the object is a string
491
- resolve = String;
492
- } else if (typeof object.length == "number") {
493
- // the object is array-like
494
- resolve = Array;
495
- }
496
- resolve.forEach(object, block, context);
497
- }
498
- };
499
-
1
+ /*
2
+ SortTable
3
+ version 2
4
+ 7th April 2007
5
+ Stuart Langridge, http://www.kryogenix.org/code/browser/sorttable/
6
+
7
+ Instructions:
8
+ Download this file
9
+ Add <script src="sorttable.js"></script> to your HTML
10
+ Add class="sortable" to any table you'd like to make sortable
11
+ Click on the headers to sort
12
+
13
+ Thanks to many, many people for contributions and suggestions.
14
+ Licenced as X11: http://www.kryogenix.org/code/browser/licence.html
15
+ This basically means: do what you want with it.
16
+ */
17
+
18
+
19
+ /* alert('DEBUG: sorttable.js run') */
20
+
21
+ var stIsIE = /*@cc_on!@*/false;
22
+
23
+ sorttable = {
24
+ init: function() {
25
+ // quit if this function has already been called
26
+ if (arguments.callee.done) return;
27
+ // flag this function so we don't do the same thing twice
28
+ arguments.callee.done = true;
29
+ // kill the timer
30
+ if (_timer) clearInterval(_timer);
31
+
32
+ if (!document.createElement || !document.getElementsByTagName) return;
33
+
34
+ sorttable.DATE_RE = /^(\d\d?)[\/\.-](\d\d?)[\/\.-]((\d\d)?\d\d)$/;
35
+
36
+ forEach(document.getElementsByTagName('table'), function(table) {
37
+ if (table.className.search(/\bsortable\b/) != -1) {
38
+ sorttable.makeSortable(table);
39
+ }
40
+ });
41
+
42
+ },
43
+
44
+ makeSortable: function(table) {
45
+ if (table.getElementsByTagName('thead').length == 0) {
46
+ // table doesn't have a tHead. Since it should have, create one and
47
+ // put the first table row in it.
48
+ the = document.createElement('thead');
49
+ the.appendChild(table.rows[0]);
50
+ table.insertBefore(the,table.firstChild);
51
+ }
52
+ // Safari doesn't support table.tHead, sigh
53
+ if (table.tHead == null) table.tHead = table.getElementsByTagName('thead')[0];
54
+
55
+ if (table.tHead.rows.length != 1) return; // can't cope with two header rows
56
+
57
+ // Sorttable v1 put rows with a class of "sortbottom" at the bottom (as
58
+ // "total" rows, for example). This is B&R, since what you're supposed
59
+ // to do is put them in a tfoot. So, if there are sortbottom rows,
60
+ // for backwards compatibility, move them to tfoot (creating it if needed).
61
+ sortbottomrows = [];
62
+ for (var i=0; i<table.rows.length; i++) {
63
+ if (table.rows[i].className.search(/\bsortbottom\b/) != -1) {
64
+ sortbottomrows[sortbottomrows.length] = table.rows[i];
65
+ }
66
+ }
67
+ if (sortbottomrows) {
68
+ if (table.tFoot == null) {
69
+ // table doesn't have a tfoot. Create one.
70
+ tfo = document.createElement('tfoot');
71
+ table.appendChild(tfo);
72
+ }
73
+ for (var i=0; i<sortbottomrows.length; i++) {
74
+ tfo.appendChild(sortbottomrows[i]);
75
+ }
76
+ delete sortbottomrows;
77
+ }
78
+
79
+ // work through each column and calculate its type
80
+ headrow = table.tHead.rows[0].cells;
81
+ for (var i=0; i<headrow.length; i++) {
82
+ // manually override the type with a sorttable_type attribute
83
+ if (!headrow[i].className.match(/\bsorttable_nosort\b/)) { // skip this col
84
+ mtch = headrow[i].className.match(/\bsorttable_([a-z0-9]+)\b/);
85
+ if (mtch) { override = mtch[1]; }
86
+ if (mtch && typeof sorttable["sort_"+override] == 'function') {
87
+ headrow[i].sorttable_sortfunction = sorttable["sort_"+override];
88
+ } else {
89
+ headrow[i].sorttable_sortfunction = sorttable.guessType(table,i);
90
+ }
91
+ // make it clickable to sort
92
+ headrow[i].sorttable_columnindex = i;
93
+ headrow[i].sorttable_tbody = table.tBodies[0];
94
+ dean_addEvent(headrow[i],"click", sorttable.innerSortFunction = function(e) {
95
+
96
+ if (this.className.search(/\bsorttable_sorted\b/) != -1) {
97
+ // if we're already sorted by this column, just
98
+ // reverse the table, which is quicker
99
+ sorttable.reverse(this.sorttable_tbody);
100
+ this.className = this.className.replace('sorttable_sorted',
101
+ 'sorttable_sorted_reverse');
102
+ this.removeChild(document.getElementById('sorttable_sortfwdind'));
103
+ sortrevind = document.createElement('span');
104
+ sortrevind.id = "sorttable_sortrevind";
105
+ sortrevind.innerHTML = stIsIE ? '&nbsp<font face="webdings">5</font>' : '&nbsp;&#x25B4;';
106
+ this.appendChild(sortrevind);
107
+ return;
108
+ }
109
+ if (this.className.search(/\bsorttable_sorted_reverse\b/) != -1) {
110
+ // if we're already sorted by this column in reverse, just
111
+ // re-reverse the table, which is quicker
112
+ sorttable.reverse(this.sorttable_tbody);
113
+ this.className = this.className.replace('sorttable_sorted_reverse',
114
+ 'sorttable_sorted');
115
+ this.removeChild(document.getElementById('sorttable_sortrevind'));
116
+ sortfwdind = document.createElement('span');
117
+ sortfwdind.id = "sorttable_sortfwdind";
118
+ sortfwdind.innerHTML = stIsIE ? '&nbsp<font face="webdings">6</font>' : '&nbsp;&#x25BE;';
119
+ this.appendChild(sortfwdind);
120
+ return;
121
+ }
122
+
123
+ // remove sorttable_sorted classes
124
+ theadrow = this.parentNode;
125
+ forEach(theadrow.childNodes, function(cell) {
126
+ if (cell.nodeType == 1) { // an element
127
+ cell.className = cell.className.replace('sorttable_sorted_reverse','');
128
+ cell.className = cell.className.replace('sorttable_sorted','');
129
+ }
130
+ });
131
+ sortfwdind = document.getElementById('sorttable_sortfwdind');
132
+ if (sortfwdind) { sortfwdind.parentNode.removeChild(sortfwdind); }
133
+ sortrevind = document.getElementById('sorttable_sortrevind');
134
+ if (sortrevind) { sortrevind.parentNode.removeChild(sortrevind); }
135
+
136
+ this.className += ' sorttable_sorted';
137
+ sortfwdind = document.createElement('span');
138
+ sortfwdind.id = "sorttable_sortfwdind";
139
+ sortfwdind.innerHTML = stIsIE ? '&nbsp<font face="webdings">6</font>' : '&nbsp;&#x25BE;';
140
+ this.appendChild(sortfwdind);
141
+
142
+ // build an array to sort. This is a Schwartzian transform thing,
143
+ // i.e., we "decorate" each row with the actual sort key,
144
+ // sort based on the sort keys, and then put the rows back in order
145
+ // which is a lot faster because you only do getInnerText once per row
146
+ row_array = [];
147
+ col = this.sorttable_columnindex;
148
+ rows = this.sorttable_tbody.rows;
149
+ for (var j=0; j<rows.length; j++) {
150
+ row_array[row_array.length] = [sorttable.getInnerText(rows[j].cells[col]), rows[j]];
151
+ }
152
+ /* If you want a stable sort, uncomment the following line */
153
+ //sorttable.shaker_sort(row_array, this.sorttable_sortfunction);
154
+ /* and comment out this one */
155
+ row_array.sort(this.sorttable_sortfunction);
156
+
157
+ tb = this.sorttable_tbody;
158
+ for (var j=0; j<row_array.length; j++) {
159
+ tb.appendChild(row_array[j][1]);
160
+ }
161
+
162
+ delete row_array;
163
+ });
164
+ }
165
+ }
166
+ },
167
+
168
+ guessType: function(table, column) {
169
+ // guess the type of a column based on its first non-blank row
170
+ sortfn = sorttable.sort_alpha;
171
+ for (var i=0; i<table.tBodies[0].rows.length; i++) {
172
+ text = sorttable.getInnerText(table.tBodies[0].rows[i].cells[column]);
173
+ if (text != '') {
174
+ if (text.match(/^-?[£$¤]?[\d,.]+%?$/)) {
175
+ return sorttable.sort_numeric;
176
+ }
177
+ // check for a date: dd/mm/yyyy or dd/mm/yy
178
+ // can have / or . or - as separator
179
+ // can be mm/dd as well
180
+ possdate = text.match(sorttable.DATE_RE)
181
+ if (possdate) {
182
+ // looks like a date
183
+ first = parseInt(possdate[1]);
184
+ second = parseInt(possdate[2]);
185
+ if (first > 12) {
186
+ // definitely dd/mm
187
+ return sorttable.sort_ddmm;
188
+ } else if (second > 12) {
189
+ return sorttable.sort_mmdd;
190
+ } else {
191
+ // looks like a date, but we can't tell which, so assume
192
+ // that it's dd/mm (English imperialism!) and keep looking
193
+ sortfn = sorttable.sort_ddmm;
194
+ }
195
+ }
196
+ }
197
+ }
198
+ return sortfn;
199
+ },
200
+
201
+ getInnerText: function(node) {
202
+ // gets the text we want to use for sorting for a cell.
203
+ // strips leading and trailing whitespace.
204
+ // this is *not* a generic getInnerText function; it's special to sorttable.
205
+ // for example, you can override the cell text with a customkey attribute.
206
+ // it also gets .value for <input> fields.
207
+
208
+ if (!node) return "";
209
+
210
+ hasInputs = (typeof node.getElementsByTagName == 'function') &&
211
+ node.getElementsByTagName('input').length;
212
+
213
+ if (node.getAttribute("sorttable_customkey") != null) {
214
+ return node.getAttribute("sorttable_customkey");
215
+ }
216
+ else if (typeof node.textContent != 'undefined' && !hasInputs) {
217
+ return node.textContent.replace(/^\s+|\s+$/g, '');
218
+ }
219
+ else if (typeof node.innerText != 'undefined' && !hasInputs) {
220
+ return node.innerText.replace(/^\s+|\s+$/g, '');
221
+ }
222
+ else if (typeof node.text != 'undefined' && !hasInputs) {
223
+ return node.text.replace(/^\s+|\s+$/g, '');
224
+ }
225
+ else {
226
+ switch (node.nodeType) {
227
+ case 3:
228
+ if (node.nodeName.toLowerCase() == 'input') {
229
+ return node.value.replace(/^\s+|\s+$/g, '');
230
+ }
231
+ case 4:
232
+ return node.nodeValue.replace(/^\s+|\s+$/g, '');
233
+ break;
234
+ case 1:
235
+ case 11:
236
+ var innerText = '';
237
+ for (var i = 0; i < node.childNodes.length; i++) {
238
+ innerText += sorttable.getInnerText(node.childNodes[i]);
239
+ }
240
+ return innerText.replace(/^\s+|\s+$/g, '');
241
+ break;
242
+ default:
243
+ return '';
244
+ }
245
+ }
246
+ },
247
+
248
+ reverse: function(tbody) {
249
+ // reverse the rows in a tbody
250
+ newrows = [];
251
+ for (var i=0; i<tbody.rows.length; i++) {
252
+ newrows[newrows.length] = tbody.rows[i];
253
+ }
254
+ for (var i=newrows.length-1; i>=0; i--) {
255
+ tbody.appendChild(newrows[i]);
256
+ }
257
+ delete newrows;
258
+ },
259
+
260
+ /* sort functions
261
+ each sort function takes two parameters, a and b
262
+ you are comparing a[0] and b[0] */
263
+ sort_numeric: function(a,b) {
264
+ aa = parseFloat(a[0].replace(/[^0-9.-]/g,''));
265
+ if (isNaN(aa)) aa = 0;
266
+ bb = parseFloat(b[0].replace(/[^0-9.-]/g,''));
267
+ if (isNaN(bb)) bb = 0;
268
+ return aa-bb;
269
+ },
270
+ sort_alpha: function(a,b) {
271
+ a_lc = a[0].toLowerCase()
272
+ b_lc = b[0].toLowerCase()
273
+ if (a_lc==b_lc) return 0;
274
+ if (a_lc<b_lc) return -1;
275
+ return 1;
276
+ },
277
+ sort_ddmm: function(a,b) {
278
+ mtch = a[0].match(sorttable.DATE_RE);
279
+ y = mtch[3]; m = mtch[2]; d = mtch[1];
280
+ if (m.length == 1) m = '0'+m;
281
+ if (d.length == 1) d = '0'+d;
282
+ dt1 = y+m+d;
283
+ mtch = b[0].match(sorttable.DATE_RE);
284
+ y = mtch[3]; m = mtch[2]; d = mtch[1];
285
+ if (m.length == 1) m = '0'+m;
286
+ if (d.length == 1) d = '0'+d;
287
+ dt2 = y+m+d;
288
+ if (dt1==dt2) return 0;
289
+ if (dt1<dt2) return -1;
290
+ return 1;
291
+ },
292
+ sort_mmdd: function(a,b) {
293
+ mtch = a[0].match(sorttable.DATE_RE);
294
+ y = mtch[3]; d = mtch[2]; m = mtch[1];
295
+ if (m.length == 1) m = '0'+m;
296
+ if (d.length == 1) d = '0'+d;
297
+ dt1 = y+m+d;
298
+ mtch = b[0].match(sorttable.DATE_RE);
299
+ y = mtch[3]; d = mtch[2]; m = mtch[1];
300
+ if (m.length == 1) m = '0'+m;
301
+ if (d.length == 1) d = '0'+d;
302
+ dt2 = y+m+d;
303
+ if (dt1==dt2) return 0;
304
+ if (dt1<dt2) return -1;
305
+ return 1;
306
+ },
307
+
308
+ shaker_sort: function(list, comp_func) {
309
+ // A stable sort function to allow multi-level sorting of data
310
+ // see: http://en.wikipedia.org/wiki/Cocktail_sort
311
+ // thanks to Joseph Nahmias
312
+ var b = 0;
313
+ var t = list.length - 1;
314
+ var swap = true;
315
+
316
+ while(swap) {
317
+ swap = false;
318
+ for(var i = b; i < t; ++i) {
319
+ if ( comp_func(list[i], list[i+1]) > 0 ) {
320
+ var q = list[i]; list[i] = list[i+1]; list[i+1] = q;
321
+ swap = true;
322
+ }
323
+ } // for
324
+ t--;
325
+
326
+ if (!swap) break;
327
+
328
+ for(var i = t; i > b; --i) {
329
+ if ( comp_func(list[i], list[i-1]) < 0 ) {
330
+ var q = list[i]; list[i] = list[i-1]; list[i-1] = q;
331
+ swap = true;
332
+ }
333
+ } // for
334
+ b++;
335
+
336
+ } // while(swap)
337
+ }
338
+ }
339
+
340
+ /* ******************************************************************
341
+ Supporting functions: bundled here to avoid depending on a library
342
+ ****************************************************************** */
343
+
344
+ // Dean Edwards/Matthias Miller/John Resig
345
+
346
+ /* for Mozilla/Opera9 */
347
+ if (document.addEventListener) {
348
+ document.addEventListener("DOMContentLoaded", sorttable.init, false);
349
+ }
350
+
351
+ /* for Internet Explorer */
352
+ /*@cc_on @*/
353
+ /*@if (@_win32)
354
+ document.write("<script id=__ie_onload defer src=javascript:void(0)><\/script>");
355
+ var script = document.getElementById("__ie_onload");
356
+ script.onreadystatechange = function() {
357
+ if (this.readyState == "complete") {
358
+ sorttable.init(); // call the onload handler
359
+ }
360
+ };
361
+ /*@end @*/
362
+
363
+ /* for Safari */
364
+ if (/WebKit/i.test(navigator.userAgent)) { // sniff
365
+ var _timer = setInterval(function() {
366
+ if (/loaded|complete/.test(document.readyState)) {
367
+ sorttable.init(); // call the onload handler
368
+ }
369
+ }, 10);
370
+ }
371
+
372
+ /* for other browsers */
373
+ window.onload = sorttable.init;
374
+
375
+ // written by Dean Edwards, 2005
376
+ // with input from Tino Zijdel, Matthias Miller, Diego Perini
377
+
378
+ // http://dean.edwards.name/weblog/2005/10/add-event/
379
+
380
+ function dean_addEvent(element, type, handler) {
381
+ if (element.addEventListener) {
382
+ element.addEventListener(type, handler, false);
383
+ } else {
384
+ // assign each event handler a unique ID
385
+ if (!handler.$$guid) handler.$$guid = dean_addEvent.guid++;
386
+ // create a hash table of event types for the element
387
+ if (!element.events) element.events = {};
388
+ // create a hash table of event handlers for each element/event pair
389
+ var handlers = element.events[type];
390
+ if (!handlers) {
391
+ handlers = element.events[type] = {};
392
+ // store the existing event handler (if there is one)
393
+ if (element["on" + type]) {
394
+ handlers[0] = element["on" + type];
395
+ }
396
+ }
397
+ // store the event handler in the hash table
398
+ handlers[handler.$$guid] = handler;
399
+ // assign a global event handler to do all the work
400
+ element["on" + type] = handleEvent;
401
+ }
402
+ };
403
+ // a counter used to create unique IDs
404
+ dean_addEvent.guid = 1;
405
+
406
+ function removeEvent(element, type, handler) {
407
+ if (element.removeEventListener) {
408
+ element.removeEventListener(type, handler, false);
409
+ } else {
410
+ // delete the event handler from the hash table
411
+ if (element.events && element.events[type]) {
412
+ delete element.events[type][handler.$$guid];
413
+ }
414
+ }
415
+ };
416
+
417
+ function handleEvent(event) {
418
+ var returnValue = true;
419
+ // grab the event object (IE uses a global event object)
420
+ event = event || fixEvent(((this.ownerDocument || this.document || this).parentWindow || window).event);
421
+ // get a reference to the hash table of event handlers
422
+ var handlers = this.events[event.type];
423
+ // execute each event handler
424
+ for (var i in handlers) {
425
+ this.$$handleEvent = handlers[i];
426
+ if (this.$$handleEvent(event) === false) {
427
+ returnValue = false;
428
+ }
429
+ }
430
+ return returnValue;
431
+ };
432
+
433
+ function fixEvent(event) {
434
+ // add W3C standard event methods
435
+ event.preventDefault = fixEvent.preventDefault;
436
+ event.stopPropagation = fixEvent.stopPropagation;
437
+ return event;
438
+ };
439
+ fixEvent.preventDefault = function() {
440
+ this.returnValue = false;
441
+ };
442
+ fixEvent.stopPropagation = function() {
443
+ this.cancelBubble = true;
444
+ }
445
+
446
+ // Dean's forEach: http://dean.edwards.name/base/forEach.js
447
+ /*
448
+ forEach, version 1.0
449
+ Copyright 2006, Dean Edwards
450
+ License: http://www.opensource.org/licenses/mit-license.php
451
+ */
452
+
453
+ // array-like enumeration
454
+ if (!Array.forEach) { // mozilla already supports this
455
+ Array.forEach = function(array, block, context) {
456
+ for (var i = 0; i < array.length; i++) {
457
+ block.call(context, array[i], i, array);
458
+ }
459
+ };
460
+ }
461
+
462
+ // generic enumeration
463
+ Function.prototype.forEach = function(object, block, context) {
464
+ for (var key in object) {
465
+ if (typeof this.prototype[key] == "undefined") {
466
+ block.call(context, object[key], key, object);
467
+ }
468
+ }
469
+ };
470
+
471
+ // character enumeration
472
+ String.forEach = function(string, block, context) {
473
+ Array.forEach(string.split(""), function(chr, index) {
474
+ block.call(context, chr, index, string);
475
+ });
476
+ };
477
+
478
+ // globally resolve forEach enumeration
479
+ var forEach = function(object, block, context) {
480
+ if (object) {
481
+ var resolve = Object; // default
482
+ if (object instanceof Function) {
483
+ // functions have a "length" property
484
+ resolve = Function;
485
+ } else if (object.forEach instanceof Function) {
486
+ // the object implements a custom forEach method so use that
487
+ object.forEach(block, context);
488
+ return;
489
+ } else if (typeof object == "string") {
490
+ // the object is a string
491
+ resolve = String;
492
+ } else if (typeof object.length == "number") {
493
+ // the object is array-like
494
+ resolve = Array;
495
+ }
496
+ resolve.forEach(object, block, context);
497
+ }
498
+ };
499
+