一区二区久久-一区二区三区www-一区二区三区久久-一区二区三区久久精品-麻豆国产一区二区在线观看-麻豆国产视频

Auntion-TableSort javascript類文件第1/2頁

tableSort.class.js
復制代碼 代碼如下:
/*
*    表格名不能為空,可為已獲取的對象或名字
*    表頭名默認為:tag
*    通過自行編寫接口可實現不同的觸發排序方式
*    
*    作者:Auntion
*    E-mail:Auntion@Gmail.com
*    OICQ:82874972
*    
*    日期:2007年04月22日 - 測試 - 待修正
*/

var tableSort= function(element,tagName,upStyle,downStyle){this.table= (typeof(element) == 'string') ? TAGDom.fromId(element) : element;this.td   = this.table.getElementsByTagName("td");    this.hName= (tagName.length<1) ? "tag" : tagName;this.rows = this.table.rows;this.byUp = (upStyle == undefined) ? "DescUp" : upStyle ;this.byDown = (downStyle == undefined) ? "DescDown" : downStyle ;var totalTd = [];var totalNr = [];var totalTag= [];this.tempCellIndex;    this.tempStatus = {};var setAllTag = function(){                    for(var i = 0; i < this.td.length; i++){if(this.td[i].className === this.hName) totalTag.push(this.td[i]);}}.bind(this);var getStatus = function(tagName){this.tempStatus[tagName] = (this.tempStatus[tagName] == true) ? false : true;for(tags in this.tempStatus){if(tags == tagName) return this.tempStatus[tags];else delete this.tempStatus[tags];}}.bind(this);var changeShow = function(cellIn,status){for(var i=0; i<totalTag.length; i++){if(totalTag[i].cellIndex == cellIn){if(status == true) totalTag[i].className = this.byUp;else if(status == false) totalTag[i].className = this.byDown;}else{totalTag[i].className = this.hName;}}}.bind(this);var startSort = function(status){for (var i = totalNr[this.tempCellIndex].length - 1; i > 0; i--){for (var j = 0; j < i; ++j){if ( (status == true) ? totalNr[this.tempCellIndex][j] > totalNr[this.tempCellIndex][j + 1] : totalNr[this.tempCellIndex][j] < totalNr[this.tempCellIndex][j + 1] ){var temp = totalNr[this.tempCellIndex][j + 1];totalNr[this.tempCellIndex][j + 1] = totalNr[this.tempCellIndex][j];totalNr[this.tempCellIndex][j] = temp;for(var n=0; n<totalNr.length; n++){if(n != this.tempCellIndex){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<totalTd.length; i++){for(var j=0; j<totalTd[i].length; j++){totalTd[i][j].innerHTML = totalNr[i][j];}};totalTd.length = 0;totalNr.length = 0;};this.init = function(status){for(var i=0; i<(this.td.length/this.rows.length); i++){totalTd[i] = new Array();totalNr[i] = new Array();for(var j=0; j<this.rows.length; j++){if(this.rows[j].cells[i].className !== this.hName){totalTd[i][j-1] = this.rows[j].cells[i];if(IsNumber(this.rows[j].cells[i].innerHTML) == true){totalNr[i][j-1] = parseInt(this.rows[j].cells[i].innerHTML);}else{totalNr[i][j-1] = this.rows[j].cells[i].innerHTML;}}}}startSort(status);}    

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

/**通過點擊標簽觸發排序事件**/
    //public: 通過默認鼠標事鍵觸發 (interface example)(設置用戶接口的范例)
    this.toTagStart = function(){        
        setAllTag();    //獲取標簽
        for(var i=0; i<totalTag.length; i++){        
            totalTag[i].sIndex  = function(cIndex){ this.tempCellIndex=cIndex }.bind(this);    //設置列index
            totalTag[i].gStatus = function(values){ return getStatus(values) };                //獲取與設置狀態
            totalTag[i].ceShow  = function(i,s){ changeShow(i,s) };                            //改變顯示的東西
            totalTag[i].stSort  = function(status){ this.init(status) }.bind(this);            //初始化
            totalTag[i].onselectstart = function(){ return false };                //點擊不選中文字
            totalTag[i].onclick = function(){
                this.sIndex(this.cellIndex);
                this.status = this.gStatus(this.firstChild.nodeValue);
                this.ceShow(this.cellIndex,this.status);
                this.stSort(this.status);
            }

        }
    }

}

Language.ext.js
復制代碼 代碼如下:
/*
*
By Auntion

QQ:82874972

Blog:Auntion@blogbus.com

Email:Auntion@Gmail.com

請勿刪除此部分注釋.謝謝!

ver date-2007-02-01
*
*/
var isIe = /msie/i.test(navigator.userAgent);
var TAGDom = {
    fromId: function(i){
        return document.getElementById(i);
    },
    fromName: function(i){
        return document.getElementById(i);
    },
    fromClass: function(className,baseId) {
        this.fatherId = null;
        if(!baseId){
            this.fatherId = document;
        }else{
            this.fatherId = DOM.fromId(baseId);
        }
        var basic = fatherId.getElementsByTagName("*") || document.all; 
        var child = null;
        var classNames = null;

        var aggregate = []; 
        for (var i = 0; i < basic.length; i++) {
            child = basic[i]; 
            classNames = child.className.split(" "); 
            for (var j = 0; j < classNames.length; j++) {
                if (classNames[j] == className) { 
                    aggregate.push(child); 
                    break; 
                }
            } 
        } 
        return aggregate; 
    }
};
function externalStyle (element, target) {      
    this.setReturn;
    if (element.currentStyle){    
        this.setReturn = element.currentStyle[target];    
    }else if (window.getComputedStyle){
        this.setReturn = getComputedStyle (element,"").getPropertyValue(target);
    }
    return this.setReturn;
}
String.prototype.toInt = function(){
    return parseInt(this.replace(/[a-zA-Z]+/,''));
}
String.prototype.trim = function(){
    return this.replace(/(^/s*)|(/s*$)/g, "");
}
Function.prototype.bind = function(e) {
    var source = this;
    return function() {
        return source.apply(e,arguments);
    }
}
function IsNumber(_str){ 
    var tmp_str = _str.trim(); 
    var pattern = /^(-  ¦/+)?/d+(/d+)?$/;
    return pattern.test(tmp_str);   


使用實例_1.htm

JavaScript技術Auntion-TableSort javascript類文件第1/2頁,轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 黄站视频 | 国产精品麻豆一区二区 | 欧美激情视频一区 | 国产精品免费_区二区三区观看 | 5月婷婷6月丁香 | 伊人久久免费视频 | 国产片欧美片亚洲片久久综合 | 国产一进一出视频网站 | 天天躁天天弄天天爱 | 国产精品91av | 久久激情综合网 | 亚州国产 | 午夜国产福利在线观看 | 久久www免费人成精品 | 欧美日本在线一区二区三区 | 亚洲夜色 | 一区二区三区免费视频观看 | 日本加勒比网站 | 亚洲精品第一页 | 免费啪视频观在线视频在线 | 一区二区高清视频 | 亚洲人成综合在线播放 | 永久免费观看午夜视频在线 | 欧美裸妇 | 久久精品道一区二区三区 | 午夜欧美 | 巨人导航收录500精品 | 999无色码中文字幕 999影院成 人在线影院 | 亚洲经典在线中文字幕 | 五月婷婷在线免费观看 | 久久伊人精品一区二区三区 | 国产对白精品刺激一区二区 | 国产精品夜色视频一区二区 | 狠狠色婷婷丁香六月 | 天天躁日日躁狠狠躁中文字幕老牛 | 亚洲一区二区三区麻豆 | 四虎在线永久免费视频网站 | 最新精品国偷自产在线91 | 美女视频一区二区 | 热久久伊人 | 久久夜色精品国产欧美 |