TableSort.class.js
Copy Code code as follows:
/*
* The table name cannot be empty and can be an object or name that has been acquired
* Table header names defaults to: Tag
* A different trigger ordering method can be implemented by writing the interface
*
* Author: auntion
* e-mail:auntion@gmail.com
* oicq:82874972
*
* Date: April 22, 2007-Test-pending revision
*/
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&NBSP;=&NBSP;TOTALNR[THIS.TEMPCELLINDEX][J&NBSP;+&NBSP;1];TOTALNR[THIS.TEMPCELLINDEX][J&NBSP;+&NBSP;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;}}}}};i Nsertcontect (); 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);
/************************************************************************************************************** ******************/
/** triggers the sort event by clicking the tag **/
Public: Triggers By default mouse button (interface example) (example of setting user interface)
This.totagstart = function () {
Setalltag (); Get labels
for (var i=0; i<totaltag.length; i++) {
Totaltag[i].sindex = function (cindex) {This.tempcellindex=cindex}.bind (this); Set column index
Totaltag[i].gstatus = function (values) {return GetStatus (values)}; Get and set state
Totaltag[i].ceshow = function (i,s) {changeshow (i,s)}; Change the display of things
Totaltag[i].stsort = function (status) {This.init (status)}.bind (this); Class
Totaltag[i].onselectstart = function () {return false}; Click on the text not selected
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
Copy Code code as follows:
/*
*
by auntion
qq:82874972
Blog:auntion@blogbus.com
Email:auntion@gmail.com
Do not delete this part of the comment. Thank you!
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);
}
Use instance _1.htm
Current 1/2 page
12 Next read the full text