📄 post.js
字号:
document.writeln("<link rel=STYLESHEET type=text/css href=images/post/edit.css>")
document.writeln("<table id=TM_Container class=TM_Body width=100% height=100% cellpadding=2 cellspacing=0><tr><td>");
document.writeln("<table cellpadding=0 cellspacing=0 width='100%'><tr><td class=TM_Btn> ")
document.writeln(" <select onChange=\"FormatText('FormatBlock',this[this.selectedIndex].value);\"> <option selected>段落格式</option> <option value=\"<P>\">正文</option><option value=\"<H1>\">标题一</option><option value=\"<H2>\">标题二</option><option value=\"<H3>\">标题三</option><option value=\"<H4>\">标题四</option><option value=\"<H5>\">标题五</option><option value=\"<H6>\">标题六</option><option value=\"<PRE>\">预设格式</option></select></td>");
document.writeln("<td class=TM_Btn><select name=\"selectFont\" onChange=\"FormatText('fontname',selectFont.options[selectFont.selectedIndex].value);\"><option selected>字体<option value=\"removeFormat\">默认字体<option value=\"宋体\">宋体<option value=\"黑体\">黑体<option value=\"隶书\">隶书<option value=\"幼圆\">幼圆<option value=\"楷体_GB2312\">楷体<option value=\"仿宋_GB2312\">仿宋<option value=\"新宋体\">新宋体<option value=\"华文彩云\">华文彩云<option value=\"华文仿宋\">华文仿宋<option value=\"华文新魏\">华文新魏<option value=\"Arial\">Arial<option value=\"Arial Black\">Arial Black<option value=\"Arial Narrow\">Arial Narrow<option value=\"Century\">Century<option value=\"Courier New\">Courier New<option value=\"Georgia\">Georgia<option value=\"Impact\">Impact<option value=\"System\">System<option value=\"Symbol\">Symbol<option value=\"Tahoma\">Tahoma<option value=\"Verdana\">Verdana<option value=\"Webdings\">Webdings<option value=\"Wingdings\">Wingdings</option></select></td>");
document.writeln("<td class=TM_Btn><select onChange=\"FormatText('fontsize',this[this.selectedIndex].value);\" name=\"D2\"><option class=\"heading\" selected>字号<option value=1>一号<option value=2>二号<option value=3>三号<option value=4>四号<option value=5>五号<option value=6>六号<option value=7>七号</option></select></td>");
document.writeln("<td class=TM_Btn onclick=this.className='TM_TabOn'; onmouseover=this.className='TM_BtnMouseOverUp'; onmouseout=this.className='TM_Btn';><img src=images/post/images/fbcolor.gif alt=\"突出颜色\" align=absmiddle style=cursor:hand onClick=BackColor()></td>");
document.writeln("<td class=TM_Btn onclick=this.className='TM_TabOn'; onmouseover=this.className='TM_BtnMouseOverUp'; onmouseout=this.className='TM_Btn';><img src=images/post/images/fgcolor.gif alt=\"字体颜色\" align=absmiddle style=cursor:hand onClick=foreColor()></td>");
document.writeln("<td class=TM_Btn onclick=this.className='TM_TabOn'; onmouseover=this.className='TM_BtnMouseOverUp'; onmouseout=this.className='TM_Btn';><img src=images/post/images/replace.gif alt=\"替换\" align=absmiddle style=cursor:hand onClick=replace()></td>");
document.writeln("<td class=TM_Btn onclick=this.className='TM_TabOn'; onmouseover=this.className='TM_BtnMouseOverUp'; onmouseout=this.className='TM_Btn';><img alt=\"插入表格\" src=images/post/images/table.gif align=absmiddle style=cursor:hand onclick=fortable()></td>");
document.writeln("<td width=1><img src=images/post/images/separator.gif></td>");
document.writeln("<td class=TM_Btn onclick=this.className='TM_TabOn'; onmouseover=this.className='TM_BtnMouseOverUp'; onmouseout=this.className='TM_Btn';><img alt=\"清理代码\" src=images/post/images/cleancode.gif align=absmiddle style=cursor:hand ></td>");
document.writeln("<td class=TM_Btn onclick=this.className='TM_TabOn'; onmouseover=this.className='TM_BtnMouseOverUp'; onmouseout=this.className='TM_Btn';><img alt=\"插入表情图标\" src=images/post/images/myem.gif align=absmiddle style=cursor:hand onclick=myem()></td>");
document.writeln("<td class=TM_Btn onclick=this.className='TM_TabOn'; onmouseover=this.className='TM_BtnMouseOverUp'; onmouseout=this.className='TM_Btn';><img src=images/post/images/img.gif alt=\"插入图片\" align=absmiddle style=cursor:hand onClick=img()></td>");
document.writeln("<td class=TM_Btn onclick=this.className='TM_TabOn'; onmouseover=this.className='TM_BtnMouseOverUp'; onmouseout=this.className='TM_Btn';><img alt=\"插入FLASH文件\" src=images/post/images/swf.gif align=absmiddle style=cursor:hand onclick=flash()></td>");
document.writeln("<td width=1><img src=images/post/images/separator.gif></td>");
document.writeln("<td class=TM_Btn onclick=this.className='TM_TabOn'; onmouseover=this.className='TM_BtnMouseOverUp'; onmouseout=this.className='TM_Btn';><img alt=\"插入Media Player文件\" src=images/post/images/mp.gif align=absmiddle style=cursor:hand onclick=MediaPlayer()></td>");
document.writeln("<td class=TM_Btn onclick=this.className='TM_TabOn'; onmouseover=this.className='TM_BtnMouseOverUp'; onmouseout=this.className='TM_Btn';><img alt=\"插入RealPlayer文件\" src=images/post/images/rm.gif align=absmiddle style=cursor:hand onclick=RealPlay()></td>");
document.writeln("<td class=TM_Btn onclick=this.className='TM_TabOn'; onmouseover=this.className='TM_BtnMouseOverUp'; onmouseout=this.className='TM_Btn';><img alt=\"插入背景音乐\" src=images/post/images/csound.gif align=absmiddle style=cursor:hand onclick=Ybbsound()></td>");
document.writeln("<td class=TM_Btn onclick=this.className='TM_TabOn'; onmouseover=this.className='TM_BtnMouseOverUp'; onmouseout=this.className='TM_Btn';><img alt=\"引用\" src=images/post/images/quote.gif align=absmiddle style=cursor:hand onclick=Ybbquote()></td>");
document.writeln("</tr></table>");
if (repost=="")
{
var repost="0"
}
if (repost!=1){
document.writeln("<table cellpadding=0 cellspacing=0 width='100%'><tr>");
var FormatTextlist="全选 selectAll|取消选择 unselect|删除当前选中区 Delete|插入超链接 createLink|去掉超链接 Unlink|separator|剪切 cut|复制 copy|粘贴 paste|粗体 bold|倾斜 italic|下划线 underline|separator|上标 superscript|下标 subscript|删除线 strikethrough|删除文字格式 RemoveFormat|separator|左对齐 Justifyleft|居中 JustifyCenter|右对齐 JustifyRight|两端对齐 justifyfull|separator|编号 insertorderedlist|项目符号 InsertUnorderedList|减少缩进量 Outdent|增加缩进量 indent|普通水平线 InsertHorizontalRule "
var list= FormatTextlist.split ('|');
for(i=0;i<list.length;i++)
{
if (list[i]=="separator")
{
document.writeln("<td width=1><img src=images/post/images/separator.gif></td>");
}
else
{
var TextName= list[i].split (' ');
document.write("<td class=TM_Btn onclick=this.className='TM_TabOn'; onmouseover=this.className='TM_BtnMouseOverUp'; onmouseout=this.className='TM_Btn';><img align=absmiddle src=images/post/images/"+TextName[1]+".gif alt="+TextName[0]+" style=cursor:hand onClick=FormatText('"+TextName[1]+"')></td>");
}
}
document.writeln("</tr></table>");
}
document.writeln("</td></tr><tr><td height='100%'><iframe class=TM_Composition ID=HtmlEditor MARGINHEIGHT=5 MARGINWIDTH=5 width=100% height=100% ></iframe></td></tr><tr><td width='100%'><TABLE CELLPADDING=0 CELLSPACING=0 BORDER=0 width='100%'><tr>");
document.writeln("<td><a href='javascript:TM_Size(-150)'><img src='images/post/images/minus.gif' unselectable='on' border='0'></a> <a href='javascript:TM_Size(150)'><img src='images/post/images/plus.gif' unselectable='on' border='0'></a></TD><TD align=right><select ID=\"Zoom\" onchange=\"doZoom(this)\" ><option VALUE=100>分辨率<option VALUE=50>50%<option VALUE=75>75%<option VALUE=100>100%<option VALUE=125>125%<option VALUE=150>150%<option VALUE=175>175%<option VALUE=200>200%</option></select></td></tr></TABLE></td></tr></TABLE>");
if (document.all){
var IframeID=frames["HtmlEditor"];}
else{
var IframeID=document.getElementById("HtmlEditor").contentWindow;}
if (navigator.appVersion.indexOf("MSIE 6.0",0)==-1){
IframeID.document.designMode="On"}
if (document.all){
var TM_bodyTag="</head><BODY bgcolor=\"#FFFFFF\" onkeydown=\"ctlent();\">";}
else{
var TM_bodyTag="</head><BODY bgcolor=\"#FFFFFF\">";}
var h=document.getElementById("content").value;
var ischeck=false
IframeID.document.open();
IframeID.document.write ('<html><head>');
if (document.all){
IframeID.document.write ('<script language="javascript">');
IframeID.document.write ('var ispost=0;');
IframeID.document.write (' function ctlent(eventobject)');
IframeID.document.write (' {');
IframeID.document.write (' if(event.ctrlKey && window.event.keyCode==13&&ispost==0)');
IframeID.document.write (' {');
IframeID.document.write (' parent.TM_CopyData("content"); ');
IframeID.document.write (' if(parent.ischeck==true){');
IframeID.document.write (' parent.document.TM_form.Submit.disabled=true;');
IframeID.document.write (' parent.document.TM_form.submit();}');
IframeID.document.write (' }');
IframeID.document.write (' }');
IframeID.document.write ('<\/script>');
}
IframeID.document.write(TM_bodyTag);
IframeID.document.write("</body>");
IframeID.document.write("</html>");
if (h!="")
{
IframeID.document.body.innerHTML=h;
}
IframeID.document.close();
IframeID.document.onkeypress=DelEnter
IframeID.document.body.contentEditable = "True";
TM_setStyle();
//IframeID.focus();
//解决换行的问题
function DelEnter()
{
if(IframeID.event.keyCode==13)
{
var et=IframeID.document.selection.createRange()
et.text==""?et.text="\n":(IframeID.document.selection.clear())&(et.text="\n")
IframeID.document.selection.createRange().select()
return false
}
}
function TM_setStyle()
{
var cont;
var bs = IframeID.document.body.style;
bs.fontFamily="Arial";
bs.fontSize="10.5pt";
bs.scrollbar3dLightColor= '#D4D0C8';
bs.scrollbarArrowColor= '#000000';
bs.scrollbarBaseColor= '#D4D0C8';
bs.scrollbarDarkShadowColor= '#D4D0C8';
bs.scrollbarFaceColor= '#D4D0C8';
bs.scrollbarHighlightColor= '#808080';
bs.scrollbarShadowColor= '#808080';
bs.scrollbarTrackColor= '#D4D0C8';
bs.border='0';
}
function TM_CopyData(content)
{
ischeck=true
document.TM_form.Submit.disabled=true;
TM_formatimg();
cont = IframeID.document.body.innerHTML;
cont = TM_correctUrl(cont);
cont = TM_cleanHtml(cont);
if (cont!='')
{
cont = TM_FilterScript(cont);
}
document.getElementById(content).value = cont;
}
function TM_formatimg()
{
if (document.all){
var tmp=IframeID.document.body.all.tags("IMG");
}else{
var tmp=IframeID.document.getElementsByTagName("IMG");
}
for(var i=0;i<tmp.length;i++){
var tempstr='';
if(tmp[i].align!=''){tempstr=" align="+tmp[i].align;}
if(tmp[i].border!=''){tempstr=tempstr+" border="+tmp[i].border;}
tmp[i].outerHTML="<IMG src=\""+tmp[i].src+"\""+tempstr+">"
}
}
function TM_correctUrl(cont)
{
var regExp;
regExp = /<a([^>]*) href\s*=\s*([^\s|>]*)([^>]*)/gi
cont = cont.replace(regExp, "<a href=$2 target=\"_blank\" ");
regExp = /<a([^>]*)><\/a>/gi
cont = cont.replace(regExp, "");
return cont;
}
//代码过滤及JS提取
function TM_FilterScript(content)
{
content = content.replace(/<(\w[^div|>]*) class\s*=\s*([^>|\s]*)([^>]*)/gi,"<$1$3") ;
content = content.replace(/<(\w[^font|>]*) style\s*=\s*\"[^\"]*\"([^>]*>)/gi,"<$1 $2");
content = content.replace(/<(\w[^>]*) lang\s*=\s*([^>|\s]*)([^>]*)/gi,"<$1$3") ;
var RegExp = /<(script[^>]*)>(.*)<\/script>/gi;
content = content.replace(RegExp, "[code]<$1><br>$2<br><script>[\/code]");
RegExp = /<(\w[^>|\s]*)([^>]*)(on(finish|mouse|Exit|error|click|key|load|change|focus|blur))(.[^>]*)/gi;
content = content.replace(RegExp, "<$1")
RegExp = /<(\w[^>|\s]*)([^>]*)(&#|window\.|javascript:|js:|about:|file:|Document\.|vbs:|cookie| name| id)(.[^>]*)/gi;
content = content.replace(RegExp, "<$1")
return content;
}
//清理多余HTML代码
function TM_cleanHtml(content)
{
content = content.replace(/<p> <\/p>/gi,"")
content = content.replace(/<p><\/p>/gi,"<p>")
content = content.replace(/<div><\/\1>/gi,"")
content = content.replace(/<p>/,"<br>")
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -