OpenREM 1.0.0b2__py3-none-any.whl → 1.0.0b3__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.
Files changed (279) hide show
  1. openrem/locale/de/LC_MESSAGES/django.po +1060 -1059
  2. openrem/locale/django.pot +973 -972
  3. openrem/locale/es_MX/LC_MESSAGES/django.po +1049 -1048
  4. openrem/locale/it/LC_MESSAGES/django.po +1044 -1043
  5. openrem/locale/lt/LC_MESSAGES/django.po +989 -988
  6. openrem/locale/nb_NO/LC_MESSAGES/django.po +985 -984
  7. openrem/locale/pt_BR/LC_MESSAGES/django.po +1003 -1002
  8. openrem/manage.py +10 -10
  9. openrem/openremproject/__init__.py +1 -1
  10. openrem/openremproject/local_settings.py.linux +128 -128
  11. openrem/openremproject/local_settings.py.windows +144 -144
  12. openrem/openremproject/local_settings.py.windows-sqlite3 +129 -129
  13. openrem/openremproject/settings.py +278 -278
  14. openrem/openremproject/urls.py +32 -32
  15. openrem/openremproject/wsgi.py.example +28 -28
  16. openrem/remapp/__init__.py +2 -2
  17. openrem/remapp/admin.py +31 -31
  18. openrem/remapp/exports/ct_export.py +780 -753
  19. openrem/remapp/exports/dx_export.py +817 -805
  20. openrem/remapp/exports/export_common.py +931 -951
  21. openrem/remapp/exports/export_common_pandas.py +2422 -0
  22. openrem/remapp/exports/exportviews.py +815 -860
  23. openrem/remapp/exports/mg_csv_nhsbsp.py +292 -292
  24. openrem/remapp/exports/mg_export.py +673 -510
  25. openrem/remapp/exports/nm_export.py +796 -575
  26. openrem/remapp/exports/rf_export.py +1418 -1431
  27. openrem/remapp/extractors/ct_philips.py +424 -414
  28. openrem/remapp/extractors/ct_toshiba.py +2116 -2108
  29. openrem/remapp/extractors/dx.py +1033 -952
  30. openrem/remapp/extractors/extract_common.py +817 -817
  31. openrem/remapp/extractors/import_views.py +426 -426
  32. openrem/remapp/extractors/mam.py +685 -672
  33. openrem/remapp/extractors/nm_image.py +439 -431
  34. openrem/remapp/extractors/ptsizecsv2db.py +368 -368
  35. openrem/remapp/extractors/rdsr.py +667 -654
  36. openrem/remapp/extractors/rdsr_methods.py +1771 -1768
  37. openrem/remapp/extractors/rrdsr_methods.py +630 -622
  38. openrem/remapp/fixtures/openskin_safelist.json +11 -11
  39. openrem/remapp/forms.py +2286 -2277
  40. openrem/remapp/interface/chart_functions.py +2412 -2393
  41. openrem/remapp/interface/mod_filters.py +1241 -1243
  42. openrem/remapp/migrations/0001_initial.py.1-0-upgrade +1043 -1043
  43. openrem/remapp/models.py +3418 -3407
  44. openrem/remapp/netdicom/dicomviews.py +681 -683
  45. openrem/remapp/netdicom/qrscu.py +2646 -2646
  46. openrem/remapp/netdicom/tools.py +134 -134
  47. openrem/remapp/static/css/bootstrap-theme.css +587 -587
  48. openrem/remapp/static/css/bootstrap-theme.min.css +4 -4
  49. openrem/remapp/static/css/bootstrap.css +6800 -6800
  50. openrem/remapp/static/css/bootstrap.min.css +4 -4
  51. openrem/remapp/static/css/datepicker3.css +790 -790
  52. openrem/remapp/static/css/jquery.qtip.min.css +2 -2
  53. openrem/remapp/static/css/openrem-extra.css +442 -442
  54. openrem/remapp/static/css/openrem.css +96 -96
  55. openrem/remapp/static/css/registration.css +34 -34
  56. openrem/remapp/static/fonts/glyphicons-halflings-regular.svg +287 -287
  57. openrem/remapp/static/js/bootstrap-datepicker.js +1671 -1671
  58. openrem/remapp/static/js/bootstrap.js +2363 -2363
  59. openrem/remapp/static/js/bootstrap.min.js +6 -6
  60. openrem/remapp/static/js/charts/chartCommonFunctions.js +75 -75
  61. openrem/remapp/static/js/charts/chartFullScreen.js +41 -41
  62. openrem/remapp/static/js/charts/ctChartAjax.js +331 -331
  63. openrem/remapp/static/js/charts/dxChartAjax.js +290 -290
  64. openrem/remapp/static/js/charts/mgChartAjax.js +144 -144
  65. openrem/remapp/static/js/charts/nmChartAjax.js +64 -64
  66. openrem/remapp/static/js/charts/plotly-2.35.2.min.js +8 -0
  67. openrem/remapp/static/js/charts/rfChartAjax.js +128 -128
  68. openrem/remapp/static/js/chroma.min.js +32 -32
  69. openrem/remapp/static/js/datepicker.js +5 -5
  70. openrem/remapp/static/js/dicom.js +115 -115
  71. openrem/remapp/static/js/django_reverse/reverse.js +13 -13
  72. openrem/remapp/static/js/formatDate.js +7 -7
  73. openrem/remapp/static/js/html5shiv.min.js +8 -8
  74. openrem/remapp/static/js/jquery-1.11.0.min.js +4 -4
  75. openrem/remapp/static/js/npm.js +12 -12
  76. openrem/remapp/static/js/respond.min.js +4 -4
  77. openrem/remapp/static/js/skin-dose-maps/jquery.qtip.min.js +4 -4
  78. openrem/remapp/static/js/skin-dose-maps/rfSkinDoseMap3dHUDObject.js +112 -112
  79. openrem/remapp/static/js/skin-dose-maps/rfSkinDoseMap3dObject.js +367 -367
  80. openrem/remapp/static/js/skin-dose-maps/rfSkinDoseMap3dPersonObject.js +158 -158
  81. openrem/remapp/static/js/skin-dose-maps/rfSkinDoseMapColourScaleObject.js +153 -153
  82. openrem/remapp/static/js/skin-dose-maps/rfSkinDoseMapObject.js +367 -367
  83. openrem/remapp/static/js/skin-dose-maps/rfSkinDoseMapping.js +584 -584
  84. openrem/remapp/static/js/skin-dose-maps/rfSkinDoseMapping3d.js +255 -255
  85. openrem/remapp/static/js/skin-dose-maps/rfSkinDoseMappingAjax.js +267 -212
  86. openrem/remapp/static/js/skin-dose-maps/three.min.js +835 -835
  87. openrem/remapp/static/js/sorttable.js +495 -495
  88. openrem/remapp/templates/base.html +253 -253
  89. openrem/remapp/templates/registration/changepassword.html +25 -25
  90. openrem/remapp/templates/registration/changepassworddone.html +12 -12
  91. openrem/remapp/templates/registration/login.html +42 -42
  92. openrem/remapp/templates/remapp/backgroundtaskmaximumrows_form.html +29 -29
  93. openrem/remapp/templates/remapp/base.html +1 -1
  94. openrem/remapp/templates/remapp/ctdetail.html +235 -235
  95. openrem/remapp/templates/remapp/ctfiltered.html +310 -310
  96. openrem/remapp/templates/remapp/dicomdeletesettings_form.html +31 -31
  97. openrem/remapp/templates/remapp/dicomqr.html +147 -147
  98. openrem/remapp/templates/remapp/dicomquerydetails.html +83 -83
  99. openrem/remapp/templates/remapp/dicomqueryimages.html +49 -49
  100. openrem/remapp/templates/remapp/dicomqueryseries.html +109 -109
  101. openrem/remapp/templates/remapp/dicomquerysummary.html +48 -48
  102. openrem/remapp/templates/remapp/dicomremoteqr_confirm_delete.html +60 -60
  103. openrem/remapp/templates/remapp/dicomremoteqr_form.html +32 -32
  104. openrem/remapp/templates/remapp/dicomstorescp_confirm_delete.html +53 -53
  105. openrem/remapp/templates/remapp/dicomstorescp_form.html +48 -48
  106. openrem/remapp/templates/remapp/dicomsummary.html +257 -257
  107. openrem/remapp/templates/remapp/displaychartoptions.html +184 -184
  108. openrem/remapp/templates/remapp/displayhomepageoptions.html +57 -57
  109. openrem/remapp/templates/remapp/displayname-count.html +6 -6
  110. openrem/remapp/templates/remapp/displayname-last-date.html +3 -3
  111. openrem/remapp/templates/remapp/displayname-modality.html +86 -105
  112. openrem/remapp/templates/remapp/displayname-skinmap.html +18 -18
  113. openrem/remapp/templates/remapp/displaynameupdate.html +100 -100
  114. openrem/remapp/templates/remapp/displaynameview.html +222 -219
  115. openrem/remapp/templates/remapp/dxdetail.html +176 -176
  116. openrem/remapp/templates/remapp/dxfiltered.html +324 -324
  117. openrem/remapp/templates/remapp/exports-active.html +25 -25
  118. openrem/remapp/templates/remapp/exports-complete.html +35 -35
  119. openrem/remapp/templates/remapp/exports-error.html +26 -26
  120. openrem/remapp/templates/remapp/exports-queue.html +18 -18
  121. openrem/remapp/templates/remapp/exports.html +191 -191
  122. openrem/remapp/templates/remapp/failed_summary_list.html +27 -27
  123. openrem/remapp/templates/remapp/filteredbase.html +162 -162
  124. openrem/remapp/templates/remapp/highdosemetricalertsettings_form.html +76 -76
  125. openrem/remapp/templates/remapp/home-list-modalities.html +94 -94
  126. openrem/remapp/templates/remapp/home.html +202 -202
  127. openrem/remapp/templates/remapp/list_filters.html +24 -24
  128. openrem/remapp/templates/remapp/mgdetail.html +160 -138
  129. openrem/remapp/templates/remapp/mgfiltered.html +311 -311
  130. openrem/remapp/templates/remapp/nmdetail.html +300 -300
  131. openrem/remapp/templates/remapp/nmfiltered.html +255 -255
  132. openrem/remapp/templates/remapp/notpatient.html +190 -190
  133. openrem/remapp/templates/remapp/notpatientindicators_form_base.html +81 -81
  134. openrem/remapp/templates/remapp/notpatientindicatorsid_confirm_delete.html +54 -54
  135. openrem/remapp/templates/remapp/notpatientindicatorsid_form.html +23 -23
  136. openrem/remapp/templates/remapp/notpatientindicatorsname_confirm_delete.html +54 -54
  137. openrem/remapp/templates/remapp/notpatientindicatorsname_form.html +23 -23
  138. openrem/remapp/templates/remapp/notpatientindicatorsname_form_base.html +85 -85
  139. openrem/remapp/templates/remapp/openskinsafelist_add.html +130 -130
  140. openrem/remapp/templates/remapp/openskinsafelist_confirm_delete.html +100 -100
  141. openrem/remapp/templates/remapp/openskinsafelist_form.html +207 -207
  142. openrem/remapp/templates/remapp/patientidsettings_form.html +83 -83
  143. openrem/remapp/templates/remapp/populate_summary_progress.html +83 -83
  144. openrem/remapp/templates/remapp/populate_summary_progress_error.html +36 -36
  145. openrem/remapp/templates/remapp/review_failed_imports.html +157 -157
  146. openrem/remapp/templates/remapp/review_failed_study.html +41 -41
  147. openrem/remapp/templates/remapp/review_studies_delete_button.html +20 -20
  148. openrem/remapp/templates/remapp/review_study.html +19 -19
  149. openrem/remapp/templates/remapp/review_summary_list.html +245 -245
  150. openrem/remapp/templates/remapp/rf_dose_alert_email_template.html +14 -1
  151. openrem/remapp/templates/remapp/rfalertnotificationsview.html +59 -59
  152. openrem/remapp/templates/remapp/rfdetail.html +547 -543
  153. openrem/remapp/templates/remapp/rfdetailbase.html +18 -18
  154. openrem/remapp/templates/remapp/rffiltered.html +404 -404
  155. openrem/remapp/templates/remapp/sizeimports.html +119 -119
  156. openrem/remapp/templates/remapp/sizeprocess.html +96 -96
  157. openrem/remapp/templates/remapp/sizeupload.html +110 -110
  158. openrem/remapp/templates/remapp/skindosemapcalcsettings_form.html +28 -28
  159. openrem/remapp/templates/remapp/standardname-modality.html +69 -69
  160. openrem/remapp/templates/remapp/standardnames_confirm_delete.html +71 -71
  161. openrem/remapp/templates/remapp/standardnames_form.html +87 -87
  162. openrem/remapp/templates/remapp/standardnamesettings_form.html +41 -41
  163. openrem/remapp/templates/remapp/standardnamesrefreshall.html +92 -92
  164. openrem/remapp/templates/remapp/standardnameview.html +103 -103
  165. openrem/remapp/templates/remapp/study_confirm_delete.html +147 -147
  166. openrem/remapp/templates/remapp/task_admin.html +265 -265
  167. openrem/remapp/templates/remapp/tasks.html +76 -76
  168. openrem/remapp/templatetags/formfilters.py +13 -13
  169. openrem/remapp/templatetags/proper_paginate.py +38 -38
  170. openrem/remapp/templatetags/remappduration.py +36 -36
  171. openrem/remapp/templatetags/sigdig.py +38 -38
  172. openrem/remapp/templatetags/sort_class_property_value.py +15 -15
  173. openrem/remapp/templatetags/update_variable.py +20 -20
  174. openrem/remapp/templatetags/url_replace.py +25 -25
  175. openrem/remapp/tests/test_charts_common.py +202 -202
  176. openrem/remapp/tests/test_charts_ct.py +7111 -7111
  177. openrem/remapp/tests/test_charts_dx.py +3513 -3513
  178. openrem/remapp/tests/test_charts_mg.py +1116 -1115
  179. openrem/remapp/tests/test_dcmdatetime.py +189 -189
  180. openrem/remapp/tests/test_dicom_qr.py +2580 -2580
  181. openrem/remapp/tests/test_display_name.py +274 -274
  182. openrem/remapp/tests/test_export_ct_xlsx.py +272 -248
  183. openrem/remapp/tests/test_export_dx_xlsx.py +137 -134
  184. openrem/remapp/tests/test_export_mammo_csv.py +242 -242
  185. openrem/remapp/tests/test_export_rf_xlsx.py +246 -246
  186. openrem/remapp/tests/test_files/DX-Im-DRGEM.dcm +0 -0
  187. openrem/remapp/tests/test_files/MG-RDSR-GEPristina-2D.dcm +0 -0
  188. openrem/remapp/tests/test_files/MG-RDSR-GEPristina-DBT.dcm +0 -0
  189. openrem/remapp/tests/test_files/MG-RDSR-Giotto-DBT.dcm +0 -0
  190. openrem/remapp/tests/test_files/skin_map_alphenix.py +590 -590
  191. openrem/remapp/tests/test_files/skin_map_zee.py +354 -354
  192. openrem/remapp/tests/test_filters_ct.py +321 -321
  193. openrem/remapp/tests/test_filters_dx.py +92 -92
  194. openrem/remapp/tests/test_filters_mammo.py +183 -183
  195. openrem/remapp/tests/test_filters_rf.py +118 -118
  196. openrem/remapp/tests/test_get_values.py +72 -72
  197. openrem/remapp/tests/test_hash_id.py +65 -65
  198. openrem/remapp/tests/test_import_ct_esr_ge.py +3034 -3034
  199. openrem/remapp/tests/test_import_ct_philips_rdsr.py +42 -42
  200. openrem/remapp/tests/test_import_ct_rdsr_multiple.py +256 -256
  201. openrem/remapp/tests/test_import_ct_rdsr_siemens.py +827 -827
  202. openrem/remapp/tests/test_import_ct_rdsr_spectrumdynamics.py +91 -91
  203. openrem/remapp/tests/test_import_ct_rdsr_toshiba_dosecheck.py +67 -67
  204. openrem/remapp/tests/test_import_ct_rdsr_toshiba_multivaluesd.py +33 -33
  205. openrem/remapp/tests/test_import_ct_rdsr_toshiba_pixelmed.py +118 -118
  206. openrem/remapp/tests/test_import_ct_sc_philips.py +44 -44
  207. openrem/remapp/tests/test_import_dual_rdsr.py +110 -110
  208. openrem/remapp/tests/test_import_dx.py +1267 -1191
  209. openrem/remapp/tests/test_import_dx_rdsr.py +1250 -1253
  210. openrem/remapp/tests/test_import_mam.py +438 -438
  211. openrem/remapp/tests/test_import_mg_im_hol_proj.py +46 -46
  212. openrem/remapp/tests/test_import_mg_rdsr.py +586 -586
  213. openrem/remapp/tests/test_import_nm_image.py +420 -420
  214. openrem/remapp/tests/test_import_nm_siemens_rdsr.py +396 -396
  215. openrem/remapp/tests/test_import_px.py +161 -161
  216. openrem/remapp/tests/test_import_rf_rdsr.py +420 -418
  217. openrem/remapp/tests/test_missing_date.py +42 -42
  218. openrem/remapp/tests/test_not_patient.py +60 -60
  219. openrem/remapp/tests/test_openskin.py +272 -272
  220. openrem/remapp/tests/test_patient_id_settings.py +72 -72
  221. openrem/remapp/tests/test_pt_size_import.py +232 -232
  222. openrem/remapp/tests/test_rf_detail.py +113 -113
  223. openrem/remapp/tests/test_rf_high_dose_alert.py +361 -361
  224. openrem/remapp/tools/background.py +361 -361
  225. openrem/remapp/tools/check_standard_name_status.py +47 -0
  226. openrem/remapp/tools/check_uid.py +70 -70
  227. openrem/remapp/tools/dcmdatetime.py +248 -248
  228. openrem/remapp/tools/default_import.py +44 -47
  229. openrem/remapp/tools/get_values.py +230 -230
  230. openrem/remapp/tools/hash_id.py +58 -58
  231. openrem/remapp/tools/make_skin_map.py +448 -406
  232. openrem/remapp/tools/not_patient_indicators.py +72 -72
  233. openrem/remapp/tools/openskin/calc_exp_map.py +173 -173
  234. openrem/remapp/tools/openskin/geomclass.py +475 -475
  235. openrem/remapp/tools/openskin/geomfunc.py +433 -432
  236. openrem/remapp/tools/openskin/skinmap.py +417 -417
  237. openrem/remapp/tools/populate_summary.py +185 -193
  238. openrem/remapp/tools/save_skin_map_structure.py +73 -73
  239. openrem/remapp/tools/send_high_dose_alert_emails.py +238 -207
  240. openrem/remapp/urls.py +456 -448
  241. openrem/remapp/version.py +11 -11
  242. openrem/remapp/views.py +1147 -1052
  243. openrem/remapp/views_admin.py +3876 -3936
  244. openrem/remapp/views_charts_ct.py +2110 -2058
  245. openrem/remapp/views_charts_dx.py +1906 -1836
  246. openrem/remapp/views_charts_mg.py +1349 -1196
  247. openrem/remapp/views_charts_nm.py +535 -535
  248. openrem/remapp/views_charts_rf.py +1219 -1241
  249. openrem/remapp/views_openskin.py +379 -384
  250. openrem/sample-config/openrem-consumer.service +12 -12
  251. openrem/sample-config/openrem-gunicorn.service +13 -13
  252. openrem/sample-config/openrem-server +14 -13
  253. openrem/sample-config/openrem_orthanc_config_linux.lua +454 -454
  254. openrem/sample-config/openrem_orthanc_config_windows.lua +455 -455
  255. openrem/sample-config/queue-init.bat +73 -73
  256. openrem/scripts/openrem_ctphilips.py +25 -25
  257. openrem/scripts/openrem_cttoshiba.py +28 -28
  258. openrem/scripts/openrem_dx.py +22 -22
  259. openrem/scripts/openrem_mg.py +22 -22
  260. openrem/scripts/openrem_nm.py +22 -22
  261. openrem/scripts/openrem_ptsizecsv.py +17 -17
  262. openrem/scripts/openrem_qr.py +12 -12
  263. openrem/scripts/openrem_rdsr.py +25 -25
  264. {OpenREM-1.0.0b2.dist-info → openrem-1.0.0b3.dist-info}/METADATA +39 -29
  265. openrem-1.0.0b3.dist-info/RECORD +379 -0
  266. {OpenREM-1.0.0b2.dist-info → openrem-1.0.0b3.dist-info}/WHEEL +1 -1
  267. {OpenREM-1.0.0b2.dist-info → openrem-1.0.0b3.dist-info/licenses}/COPYING-GPLv3 +674 -674
  268. {OpenREM-1.0.0b2.dist-info → openrem-1.0.0b3.dist-info/licenses}/LICENSE +22 -22
  269. OpenREM-1.0.0b2.dist-info/RECORD +0 -373
  270. openrem/remapp/static/js/charts/plotly-2.17.1.min.js +0 -8
  271. {OpenREM-1.0.0b2.data → openrem-1.0.0b3.data}/scripts/openrem_ctphilips.py +0 -0
  272. {OpenREM-1.0.0b2.data → openrem-1.0.0b3.data}/scripts/openrem_cttoshiba.py +0 -0
  273. {OpenREM-1.0.0b2.data → openrem-1.0.0b3.data}/scripts/openrem_dx.py +0 -0
  274. {OpenREM-1.0.0b2.data → openrem-1.0.0b3.data}/scripts/openrem_mg.py +0 -0
  275. {OpenREM-1.0.0b2.data → openrem-1.0.0b3.data}/scripts/openrem_nm.py +0 -0
  276. {OpenREM-1.0.0b2.data → openrem-1.0.0b3.data}/scripts/openrem_ptsizecsv.py +0 -0
  277. {OpenREM-1.0.0b2.data → openrem-1.0.0b3.data}/scripts/openrem_qr.py +0 -0
  278. {OpenREM-1.0.0b2.data → openrem-1.0.0b3.data}/scripts/openrem_rdsr.py +0 -0
  279. {OpenREM-1.0.0b2.dist-info → openrem-1.0.0b3.dist-info}/top_level.txt +0 -0
