把代码高亮插件改进了下
把原来的代码高亮插件 http://defe.me/article.asp?id=73,稍微改进了下,可以实现在网页载入的时候自动高亮显示代码,无需再手动点击“高亮”按钮。改动很小:
在HiLightCode.asp中加入
function code_hi(){
var code_hi
var ltp=document.getElementsByName('dftype')
var lcd=document.getElementsByName('dfcode')
for(i=0;i
var tp=ltp.item(i).innerText
var cd=lcd.item(i).innerText
cd=cd.replace(/\&/g,"(|D|F|)");
cd=cd.replace(/\+/g,"(|D|J|)");
cd=cd.replace(/\\/g,"(|D|G|)");
tp=tp.split(" ")[0];
var ul="lang=" + tp + "&code=" + cd;
df = getXmlHttp();
df.open("post","./common/code.php",false);
df.setRequestHeader("Content-Type","application/x-www-form-urlencoded;");
df.send(ul);
var result = df.status;
if(result==200)
{
code_hi=df.responseText;
}
df = null;
lcd.item(i).innerHTML=code_hi
}
}
code_hi();
在ubbcode.asp中254左右原来添加到内容替换为:
re.Pattern = "\[code=(.[^\]]*)\](.*?)\[\/code\]"
Set strMatchs = re.Execute(strContent)
For Each strMatch in strMatchs
Dim lang,code,rnd_ID,rndID_t,rndID_c,Code_hi,Code_nm
lang=strMatch.SubMatches(0)
code=strMatch.SubMatches(1)
Randomize
rnd_ID = Int(100000 * Rnd)
rndID_t = "Type"& rnd_ID
rndID_c ="Code"& rnd_ID
Code_hi="
显示: 高亮"
Code_nm=" | 普通
"
strContent = Replace(strContent,strMatch.Value,"
"〈&" 代码"&Code_hi & Code_nm &"
"&code&"
")