var dom = (document.getElementsByTagName) ?真假;
var ie5 = (document.getElementsByTagName && document.all) ?真假;
var arrowUp, arrowDown;
if (ie5 || dom)
initSortTable();
function initSortTable() {
arrowUp = document.createElement("SPAN");
var tn = document.createTextNode("↑");
arrowUp.appendChild(tn);
arrowUp.className = "箭頭";
arrowDown = document.createElement("SPAN");
var tn = document.createTextNode("↓");
arrowDown.appendChild(tn);
arrowDown.className = "箭頭";
}
function sortTable(tableNode, nCol, bDesc, sType) {
var tBody = tableNode.t];
var trs = tBody.rows;
var trl= trs.length;
var a = new Array();
for (var i = 0; i a[i] = trs[i];
}
var start = 新日期;
window.status = "正在對資料進行排序...";
a.sort(compareByColumn(nCol,bDesc,sType));
window.status = "資料排序完成";
for (var i = 0; i tBody.appendChild(a[i]);
window.status = "正在更新行 " + (i + 1) + " of " + trl +
}
// 以檢查 onsort
tableNode.onsort = new Function("", tableNode.onsort);
if (typeof tableNode.onsort == "function")
tableNode.onsort();
}
function CaseInsensitiveString(s) {
return String(s).toUpperCase);
}
function parseDate(s) {
return Date.parse(s.replace(/-/g, //));
}
function toNumber(s) {
return Number(s.replace(/[^0-9.]/g, "");
}
function Percent(s) {
return Number(s.replace("%", ""));
}
functioncompareByColumn(nCol, bDescending, sType) {
var c = n n n;
var d = b降序;
var fTypeCast = String;
if (sType == "Number")
TypeCast = Number;
else if (sType == "Date")
fTypeCast = parseDate;
else if (sType == "CaseInsensitiveString")
類型Cast = CaseInsensitiveString;
else if (sType == "Percent")
fTypeCast = Percent;
return function (n1, n2) {
if (fTypeCast(getIn return d ? -1:+1;
d ?
回 0;
};
}
函數 sortColumnWithHold(e) {
var el = ie5 ? e.srcElement : e.target;
var table = getParent(el, "TABLE");
var oldCursor = table.style.cursor;
var oldClick = table.onclick;
table.style.cursor = "等待";
table.onclick = null;
var fakeEvent = {srcElement : e.srcElement, target : e.target};
window.setTimeout(function () {
table.onclick = oldClick;
}, 100);
var tmp = e.target ? e.target : e.srcElement;
var tHeadParent = getParent(tmp, "THEAD"); Par if (tHeadParent == null)