SoFunction
Updated on 2025-04-10

Auntion-TableSort javascript class file page 1/2


Copy the codeThe code is as follows:

/*
*   The table name cannot be empty, it can be an object or name that has been retrieved
*   The header name of the table is: tag
*      Different trigger sorting methods can be achieved by writing the interface by yourself
*    
*    Author:Auntion
*    E-mail:Auntion@
*    OICQ:82874972
*    
*   Date: April 22, 2007 - Test - To be corrected
*/

var tableSort= function(element,tagName,upStyle,downStyle){= (typeof(element) == 'string') ? (element) : element;   = ("td");    = (<1) ? "tag" : tagName; = ; = (upStyle == undefined) ? "DescUp" : upStyle ; = (downStyle == undefined) ? "DescDown" : downStyle ;var totalTd = [];var totalNr = [];var totalTag= [];;     = {};var setAllTag = function(){                    for(var i = 0; i < ; i++){if([i].className === ) ([i]);}}.bind(this);var getStatus = function(tagName){[tagName] = ([tagName] == true) ? false : true;for(tags in ){if(tags == tagName) return [tags];else delete [tags];}}.bind(this);var changeShow = function(cellIn,status){for(var i=0; i<; i++){if(totalTag[i].cellIndex == cellIn){if(status == true) totalTag[i].className = ;else if(status == false) totalTag[i].className = ;}else{totalTag[i].className = ;}}}.bind(this);var startSort = function(status){for (var i = totalNr[].length - 1; i > 0; i--){for (var j = 0; j < i; ++j){if ( (status == true) ? totalNr[][j] > totalNr[][j + 1] : totalNr[][j] < totalNr[][j + 1] ){var temp = totalNr[][j + 1];totalNr[][j + 1] = totalNr[][j];totalNr[][j] = temp;for(var n=0; n<; n++){if(n != ){var temps = totalNr[n][j+1];totalNr[n][j + 1] = totalNr[n][j];totalNr[n][j] = temps;}}}}};InsertContect();}.bind(this);var InsertContect = function(){                for(var i=0; i<; i++){for(var j=0; j<totalTd[i].length; j++){totalTd[i][j].innerHTML = totalNr[i][j];}}; = 0; = 0;}; = function(status){for(var i=0; i<(/); i++){totalTd[i] = new Array();totalNr[i] = new Array();for(var j=0; j<; j++){if([j].cells[i].className !== ){totalTd[i][j-1] = [j].cells[i];if(IsNumber([j].cells[i].innerHTML) == true){totalNr[i][j-1] = parseInt([j].cells[i].innerHTML);}else{totalNr[i][j-1] = [j].cells[i].innerHTML;}}}}startSort(status);}    

/********************************************************************************************************************************/

/**Trigger sorting event by clicking on the tag**/
//public: Triggered via the default mouse key (interface example) (example for setting user interface)
     = function(){        
setAllTag();    //Get tags
        for(var i=0; i<; i++){        
totalTag[i].sIndex  = function(cIndex){ =cIndex }.bind(this);    //Set column index
totalTag[i].gStatus = function(values){ return getStatus(values)};                                                                                                             �
totalTag[i].ceShow = function(i,s){ changeShow(i,s)};
totalTag[i].stSort = function(status){ (status)}.bind(this);                                                                                                             �
totalTag[i].onselectstart= function(){ return false };                                                                                                               �
            totalTag[i].onclick = function(){
                ();
                 = ();
                (,);
                ();
            }

        }
    }

}


Copy the codeThe code is as follows:

/*
*
By Auntion

QQ:82874972

Blog:Auntion@

Email:Auntion@

Please do not delete this part of the comments. Thank you!

ver date-2007-02-01
*
*/
var isIe = /msie/();
var TAGDom = {
    fromId: function(i){
        return (i);
    },
    fromName: function(i){
        return (i);
    },
    fromClass: function(className,baseId) {
         = null;
        if(!baseId){
             = document;
        }else{
             = (baseId);
        }
        var basic = ("*") || ; 
        var child = null;
        var classNames = null;

        var aggregate = []; 
        for (var i = 0; i < ; i++) {
            child = basic[i]; 
            classNames = (" "); 
            for (var j = 0; j < ; j++) {
                if (classNames[j] == className) { 
                    (child); 
                    break; 
                }
            } 
        } 
        return aggregate; 
    }
};
function externalStyle (element, target) {      
    ;
    if (){    
         = [target];    
    }else if (){
         = getComputedStyle (element,"").getPropertyValue(target);
    }
    return ;
}
 = function(){
    return parseInt((/[a-zA-Z]+/,''));
}
 = function(){
    return (/(^\s*)|(\s*$)/g, "");
}
 = function(e) {
    var source = this;
    return function() {
        return (e,arguments);
    }
}
function IsNumber(_str){ 
    var tmp_str = _str.trim(); 
    var pattern = /^(-  ¦\+)?\d+(\d+)?$/;
    return (tmp_str);   


Usage example_1.htm
12Next pageRead the full text