中国开发网: 论坛: 程序员情感CBD: 贴子 540867
haitao
因为你木有小JJ。。。。。。。。。function showdate(strDate)。。。。。。。
// JScript File

var g_showdate_curDate = new Date();
var g_showdate_urlResource = "../_res/forum/";

function showdate_init( curDate, urlResource )
{
g_showdate_curDate = new Date(curDate);
g_showdate_urlResource = urlResource;
}

function showdate(strDate)
{
document.write( getFriendlyDate(strDate) );
}

function getFriendlyDate(xdate)
{
var anDate = new Date(xdate);

var anDateOnly = new Date(anDate);
anDateOnly.setHours(0,0,0,0);
var TheDate = g_showdate_curDate;
TheDate.setHours(0,0,0,0);

var daydif = (TheDate - anDateOnly)/60/60/24/1000;

var rs = "";

if ( daydif <= 2 )
{
var daynames = "今天;昨天;前天";
var dayname = daynames.split(";")[daydif];

rs = rs + dayname + " " + showdate_T(anDate);

}
else if ( anDate.getFullYear() != TheDate.getFullYear() )
{
rs = rs + showdate_YMDT(anDate);
}
else
{
rs = rs + showdate_MDT(anDate);
}

if ( (TheDate - anDate)/1000/60/60/24 <= 1 )
{
rs = rs + " <img src='" + g_showdate_urlResource + "new.gif' align='absmiddle' width='28' height='11'>";
}

return rs;
}

function getFillZero( str )
{
str = str.toString();
while ( str.length < 2 )
{
str = "0" + str;
}

return str;
}

function showdate_YMDT(anDate)
{
return anDate.getFullYear() + "-" + showdate_MDT(anDate);
}

function showdate_MDT(anDate)
{
return (anDate.getMonth()+1) + "-" + anDate.getDate() + " " + showdate_T(anDate);
}

function showdate_T(anDate)
{
return getFillZero(anDate.getHours()) + ":" + getFillZero(anDate.getMinutes());
}



/* */
function highlightWord(node,word)
{
// Iterate into this nodes childNodes
if (node.hasChildNodes)
{
var hi_cn;

for (hi_cn=0;hi_cn<node.childNodes.length;hi_cn++)
{
highlightWord(node.childNodes[hi_cn],word);
}
}
// And do this node itself
if (node.nodeType == 3)
{
// text node
tempNodeVal = node.nodeValue.toLowerCase();
tempWordVal = word.toLowerCase();
if (tempNodeVal.indexOf(tempWordVal) != -1)
{
pn = node.parentNode;
if (pn.className != "highlight")
{
// word has not already been highlighted!
nv = node.nodeValue;
ni = tempNodeVal.indexOf(tempWordVal);
// Create a load of replacement nodes
before = document.createTextNode(nv.substr(0,ni));
docWordVal = nv.substr(ni,word.length);
after = document.createTextNode(nv.substr(ni+word.length));
hiwordtext = document.createTextNode(docWordVal);
hiword = document.createElement("span");
hiword.className = "highlight";
hiword.appendChild(hiwordtext);
pn.insertBefore(before,node);
pn.insertBefore(hiword,node);
pn.insertBefore(after,node);
pn.removeChild(node);
}
}
}

}

function searchHighlight()
{
if (!document.createElement) return;
ref = document.referrer;
if (ref.indexOf('?') == -1 || ref.indexOf('http://www.cndev.org/') != -1)
{
ref = document.location.href;
if (ref.indexOf('?') == -1) return;
}
qs = ref.substr(ref.indexOf('?')+1);
qsa = qs.split('&');
for (i=0;i<qsa.length;i++)
{
qsip = qsa[i].split('=');
if (qsip.length == 1) continue;
// keyword refer: q= for Google or for msn, p= for Yahoo, wd= for baidu, w= for QQ
if (qsip[0] == 'q' || qsip[0] == 'p' || qsip[0] == 'wd' || qsip[0] == 'w' )
{
words = unescape(qsip[1].replace(/\+/g,' ')).split(/\s+/);
for (w=0;w<words.length;w++)
{
highlightWord(document.getElementsByTagName("body")[0],words[w]);
}
}
}
}


window.attachEvent('onload', searchHighlight);
我的blog:http://szhaitao.blog.hexun.com & http://www.hoolee.com/user/haitao
--以上均为泛泛之谈--
不尽牛人滚滚来,无边硬伤纷纷现 人在江湖(出来的),哪能不挨刀(总归是要的)
网络对话,歧义纷生;你以为明白了对方的话,其实呢?

您所在的IP暂时不能使用低版本的QQ,请到:http://im.qq.com/下载安装最新版的QQ,感谢您对QQ的支持和使用

相关信息:


欢迎光临本社区,您还没有登录,不能发贴子。请在 这里登录