Restructure dashboard project for docker deploying
[pharos.git] / tools / pharos-dashboard / src / static / js / dataTables-sort.js
1 /*****************************************************************************
2 * Copyright (c) 2016 Max Breitenfeldt and others.
3 *
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Apache License, Version 2.0
6 * which accompanies this distribution, and is available at
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *****************************************************************************/
9
10
11 /**
12  * This is a sort function for dataTables to sort tables by the status column.
13  * The order should be: online < online/idle < offline
14  */
15 jQuery.extend(jQuery.fn.dataTableExt.oSort, {
16     "status-pre": function (a) {
17         switch (a) {
18             case 'online':
19                 return 1;
20             case 'online / idle':
21                 return 2;
22             case 'offline':
23                 return 3;
24             default:
25                 return a;
26         }
27     },
28
29     "status-asc": function (a, b) {
30         return ((a < b) ? -1 : ((a > b) ? 1 : 0));
31     },
32
33     "status-desc": function (a, b) {
34         return ((a < b) ? 1 : ((a > b) ? -1 : 0));
35     }
36 });