@@ -1,495 +1,495 @@
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
- var stIsIE = /*@cc_on!@*/false;
20
-
21
- sorttable = {
22
- init: function() {
23
- // quit if this function has already been called
24
- if (arguments.callee.done) return;
25
- // flag this function so we don't do the same thing twice
26
- arguments.callee.done = true;
27
- // kill the timer
28
- if (_timer) clearInterval(_timer);
29
-
30
- if (!document.createElement || !document.getElementsByTagName) return;
31
-
32
- sorttable.DATE_RE = /^(\d\d?)[\/\.-](\d\d?)[\/\.-]((\d\d)?\d\d)$/;
33
-
34
- forEach(document.getElementsByTagName('table'), function(table) {
35
- if (table.className.search(/\bsortable\b/) != -1) {
36
- sorttable.makeSortable(table);
37
- }
38
- });
39
-
40
- },
41
-
42
- makeSortable: function(table) {
43
- if (table.getElementsByTagName('thead').length == 0) {
44
- // table doesn't have a tHead. Since it should have, create one and
45
- // put the first table row in it.
46
- the = document.createElement('thead');
47
- the.appendChild(table.rows[0]);
48
- table.insertBefore(the,table.firstChild);
49
- }
50
- // Safari doesn't support table.tHead, sigh
51
- if (table.tHead == null) table.tHead = table.getElementsByTagName('thead')[0];
52
-
53
- if (table.tHead.rows.length != 1) return; // can't cope with two header rows
54
-
55
- // Sorttable v1 put rows with a class of "sortbottom" at the bottom (as
56
- // "total" rows, for example). This is B&R, since what you're supposed
57
- // to do is put them in a tfoot. So, if there are sortbottom rows,
58
- // for backwards compatibility, move them to tfoot (creating it if needed).
59
- sortbottomrows = [];
60
- for (var i=0; i<table.rows.length; i++) {
61
- if (table.rows[i].className.search(/\bsortbottom\b/) != -1) {
62
- sortbottomrows[sortbottomrows.length] = table.rows[i];
63
- }
64
- }
65
- if (sortbottomrows) {
66
- if (table.tFoot == null) {
67
- // table doesn't have a tfoot. Create one.
68
- tfo = document.createElement('tfoot');
69
- table.appendChild(tfo);
70
- }
71
- for (var i=0; i<sortbottomrows.length; i++) {
72
- tfo.appendChild(sortbottomrows[i]);
73
- }
74
- delete sortbottomrows;
75
- }
76
-
77
- // work through each column and calculate its type
78
- headrow = table.tHead.rows[0].cells;
79
- for (var i=0; i<headrow.length; i++) {
80
- // manually override the type with a sorttable_type attribute
81
- if (!headrow[i].className.match(/\bsorttable_nosort\b/)) { // skip this col
82
- mtch = headrow[i].className.match(/\bsorttable_([a-z0-9]+)\b/);
83
- if (mtch) { override = mtch[1]; }
84
- if (mtch && typeof sorttable["sort_"+override] == 'function') {
85
- headrow[i].sorttable_sortfunction = sorttable["sort_"+override];
86
- } else {
87
- headrow[i].sorttable_sortfunction = sorttable.guessType(table,i);
88
- }
89
- // make it clickable to sort
90
- headrow[i].sorttable_columnindex = i;
91
- headrow[i].sorttable_tbody = table.tBodies[0];
92
- dean_addEvent(headrow[i],"click", sorttable.innerSortFunction = function(e) {
93
-
94
- if (this.className.search(/\bsorttable_sorted\b/) != -1) {
95
- // if we're already sorted by this column, just
96
- // reverse the table, which is quicker
97
- sorttable.reverse(this.sorttable_tbody);
98
- this.className = this.className.replace('sorttable_sorted',
99
- 'sorttable_sorted_reverse');
100
- this.removeChild(document.getElementById('sorttable_sortfwdind'));
101
- sortrevind = document.createElement('span');
102
- sortrevind.id = "sorttable_sortrevind";
103
- sortrevind.innerHTML = stIsIE ? '&nbsp<font face="webdings">5</font>' : '&nbsp;&#x25B4;';
104
- this.appendChild(sortrevind);
105
- return;
106
- }
107
- if (this.className.search(/\bsorttable_sorted_reverse\b/) != -1) {
108
- // if we're already sorted by this column in reverse, just
109
- // re-reverse the table, which is quicker
110
- sorttable.reverse(this.sorttable_tbody);
111
- this.className = this.className.replace('sorttable_sorted_reverse',
112
- 'sorttable_sorted');
113
- this.removeChild(document.getElementById('sorttable_sortrevind'));
114
- sortfwdind = document.createElement('span');
115
- sortfwdind.id = "sorttable_sortfwdind";
116
- sortfwdind.innerHTML = stIsIE ? '&nbsp<font face="webdings">6</font>' : '&nbsp;&#x25BE;';
117
- this.appendChild(sortfwdind);
118
- return;
119
- }
120
-
121
- // remove sorttable_sorted classes
122
- theadrow = this.parentNode;
123
- forEach(theadrow.childNodes, function(cell) {
124
- if (cell.nodeType == 1) { // an element
125
- cell.className = cell.className.replace('sorttable_sorted_reverse','');
126
- cell.className = cell.className.replace('sorttable_sorted','');
127
- }
128
- });
129
- sortfwdind = document.getElementById('sorttable_sortfwdind');
130
- if (sortfwdind) { sortfwdind.parentNode.removeChild(sortfwdind); }
131
- sortrevind = document.getElementById('sorttable_sortrevind');
132
- if (sortrevind) { sortrevind.parentNode.removeChild(sortrevind); }
133
-
134
- this.className += ' sorttable_sorted';
135
- sortfwdind = document.createElement('span');
136
- sortfwdind.id = "sorttable_sortfwdind";
137
- sortfwdind.innerHTML = stIsIE ? '&nbsp<font face="webdings">6</font>' : '&nbsp;&#x25BE;';
138
- this.appendChild(sortfwdind);
139
-
140
- // build an array to sort. This is a Schwartzian transform thing,
141
- // i.e., we "decorate" each row with the actual sort key,
142
- // sort based on the sort keys, and then put the rows back in order
143
- // which is a lot faster because you only do getInnerText once per row
144
- row_array = [];
145
- col = this.sorttable_columnindex;
146
- rows = this.sorttable_tbody.rows;
147
- for (var j=0; j<rows.length; j++) {
148
- row_array[row_array.length] = [sorttable.getInnerText(rows[j].cells[col]), rows[j]];
149
- }
150
- /* If you want a stable sort, uncomment the following line */
151
- //sorttable.shaker_sort(row_array, this.sorttable_sortfunction);
152
- /* and comment out this one */
153
- row_array.sort(this.sorttable_sortfunction);
154
-
155
- tb = this.sorttable_tbody;
156
- for (var j=0; j<row_array.length; j++) {
157
- tb.appendChild(row_array[j][1]);
158
- }
159
-
160
- delete row_array;
161
- });
162
- }
163
- }
164
- },
165
-
166
- guessType: function(table, column) {
167
- // guess the type of a column based on its first non-blank row
168
- sortfn = sorttable.sort_alpha;
169
- for (var i=0; i<table.tBodies[0].rows.length; i++) {
170
- text = sorttable.getInnerText(table.tBodies[0].rows[i].cells[column]);
171
- if (text != '') {
172
- if (text.match(/^-?[Ł$¤]?[\d,.]+%?$/)) {
173
- return sorttable.sort_numeric;
174
- }
175
- // check for a date: dd/mm/yyyy or dd/mm/yy
176
- // can have / or . or - as separator
177
- // can be mm/dd as well
178
- possdate = text.match(sorttable.DATE_RE)
179
- if (possdate) {
180
- // looks like a date
181
- first = parseInt(possdate[1]);
182
- second = parseInt(possdate[2]);
183
- if (first > 12) {
184
- // definitely dd/mm
185
- return sorttable.sort_ddmm;
186
- } else if (second > 12) {
187
- return sorttable.sort_mmdd;
188
- } else {
189
- // looks like a date, but we can't tell which, so assume
190
- // that it's dd/mm (English imperialism!) and keep looking
191
- sortfn = sorttable.sort_ddmm;
192
- }
193
- }
194
- }
195
- }
196
- return sortfn;
197
- },
198
-
199
- getInnerText: function(node) {
200
- // gets the text we want to use for sorting for a cell.
201
- // strips leading and trailing whitespace.
202
- // this is *not* a generic getInnerText function; it's special to sorttable.
203
- // for example, you can override the cell text with a customkey attribute.
204
- // it also gets .value for <input> fields.
205
-
206
- if (!node) return "";
207
-
208
- hasInputs = (typeof node.getElementsByTagName == 'function') &&
209
- node.getElementsByTagName('input').length;
210
-
211
- if (node.getAttribute("sorttable_customkey") != null) {
212
- return node.getAttribute("sorttable_customkey");
213
- }
214
- else if (typeof node.textContent != 'undefined' && !hasInputs) {
215
- return node.textContent.replace(/^\s+|\s+$/g, '');
216
- }
217
- else if (typeof node.innerText != 'undefined' && !hasInputs) {
218
- return node.innerText.replace(/^\s+|\s+$/g, '');
219
- }
220
- else if (typeof node.text != 'undefined' && !hasInputs) {
221
- return node.text.replace(/^\s+|\s+$/g, '');
222
- }
223
- else {
224
- switch (node.nodeType) {
225
- case 3:
226
- if (node.nodeName.toLowerCase() == 'input') {
227
- return node.value.replace(/^\s+|\s+$/g, '');
228
- }
229
- case 4:
230
- return node.nodeValue.replace(/^\s+|\s+$/g, '');
231
- break;
232
- case 1:
233
- case 11:
234
- var innerText = '';
235
- for (var i = 0; i < node.childNodes.length; i++) {
236
- innerText += sorttable.getInnerText(node.childNodes[i]);
237
- }
238
- return innerText.replace(/^\s+|\s+$/g, '');
239
- break;
240
- default:
241
- return '';
242
- }
243
- }
244
- },
245
-
246
- reverse: function(tbody) {
247
- // reverse the rows in a tbody
248
- newrows = [];
249
- for (var i=0; i<tbody.rows.length; i++) {
250
- newrows[newrows.length] = tbody.rows[i];
251
- }
252
- for (var i=newrows.length-1; i>=0; i--) {
253
- tbody.appendChild(newrows[i]);
254
- }
255
- delete newrows;
256
- },
257
-
258
- /* sort functions
259
- each sort function takes two parameters, a and b
260
- you are comparing a[0] and b[0] */
261
- sort_numeric: function(a,b) {
262
- aa = parseFloat(a[0].replace(/[^0-9.-]/g,''));
263
- if (isNaN(aa)) aa = 0;
264
- bb = parseFloat(b[0].replace(/[^0-9.-]/g,''));
265
- if (isNaN(bb)) bb = 0;
266
- return aa-bb;
267
- },
268
- sort_alpha: function(a,b) {
269
- if (a[0]==b[0]) return 0;
270
- if (a[0]<b[0]) return -1;
271
- return 1;
272
- },
273
- sort_ddmm: function(a,b) {
274
- mtch = a[0].match(sorttable.DATE_RE);
275
- y = mtch[3]; m = mtch[2]; d = mtch[1];
276
- if (m.length == 1) m = '0'+m;
277
- if (d.length == 1) d = '0'+d;
278
- dt1 = y+m+d;
279
- mtch = b[0].match(sorttable.DATE_RE);
280
- y = mtch[3]; m = mtch[2]; d = mtch[1];
281
- if (m.length == 1) m = '0'+m;
282
- if (d.length == 1) d = '0'+d;
283
- dt2 = y+m+d;
284
- if (dt1==dt2) return 0;
285
- if (dt1<dt2) return -1;
286
- return 1;
287
- },
288
- sort_mmdd: function(a,b) {
289
- mtch = a[0].match(sorttable.DATE_RE);
290
- y = mtch[3]; d = mtch[2]; m = mtch[1];
291
- if (m.length == 1) m = '0'+m;
292
- if (d.length == 1) d = '0'+d;
293
- dt1 = y+m+d;
294
- mtch = b[0].match(sorttable.DATE_RE);
295
- y = mtch[3]; d = mtch[2]; m = mtch[1];
296
- if (m.length == 1) m = '0'+m;
297
- if (d.length == 1) d = '0'+d;
298
- dt2 = y+m+d;
299
- if (dt1==dt2) return 0;
300
- if (dt1<dt2) return -1;
301
- return 1;
302
- },
303
-
304
- shaker_sort: function(list, comp_func) {
305
- // A stable sort function to allow multi-level sorting of data
306
- // see: http://en.wikipedia.org/wiki/Cocktail_sort
307
- // thanks to Joseph Nahmias
308
- var b = 0;
309
- var t = list.length - 1;
310
- var swap = true;
311
-
312
- while(swap) {
313
- swap = false;
314
- for(var i = b; i < t; ++i) {
315
- if ( comp_func(list[i], list[i+1]) > 0 ) {
316
- var q = list[i]; list[i] = list[i+1]; list[i+1] = q;
317
- swap = true;
318
- }
319
- } // for
320
- t--;
321
-
322
- if (!swap) break;
323
-
324
- for(var i = t; i > b; --i) {
325
- if ( comp_func(list[i], list[i-1]) < 0 ) {
326
- var q = list[i]; list[i] = list[i-1]; list[i-1] = q;
327
- swap = true;
328
- }
329
- } // for
330
- b++;
331
-
332
- } // while(swap)
333
- }
334
- }
335
-
336
- /* ******************************************************************
337
- Supporting functions: bundled here to avoid depending on a library
338
- ****************************************************************** */
339
-
340
- // Dean Edwards/Matthias Miller/John Resig
341
-
342
- /* for Mozilla/Opera9 */
343
- if (document.addEventListener) {
344
- document.addEventListener("DOMContentLoaded", sorttable.init, false);
345
- }
346
-
347
- /* for Internet Explorer */
348
- /*@cc_on @*/
349
- /*@if (@_win32)
350
- document.write("<script id=__ie_onload defer src=javascript:void(0)><\/script>");
351
- var script = document.getElementById("__ie_onload");
352
- script.onreadystatechange = function() {
353
- if (this.readyState == "complete") {
354
- sorttable.init(); // call the onload handler
355
- }
356
- };
357
- /*@end @*/
358
-
359
- /* for Safari */
360
- if (/WebKit/i.test(navigator.userAgent)) { // sniff
361
- var _timer = setInterval(function() {
362
- if (/loaded|complete/.test(document.readyState)) {
363
- sorttable.init(); // call the onload handler
364
- }
365
- }, 10);
366
- }
367
-
368
- /* for other browsers */
369
- window.onload = sorttable.init;
370
-
371
- // written by Dean Edwards, 2005
372
- // with input from Tino Zijdel, Matthias Miller, Diego Perini
373
-
374
- // http://dean.edwards.name/weblog/2005/10/add-event/
375
-
376
- function dean_addEvent(element, type, handler) {
377
- if (element.addEventListener) {
378
- element.addEventListener(type, handler, false);
379
- } else {
380
- // assign each event handler a unique ID
381
- if (!handler.$$guid) handler.$$guid = dean_addEvent.guid++;
382
- // create a hash table of event types for the element
383
- if (!element.events) element.events = {};
384
- // create a hash table of event handlers for each element/event pair
385
- var handlers = element.events[type];
386
- if (!handlers) {
387
- handlers = element.events[type] = {};
388
- // store the existing event handler (if there is one)
389
- if (element["on" + type]) {
390
- handlers[0] = element["on" + type];
391
- }
392
- }
393
- // store the event handler in the hash table
394
- handlers[handler.$$guid] = handler;
395
- // assign a global event handler to do all the work
396
- element["on" + type] = handleEvent;
397
- }
398
- };
399
- // a counter used to create unique IDs
400
- dean_addEvent.guid = 1;
401
-
402
- function removeEvent(element, type, handler) {
403
- if (element.removeEventListener) {
404
- element.removeEventListener(type, handler, false);
405
- } else {
406
- // delete the event handler from the hash table
407
- if (element.events && element.events[type]) {
408
- delete element.events[type][handler.$$guid];
409
- }
410
- }
411
- };
412
-
413
- function handleEvent(event) {
414
- var returnValue = true;
415
- // grab the event object (IE uses a global event object)
416
- event = event || fixEvent(((this.ownerDocument || this.document || this).parentWindow || window).event);
417
- // get a reference to the hash table of event handlers
418
- var handlers = this.events[event.type];
419
- // execute each event handler
420
- for (var i in handlers) {
421
- this.$$handleEvent = handlers[i];
422
- if (this.$$handleEvent(event) === false) {
423
- returnValue = false;
424
- }
425
- }
426
- return returnValue;
427
- };
428
-
429
- function fixEvent(event) {
430
- // add W3C standard event methods
431
- event.preventDefault = fixEvent.preventDefault;
432
- event.stopPropagation = fixEvent.stopPropagation;
433
- return event;
434
- };
435
- fixEvent.preventDefault = function() {
436
- this.returnValue = false;
437
- };
438
- fixEvent.stopPropagation = function() {
439
- this.cancelBubble = true;
440
- }
441
-
442
- // Dean's forEach: http://dean.edwards.name/base/forEach.js
443
- /*
444
- forEach, version 1.0
445
- Copyright 2006, Dean Edwards
446
- License: http://www.opensource.org/licenses/mit-license.php
447
- */
448
-
449
- // array-like enumeration
450
- if (!Array.forEach) { // mozilla already supports this
451
- Array.forEach = function(array, block, context) {
452
- for (var i = 0; i < array.length; i++) {
453
- block.call(context, array[i], i, array);
454
- }
455
- };
456
- }
457
-
458
- // generic enumeration
459
- Function.prototype.forEach = function(object, block, context) {
460
- for (var key in object) {
461
- if (typeof this.prototype[key] == "undefined") {
462
- block.call(context, object[key], key, object);
463
- }
464
- }
465
- };
466
-
467
- // character enumeration
468
- String.forEach = function(string, block, context) {
469
- Array.forEach(string.split(""), function(chr, index) {
470
- block.call(context, chr, index, string);
471
- });
472
- };
473
-
474
- // globally resolve forEach enumeration
475
- var forEach = function(object, block, context) {
476
- if (object) {
477
- var resolve = Object; // default
478
- if (object instanceof Function) {
479
- // functions have a "length" property
480
- resolve = Function;
481
- } else if (object.forEach instanceof Function) {
482
- // the object implements a custom forEach method so use that
483
- object.forEach(block, context);
484
- return;
485
- } else if (typeof object == "string") {
486
- // the object is a string
487
- resolve = String;
488
- } else if (typeof object.length == "number") {
489
- // the object is array-like
490
- resolve = Array;
491
- }
492
- resolve.forEach(object, block, context);
493
- }
494
- };
495
-
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
+ var stIsIE = /*@cc_on!@*/false;
20
+
21
+ sorttable = {
22
+ init: function() {
23
+ // quit if this function has already been called
24
+ if (arguments.callee.done) return;
25
+ // flag this function so we don't do the same thing twice
26
+ arguments.callee.done = true;
27
+ // kill the timer
28
+ if (_timer) clearInterval(_timer);
29
+
30
+ if (!document.createElement || !document.getElementsByTagName) return;
31
+
32
+ sorttable.DATE_RE = /^(\d\d?)[\/\.-](\d\d?)[\/\.-]((\d\d)?\d\d)$/;
33
+
34
+ forEach(document.getElementsByTagName('table'), function(table) {
35
+ if (table.className.search(/\bsortable\b/) != -1) {
36
+ sorttable.makeSortable(table);
37
+ }
38
+ });
39
+
40
+ },
41
+
42
+ makeSortable: function(table) {
43
+ if (table.getElementsByTagName('thead').length == 0) {
44
+ // table doesn't have a tHead. Since it should have, create one and
45
+ // put the first table row in it.
46
+ the = document.createElement('thead');
47
+ the.appendChild(table.rows[0]);
48
+ table.insertBefore(the,table.firstChild);
49
+ }
50
+ // Safari doesn't support table.tHead, sigh
51
+ if (table.tHead == null) table.tHead = table.getElementsByTagName('thead')[0];
52
+
53
+ if (table.tHead.rows.length != 1) return; // can't cope with two header rows
54
+
55
+ // Sorttable v1 put rows with a class of "sortbottom" at the bottom (as
56
+ // "total" rows, for example). This is B&R, since what you're supposed
57
+ // to do is put them in a tfoot. So, if there are sortbottom rows,
58
+ // for backwards compatibility, move them to tfoot (creating it if needed).
59
+ sortbottomrows = [];
60
+ for (var i=0; i<table.rows.length; i++) {
61
+ if (table.rows[i].className.search(/\bsortbottom\b/) != -1) {
62
+ sortbottomrows[sortbottomrows.length] = table.rows[i];
63
+ }
64
+ }
65
+ if (sortbottomrows) {
66
+ if (table.tFoot == null) {
67
+ // table doesn't have a tfoot. Create one.
68
+ tfo = document.createElement('tfoot');
69
+ table.appendChild(tfo);
70
+ }
71
+ for (var i=0; i<sortbottomrows.length; i++) {
72
+ tfo.appendChild(sortbottomrows[i]);
73
+ }
74
+ delete sortbottomrows;
75
+ }
76
+
77
+ // work through each column and calculate its type
78
+ headrow = table.tHead.rows[0].cells;
79
+ for (var i=0; i<headrow.length; i++) {
80
+ // manually override the type with a sorttable_type attribute
81
+ if (!headrow[i].className.match(/\bsorttable_nosort\b/)) { // skip this col
82
+ mtch = headrow[i].className.match(/\bsorttable_([a-z0-9]+)\b/);
83
+ if (mtch) { override = mtch[1]; }
84
+ if (mtch && typeof sorttable["sort_"+override] == 'function') {
85
+ headrow[i].sorttable_sortfunction = sorttable["sort_"+override];
86
+ } else {
87
+ headrow[i].sorttable_sortfunction = sorttable.guessType(table,i);
88
+ }
89
+ // make it clickable to sort
90
+ headrow[i].sorttable_columnindex = i;
91
+ headrow[i].sorttable_tbody = table.tBodies[0];
92
+ dean_addEvent(headrow[i],"click", sorttable.innerSortFunction = function(e) {
93
+
94
+ if (this.className.search(/\bsorttable_sorted\b/) != -1) {
95
+ // if we're already sorted by this column, just
96
+ // reverse the table, which is quicker
97
+ sorttable.reverse(this.sorttable_tbody);
98
+ this.className = this.className.replace('sorttable_sorted',
99
+ 'sorttable_sorted_reverse');
100
+ this.removeChild(document.getElementById('sorttable_sortfwdind'));
101
+ sortrevind = document.createElement('span');
102
+ sortrevind.id = "sorttable_sortrevind";
103
+ sortrevind.innerHTML = stIsIE ? '&nbsp<font face="webdings">5</font>' : '&nbsp;&#x25B4;';
104
+ this.appendChild(sortrevind);
105
+ return;
106
+ }
107
+ if (this.className.search(/\bsorttable_sorted_reverse\b/) != -1) {
108
+ // if we're already sorted by this column in reverse, just
109
+ // re-reverse the table, which is quicker
110
+ sorttable.reverse(this.sorttable_tbody);
111
+ this.className = this.className.replace('sorttable_sorted_reverse',
112
+ 'sorttable_sorted');
113
+ this.removeChild(document.getElementById('sorttable_sortrevind'));
114
+ sortfwdind = document.createElement('span');
115
+ sortfwdind.id = "sorttable_sortfwdind";
116
+ sortfwdind.innerHTML = stIsIE ? '&nbsp<font face="webdings">6</font>' : '&nbsp;&#x25BE;';
117
+ this.appendChild(sortfwdind);
118
+ return;
119
+ }
120
+
121
+ // remove sorttable_sorted classes
122
+ theadrow = this.parentNode;
123
+ forEach(theadrow.childNodes, function(cell) {
124
+ if (cell.nodeType == 1) { // an element
125
+ cell.className = cell.className.replace('sorttable_sorted_reverse','');
126
+ cell.className = cell.className.replace('sorttable_sorted','');
127
+ }
128
+ });
129
+ sortfwdind = document.getElementById('sorttable_sortfwdind');
130
+ if (sortfwdind) { sortfwdind.parentNode.removeChild(sortfwdind); }
131
+ sortrevind = document.getElementById('sorttable_sortrevind');
132
+ if (sortrevind) { sortrevind.parentNode.removeChild(sortrevind); }
133
+
134
+ this.className += ' sorttable_sorted';
135
+ sortfwdind = document.createElement('span');
136
+ sortfwdind.id = "sorttable_sortfwdind";
137
+ sortfwdind.innerHTML = stIsIE ? '&nbsp<font face="webdings">6</font>' : '&nbsp;&#x25BE;';
138
+ this.appendChild(sortfwdind);
139
+
140
+ // build an array to sort. This is a Schwartzian transform thing,
141
+ // i.e., we "decorate" each row with the actual sort key,
142
+ // sort based on the sort keys, and then put the rows back in order
143
+ // which is a lot faster because you only do getInnerText once per row
144
+ row_array = [];
145
+ col = this.sorttable_columnindex;
146
+ rows = this.sorttable_tbody.rows;
147
+ for (var j=0; j<rows.length; j++) {
148
+ row_array[row_array.length] = [sorttable.getInnerText(rows[j].cells[col]), rows[j]];
149
+ }
150
+ /* If you want a stable sort, uncomment the following line */
151
+ //sorttable.shaker_sort(row_array, this.sorttable_sortfunction);
152
+ /* and comment out this one */
153
+ row_array.sort(this.sorttable_sortfunction);
154
+
155
+ tb = this.sorttable_tbody;
156
+ for (var j=0; j<row_array.length; j++) {
157
+ tb.appendChild(row_array[j][1]);
158
+ }
159
+
160
+ delete row_array;
161
+ });
162
+ }
163
+ }
164
+ },
165
+
166
+ guessType: function(table, column) {
167
+ // guess the type of a column based on its first non-blank row
168
+ sortfn = sorttable.sort_alpha;
169
+ for (var i=0; i<table.tBodies[0].rows.length; i++) {
170
+ text = sorttable.getInnerText(table.tBodies[0].rows[i].cells[column]);
171
+ if (text != '') {
172
+ if (text.match(/^-?[Ł$¤]?[\d,.]+%?$/)) {
173
+ return sorttable.sort_numeric;
174
+ }
175
+ // check for a date: dd/mm/yyyy or dd/mm/yy
176
+ // can have / or . or - as separator
177
+ // can be mm/dd as well
178
+ possdate = text.match(sorttable.DATE_RE)
179
+ if (possdate) {
180
+ // looks like a date
181
+ first = parseInt(possdate[1]);
182
+ second = parseInt(possdate[2]);
183
+ if (first > 12) {
184
+ // definitely dd/mm
185
+ return sorttable.sort_ddmm;
186
+ } else if (second > 12) {
187
+ return sorttable.sort_mmdd;
188
+ } else {
189
+ // looks like a date, but we can't tell which, so assume
190
+ // that it's dd/mm (English imperialism!) and keep looking
191
+ sortfn = sorttable.sort_ddmm;
192
+ }
193
+ }
194
+ }
195
+ }
196
+ return sortfn;
197
+ },
198
+
199
+ getInnerText: function(node) {
200
+ // gets the text we want to use for sorting for a cell.
201
+ // strips leading and trailing whitespace.
202
+ // this is *not* a generic getInnerText function; it's special to sorttable.
203
+ // for example, you can override the cell text with a customkey attribute.
204
+ // it also gets .value for <input> fields.
205
+
206
+ if (!node) return "";
207
+
208
+ hasInputs = (typeof node.getElementsByTagName == 'function') &&
209
+ node.getElementsByTagName('input').length;
210
+
211
+ if (node.getAttribute("sorttable_customkey") != null) {
212
+ return node.getAttribute("sorttable_customkey");
213
+ }
214
+ else if (typeof node.textContent != 'undefined' && !hasInputs) {
215
+ return node.textContent.replace(/^\s+|\s+$/g, '');
216
+ }
217
+ else if (typeof node.innerText != 'undefined' && !hasInputs) {
218
+ return node.innerText.replace(/^\s+|\s+$/g, '');
219
+ }
220
+ else if (typeof node.text != 'undefined' && !hasInputs) {
221
+ return node.text.replace(/^\s+|\s+$/g, '');
222
+ }
223
+ else {
224
+ switch (node.nodeType) {
225
+ case 3:
226
+ if (node.nodeName.toLowerCase() == 'input') {
227
+ return node.value.replace(/^\s+|\s+$/g, '');
228
+ }
229
+ case 4:
230
+ return node.nodeValue.replace(/^\s+|\s+$/g, '');
231
+ break;
232
+ case 1:
233
+ case 11:
234
+ var innerText = '';
235
+ for (var i = 0; i < node.childNodes.length; i++) {
236
+ innerText += sorttable.getInnerText(node.childNodes[i]);
237
+ }
238
+ return innerText.replace(/^\s+|\s+$/g, '');
239
+ break;
240
+ default:
241
+ return '';
242
+ }
243
+ }
244
+ },
245
+
246
+ reverse: function(tbody) {
247
+ // reverse the rows in a tbody
248
+ newrows = [];
249
+ for (var i=0; i<tbody.rows.length; i++) {
250
+ newrows[newrows.length] = tbody.rows[i];
251
+ }
252
+ for (var i=newrows.length-1; i>=0; i--) {
253
+ tbody.appendChild(newrows[i]);
254
+ }
255
+ delete newrows;
256
+ },
257
+
258
+ /* sort functions
259
+ each sort function takes two parameters, a and b
260
+ you are comparing a[0] and b[0] */
261
+ sort_numeric: function(a,b) {
262
+ aa = parseFloat(a[0].replace(/[^0-9.-]/g,''));
263
+ if (isNaN(aa)) aa = 0;
264
+ bb = parseFloat(b[0].replace(/[^0-9.-]/g,''));
265
+ if (isNaN(bb)) bb = 0;
266
+ return aa-bb;
267
+ },
268
+ sort_alpha: function(a,b) {
269
+ if (a[0]==b[0]) return 0;
270
+ if (a[0]<b[0]) return -1;
271
+ return 1;
272
+ },
273
+ sort_ddmm: function(a,b) {
274
+ mtch = a[0].match(sorttable.DATE_RE);
275
+ y = mtch[3]; m = mtch[2]; d = mtch[1];
276
+ if (m.length == 1) m = '0'+m;
277
+ if (d.length == 1) d = '0'+d;
278
+ dt1 = y+m+d;
279
+ mtch = b[0].match(sorttable.DATE_RE);
280
+ y = mtch[3]; m = mtch[2]; d = mtch[1];
281
+ if (m.length == 1) m = '0'+m;
282
+ if (d.length == 1) d = '0'+d;
283
+ dt2 = y+m+d;
284
+ if (dt1==dt2) return 0;
285
+ if (dt1<dt2) return -1;
286
+ return 1;
287
+ },
288
+ sort_mmdd: function(a,b) {
289
+ mtch = a[0].match(sorttable.DATE_RE);
290
+ y = mtch[3]; d = mtch[2]; m = mtch[1];
291
+ if (m.length == 1) m = '0'+m;
292
+ if (d.length == 1) d = '0'+d;
293
+ dt1 = y+m+d;
294
+ mtch = b[0].match(sorttable.DATE_RE);
295
+ y = mtch[3]; d = mtch[2]; m = mtch[1];
296
+ if (m.length == 1) m = '0'+m;
297
+ if (d.length == 1) d = '0'+d;
298
+ dt2 = y+m+d;
299
+ if (dt1==dt2) return 0;
300
+ if (dt1<dt2) return -1;
301
+ return 1;
302
+ },
303
+
304
+ shaker_sort: function(list, comp_func) {
305
+ // A stable sort function to allow multi-level sorting of data
306
+ // see: http://en.wikipedia.org/wiki/Cocktail_sort
307
+ // thanks to Joseph Nahmias
308
+ var b = 0;
309
+ var t = list.length - 1;
310
+ var swap = true;
311
+
312
+ while(swap) {
313
+ swap = false;
314
+ for(var i = b; i < t; ++i) {
315
+ if ( comp_func(list[i], list[i+1]) > 0 ) {
316
+ var q = list[i]; list[i] = list[i+1]; list[i+1] = q;
317
+ swap = true;
318
+ }
319
+ } // for
320
+ t--;
321
+
322
+ if (!swap) break;
323
+
324
+ for(var i = t; i > b; --i) {
325
+ if ( comp_func(list[i], list[i-1]) < 0 ) {
326
+ var q = list[i]; list[i] = list[i-1]; list[i-1] = q;
327
+ swap = true;
328
+ }
329
+ } // for
330
+ b++;
331
+
332
+ } // while(swap)
333
+ }
334
+ }
335
+
336
+ /* ******************************************************************
337
+ Supporting functions: bundled here to avoid depending on a library
338
+ ****************************************************************** */
339
+
340
+ // Dean Edwards/Matthias Miller/John Resig
341
+
342
+ /* for Mozilla/Opera9 */
343
+ if (document.addEventListener) {
344
+ document.addEventListener("DOMContentLoaded", sorttable.init, false);
345
+ }
346
+
347
+ /* for Internet Explorer */
348
+ /*@cc_on @*/
349
+ /*@if (@_win32)
350
+ document.write("<script id=__ie_onload defer src=javascript:void(0)><\/script>");
351
+ var script = document.getElementById("__ie_onload");
352
+ script.onreadystatechange = function() {
353
+ if (this.readyState == "complete") {
354
+ sorttable.init(); // call the onload handler
355
+ }
356
+ };
357
+ /*@end @*/
358
+
359
+ /* for Safari */
360
+ if (/WebKit/i.test(navigator.userAgent)) { // sniff
361
+ var _timer = setInterval(function() {
362
+ if (/loaded|complete/.test(document.readyState)) {
363
+ sorttable.init(); // call the onload handler
364
+ }
365
+ }, 10);
366
+ }
367
+
368
+ /* for other browsers */
369
+ window.onload = sorttable.init;
370
+
371
+ // written by Dean Edwards, 2005
372
+ // with input from Tino Zijdel, Matthias Miller, Diego Perini
373
+
374
+ // http://dean.edwards.name/weblog/2005/10/add-event/
375
+
376
+ function dean_addEvent(element, type, handler) {
377
+ if (element.addEventListener) {
378
+ element.addEventListener(type, handler, false);
379
+ } else {
380
+ // assign each event handler a unique ID
381
+ if (!handler.$$guid) handler.$$guid = dean_addEvent.guid++;
382
+ // create a hash table of event types for the element
383
+ if (!element.events) element.events = {};
384
+ // create a hash table of event handlers for each element/event pair
385
+ var handlers = element.events[type];
386
+ if (!handlers) {
387
+ handlers = element.events[type] = {};
388
+ // store the existing event handler (if there is one)
389
+ if (element["on" + type]) {
390
+ handlers[0] = element["on" + type];
391
+ }
392
+ }
393
+ // store the event handler in the hash table
394
+ handlers[handler.$$guid] = handler;
395
+ // assign a global event handler to do all the work
396
+ element["on" + type] = handleEvent;
397
+ }
398
+ };
399
+ // a counter used to create unique IDs
400
+ dean_addEvent.guid = 1;
401
+
402
+ function removeEvent(element, type, handler) {
403
+ if (element.removeEventListener) {
404
+ element.removeEventListener(type, handler, false);
405
+ } else {
406
+ // delete the event handler from the hash table
407
+ if (element.events && element.events[type]) {
408
+ delete element.events[type][handler.$$guid];
409
+ }
410
+ }
411
+ };
412
+
413
+ function handleEvent(event) {
414
+ var returnValue = true;
415
+ // grab the event object (IE uses a global event object)
416
+ event = event || fixEvent(((this.ownerDocument || this.document || this).parentWindow || window).event);
417
+ // get a reference to the hash table of event handlers
418
+ var handlers = this.events[event.type];
419
+ // execute each event handler
420
+ for (var i in handlers) {
421
+ this.$$handleEvent = handlers[i];
422
+ if (this.$$handleEvent(event) === false) {
423
+ returnValue = false;
424
+ }
425
+ }
426
+ return returnValue;
427
+ };
428
+
429
+ function fixEvent(event) {
430
+ // add W3C standard event methods
431
+ event.preventDefault = fixEvent.preventDefault;
432
+ event.stopPropagation = fixEvent.stopPropagation;
433
+ return event;
434
+ };
435
+ fixEvent.preventDefault = function() {
436
+ this.returnValue = false;
437
+ };
438
+ fixEvent.stopPropagation = function() {
439
+ this.cancelBubble = true;
440
+ }
441
+
442
+ // Dean's forEach: http://dean.edwards.name/base/forEach.js
443
+ /*
444
+ forEach, version 1.0
445
+ Copyright 2006, Dean Edwards
446
+ License: http://www.opensource.org/licenses/mit-license.php
447
+ */
448
+
449
+ // array-like enumeration
450
+ if (!Array.forEach) { // mozilla already supports this
451
+ Array.forEach = function(array, block, context) {
452
+ for (var i = 0; i < array.length; i++) {
453
+ block.call(context, array[i], i, array);
454
+ }
455
+ };
456
+ }
457
+
458
+ // generic enumeration
459
+ Function.prototype.forEach = function(object, block, context) {
460
+ for (var key in object) {
461
+ if (typeof this.prototype[key] == "undefined") {
462
+ block.call(context, object[key], key, object);
463
+ }
464
+ }
465
+ };
466
+
467
+ // character enumeration
468
+ String.forEach = function(string, block, context) {
469
+ Array.forEach(string.split(""), function(chr, index) {
470
+ block.call(context, chr, index, string);
471
+ });
472
+ };
473
+
474
+ // globally resolve forEach enumeration
475
+ var forEach = function(object, block, context) {
476
+ if (object) {
477
+ var resolve = Object; // default
478
+ if (object instanceof Function) {
479
+ // functions have a "length" property
480
+ resolve = Function;
481
+ } else if (object.forEach instanceof Function) {
482
+ // the object implements a custom forEach method so use that
483
+ object.forEach(block, context);
484
+ return;
485
+ } else if (typeof object == "string") {
486
+ // the object is a string
487
+ resolve = String;
488
+ } else if (typeof object.length == "number") {
489
+ // the object is array-like
490
+ resolve = Array;
491
+ }
492
+ resolve.forEach(object, block, context);
493
+ }
494
+ };
495
+