Home directory for Malawi's wwwroot
Duncan Ewan
2021-02-19 3e758c29e0fde36fc088efcfc88f9a3014432b64
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// Thanks to Bernhard Wagner for submitting this function
 
function replace8a8(str) {
    str = str.toUpperCase();
    var splitstr = "____";
    var ar = str.replace(
        /(([0-9]*\.)?[0-9]+([eE][-+]?[0-9]+)?)(.*)/,
     "$1"+splitstr+"$4").split(splitstr);
    var num = Number(ar[0]).valueOf();
    var ml = ar[1].replace(/\s*([KMGB])\s*/, "$1");
 
    if (ml == "K")
        num *= 1024;
    else if(ml == "M")
        num *= 1024 * 1024;
    else if (ml == "G")
        num *= 1024 * 1024 * 1024;
    else if (ml == "T")
        num *= 1024 * 1024 * 1024 * 1024;
    // B and no prefix
 
    return num;
}
 
SortableTable.prototype.addSortType( "NumberK", replace8a8 );