<div name="diviframe" style="top:0;left:0;width:100%;height:600;"><iframe id="loghtml" FRAMEBORDER=0 style=top:0;left:0;width:100%;height:100%;></iframe></div>
<SCRIPT LANGUAGE="JavaScript">
<!--
/*----------------------------------------------------------------------------\
| Table Sort |
|-----------------------------------------------------------------------------|
| Created by Erik Arvidsson |
| ([url]http://webfx.eae.net/contact.html#erik)[/url] |
| For WebFX ([url]http://webfx.eae.net/)[/url] |
|-----------------------------------------------------------------------------|
| A DOM 1 based script that allows an ordinary HTML table to be sortable. |
|-----------------------------------------------------------------------------|
| Copyright (c) 1998 - 2002 Erik Arvidsson |
|-----------------------------------------------------------------------------|
| 1998-??-?? | First version |
|-----------------------------------------------------------------------------|
| Created 1998-??-?? | All changes are in the log above. | Updated 2001-??-?? |
\----------------------------------------------------------------------------*/
var dom = true;
var ie5 = true ;
var arrowUp, arrowDown;
function initSortTable() {
arrowUp = loghtml.document.createElement("SPAN");
var tn = loghtml.document.createTextNode("5");
arrowUp.appendChild(tn);
arrowUp.className = "arrow";
arrowDown = loghtml.document.createElement("SPAN");
var tn = loghtml.document.createTextNode("6");
arrowDown.appendChild(tn);
arrowDown.className = "arrow";
}
function sortTable(tableNode, nCol, bDesc, sType) {
var tBody = tableNode.tBodies[0];
var trs = tBody.rows;
var trl= trs.length;
var a = new Array();
for (var i = 0; i < trl; i++) {
a[i] = trs[i];
}
var start = new Date;
window.status = "Sorting data...";
a.sort(compareByColumn(nCol,bDesc,sType));
window.status = "Sorting data done";
for (var i = 0; i < trl; i++) {
tBody.appendChild(a[i]);
window.status = "Updating row " + (i + 1) + " of " + trl +
" (Time spent: " + (new Date - start) +
"ms)";
}
// check for onsort
if (typeof tableNode.onsort == "string")
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, '/'));
}
/* alternative to number function
* This one is slower but can handle non numerical characters in
* the string allow strings like the follow (as well as a lot more)
* to be used:
* "1,000,000"
* "1 000 000"
* "100cm"
*/
function toNumber(s) {
return Number(s.replace(/[^0-9\.]/g, ""));
}
function compareByColumn(nCol, bDescending, sType) {
var c = nCol;
var d = bDescending;
var fTypeCast = String;
if (sType == "Number")
fTypeCast = Number;
else if (sType == "Date")
fTypeCast = parseDate;
else if (sType == "CaseInsensitiveString")
fTypeCast = CaseInsensitiveString;
return function (n1, n2) {
if(fTypeCast(getInnerText(n1.cells[c])) <
fTypeCast(getInnerText(n2.cells[c])))
return d ? -1 : +1;
if (fTypeCast(getInnerText(n1.cells[c])) >
fTypeCast(getInnerText(n2.cells[c])))
return d ? +1 : -1;
return 0;
};
}
function sortColumnWithHold(e) {
// find table element
var el = ie5 ? e.srcElement : e.target;
var table = getParent(el, "TABLE");
// backup old cursor and onclick
var oldCursor = table.style.cursor;
var oldClick = table.onclick;
// change cursor and onclick
table.style.cursor = "wait";
table.onclick = null;
// the event object is destroyed after this thread but we only need
// the srcElement and/or the target
var fakeEvent = {srcElement : e.srcElement, target : e.target};
// call sortColumn in a new thread to allow the ui thread to be updated
// with the cursor/onclick
window.setTimeout(function () {
sortColumn(fakeEvent);
// once done resore cursor and onclick
table.style.cursor = oldCursor;
table.onclick = oldClick;
}, 100);
}
function sortColumn(e) {
var tmp = e.target ? e.target : e.srcElement;
var tHeadParent = getParent(tmp, "THEAD");
var el = getParent(tmp, "TD");
if (tHeadParent == null)
return;
if (el != null) {
var p = el.parentNode;
var i;
// typecast to Boolean
el._descending = !Boolean(el._descending);
if (tHeadParent.arrow != null) {
if (tHeadParent.arrow.parentNode != el) {
tHeadParent.arrow.parentNode._descending = null;
//reset sort order
}
tHeadParent.arrow.parentNode.removeChild(tHeadParent.arrow);
}
if (el._descending)
tHeadParent.arrow = arrowUp.cloneNode(true);
else
tHeadParent.arrow = arrowDown.cloneNode(true);
el.appendChild(tHeadParent.arrow);
// get the index of the td
var cells = p.cells;
var l = cells.length;
for (i = 0; i < l; i++) {
if (cells[i] == el) break;
}
var table = getParent(el, "TABLE");
// can't fail
sortTable(table,i,el._descending, el.getAttribute("type"));
}
}
function getInnerText(el) {
if (ie5) return el.innerText; //Not needed but it is faster
var str = "";
var cs = el.childNodes;
var l = cs.length;
for (var i = 0; i < l; i++) {
switch (cs[i].nodeType) {
case 1: //ELEMENT_NODE
str += getInnerText(cs[i]);
break;
case 3: //TEXT_NODE
str += cs[i].nodeValue;
break;
}
}
return str;
}
function getParent(el, pTagName) {
if (el == null) return null;
else if (el.nodeType == 1 && el.tagName.toLowerCase() == pTagName.toLowerCase())
// Gecko bug, supposed to be uppercase
return el;
else
return getParent(el.parentNode, pTagName);
}
//-->
</SCRIPT>
<script>
var startYear = 2005; //修改这里你的博客起始年份
var d = new Date();
var currYear = d.getUTCFullYear();
for(i=currYear;i>=startYear;i--)
{
document.writeln('<iframe id="cataloghtml'+i+'" src="catalog_'+i+'.html" style="display:none;" ></iframe>');
}
</script>
<img id="loghtml" style=display:none;>
<script>
function findIt(o,s)
{
ol = o.all;
if(ol ==null || ol.length <=0) return null;
for(i=0;i<ol.length;i++)
{
if(ol[i].name == s) return ol[i];
}
for(i=0;i<ol.length;i++)
{
oo = findIt(ol[i],s);
if(oo) return oo;
}
return null;
}
function showcatalog()
{
var lhref,ss
ss=""
lhref=location.href
if(lhref.indexOf("?")!=-1){
ss=lhref.slice(lhref.indexOf("?")+1)
}
l="<body><script> if (parent.ie5 || parent.dom) parent.initSortTable();<"+"/script>";
l+='<STYLE TYPE="text/css">\r\n\
tr {background: window;}\r\n\
td {color: windowtext; font: menu; padding: 1px; padding-left: 5px; padding-right: 5px;border:1px solid #eeeeee;}\r\n\
table {border-top: 1px solid buttonshadow;\r\n\
border-left: 1px solid buttonshadow;\r\n\
border-right: 1px solid buttonhighlight;\r\n\
border-bottom: 1px solid buttonhighlight;margin: 20px;\r\n\
border-collapse:collapse;}\r\n\
thead td {background: buttonface; font: menu; border: 1px outset white;\r\n\
cursor: default; padding-top: 0; padding: bottom: 0;\r\n\
border-top: 1px solid buttonhighlight;\r\n\
border-left: 1px solid buttonhighlight;\r\n\
border-right: 1px solid buttonshadow;\r\n\
border-bottom: 1px solid buttonshadow;\r\n\
height: 16px;\r\n\
}\r\n\
thead .arrow {font-family: webdings; color: black; padding: 0; font-size: 10px;\r\n\
height: 11px; width: 10px; overflow: hidden;\r\n\
margin-bottom: 2; margin-top: -3; padding: 0; padding-top: 0; padding-bottom: 2;}\r\n\
</STYLE>\r\n';
l +="\r\n<div align=center><b><font size=5 face=黑体>跨年度文章分栏索引</font></b></div>\r\n<div align=center>(点击列头排序显示) 作者:<a href=http://dozb.blogchina.com>dozb</a></div>\r\n<table id='tLogList' onclick='parent.sortColumn(event)' cellspacing=1 cellpadding=0 width=700 align=center bgcolor=#2f6cd2 border=0>";
l+="<thead><tr bgcolor=#dbe4f4 height=30> <td width=45% align=center>文章主题</td><td width=12% align=center>作者</td><td width=16% align=center>发布时间</td><td width=12% align=center>分类</td></tr></thead><tbody >";
count=0;
loghtml.document.write(l);
for(iyear=currYear;iyear>=startYear;iyear--)
{
ol = eval("cataloghtml"+iyear+".document.body.all");
if(ol == null)
{
alert("ol==null");
return ;
}
var entityDiv = null;
for(i=0;i<ol.length;i++)
{
if(ol[i].className =="entity")
{
entityDiv = ol[i];break;
}
}
if(entityDiv == null)
{
alert("entityDiv==null");
return ;
}
ol = entityDiv.children.tags("UL");
if(ol == null)
{
alert("entityDiv.children.tags('UL')==null");
&bsp; return ;
}
for(i=0;i<ol.length;i++)
{
if(ss!="" && ss != ol[i].children(0).name) continue;
categoryName = ol[i].children(0).innerHTML;
oLI = ol[i].children.tags("LI");
for(j=0;j<oLI.length;j++)
{
oA = oLI[j].children(1);
s = oA.innerHTML;
pos = 0;
if(pos>0)s=s.slice(pos+1);
oCatagoryName = categoryName;
oHref = oA.href;
oInnerHTML = s;
s = oA.href;
pos = s.lastIndexOf("/");
if(pos <0) pos = 0; else pos++;
oPageid = s.slice(pos,-5);
oSpan = oLI[j].children(2);
s = oSpan.innerHTML;
oDate = s.slice(s.length-19,-3);
oAuthor = s.slice(3,s.length-20);
l="\r\n<tr bgcolor=#ffffff height=25><td width=45% align=left><a href='"+oHref+"' target='_blank'>"+oInnerHTML+"</a></td><td width=12% align=center>"+oAuthor+"</td><td width=16%>"+oDate+"</td>";
loghtml.document.write(l);
l="<td width=12% align=center>"+oCatagoryName+"</td></tr>";
loghtml.document.write(l);
count++;
}
}
}
l="\r\n</tbody><tr bgcolor=#dbe4f4 height=20><td width=100% colspan=6 align=right>总计文章: "+count+" </td></tr></table>";
loghtml.document.write(l);
loghtml.document.write("</body>");
odiv = findIt(document.body,"diviframe");
if(odiv) odiv.style.posHeight = 28*(count+3)+80;
}
</script>
</body>
你可以使用这个链接引用该篇文章 http://publishblog.blogchina.com/blog/tb.b?diaryID=4594932
|
- 评论人:临屏追风
2007-01-01 19:18:38
|
|||
照你说的,依旧不行!错哪了?快帮偶看看! |
||||
|
- 评论人:禅
2007-01-01 16:59:45
|
|||
呵呵!! 全部复制然后发表就可以咯!!! |
||||
|
- 评论人:临屏追风
2007-01-01 14:04:35
|
|||
这些代码放在哪里啊??! 晕 |
||||