From 66eff923a353c2bc8d855083a3dd9e2562f7ea7b Mon Sep 17 00:00:00 2001 From: Bill Marquette Date: Fri, 5 Oct 2007 21:11:53 +0000 Subject: Ticket #1448: IP Address sorting was MFC'd from HEAD (this whole file should probably be MFC'd) MFC: to RELENG_1_2 --- usr/local/www/javascript/sorttable.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/usr/local/www/javascript/sorttable.js b/usr/local/www/javascript/sorttable.js index 9995de0..bbcca46 100644 --- a/usr/local/www/javascript/sorttable.js +++ b/usr/local/www/javascript/sorttable.js @@ -69,6 +69,7 @@ function ts_resortTable(lnk) { if (itm.match(/^\d\d[\/-]\d\d[\/-]\d\d$/)) sortfn = ts_sort_date; if (itm.match(/^[£$]/)) sortfn = ts_sort_currency; if (itm.match(/^[\d\.]+$/)) sortfn = ts_sort_numeric; + if (itm.match(/^\s*[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\s*$/)) sortfn = ts_sortIpAddress; SORT_COLUMN_INDEX = column; var firstRow = new Array(); var newRows = new Array(); @@ -149,6 +150,18 @@ function ts_sort_numeric(a,b) { return aa-bb; } +function ts_sortIpAddress(a, b) { + var oa = a.split("."); + var ob = b.split("."); + + for(var i = 0; i < 4; i++) { + if(parseInt(oa[i]) < parseInt(ob[i])) return -1; + if(parseInt(oa[i]) > parseInt(ob[i])) return 1; + } + return 0; +} + + function ts_sort_caseinsensitive(a,b) { aa = ts_getInnerText(a.cells[SORT_COLUMN_INDEX]).toLowerCase(); bb = ts_getInnerText(b.cells[SORT_COLUMN_INDEX]).toLowerCase(); -- cgit v1.1