Z-Blog中用到的js代码
Z-Blog中用到的js代码
发布时间:2016-12-30 来源:查字典编辑
摘要://////////////////////////////////////////////////////////////////////...

///////////////////////////////////////////////////////////////////////////////

//Z-Blog

//作者:朱煊(zx.asd)

//版权所有:RainbowSoftStudio

//技术支持:rainbowsoft@163.com

//程序名称:

//程序版本:

//单元名称:common.js

//开始时间:2004.07.25

//最后修改:

//备注:全局脚本

///////////////////////////////////////////////////////////////////////////////

//*********************************************************

//目的:加载样式表

//输入:无

//返回:无

//*********************************************************

functionLoadActiveStyleSheet(){

vartitle=GetCookie("sk")

vara;

if(title){

a=document.getElementsByTagName("link")[0];

a.href=str00+"style/"+title+".css"

}

}

//*********************************************************

//*********************************************************

//目的:设置样式表

//输入:title

//返回:无

//*********************************************************

functionSetActiveStyleSheet(title){

vara;

if(title){

{

SetCookie("sk",title,365);

}

a=document.getElementsByTagName("link")[0];

a.href=str00+"style/"+title+".css"

}

}

//*********************************************************

//*********************************************************

//目的:设置Cookie

//输入:sName,sValue,iExpireDays

//返回:无

//*********************************************************

functionSetCookie(sName,sValue,iExpireDays){

if(iExpireDays){

vardExpire=newDate();

dExpire.setTime(dExpire.getTime()+parseInt(iExpireDays*24*60*60*1000));

document.cookie=sName+"="+escape(sValue)+";expires="+dExpire.toGMTString();

}

else{

document.cookie=sName+"="+escape(sValue);

}

}

//*********************************************************

//*********************************************************

//目的:返回Cookie

//输入:Name

//返回:Cookie值

//*********************************************************

functionGetCookie(sName){

vararr=document.cookie.match(newRegExp("(^|)"+sName+"=([^;]*)(;|$)"));

if(arr!=null){returnunescape(arr[2])};

returnnull;

}

//*********************************************************

//*********************************************************

//目的:验证信息

//输入:无

//返回:无

//*********************************************************

varstrFormAction;

varobjImageValid;

functionVerifyMessage(){

varstrName=document.getElementById("inpName").value;

varstrEmail=document.getElementById("inpEmail").value;

varstrHomePage=document.getElementById("inpHomePage").value;

varstrArticle;

if(document.getElementById("txaArticle").value){

strArticle=document.getElementById("txaArticle").value;

}

else{

strArticle=document.getElementById("txaArticle").innerText;

}

if(strName==""){

alert(str01);

returnfalse;

}

else{

re=newRegExp("^[.A-Za-z0-9u4e00-u9fa5]+$");

if(!re.test(strName)){

alert(str02);

returnfalse;

}

}

if(strEmail==""){

//alert(str01);

//returnfalse;

}

else{

re=newRegExp("^[w-]+(.[w-]+)*@[w-]+(.[w-]+)+$");

if(!re.test(strEmail)){

alert(str02);

returnfalse;

}

}

if(typeof(strArticle)=="undefined"){

alert(str03);

returnfalse;

}

if(typeof(strArticle)=="string"){

if(strArticle==""){

alert(str03);

returnfalse;

}

if(strArticle.length>intMaxLen)

{

alert(str03);

returnfalse;

}

}

document.getElementById("inpArticle").value=strArticle;

document.getElementById("inpLocation").value=parent.window.location.href;

if(document.getElementById("frmSumbit").action.search("act=cmt")>0){

strFormAction=document.getElementById("frmSumbit").action;

}

varbolRemember=document.getElementById("chkRemember").checked;

if(bolRemember==true){

SaveRememberInfo();

}

else{

SetCookie("chkRemember",bolRemember,365);

}

//ajaxcommentbegin

$.post(document.getElementById("frmSumbit").action,

{

"inpAjax":true,

"inpID":$("#inpId").val(),

"inpVerify":(document.getElementById("inpVerify")?$("#inpVerify").val():""),

"inpEmail":strEmail,

"inpName":strName,

"inpArticle":strArticle,

"inpHomePage":strHomePage

},

function(data){

vars=data;

if((s.search("faultCode")>0)&&(s.search("faultString")>0))

{

alert(s.match("<string>.+?</string>")[0].replace("<string>","").replace("</string>",""))

}

else{

vari=Math.round(Math.random()*1000)

vars="<divid="divAjaxComment"+i+"">"+data+"</div>";

$(s).insertBefore("#divAjaxComment");

$("#divAjaxComment"+i).fadeIn("slow");

//$("#divAjaxComment"+i).fadeTo("normal",0);

//$("#divAjaxComment"+i).fadeTo("normal",1);

//$("#divAjaxComment"+i).show("slow");

if(strFormAction){

document.getElementById("frmSumbit").action=strFormAction;

}

$("#txaArticle").val("");

}

if(document.getElementById("inpVerify")){

$("#inpVerify").val("");

if(!objImageValid){

objImageValid=$("img[@src='"+str00+"function/c_validcode.asp?name=commentvalid']");

}

objImageValid.src(str00+"function/c_validcode.asp?name=commentvalid"+"&random="+Math.random());

}

}

);

returnfalse;

//ajaxcommentend

}

