⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 post.js

📁 这是一套基于WEB的网站管理系统
💻 JS
📖 第 1 页 / 共 2 页
字号:
	sel.pasteHTML(arr);
	}
}

function CleanCode(){
	if (!	validateMode())	return;
	var body = IframeID.document.body;
	var html = IframeID.document.body.innerHTML;
	html = html.replace(/\<p>/gi,"[$p]");
	html = html.replace(/\<\/p>/gi,"[$\/p]");
	html = html.replace(/\<br>/gi,"[$br]");
	html = html.replace(/\<[^>]*>/g,"");
	html = html.replace(/\[\$p\]/gi,"<p>");
	html = html.replace(/\[\$\/p\]/gi,"<\/p>");
	html = html.replace(/\[\$br\]/gi,"<br>");
	IframeID.document.body.innerHTML = html;
}


function FormatText(command,option){
	if (!	validateMode())	return;
	IframeID.focus();IframeID.document.execCommand(command,true,option);
}

function CheckLength(){
	alert("\n您的内容已有 "+IframeID.document.body.innerHTML.length+" 字节");
}

function emoticon(theSmilie){
	if (!	validateMode())	return;
	IframeID.focus();
	sel=IframeID.document.selection.createRange();
	sel.pasteHTML("<img src=../images/emotion/"+theSmilie+".gif>");
}

function DoTitle(addTitle) {
var revisedTitle;var currentTitle = document.myform.topic.value;revisedTitle = addTitle+currentTitle;document.myform.topic.value=revisedTitle;document.myform.topic.focus();
}

function Gopreview()
{
	if (!	validateMode())	return;
	document.preview.content.value=IframeID.document.body.innerHTML; 
	window.open('', 'preview_page', 'resizable,scrollbars,width=750,height=450');
	document.preview.submit()
}

function BackColor()
{
	if (!	validateMode())	return;
	var arr = showModalDialog("" +strFilePath+ "selcolor.htm", "", "dialogWidth:18em; dialogHeight:17.5em; status:0;help:0");
	if (arr != null) FormatText('BackColor', arr);
	else IframeID.focus();
}

function foreColor()
{
	if (!	validateMode())	return;
	var arr = showModalDialog("" +strFilePath+ "selcolor.htm", "", "dialogWidth:18em; dialogHeight:17.5em; status:0;help:0");
	if (arr != null) FormatText('forecolor', arr);
	else IframeID.focus();
}

//////替换内容
function replace()
{
	if (!	validateMode())	return;
  var arr = showModalDialog("" +strFilePath+ "replace.htm", "", "dialogWidth:22em;dialogHeight:10em;status:0;help:0");
	if (arr != null){
		var ss;
		ss = arr.split("*")
		a = ss[0];
		b = ss[1];
		i = ss[2];
		con = IframeID.document.body.innerHTML;
		if (i == 1)
		{
			con = newasp_rCode(con,a,b,true);
		}else{
			con = newasp_rCode(con,a,b);
		}
		IframeID.document.body.innerHTML = con;
	}
	else IframeID.focus();
}
function newasp_rCode(s,a,b,i){
	a = a.replace("?","\\?");
	if (i==null)
	{
		var r = new RegExp(a,"gi");
	}else if (i) {
		var r = new RegExp(a,"g");
	}
	else{
		var r = new RegExp(a,"gi");
	}
	return s.replace(r,b); 
}
//////替换内容结束

function img(){
	if (!	validateMode())	return;
	url=prompt("请输入图片文件地址:","http://");
	if(!url || url=="http://") return;
	IframeID.focus();
	sel=IframeID.document.selection.createRange();
	sel.pasteHTML("<img border=0 src="+url+">");
}

function RealPlay(){
	if (!	validateMode())	return;
	var arr = showModalDialog("" +strFilePath+ "RealPlay.htm", "", "dialogWidth:22em; dialogHeight:10.5em; status:0;help:0");
	if (arr != null){
	IframeID.focus()
	sel=IframeID.document.selection.createRange();
	sel.pasteHTML(arr);
	}
}

function MediaPlayer(){
	if (!	validateMode())	return;
	var arr = showModalDialog("" +strFilePath+ "MediaPlayer.htm", "", "dialogWidth:22em; dialogHeight:10.5em; status:0;help:0");
	if (arr != null){
	IframeID.focus()
	sel=IframeID.document.selection.createRange();
	sel.pasteHTML(arr);
	}
}

function flash(){
	if (!	validateMode())	return;
	var arr = showModalDialog("" +strFilePath+ "flash.htm", "", "dialogWidth:22em; dialogHeight:9em; status:0;help:0");
	if (arr != null){
	//IframeID.focus()
	sel=IframeID.document.selection.createRange();
	sel.pasteHTML(arr);
	}
}

function WBTB_quote()
{
	WBTB_specialtype("<div style=\"margin:5px; padding:5px; border: 1px Dotted #CCCCCC; TABLE-LAYOUT: fixed; background:#F8F8F8\"><font style=\"color: #990000;font-weight:bold\">以下是引用片段:</font><br>","</div>");	

}
function WBTB_code()
{
	WBTB_specialtype("<div style=\"margin:5px;border:1px solid #CCCCCC;padding:5px;background:#FDFDDF;font-size:14px;font-family:Tahoma;font-style : oblique;line-height : normal ;font-weight:bold;\"><font style=\"color: #990000;font-weight:bold\">以下是代码片段:</font><br>","</div>");	

}
var WBTB_bIsIE5 = (navigator.userAgent.indexOf("IE 5")  > -1) || (navigator.userAgent.indexOf("IE 6")  > -1);
var WBTB_edit;	//selectRang
var WBTB_RangeType;
var WBTB_selection;

