?? comm2.js
字號:
var mRegExp = new Object();
function insert(what)
{
mEditor.focus();
var sel = mEditor.document.selection.createRange();
switch(what){
case "excel":
insertHTML(getLangText("Cmpnts","0x2003"));
break;
case "quote":
insertHTML('<table width=95% border="0" align="Center" cellpadding="6" cellspacing="0" style="border: 1px Dotted #6595d6; TABLE-LAYOUT: fixed; background-color:#e8f4ff"><tr><td style="WORD-WRAP: break-word"><font style="color: #990066;font-weight:bold">' + getLangText("Cmpnts","0x2001") + ':</font><br>' + String.HTMLEncode(sel.text) + '</td></tr></table>');
break;
case "code":
insertHTML('<table width=95% border="0" align="Center" cellpadding="6" cellspacing="0" style="border: 1px Dotted #78DCCA; TABLE-LAYOUT: fixed; background-color:#e8f4ff"><tr><td style="WORD-WRAP: break-word"><font style="color: #990033;font-weight:bold">' + getLangText("Cmpnts","0x2002") + '</font><br>' + String.HTMLEncode(sel.text) + '</td></tr></table>');
break;
case "date":
window.execScript('pasteHTML(FormatDateTime(now,1))','VBScript');
break;
case "time":
window.execScript('pasteHTML(FormatDateTime(now,3))','VBScript');
break;
case "big":
insertHTML("<big>" + sel.text + "</big>");
break;
case "small":
insertHTML("<small>" + sel.text + "</small>");
break;
case "br":
insertHTML("<br>")
break;
default:
break;
}
sel=null;
mEditor.focus();
}
function URLFilters(s)
{
var re;
var sHttpUploadPath = relativePath2AbsoluteHttpPath(mSystem["UploadPath"],getEditorHttpPath())
var sHttpIconImage = relativePath2AbsoluteHttpPath(mSystem["IconImage"],getEditorHttpPath())
var sHttpFilesImage = relativePath2AbsoluteHttpPath(mSystem["FilesImage"],getEditorHttpPath())
var sHttpBgImage = relativePath2AbsoluteHttpPath(mSystem["BgImage"],getEditorHttpPath())
re = new RegExp("(" + sHttpUploadPath + ")+","ig");
s = s.replace(re,ConvertURL(mSystem["UploadPath"],mSystem["UrlMode"]));
re = new RegExp("(" + sHttpIconImage + ")+","ig");
s = s.replace(re,ConvertURL(mSystem["IconImage"],"1"));
re = new RegExp("(" + sHttpFilesImage + ")+","ig");
s = s.replace(re,ConvertURL(mSystem["FilesImage"],"1"));
re = new RegExp("(" + sHttpBgImage + ")+","ig");
s = s.replace(re,ConvertURL(mSystem["BgImage"],"1"));
return s;
}
//alert(ConvertURL(mSystem["UploadPath"],"3"));
//=============================================================================================
// 相對路徑或絕對根路徑URL轉(zhuǎn)換 sPath:相對路徑或絕對根路徑
//=============================================================================================
function ConvertURL(sPath,v)
{
switch(v)
{
case "1": //絕對根路徑模式
sPath = absoluteHttpPath2AbsoluteRootPath(relativePath2AbsoluteHttpPath(sPath,getEditorHttpPath()),getSitePath());
break;
case "2": //絕對URL全路徑模式
sPath = relativePath2AbsoluteHttpPath(sPath,getEditorHttpPath());
break;
case "3": //相對路徑模式
sPath = absoluteHttpPath2RelativePath(relativePath2AbsoluteHttpPath(sPath,getEditorHttpPath()),getEditorHttpPath(),getSitePath())
break;
}
return sPath;
}
//=============================================================================================
// 網(wǎng)站全稱
//=============================================================================================
function getSitePath()
{
return (document.location.protocol + "//" + document.location.host).toLowerCase();
}
//alert(getSitePath()); //后面不帶"/"
//=============================================================================================
// mEditor所在的根路徑
//=============================================================================================
function getEditorRootPath()
{
var url = document.location.pathname;
return url.substring(0,url.lastIndexOf("/")+1);
}
//alert(getEditorRootPath());
//=============================================================================================
// mEditor所在的http路徑
//=============================================================================================
function getEditorHttpPath()
{
return getSitePath()+getEditorRootPath();
}
//alert(getEditorHttpPath());
//=============================================================================================
// 在同網(wǎng)將http絕對路徑轉(zhuǎn)換成絕對根路徑
//=============================================================================================
function absoluteHttpPath2AbsoluteRootPath(str,sSitePath)
{
sSitePath = sSitePath.toLowerCase();
if(sSitePath.substr(sSitePath.length-1)!="/")sSitePath += "/";
var re = new RegExp("(" + sSitePath + ")+","ig");
str = str.replace(re,"/")
return str;
}
//alert(absoluteHttpPath2AbsoluteRootPath("http://localhost/sina",getSitePath()));
//=============================================================================================
// 在同網(wǎng)將http絕對路徑轉(zhuǎn)換成與某目錄的相對路徑(相對同網(wǎng)某個http絕對地址:sRelativeFldrHttpPath)
//=============================================================================================
function absoluteHttpPath2RelativePath(sAbsoluteHttpPath,sRelativeFldrHttpPath,sSitePath)
{
var i,j,k,sResultPath = "";
sSitePath = sSitePath.toLowerCase();
sAbsoluteHttpPath = sAbsoluteHttpPath.toLowerCase().replace(sSitePath + "/","");
sRelativeFldrHttpPath = sRelativeFldrHttpPath.toLowerCase().replace(sSitePath + "/","");
if(sAbsoluteHttpPath.substr(sAbsoluteHttpPath.length-1)=="/")sAbsoluteHttpPath = sAbsoluteHttpPath.substr(0,sAbsoluteHttpPath.length-1);
if(sRelativeFldrHttpPath.substr(sRelativeFldrHttpPath.length-1)=="/")sRelativeFldrHttpPath = sRelativeFldrHttpPath.substr(0,sRelativeFldrHttpPath.length-1);
aAbsolutePath = sAbsoluteHttpPath.split("/");
aRelativeFldrHttpPath = sRelativeFldrHttpPath.split("/");
for(i=0;i<aAbsolutePath.length ;i++){
if(aAbsolutePath[i] != aRelativeFldrHttpPath[i]){break;}
}
k = aRelativeFldrHttpPath.length - i;
if(sRelativeFldrHttpPath =="")
{
sResultPath = "";
}
else
{
for(j=0;j<k;j++){sResultPath +="../";}
}
for(;i<aAbsolutePath.length;i++){
if(sAbsoluteHttpPath == "")break;
sResultPath += aAbsolutePath[i] + "/";
}
if(sResultPath=="")sResultPath = "./";
return sResultPath;
}
//alert(absoluteHttpPath2RelativePath("http://localhost/sina",getEditorHttpPath(),getSitePath()));
//=============================================================================================
// 在同網(wǎng)將相對路徑或絕對根路徑(sRelativePath)轉(zhuǎn)換成http絕對路徑(相對同網(wǎng)某個http絕對地址:sEditorRootPath)
//=============================================================================================
function relativePath2AbsoluteHttpPath(sRelativePath,sEditorRootPath)
{
var sResultPath = "",sTemp1 = "",sTemp2 = "";
var sSitePath = getSitePath();
var sRelativePath = sRelativePath.toLowerCase();
var sEditorRootPath = sEditorRootPath.toLowerCase();
if(sEditorRootPath.substr(sEditorRootPath.length-1)=="/")sEditorRootPath = sEditorRootPath.substr(0,sEditorRootPath.length-1);
sEditorRootPath = sEditorRootPath.replace(sSitePath + "/","");
aRelativePath = sRelativePath.split("/");
aEditorRootPath = sEditorRootPath.split("/");
var pos = aEditorRootPath.length - 1;
if(sRelativePath.substr(0,1)=="/")
{
sResultPath = sSitePath + sRelativePath;
}
else if(sRelativePath.substr(0,1)=="")
{
sResultPath = sSitePath + "/" + sEditorRootPath;
}
else
{
for(var i=0;i<aRelativePath.length;i++)
{
if(aRelativePath[i] =="..")
{
if(pos>=0)pos--;
}
else if(aRelativePath[i] == "." || aRelativePath[i] == ""){}
else
{
sTemp2 += aRelativePath[i] + "/";
}
}
for(var j=0;j<=pos&&pos>=0;j++)
{
sTemp1 += aEditorRootPath[j] + "/";
}
sResultPath = sSitePath + "/" + sTemp1 + sTemp2;
}
return sResultPath;
}
//alert(relativePath2AbsoluteHttpPath("../upload/",getEditorHttpPath()));
//=============================================================================================
// 在同網(wǎng)將相對路徑轉(zhuǎn)換成絕對根路徑(相對同網(wǎng)某個http絕對地址)
//=============================================================================================
function relativePath2AbsoluteRootPath(url)
{
return absoluteHttpPath2AbsoluteRootPath(relativePath2AbsoluteHttpPath(url,getEditorHttpPath()),getSitePath());
}
//alert(relativePath2AbsoluteRootPath("images"));
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -