Devel-Cover

 view release on metacpan or  search on metacpan

lib/Devel/Cover/Web.pm  view on Meta::CPAN

        }
    },

    sortDate : function(a,b) {
        var that = standardistaTableSorting.that;

        // y2k notes: two digit years less than 50 are treated as 20XX,
        // greater than 50 are treated as 19XX
        var aa = that.getInnerText(a.cells[that.sortColumnIndex]);
        var bb = that.getInnerText(b.cells[that.sortColumnIndex]);

        var dt1, dt2, yr = -1;

        if (aa.length == 10) {
            dt1 = aa.substr(6,4)+aa.substr(3,2)+aa.substr(0,2);
        } else {
            yr = aa.substr(6,2);
            if (parseInt(yr) < 50) {
                yr = '20'+yr;
            } else {
                yr = '19'+yr;
            }
            dt1 = yr+aa.substr(3,2)+aa.substr(0,2);
        }

        if (bb.length == 10) {
            dt2 = bb.substr(6,4)+bb.substr(3,2)+bb.substr(0,2);
        } else {
            yr = bb.substr(6,2);
            if (parseInt(yr) < 50) {
                yr = '20'+yr;
            } else {
                yr = '19'+yr;
            }
            dt2 = yr+bb.substr(3,2)+bb.substr(0,2);
        }

        if (dt1==dt2) {
            return 0;
        } else if (dt1<dt2) {
            return -1;
        }
        return 1;
    },

    sortCurrency : function(a,b) {
        var that = standardistaTableSorting.that;

        var aa = that.getInnerText(a.cells[that.sortColumnIndex])
            .replace(/[^0-9.]/g,'');
        var bb = that.getInnerText(b.cells[that.sortColumnIndex])
            .replace(/[^0-9.]/g,'');
        return parseFloat(aa) - parseFloat(bb);
    },

    get_val : function(x) {
        var that = standardistaTableSorting.that;

        var val = that.getInnerText(x.cells[that.sortColumnIndex]);
        var v   = val == "n/a" ? -1 : parseFloat(val);
        return isNaN(v) ? 0 : v;
    },

    sortNumeric : function(a, b) {
        var that = standardistaTableSorting.that;

        var aval = that.get_val(a);
        var bval = that.get_val(b);

        return aval - bval;
    },

    makeStandardIPAddress : function(val) {
        var vals = val.split('.');

        for (x in vals) {
            val = vals[x];

            while (3 > val.length) {
                val = '0'+val;
            }
            vals[x] = val;
        }

        val = vals.join('.');

        return val;
    },

    sortIP : function(a,b) {
        var that = standardistaTableSorting.that;

        var aa = that.makeStandardIPAddress(
            that.getInnerText(a.cells[that.sortColumnIndex]).toLowerCase());
        var bb = that.makeStandardIPAddress(
            that.getInnerText(b.cells[that.sortColumnIndex]).toLowerCase());
        if (aa==bb) {
            return 0;
        } else if (aa<bb) {
            return -1;
        } else {
            return 1;
        }
    },

    moveRows : function(table, newRows) {
        this.isOdd = false;

        // We appendChild rows that already exist to the tbody, so it moves
        // them rather than creating new ones
        for (var i=0;i<newRows.length;i++) {
            var rowItem = newRows[i];

            this.doStripe(rowItem);

            table.tBodies[0].appendChild(rowItem);
        }
    },

    doStripe : function(rowItem) {
        if (this.isOdd) {



( run in 3.319 seconds using v1.01-cache-2.11-cpan-97f6503c9c8 )