7189ca150b66061ec893e76be151985377706626
[pharos.git] / tools / pharos-dashboard / static / js / dataTables-sort.js
1 /**
2  * This is a sort function for dataTables to sort tables by the status column.
3  * The order should be: online < online/idle < offline
4  */
5 jQuery.extend(jQuery.fn.dataTableExt.oSort, {
6     "status-pre": function (a) {
7         switch (a) {
8             case 'online':
9                 return 1;
10             case 'online / idle':
11                 return 2;
12             case 'offline':
13                 return 3;
14             default:
15                 return a;
16         }
17     },
18
19     "status-asc": function (a, b) {
20         return ((a < b) ? -1 : ((a > b) ? 1 : 0));
21     },
22
23     "status-desc": function (a, b) {
24         return ((a < b) ? 1 : ((a > b) ? -1 : 0));
25     }
26 });