?? edit.js
字號:
/*
Copyright 2001~2002 WWW.ZWCITY.COM 易影中國. All rights reserved.
Write by 2002-4-1
Edit by XiaoZeLin
Emailto: XiaoZeLin@163.net
HomePage: http://www.zwcity.com
Address: Shantou Guangdong China
*/
var sHeader='<meta http-equiv="Content-Language" content="zh-cn">' +
'<meta http-equiv="Content-Type" content="text/html; charset=gb2312">' +
'<style>' +
'body{margin:0px;scrollbar-face-color:buttonface;scrollbar-highlight-color:buttonface;scrollbar-shadow-color:buttonface;scrollbar-3dlight-color:buttonhighlight;scrollbar-arrow-color:#797979;scrollbar-track-color:#EEEEEE;scrollbar-darkshadow-color:buttonshadow}' +
'body,a,table,div,span,td,th,input,select{font:9pt;font-family: "宋體", Verdana, Arial, Helvetica, sans-serif;}' +
'</style>' +
'<body topmargin="0" leftmargin="0" onConTextMenu="event.returnValue=false;">';
var bMode=true,sel=null
function EditLoad(data) {
if (data!=null) data=data.replace(/&/ig,'&');
else data='';
bLoad=true;
EditContent.document.designMode="On";
idEdit = EditContent
idEdit.document.open()
idEdit.document.write(sHeader+data)
idEdit.document.close()
idEdit.focus();
}
function Error() {
if (bMode) return true;
alert("請選擇“編輯狀態(tài)”選項,才能使用系統(tǒng)編輯功能!");
idEdit.focus();
return false;
}
function format(what,opt) {
if (!Error()) return;
if (opt=="removeFormat"){
what=opt;opt=null
}
if (opt==null) idEdit.document.execCommand(what)
else idEdit.document.execCommand(what,"",opt)
idEdit.focus()
sel=null
}
function getEl(sTag,start) {
while ((start!=null) && (start.tagName!=sTag))
start = start.parentElement
return start
}
function create(what) {
if (!Error()) return;
idEdit.document.execCommand(what, true);
idEdit.focus()
}
function specialtype(Mark){
if (!Error()) return;
var sel,RangeType
sel = idEdit.document.selection.createRange();
RangeType = idEdit.document.selection.type;
if (RangeType == "Text"){
sel.pasteHTML("<" + Mark + ">" + sel.text + "</" + Mark + ">");
sel.select();
}
idEdit.focus();
}
function forecolor() {
if (!Error()) return;
var arr = showModalDialog("color.htm","color","dialogWidth:200pt;dialogHeight:175pt;help:0;status:0");
if (arr != null) format('forecolor',arr);
else idEdit.focus();
}
//***************************************************
function inphoto(url){
if (!Error()) return;
if (url!="") {
var sel,RangeType
sel = idEdit.document.selection.createRange();
sel.pasteHTML("<img src=\"../pic.asp?id=" + url + "\" align=\"right\">");
sel.select();
}
idEdit.focus();
}
//***************************************************
function clearEdit(){
setMode(false)
idEdit.document.open();
idEdit.document.write(sHeader)
idEdit.document.close();
}
function selectAll(){
setMode(false)
idEdit.document.all[0].innerHTML.select();
}
//**************************************************
function setMode(NewMode) {
showContent(false,NewMode)
if (NewMode!=bMode) {
if (NewMode) {
var sContents=document.all.SaveContent.value
idEdit.document.open()
idEdit.document.write(sContents)
idEdit.document.close()
}
else {
document.all.SaveContent.value=idEdit.document.all.tags("HTML")[0].innerHTML
idEdit.document.body.innerText=getPureHtml(idEdit.document.body.innerHTML);
}
bMode=NewMode
for (var i=0;i<htmlOnly.children.length;i++)
htmlOnly.children[i].disabled=(!bMode)
}
idEdit.focus()
}
function showContent(show,NewMode){
document.all.bW.checked=false;
document.all.bH.checked=false;
document.all.bE.checked=false;
document.all.bF.checked=false;
document.all.EditContent.style.display='';
document.all.SaveContent.style.display='';
if (show) {
document.all.EditContent.style.display='none';
if (NewMode) document.all.bE.checked=true;
else document.all.bF.checked=true;
}
else {
document.all.SaveContent.style.display='none';
if (NewMode) document.all.bW.checked=true;
else document.all.bH.checked=true;
}
}
function getPureHtml(){
var str = idEdit.document.body.innerHTML;
return str;
}
function rCode(s,a,b){
var r = new RegExp(a,"gi");
return s.replace(r,b);
}
function setSave(NewMode){
setMode(true)
showContent(true,NewMode)
if (NewMode) {
var sContents=getPureHtml(idEdit.document.body.innerHTML);
sContents=sContents.replace(/<(\/|)(td|th|tr|tbody|table)(.[^\<]*|)>/ig,'\[$1$2]');
sContents=sContents.replace(/\[(td|th)]/ig,' \[$1]');
sContents=sContents.replace(/\[tr]/ig,' \[TR]');
sContents=sContents.replace(/\[tbody]\r\n \[TR]/ig,'\[tbody]\n \[TR bgcolor="efefef"]');
sContents=sContents.replace(/\[table]/ig,'\[table width="1" border="0" cellpadding="1" cellspacing="1" style="border:1 ridge #eaeaea" align=right]');
var aryCode0 = new Array("<strong>","[b]","</strong>","[/b]","<p","[p","</p>","","<a href=","[url=","</a>","[/url]");
var aryCode1 = new Array("<em>","[i]","</em>","[/i]","<u>","[u]","</u>","[/u]","<ul>","[list]","</ul>","[/list]","<ol>","[list=1]","</ol>","[/list]");
var aryCode2 = new Array("<li>","[*]","</li>","","<font size=","[size=","<font color=","[color=","<font face=","[face=");
var aryCode9 = new Array(">","]","<","[","</","[/");
var aryCode = aryCode0.concat(aryCode1).concat(aryCode2).concat(aryCode9);
for (var i=0;i<aryCode.length;i+=2){
sContents=rCode(sContents,aryCode[i],aryCode[i+1]);
}
sContents=sContents.replace(/\[p([^\]]*|)]/ig,'[BR]');
} else {
var sContents=idEdit.document.all[0].innerText
sContents=sContents.replace(/\r\n/ig,'[BR]\n');
}
sContents=sContents.replace(/\ \[BR]/ig,'[BR]');
document.all.SaveContent.value=sContents.replace(/([0-9a-zA-Z@]{32})/ig,"$1 ");
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -