sort function for Last Contact columns
authorBarış Metin <Talip-Baris.Metin@sophia.inria.fr>
Thu, 2 Jul 2009 14:25:53 +0000 (14:25 +0000)
committerBarış Metin <Talip-Baris.Metin@sophia.inria.fr>
Thu, 2 Jul 2009 14:25:53 +0000 (14:25 +0000)
plekit/table/table.css
plekit/tablesort/customsort.js

index c164981..1ba1fe6 100644 (file)
@@ -62,6 +62,7 @@ th.sortable-sortScientificNotation,
 th.sortable-sortImage,
 th.sortable-sortFileSize,
 th.sortable-sortBandwidth,
+th.sortable-sortLastContact,
 th.sortable-sortAlphaNumeric,
 th.sortable-sortEnglishDateTime {
     cursor:pointer;
index a31af9e..4155b2b 100644 (file)
@@ -380,3 +380,33 @@ function sortBandwidthPrepareData(td, innerText) {
 
         return isNaN(innerText) ? "" : innerText * mult;
 };
+
+
+var sortLastContact = fdTableSort.sortNumeric;
+
+function sortLastContactPrepareData(td, innerText) {
+    var regExp = /(min|hrs|days|wks|mnths)/i;
+
+    var type = innerText.search(regExp) != -1 ? innerText.match(regExp)[0] : "";
+
+    switch (type.toLowerCase()) {
+    case "hrs" :
+        mult = 60;
+        break;
+    case "days" :
+        mult = 60*24;
+        break;
+    case "wks" :
+        mult = 60*24*7;
+        break;
+    case "mnths" :
+        mult = 60*24*30;
+        break;
+    default :
+        mult = 1;
+    };
+
+    innerText = parseFloat(innerText.replace(/[^0-9\.\-]/g,''));
+
+    return isNaN(innerText) ? "" : innerText * mult;
+};
\ No newline at end of file