PBlog2 公用JS代码
本文导语: 代码如下: //PBlog2 公用JS代码//Author:PuterJam //查找网页内宽度太大的图片进行缩放以及PNG纠正 function ReImgSize(){ for (i=0;i500) { document.images[i].width="500" document.images[i].outerHTML=''+document.images[i].outerHTML+'' } }...
//PBlog2 公用JS代码
//Author:PuterJam
//查找网页内宽度太大的图片进行缩放以及PNG纠正
function ReImgSize(){
for (i=0;i500)
{
document.images[i].width="500"
document.images[i].outerHTML=''+document.images[i].outerHTML+''
}
}
else{
if (document.images[i].width>400) {
document.images[i].title="在新窗口打开图片"
document.images[i].style.cursor="pointer"
document.images[i].onclick=function(e){window.open(this.src)}
}
}
}
}
//AccessKey 转换For IE Design By PuterJam
var NKey=new Array()
var KeyCode=new Array()
var KeyInit=false
//======== keyCode ============
KeyCode["1"]=49
KeyCode["2"]=50
KeyCode["3"]=51
KeyCode["["]=219
KeyCode["]"]=221
KeyCode[","]=188
KeyCode["."]=190
var EKey="abcdefghijklmnopqrstuwvxyz"
for (i=0;i -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("/")
var Fhref=/tech-program-other/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]'+path+'[/img]n'}
else{oEditor.InsertHtml('')}
break;
case 'jpg':
if (EditType=="UBBEditor"){parent.document.forms[0].Message.value+='[img]'+path+'[/img]n'}
else{oEditor.InsertHtml('')}
break;
case 'png':
if (EditType=="UBBEditor"){parent.document.forms[0].Message.value+='[img]'+path+'[/img]n'}
else{oEditor.InsertHtml('')}
break;
case 'bmp':
if (EditType=="UBBEditor"){parent.document.forms[0].Message.value+='[img]'+path+'[/img]n'}
else{oEditor.InsertHtml('')}
break;
case 'jpeg':
if (EditType=="UBBEditor"){parent.document.forms[0].Message.value+='[img]'+path+'[/img]n'}
else{oEditor.InsertHtml('')}
break;
case 'mp3':
if (EditType=="UBBEditor"){parent.document.forms[0].Message.value+='
else{oEditor.InsertHtml('')}
break;
case 'rm':
if (EditType=="UBBEditor"){parent.document.forms[0].Message.value+='
else{oEditor.InsertHtml('
')}
break;
case 'rmvb':
if (EditType=="UBBEditor"){parent.document.forms[0].Message.value+='
else{oEditor.InsertHtml('
')}
break;
case 'ra':
if (EditType=="UBBEditor"){parent.document.forms[0].Message.value+='
else{oEditor.InsertHtml('')}
break;
case 'asf':
if (EditType=="UBBEditor"){parent.document.forms[0].Message.value+='
else{oEditor.InsertHtml('')}
break;
case 'avi':
if (EditType=="UBBEditor"){parent.document.forms[0].Message.value+='
else{oEditor.InsertHtml('')}
break;
case 'wmv':
if (EditType=="UBBEditor"){parent.document.forms[0].Message.value+='
else{oEditor.InsertHtml('')}
break;
case 'swf':
if (EditType=="UBBEditor"){parent.document.forms[0].Message.value+='
else{oEditor.InsertHtml('')}
break;
default :
if (EditType=="UBBEditor"){
if (memberDown==1)
{parent.document.forms[0].Message.value+='[mDown='+path+']点击下载此文件[/mDown]n'}
else
{parent.document.forms[0].Message.value+=' 点击下载此文件n'}
}
else{oEditor.InsertHtml('点击下载此文件')}
break;
}
}
//写入顶部Flash文件
function WriteHeadFlash(Path,Width,Height,Transparent){
var Temp,T=""
Temp=''
Temp+=''
Temp+=''
Temp+=''
if (Transparent) {Temp+=' ';T='wmode="transparent"'}
Temp+=''
Temp+=''
document.getElementById("FlashHead").innerHTML=Temp
}
您可能感兴趣的文章:
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。