//*********************************************************

//*********************************************************

//目的:加载信息

//输入:无

//返回:无

//*********************************************************

functionLoadRememberInfo(){

varstrName=GetCookie("inpName")

varstrEmail=GetCookie("inpEmail")

varstrHomePage=GetCookie("inpHomePage")

varbolRemember=GetCookie("chkRemember")

if(bolRemember=="true"){

if(strName){document.getElementById("inpName").value=strName;};

if(strEmail){document.getElementById("inpEmail").value=strEmail;};

if(strHomePage){document.getElementById("inpHomePage").value=strHomePage;};

if(bolRemember){document.getElementById("chkRemember").checked=bolRemember;};

}

if(GetCookie("username")){

document.getElementById("inpName").value=unescape(GetCookie("username"))

}

}

//*********************************************************

//*********************************************************

//目的:保存信息

//输入:无

//返回:无

//*********************************************************

functionSaveRememberInfo(){

varstrName=document.getElementById("inpName").value;

varstrEmail=document.getElementById("inpEmail").value;

varstrHomePage=document.getElementById("inpHomePage").value;

varbolRemember=document.getElementById("chkRemember").checked;

SetCookie("inpName",strName,365);

SetCookie("inpEmail",strEmail,365);

SetCookie("inpHomePage",strHomePage,365);

SetCookie("chkRemember",bolRemember,365);

}

//*********************************************************

//*********************************************************

//目的:输出UBB

//输入:无

//返回:无

//*********************************************************

functionExportUbbFrame(){

if(!objActive){objActive="txaArticle"};

document.write("<pid="UbbFrame"style="display:none;"></p>")

document.write("<p>")

document.write("<aalt=""onmousedown="InsertText(objActive,ReplaceText(objActive,'[URL]','[/URL]'),true);"style="padding:2px;cursor:pointer;">[URL]</a>")

document.write("<aalt=""onmousedown="InsertText(objActive,ReplaceText(objActive,'[URL=http://]','[/URL]'),true);"style="padding:2px;cursor:pointer;">[URL2]</a>")

document.write("<aalt=""onmousedown="InsertText(objActive,ReplaceText(objActive,'[EMAIL]','[/EMAIL]'),true);"style="padding:2px;cursor:pointer;">[EMAIL]</a>")

document.write("<aalt=""onmousedown="InsertText(objActive,ReplaceText(objActive,'[EMAIL=@]','[/EMAIL]'),true);"style="padding:2px;cursor:pointer;">[EMAIL2]</a>")

document.write("<aalt=""onmousedown="InsertText(objActive,ReplaceText(objActive,'[B]','[/B]'),true);"style="padding:2px;cursor:pointer;">[B]</a>")

document.write("<aalt=""onmousedown="InsertText(objActive,ReplaceText(objActive,'[I]','[/I]'),true);"style="padding:2px;cursor:pointer;">[I]</a>")

document.write("<aalt=""onmousedown="InsertText(objActive,ReplaceText(objActive,'[U]','[/U]'),true);"style="padding:2px;cursor:pointer;">[U]</a>")

document.write("<aalt=""onmousedown="InsertText(objActive,ReplaceText(objActive,'[S]','[/S]'),true);"style="padding:2px;cursor:pointer;">[S]</a>")

document.write("<aalt=""onmousedown="InsertText(objActive,ReplaceText(objActive,'[QUOTE]','[/QUOTE]'),true);"style="padding:2px;cursor:pointer;">[QUOTE]</a>")

document.write("<u><astyle="cursor:pointer;text-align:right;"onclick="InsertUbbFace();if(document.getElementById('UbbFrame').style.display=='none'){document.getElementById('UbbFrame').style.display='block';}else{document.getElementById('UbbFrame').style.display='none'};this.style.display='none'">"+str06+"</a></u>")

document.write("</p>")

}

//*********************************************************

//*********************************************************

//目的:插入表情图片HTML代码

//输入:无

//返回:无

//*********************************************************

functionInsertUbbFace(){

if(!document.getElementById("UbbFrame").innerHTML&&strFaceName){

vararyFileName="";

varstrFileName="";

varstrFaceHtml="";

aryFileName=strFaceName.split("|");

for(vari=0;i<aryFileName.length;i++)

{

strFileName=aryFileName[i];

strFaceHtml=strFaceHtml+"<imgsrc=""+str00+"image/face/"+strFileName+".gif"title=""+strFileName+""alt=""+strFileName+""width=""+strFaceSize+""height=""+strFaceSize+""onclick="InsertText(objActive,'[F]'+this.alt+'[/F]',false);"style="padding:2px;cursor:pointer;">"

}

document.getElementById("UbbFrame").innerHTML=strFaceHtml;

}

}

//*********************************************************

//*********************************************************

//目的:自动插入并替换

//输入:无

//返回:无

//*********************************************************

varobjActive;

functionGetActiveText(objHTML){

objActive=objHTML;

if(document.selection){

varobj=document.getElementById(objHTML);

obj.currPos=document.selection.createRange().duplicate()

}

}

functionInsertText(objHTML,strText,bolReplace){

if(strText==""){return("")}

varobj=document.getElementById(objHTML);

if(document.selection){

if(obj.currPos){

if(bolReplace&&(obj.value=="")){

obj.currPos.text=strText

}

else{

obj.currPos.text+=strText

}

}

else{

obj.value+=strText

}

}

else{

if(bolReplace){

obj.value=obj.value.slice(0,obj.selectionStart)+strText+obj.value.slice(obj.selectionEnd,obj.value.length)

}

else{

obj.value=obj.value.slice(0,obj.selectionStart)+strText+obj.value.slice(obj.selectionStart,obj.value.length)

}

}

//obj.focus();

}

functionReplaceText(objHTML,strPrevious,strNext){

varobj=document.getElementById(objHTML);

varstrText;

if(document.selection&&document.selection.type=="Text"){

if(obj.currPos){

varrange=document.selection.createRange();

range.text=strPrevious+range.text+strNext;

return("");

}

else{

strText=strPrevious+strNext;

return(strText);

}

}

else{

if(obj.selectionStart||obj.selectionEnd){

strText=strPrevious+obj.value.slice(obj.selectionStart,obj.selectionEnd)+strNext;

return(strText);

}

else{

strText=strPrevious+strNext;

return(strText);

}

}

}

//*********************************************************

//*********************************************************

//目的:ShowMediaByUBB

//输入:无

//返回:无

//*********************************************************

functionShowMedia(objHTML,strURL,strType,intWidth,intHeight){

varstrMedia="";

varblnShow=false;

varobjMedia=objHTML;

if(objMedia.innerHTML){blnShow=true};

varre=newRegExp(".[a-z0-9]+$","ig");

varstrExtend=re.exec(strURL);

strExtend="|"+String(strExtend).toLowerCase()+"|";

if(strType=="AUTO"){

if(String("|.swf|").indexOf(strExtend)>=0){strType="SWF"}

if(String("|.mov|.qt|").indexOf(strExtend)>=0){strType="QT"}

if(String("|.wmv|.wmp|.wm|.avi|.mp4|.mpg|.mpeg|.m3u|.pls|.wvx|.wax|.wmx|").indexOf(strExtend)>=0){strType="WMV"}

if(String("|.asf|.wma|.asx|.wav|.mp3|.mpa|.mp2|.m1a|.m2a|.aac|").indexOf(strExtend)>=0){strType="WMA"}

if(String("|.rm|.ram|.rmvb|.rpm|.amr|.3gp|.3gpp|.3g2|.3gp2|.rt|.rp|.smi|.smil|").indexOf(strExtend)>=0){strType="RM"}

if(String("|.ra|").indexOf(strExtend)>=0){strType="RA"}

}

if(blnShow){

objMedia.innerHTML=strMedia;

}

else{

switch(strType){

case"SWF":

strMedia="<objectclassid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0"width=""+intWidth+""height=""+intHeight+""><paramname="movie"value=""+strURL+""><paramname="quality"value="high"><paramname="play"value="true"><embedsrc=""+strURL+""quality="high"pluginspage="http://www.macromedia.com/go/getflashplayer"type="application/x-shockwave-flash"width=""+intWidth+""height=""+intHeight+""play="true"></embed></object>"

break;

case"QT":

strMedia="<objectclassid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"codebase="http://www.apple.com/qtactivex/qtplugin.cab"width=""+intWidth+""height=""+intHeight+""><paramname="src"value=""+strURL+""><paramname="autoplay"value="true"><embedsrc="qtmimetype.pntg"type="image/x-macpaint"pluginspage="http://www.apple.com/quicktime/download"qtsrc=""+strURL+""width=""+intHeight+""height=""+intHeight+""autoplay="true"></embed></object>"

break;

case"WMV":

strMedia="<objectclassid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95"width=""+intWidth+""height=""+intHeight+""><paramname="ShowStatusBar"value="-1"><paramname="AutoStart"value="true"><paramname="Filename"value=""+strURL+""><embedtype="application/x-mplayer2"pluginspage="http://www.microsoft.com/Windows/MediaPlayer/"src=""+strURL+""autostart="true"width=""+intWidth+""height=""+intHeight+""></embed></object>"

break;

case"WMA":

strMedia="<objectclassid="clsid:22D6F312-B0F6-11D0-94AB-0080C74C7E95"height="68"width="350"><paramname="ShowStatusBar"value="-1"><paramname="AutoStart"value="true"><paramname="Filename"value=""+strURL+""><embedtype="application/x-mplayer2"pluginspage="http://www.microsoft.com/Windows/MediaPlayer/"src=""+strURL+""autostart="true"width="350"height="45"></embed></object>"

break;

case"RM":

strMedia="<objectclassid="clsid:CFCDAA03-8BE4-11CF-B84B-0020AFBBCCFA"width=""+intWidth+""height=""+intWidth+""><paramname="src"value=""+strURL+""><paramname="controls"value="imagewindow"><paramname="console"value="one"><paramname="AutoStart"value="true"><embedsrc=""+strURL+""width=""+intWidth+""height=""+intWidth+""type="audio/x-pn-realaudio-plugin"nojava="true"controls="imagewindow,ControlPanel,StatusBar"console="one"autostart="true"></object>"

break;

case"RA":

strMedia="<objectclassid="clsid:CFCDAA03-8BE4-11CF-B84B-0020AFBBCCFA"width="350"height="36"><paramname="src"value=""+strURL+""><paramname="controls"value="ControlPanel"><paramname="console"value="one"><paramname="AutoStart"value="true"><embedsrc=""+strURL+""type="audio/x-pn-realaudio-plugin"nojava="true"controls="ControlPanel,StatusBar"console="one"autostart="true"width="350"height="36"></object>"

}

objMedia.innerHTML=strMedia;

}

}

//*********************************************************

//*********************************************************

//目的:InsertQuoteTotxaArticle

//输入:无

//返回:无

//*********************************************************

functionInsertQuote(strName,strText){

if(!objActive){objActive="txaArticle"};

varre;

re=newRegExp("<br/?>","ig");

strText=strText.replace(re,"n");

re=newRegExp("<[^>]*>","ig");

strText=strText.replace(re,"");

InsertText(objActive,"[QUOTE=",false);

InsertText(objActive,strName,false);

InsertText(objActive,"]",false);

InsertText(objActive,strText,false);

InsertText(objActive,"[/QUOTE]",false);

}

//*********************************************************

//*********************************************************

//目的:全选

//输入:无

//返回:无

//*********************************************************

functionBatchSelectAll(){

vararyChecks=document.getElementsByTagName("input");

for(vari=0;i<aryChecks.length;i++){

if((aryChecks[i].type=="checkbox")&&(aryChecks[i].id.indexOf("edt")!==-1)){

if(aryChecks[i].checked==true){

aryChecks[i].checked=false;

}

else{

aryChecks[i].checked=true;

};

}

}

}

//*********************************************************

//*********************************************************

//目的:

//输入:无

//返回:无

//*********************************************************

functionBatchDeleteAll(objEdit){

objEdit=document.getElementById(objEdit)

objEdit.value=""

vararyChecks=document.getElementsByTagName("input");

for(vari=0;i<aryChecks.length;i++){

if((aryChecks[i].type=="checkbox")&&(aryChecks[i].id.indexOf("edt")!==-1)){

if(aryChecks[i].checked){

objEdit.value=aryChecks[i].value+","+objEdit.value

}

}

}

}

//*********************************************************

//*********************************************************

//目的:图片自动缩小点击放大

//输入:无

//返回:无

//*********************************************************

functionResizeImage(objImage,maxWidth){

try{

if(maxWidth>0){

if(objImage.width>maxWidth){

objImage.width=maxWidth;

objImage.attachEvent('onclick',function(){try{showModelessDialog(objImage.src);}catch(e){window.open(objImage.src);}});

objImage.attachEvent('onmouseover',function(){objImage.style.cursor='pointer';});

}

}

}catch(e){};

}

//*********************************************************

//*********************************************************

//目的:回复留言

//输入:无

//返回:无

//*********************************************************

functionRevertComment(intRevertID){

varf;

if(objActive){

f=document.getElementById(objActive).form

}

else{

f=document.getElementsByTagName("form")[document.getElementsByTagName("form").length-1]

}

if(f.action.search("act=cmt")>0){

f.action=f.action.replace("cmd.asp?act=cmt","cmd.asp?act=CommentRev&id="+intRevertID);

returntrue;

}

else{

f.action=f.action.substr(0,f.action.search("id="))+"id="+intRevertID+"&"+f.action.substr(f.action.search("key="))

returntrue;

}

}

推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
相关阅读
网友关注
最新Javascript教程学习
热门Javascript教程学习
编程开发子分类