1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Column sorting problems

Discussion in 'Tomato Firmware' started by tony550, Jul 13, 2012.

  1. tony550

    tony550 Serious Server Member

    I am using Shibby 095 for a couple of new routers and I noticed some problems with the column sorts:

    1. IPTraffic->(Daily, Monthly)
    - all columns broken, except date.

    2. Tools->WOL
    - IP address column broken

    3. In various places, the IP address column did not sort right if "Show shortcuts" was selected.

    I patched a few things and now it works better for me. I have never patched javascript before, so someone should double check this before putting it into git. I completely release all claims to the following patches.

    For problem 1:
    Code:
    diff --git a/release/src/router/www/ipt-daily.asp b/release/src/router/www/ipt-daily.asp
    index ba30d33..5b2cd4e 100644
    --- a/release/src/router/www/ipt-daily.asp
    +++ b/release/src/router/www/ipt-daily.asp
    @@ -249,13 +249,17 @@ dg.sortCompare = function(a, b) {
            var r = 0;
            switch (col) {
            case 0: // Date
    -      case 1: // Hostname
                    r = cmpText(da[col], db[col]);
                    break;
    +      case 1: // Hostname
    +              r = cmpIP(da[col], db[col]);
    +              if (r == 0)
    +                      r = cmpText(da[col], db[col]);
    +              break;
            case 2: // Download
            case 3: // Upload
            case 4: // Total
    -              r = cmpFloat(parseFloat(da[col].replace(",","")), parseFloat(db[col].replace(",","")));
    +              r = cmpFloat(da[col].replace(/,/g,""), db[col].replace(/,/g,""));
                    break;
            }
            return this.sortAscending ? r : -r;
    diff --git a/release/src/router/www/ipt-monthly.asp b/release/src/router/www/ipt-monthly.asp
    index f63de72..27a3df5 100644
    --- a/release/src/router/www/ipt-monthly.asp
    +++ b/release/src/router/www/ipt-monthly.asp
    @@ -249,13 +249,17 @@ dg.sortCompare = function(a, b) {
            var r = 0;
            switch (col) {
            case 0: // Date
    -      case 1: // Hostname
                    r = cmpText(da[col], db[col]);
                    break;
    +      case 1: // Hostname
    +              r = cmpIP(da[col], db[col]);
    +              if (r == 0)
    +                      r = cmpText(da[col], db[col]);
    +              break;
            case 2: // Download
            case 3: // Upload
            case 4: // Total
    -              r = cmpFloat(parseFloat(da[col].replace(",","")), parseFloat(db[col].replace(",","")));
    +              r = cmpFloat(da[col].replace(/,/g,""), db[col].replace(/,/g,""));
                    break;
            }
            return this.sortAscending ? r : -r;
    
    For problem 2:
    Code:
    diff --git a/release/src/router/www/tools-wol.asp b/release/src/router/www/tools-wol.asp
    index 331fc4d..d214e3e 100644
    --- a/release/src/router/www/tools-wol.asp
    +++ b/release/src/router/www/tools-wol.asp
    @@ -53,6 +53,17 @@ wg.setup = function() {
            this.headerSet(['MAC Address', 'IP Address', 'Status', 'Name']);
            this.sort(3);
    }
    +wg.sortCompare = function(a, b) {
    +      var da = a.getRowData();
    +      var db = b.getRowData();
    +      var r = 0;
    +      var c = this.sortColumn;
    +      if (c == 1)
    +              r = cmpIP(da[c], db[c]);
    +      else
    +              r = cmpText(da[c], db[c]);
    +      return this.sortAscending ? r : -r;
    +}
    wg.populate = function()
    {
            var i, j, r, s;
    
    For problem 3:
    Code:
    diff --git a/release/src/router/www/tomato.js b/release/src/router/www/tomato.js
    index 628f687..4250c1c 100644
    --- a/release/src/router/www/tomato.js
    +++ b/release/src/router/www/tomato.js
    @@ -480,7 +480,12 @@ function fixIP(ip, x)
    {
            var a, n, i;
     
    -      a = ip.split('.');
    +      a = ip;
    +      i = a.indexOf("<br>");
    +      if (i > 0)
    +              a = a.slice(0,i);
    +
    +      a = a.split('.');
            if (a.length != 4) return null;
            for (i = 0; i < 4; ++i) {
                    n = a[i] * 1;
    
     
  2. shibby20

    shibby20 Network Guru Member

    thx. I have ready to publish new build 097, well your fixes i will add with new (098?) release.
    Best Regaeds!
     

Share This Page