📄 edit_source.js
字号:
function inphototable(url){
if (!Error()) return;
if (url!="") {
var sel,RangeType
sel = idEdit.document.selection.createRange();
sel.pasteHTML('<table width="1" border="0" cellpadding="0" cellspacing="0" align=right><tr><td><img src="' + url + '"></td></tr><tr><td bgcolor="eaeaea">圖片說明</td></tr></table>');
sel.select();
}
idEdit.focus();
}
function insertpagesign(){
if (!Error()) return;
ab=showModalDialog("editor/js/page.html","color","dialogWidth:290pt;dialogHeight:50pt;help:0;status:0");
if(ab=="undefined") {
} else{
var sel,RangeType
sel = idEdit.document.selection.createRange();
sel.pasteHTML(ab);
sel.select();
idEdit.focus();
}
}
function insertcode(){
if (!Error()) return;
ab=showModalDialog("editor/js/code.html","color","dialogWidth:290pt;dialogHeight:170pt;help:0;status:0");
if(ab=="undefined") {
return false;
}else if (ab!="") {
var sel,RangeType
sel = idEdit.document.selection.createRange();
sel.pasteHTML(ab);
sel.select();
}
idEdit.focus();
}
function inserthtmllist() {
//if (!Error()) return;
url="make.php?action=make_list&cId=1" ;
ab=showModalDialog(url,"color","dialogWidth:530pt;dialogHeight:270pt;help:0;status:0");
if(ab=="undefined") {
return false;
}else if (ab!="") {
var sel,RangeType
sel = idEdit.document.selection.createRange();
sel.pasteHTML(ab);
sel.select();
}
idEdit.focus();
}
function insertflash(){
if (!Error()) return;
//ab=window.prompt("請輸入圖片的鏈接地址:","http://");
Today = new Date();
newName=Today.valueOf();
url="upload.php?type=flash&o=display&cId=" + document.content.cId.value + "&newName=" + newName;
ab=showModalDialog(url,"color","dialogWidth:477pt;dialogHeight:200pt;help:0;status:0");
//window.open(url, '', 'width=300,height=170,resizable=1,scrollbars=yes');
if (ab!="") {
var sel,RangeType
sel = idEdit.document.selection.createRange();
sel.pasteHTML( ab );
sel.select();
}
idEdit.focus();
}
/*
function insertattach(){
if (!Error()) return;
//ab=window.prompt("請輸入圖片的鏈接地址:","http://");
Today = new Date();
newName=Today.valueOf();
//url="upload.php?type=img&o=display&mode=single&cId=" + document.content.cId.value + "&newName=" + newName;
// var ab=showModalDialog(url,"color","dialogWidth:530pxt;dialogHeight:480px;help:0;status:0");
var ab=showModalDialog('upload.php?sId='+ sId +'&o=display&mode=one&type=attach&NodeID=' + NodeID,"color","dialogWidth:390px;dialogHeight:120px;help:0;status:0;scroll:0");
if (ab!=null && ab['url']!="" && ab['url']!= null) {
var str = "<a href=\""+ ab['url'] +"\" target=\"_blank\"><img src='"+ ab['publish_url'] + "images/icon/" + ab['suffix'] + ".gif' border=\"0\">" + ab['src_name'] + "</a>" ;
var sel,RangeType;
sel = idEdit.document.selection.createRange();
sel.pasteHTML( str );
sel.select();
}
idEdit.focus();
}
*/
function insertattach(value, sform, element){
if (!Error()) return;
if (value!=null && value['url']!="" && value['url']!= null) {
var str = "<a href=\""+ value['url'] +"\" target=\"_blank\"><img src='"+ value['publish_url'] + "images/icon/" + value['suffix'] + ".gif' border=\"0\">" + value['src_name'] + "</a>" ;
var sel,RangeType;
sel = idEdit.document.selection.createRange();
sel.pasteHTML( str );
sel.select();
}
idEdit.focus();
}
function intable(){
if (!Error()) return;
ab=showModalDialog("editor/js/table.html","color","dialogWidth:300pt;dialogHeight:180pt;help:0;status:0");
if (ab!="") {
var sel,RangeType
sel = idEdit.document.selection.createRange();
sel.pasteHTML('<table ' + ab + '</table>');
sel.select();
}
idEdit.focus();
}
//***************************************************
var sourceselectok;
function sourceshow(){
if(document.all.sourceselect.style.visibility=='hidden')document.all.sourceselect.style.visibility='visible';
else document.all.sourceselect.style.visibility='hidden';
sourceselectok = 0;
sourceing=setInterval("sourcehidden()",5);
}
function sourcehidden(){
if (sourceselectok>=500) {
if (window.sourceing) clearInterval(sourceing)
document.all.sourceselect.style.visibility='hidden';
}
sourceselectok++;
}
//***************************************************
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=sHeader + document.all.SaveContent.value
//var sContents='abcd';
// sContents= document.all.SaveContent.value
idEdit.document.open()
idEdit.document.write(sContents)
idEdit.document.close()
document.all.EditContent.style.display='';
document.all.SaveContent.style.display='none';
}
else {
//顯示html源碼
//document.all.SaveContent.style.width=document.body.scrollWidth-25;
str=idEdit.document.all.tags("BODY")[0].innerHTML;
//CUT/ len=sHeader.length;
//CUT/ len=len+62;
//CUT/ x = str.length;
//CUT/ x=x-len-7;
//document.write("The field named "+ sHeader.length +" has value of ");
//CUT/ document.all.SaveContent.value=str.substr(len,x)
document.all.SaveContent.value=str
idEdit.document.body.innerText=getPureHtml(idEdit.document.body.innerHTML);
//document.all.data_Content_html.value = document.all.SaveContent.value
}
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.EditContent.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.substr(1,500);
}
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(/<(\/|)(tr|tbody|table)(.[^\<]*|)>/ig,'\[$1$2]');
sContents=sContents.replace(/<(\/|)(td|th)(.[^\<]*|)>/ig,'\[$1$2$3]');
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="0" cellspacing="0"]');
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 ");
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -