PBlog2 公用JS代码(3)

while(iTemp > -1){
  if(VALUE.charAt(iTemp) == w_space){
  }
  else{
   strTemp = VALUE.substring(0,iTemp +1);
   break;
  }
  iTemp = iTemp-1;

} //End While
 return strTemp;

} //End Function

function LTrim(VALUE){
 var w_space = String.fromCharCode(32);
 if(v_length < 1){
  return"";
 }
 var v_length = VALUE.length;
 var strTemp = "";
 var iTemp = 0;

while(iTemp < v_length){
  if(VALUE.charAt(iTemp) == w_space){
   }
   else{
    strTemp = VALUE.substring(iTemp,v_length);
    break;
  }
  iTemp = iTemp + 1;
 } //End While
 return strTemp;
} //End Function


function CheckPost(){
  try{
 if (Trim(document.forms[0].title.value)=="") {
   alert("标题不能为空,请写日志标题!")
   document.forms[0].title.focus()
   return false
  }
 }
  catch(e){}

try{
    if (document.getElementById("P2").checked) {
     if (!CheckDate(document.forms[0].PubTime.value)){
        alert("日期格式不正确!\n格式:yyyy-mm-dd hh:mm:ss") 
     return false
     }
     else
     {
      document.forms[0].PubTime.value=CheckDate(document.forms[0].PubTime.value)
     }
    }
  }
  catch(e){}

try{
   if (GetMessageLength()==0){
   alert("内容不能为空!")
   return false
   }
  }
  catch(e){
 if (Trim(document.forms[0].Message.value)=="") {
   alert("内容不能为空!")
   document.forms[0].Message.focus()
   return false
 }
  }
   try{document.forms[0].SaveArticle.disabled=true}catch(e){}
   try{document.forms[0].SaveDraft.disabled=true}catch(e){}
   try{document.forms[0].ReturnButton.disabled=true}catch(e){}
   try{document.forms[0].CancelEdit.disabled=true}catch(e){e}
   try{document.forms[0].DelArticle.disabled=true}catch(e){}
return true
}

function CheckDate(str){
        var reg = /^(\d{1,4})(-|\/)(\d{1,2})\2(\d{1,2}) (\d{1,2}):(\d{1,2}):(\d{1,2})$/;
        var r = str.match(reg);
        if(r==null)return false;
        var d= new Date(r[1],r[3]-1,r[4],r[5],r[6],r[7]);
        return (d.getFullYear()+"-"+(d.getMonth()+1)+"-"+d.getDate()+" "+d.getHours()+":"+d.getMinutes()+":"+d.getSeconds());
   }


function GetMessageLength()
{
 var oEditor = FCKeditorAPI.GetInstance('Message') ;
 var oDOM = oEditor.EditorDocument ;
 var iLength ;

if ( document.all )  // If Internet Explorer.
 {
  iLength = oDOM.body.innerText.length ;
 }
 else     // If Gecko.
 {
  var r = oDOM.createRange() ;
  r.selectNodeContents( oDOM.body ) ;
  iLength = r.toString().length ;
 }
// oEditor.InsertHtml('')
return iLength

function SetFont(size){
 document.getElementById("logPanel").style.fontSize=size
}
//引用
function addQuote(usr,content){
 try{
 if (document.getElementById("editorbody").style.display=="none") showUBB("Message");
    document.forms["frm"].Message.value="[quote="+usr+"]"+document.getElementById(content).innerText+"[/quote]"
 document.forms["frm"].Message.focus();
 }catch(e){}
}

//插入上传附件
function addUploadItem(type,path,memberDown){
 var EditType=""
 try{
   var oEditor = parent.FCKeditorAPI.GetInstance('Message')
   EditType="FCkEditor"
   var hrefLen=location.href.lastIndexOf("https://www.jb51.net/")
      var Fhref=location.href.substr(0,hrefLen+1)
      path=Fhref+path
 }
 catch(e){
   EditType="UBBEditor"
 }
 type=type.toLowerCase()
   switch(type){
    case 'gif':
        if (EditType=="UBBEditor"){parent.document.forms[0].Message.value+='[img]'https://www.jb51.net/article/+path+'[/img]\n'}
        else{oEditor.InsertHtml('<img src="'https://www.jb51.net/article/+path+'" alt=""/>')}
     break;
    case 'jpg':
        if (EditType=="UBBEditor"){parent.document.forms[0].Message.value+='[img]'https://www.jb51.net/article/+path+'[/img]\n'}
        else{oEditor.InsertHtml('<img src="'https://www.jb51.net/article/+path+'" alt=""/>')}
     break;
    case 'png':
        if (EditType=="UBBEditor"){parent.document.forms[0].Message.value+='[img]'https://www.jb51.net/article/+path+'[/img]\n'}
        else{oEditor.InsertHtml('<img src="'https://www.jb51.net/article/+path+'" alt=""/>')}
     break;
    case 'bmp':
        if (EditType=="UBBEditor"){parent.document.forms[0].Message.value+='[img]'https://www.jb51.net/article/+path+'[/img]\n'}
        else{oEditor.InsertHtml('<img src="'https://www.jb51.net/article/+path+'" alt=""/>')}
     break;
    case 'jpeg':
        if (EditType=="UBBEditor"){parent.document.forms[0].Message.value+='[img]'https://www.jb51.net/article/+path+'[/img]\n'}
        else{oEditor.InsertHtml('<img src="'https://www.jb51.net/article/+path+'" alt=""/>')}
     break;
    case 'mp3':
        if (EditType=="UBBEditor"){parent.document.forms[0].Message.value+='

播放音频文件

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wfzzdy.html