//应用html
function WBTB_specialtype(Mark1, Mark2){
	var strHTML;
	if (!	validateMode())	return;
	if (WBTB_bIsIE5) WBTB_selectRange();
	if (WBTB_RangeType == "Text"){
		if (Mark2==null)
		{
			strHTML = "<" + Mark1 + ">" + WBTB_edit.htmlText + "</" + Mark1 + ">"; 
		}else{
			strHTML = Mark1 + WBTB_edit.htmlText +  Mark2; 
		}
		WBTB_edit.pasteHTML(strHTML);
		Composition.focus();
		WBTB_edit.select();
	}else{window.alert("请选择相应内容!")}		
}
//选择内容替换文本
function WBTB_InsertSymbol(str1)
{
	Composition.focus();
	if (WBTB_bIsIE5) WBTB_selectRange();	
	WBTB_edit.pasteHTML(str1);
}


function WBTB_selectRange(){
	WBTB_selection = IframeID.document.selection;
	WBTB_edit = IframeID.document.selection.createRange();
	WBTB_RangeType =  IframeID.document.selection.type;
}

//////设置编辑器模式
function setMode(newMode)
{
  bTextMode = newMode;
  var content;
  if (bTextMode) {
    cleanHtml();

    content=IframeID.document.body.innerHTML;
    IframeID.document.body.innerText=content;
  } else {
    content=IframeID.document.body.innerText;
    IframeID.document.body.innerHTML=content;
  }

  Composition.focus();
}

function cleanHtml()
{
  var fonts = IframeID.document.body.all.tags("FONT");
  var curr;
  for (var i = fonts.length - 1; i >= 0; i--) {
    curr = fonts[i];
    if (curr.style.backgroundColor == "#ffffff") curr.outerHTML	= curr.innerHTML;
  }
}
//插入表格
function fortable()
{
	if (!	validateMode())	return;
	IframeID.focus();
	var arr = showModalDialog("" +strFilePath+ "table.htm", window, "dialogWidth:22em; dialogHeight:19em; status:0; help:0;scroll:no;");
	if (arr)
	{
		IframeID.document.body.innerHTML+=arr;
	}
	IframeID.focus();
}

// 改变编辑区高度
function sizeChange(size){
	//if (!BrowserInfo.IsIE55OrMore){
		//alert("此功能需要IE5.5版本以上的支持!");
		//return false;
	//}
	for (var i=0; i<parent.frames.length; i++){
		if (parent.frames[i].document==self.document){
			var obj=parent.frames[i].frameElement;
			var height = parseInt(obj.offsetHeight);
			if (height+size>=100){
				obj.height=height+size;
			}
			break;
		}
	}
}

//calc count
var _calcCountTimer;
function calcWordCount() {
	if (!	validateMode())	return;
	var s_current = '当前 ';
	var s_word = ' 个字符';
	var s_maxword = '最多 ';
	var t = document.getElementById('wordCount');
	var t1 = document.getElementById('wordCount1');
	if (t) {
		t.innerHTML = '['+s_current+ IframeID.document.body.innerHTML.length + s_word + (_maxCount > 0 ? ','+s_maxword+ _maxCount + s_word : '') + ']';
	}
	if (t1) {
		t1.innerHTML = '['+s_current + IframeID.value.length +  s_word + (_maxCount > 0 ? ','+s_maxword + _maxCount + s_word : '') + ']';
	}
	if (_calcCountTimer) {
		window.clearTimeout(_calcCountTimer);
	}
	_calcCountTimer = window.setTimeout('calcWordCount()', 1000);
}

//-------------------
function Newasp_formatimg()
{
	if (BrowserInfo.IsIE55OrMore){
		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+">"
	}
}

//清理多余HTML代码
function Newasp_cleanHtml(content)
{
	content = content.replace(/<p>&nbsp;<\/p>/gi,"")
	content = content.replace(/<p><\/p>/gi,"<p>")
	content = content.replace(/<div><\/\1>/gi,"")
	content = content.replace(/<p>/,"<br>")
	content = content.replace(/(<(meta|iframe|frame|span|tbody|layer)[^>]*>|<\/(iframe|frame|meta|span|tbody|layer)>)/gi, "");
	content = content.replace(/<\\?\?xml[^>]*>/gi, "") ;
	content = content.replace(/o:/gi, "");
	//content = content.replace(/&nbsp;/gi, " ");
	//if(BrowserInfo.IsIE55OrMore){
	//content = content.replace(/<img([^>]*) (src\s*=\s*([^\s|>])*)([^>]*)>/gi,"<img $2>");
	//}
return content;
}
//代码过滤及JS提取
function Newasp_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[^>]*)>((.|\n)*)<\/script>/gi;
	content = content.replace(RegExp, "[code]&lt;$1&gt;<br>$2<br>&lt;\/script&gt;[\/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;
}
// 取编辑器的内容
function getHTML() {
	var html;
	Newasp_formatimg();
	html = IframeID.document.body.innerHTML;
	html = Newasp_cleanHtml(html);
	html = Newasp_FilterScript(html);
	return html;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -