Home > Web Front-end > JS Tutorial > js code used in Z-Blog_javascript skills

js code used in Z-Blog_javascript skills

WBOY
Release: 2016-05-16 19:16:33
Original
973 people have browsed it

///////////////////////////////////////////////////// //////////////////////////////
//                                                                                                       asd)
// Copyright: RainbowSoft Studio
// Technical support: rainbowsoft@163.com
// Program name:
// Program version:
// Unit name: common .js
// Start time: 2004.07.25
// Last modified:
// Note: Global script
/////////////// ///////////////////////////////////////////////////// /////////////





//********************** ******************************************
//Purpose: Load style sheet
//Input: None
// Return: None
//****************************** ****************************
function LoadActiveStyleSheet(){

var title=GetCookie("sk" )
var a;

if (title) {

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

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

}

}
//********************** **********************************




/ /****************************************************** ********
// Purpose: Set style sheet
// Input: title
// Return: None
//************* **********************************************
function SetActiveStyleSheet(title){

var a;

if (title) {

{
SetCookie("sk",title,365);
}
a = document.getElementsByTagName("link")[0];

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

}

}
//************************************************ ***************




//******************** ***********************************
// Purpose: Set Cookie
/ / Input: sName, sValue,iExpireDays
// Return: None
//******************************* ****************************
function SetCookie(sName, sValue,iExpireDays) {
if (iExpireDays){
var dExpire = new Date();
dExpire.setTime(dExpire.getTime() parseInt(iExpireDays*24*60*60*1000));
document.cookie = sName "=" escape (sValue ) "; expires=" dExpire.toGMTString();
}
else{
else{
document.cookie = sName "" escape(sValue);
}
}
// *************************************************** *******




//************************** *******************************
// Purpose: Return Cookie
// Input: Name
//Return: Cookie value
//****************************************** *******************
function GetCookie(sName) {

var arr = document.cookie.match(new RegExp("(^| )" sName "=([^;]*)(;|$)"));
if(arr !=null){return unescape(arr[2])};
return null;

}
//*********************************************************




//*********************************************************
// 目的:    验证信息
// 输入:    无
// 返回:    无
//*********************************************************
var strFormAction;
var objImageValid;
function VerifyMessage() {

    var strName=document.getElementById("inpName").value;
    var strEmail=document.getElementById("inpEmail").value;
    var strHomePage=document.getElementById("inpHomePage").value;
    var strArticle;

    if(document.getElementById("txaArticle").value){
        strArticle=document.getElementById("txaArticle").value;
    }
    else{
        strArticle=document.getElementById("txaArticle").innerText;
    }

    if(strName==""){
        alert(str01);
        return false;
    }
    else{
        re = new RegExp("^[.A-Za-z0-9u4e00-u9fa5] $");
        if (!re.test(strName)){
            alert(str02);
            return false;
        }
    }

    if(strEmail==""){
        //alert(str01);
        //return false;
    }
    else{
        re = new RegExp("^[\w-] (\.[\w-] )*@[\w-] (\.[\w-] ) $");
        if (!re.test(strEmail)){
            alert(str02);
            return false;
        }
    }

    if(typeof(strArticle)=="undefined"){
        alert(str03);
        return false;
    }

    if(typeof(strArticle)=="string"){
        if(strArticle==""){
            alert(str03);
            return false;
        }
        if(strArticle.length>intMaxLen)
        {
            alert(str03);
            return false;
        }
    }

    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;
    }

    var bolRemember=document.getElementById("chkRemember").checked;

    if(bolRemember==true){
        SaveRememberInfo();
    }
    else{
        SetCookie("chkRemember",bolRemember,365);
    }


    //ajax comment begin
    $.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){
            var s =data;
            if((s.search("faultCode")>0)&&(s.search("faultString")>0))
            {
                alert(s.match(". ?")[0].replace("","").replace("",""))
            }
            else{
                var i=Math.round(Math.random()*1000)
                var s ="

" data "
";
                $(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());
            }
        }
    );

    return false;
    //ajax comment end

}
//*********************************************************




//*********************************************************
// 目的:    加载信息
// 输入:    无
// 返回:    无
//*********************************************************
function LoadRememberInfo() {

    var strName=GetCookie("inpName")
    var strEmail=GetCookie("inpEmail")
    var strHomePage=GetCookie("inpHomePage")
    var bolRemember=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"))
    }

}
//********************************************** ************




//********************** **********************************
// Purpose: Save information
// Input: None
// Return: None
//************************************ ***********************
function SaveRememberInfo() {

var strName=document.getElementById("inpName").value ;
var strEmail=document.getElementById("inpEmail").value;
var strHomePage=document.getElementById("inpHomePage").value;
var bolRemember=document.getElementById("chkRemember"). checked;


SetCookie("inpName",strName,365);
SetCookie("inpEmail",strEmail,365);
SetCookie("inpHomePage",strHomePage,365);
SetCookie("chkRemember",bolRemember,365);

}
//************************ *********************************





//*********************************************** **********
// Purpose: Output UBB
// Input: None
// Return: None
//************ ***********************************************
function ExportUbbFrame() {

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

document.write("

")

document .write("

")

document.write("[URL] ")
document.write("[URL2] ")
document.write("[EMAIL] ")
document.write("[EMAIL2] ")
document.write("[ B] ")
document.write("[I] ")
document.write("[U] ")
document. write("[S] ")
document.write("[QUOTE] ")

document.write(" " str06 " ")

document.write("

")
}
//****************************************** ****************




//****************** ******************************************
//Purpose: Insert Expression picture HTML code
//Input: None
// Return: None
//************************* **********************************
function InsertUbbFace() {

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

var aryFileName="";
var strFileName="";
var strFaceHtml="";

aryFileName =strFaceName.split("|");

for (var i=0;i aceHtml= strFaceHtml "
"
} document.getElementById("UbbFrame").innerHTML=strFaceHtml;
}

}
//******** *************************************************




//********************************** ***********************
// Purpose: Automatically insert and replace
// Input: None
// Return: None
//********************************************** ************
var objActive;
function GetActiveText(objHTML) {
objActive=objHTML;
if(document.selection){
var obj= document.getElementById(objHTML); 🎜> if(strText==""){return("")}
var obj=document.getElementById(objHTML);
if(document.selection){
if (obj.currPos){
if(bolReplace && (obj.value=="")){
obj.currPos.text=strText
else{
                  obj.currPos.text =strText
}
                                                                                                                                                     🎜>                 obj.value=obj.value. slice(0,obj.selectionStart) strText obj.value.slice(obj.selectionEnd,obj.value.length)
}
else{
else{
obj.value=obj.value.slice(0,obj .selectionStart) strText obj.value.slice(obj.selectionStart,obj.value.length)
    }
  }
  //obj.focus();
}

function ReplaceText(objHTML,strPrevious,strNext) {
    var obj=document.getElementById(objHTML);
    var strText;
    if(document.selection && document.selection.type == "Text"){
        if (obj.currPos){
            var range = 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);
        }
    }
}
//*********************************************************




//*********************************************************
// 目的:    ShowMedia By UBB
// 输入:    无
// 返回:    无
//*********************************************************
function ShowMedia(objHTML,strURL,strType,intWidth,intHeight) {
    var strMedia="";
    var blnShow = false;
    var objMedia=objHTML;

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

    var re = new RegExp(".[a-z0-9] $","ig");

    var strExtend = 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=" "
                break;
            case "QT":
                strMedia=" "
                break;
            case "WMV":
                strMedia=" "
                break;
            case "WMA":
                strMedia=" "
                break;
            case "RM":
                strMedia=" "
                break;
            case "RA":
                strMedia=" "
        }
        objMedia.innerHTML = strMedia;
    }
}
//*********************************************************




//*********************************************************
// 目的:    InsertQuote To txaArticle
// 输入:    无
// 返回:    无
//*********************************************************
function InsertQuote(strName,strText) {
    if(!objActive){objActive="txaArticle"};

    var re;
    re=new RegExp("
","ig");
    strText=strText.replace(re, "n");
    re=new RegExp("]*>","ig");
    strText=strText.replace(re, "");

    InsertText(objActive,"[QUOTE=",false);
    InsertText(objActive,strName,false);
    InsertText(objActive,"]",false);
    InsertText(objActive,strText,false);
    InsertText(objActive,"[/QUOTE]",false);
}
//*********************************************************




//*********************************************************
// 目的:    全选
// 输入:    无
// 返回:    无
//*********************************************************
function BatchSelectAll() {
    var aryChecks = document.getElementsByTagName("input");

    for (var i = 0; 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;
            };
        }
    }
}
//*********************************************************




//*********************************************************
// 目的:    
// 输入:    无
// 返回:    无
//*********************************************************
function BatchDeleteAll(objEdit) {

    objEdit=document.getElementById(objEdit)
    objEdit.value=""
    var aryChecks = document.getElementsByTagName("input");
    for (var i = 0; i         if((aryChecks[i].type=="checkbox")&&(aryChecks[i].id.indexOf("edt")!==-1)){
            if(aryChecks[i].checked){
                objEdit.value=aryChecks[i].value "," objEdit.value
            }
        }
    }

}
//********************************************** ************




//********************** **********************************
//Purpose: Automatically reduce the picture Click to enlarge
//Input: None
// Return: None
//************************************ ****************************
function ResizeImage(objImage,maxWidth) {
try{
if(maxWidth>0 ; lessDialog(objImage.src);}catch( e){window.open(objImage.src);}}); >                                                                                                                *****************************




//**** *************************************************** ***
// Purpose: Reply to message
// Input: None
// Return: None
//******************* ****************************************
function RevertComment(intRevertID) {
var f; [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);
                                                                                                                                                  . action.substr(0,f.action.search("id=")) "id=" intRevertID "&" f.action.substr(f.action.search("key="))
return true;
}
}
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template