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

📄 editor.js

📁 动网论坛系列产品倍受用户赞誉的就是强大的功能和出色的用户体验表现
💻 JS
📖 第 1 页 / 共 2 页
字号:
			bbsEditor.insert("<U>$content</U>");
			break;
		case "strikethrough":
			bbsEditor.insert("<STRIKE>$content</STRIKE>");
			break;
		case "insertorderedlist":
			bbsEditor.insert("<UL><LI>$content</LI></UL>");
			break;
		case "insertunorderedlist":
			bbsEditor.insert("<OL><LI>$content</LI></OL>");
			break;
		case "indent":
			bbsEditor.insert("<BLOCKQUOTE dir=ltr style=\"MARGIN-RIGHT: 0px\"><P>$content</P></BLOCKQUOTE>");
			break;
		case "outdent":
			bbsEditor.insert("<P align=left>$content</P>");
			break;
		case "subscript":
			bbsEditor.insert("<SUB>$content</SUB>");
			break;
		case "superscript":
			bbsEditor.insert("<SUP>$content</SUP>");
			break;
				
		}
	}
}

function setFont(item, obj)
{
	bbsEditor.cmd(item, false, obj.options[obj.selectedIndex].value);
}

function createlink()
{
	var value = prompt("请输入URL地址", "http://");
	if (value == null) return;
	if (value.search(/^http:\/\/[A-Za-z0-9]+\.[A-Za-z0-9]+[\/=\?%\-&_~`@[\]\':+!]*([^<>\"\"])*$/) < 0)
	{
		alert('无效的URL地址');
		return;
	}
	if (bbsEditor.design)
		bbsEditor.cmd("createlink", false, value);
	else
		bbsEditor.insert("<A href=\"" + value + "\">$content</A>");
}

function email()
{
	var value = prompt("请输入Email地址", "");
	if (value == null) return;
	if (value.search(/^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/) < 0)
	{
		alert("无效的EMAIL地址.");
		return;
	}
	if (bbsEditor.design)
		bbsEditor.cmd("createlink", false, "mailto:" + value);
	else
		bbsEditor.insert("<A href=\"mailto:" + value + "\">$content</A>");
}

function image()
{
	var value = prompt("请输入图象地址", "http://");
	if (value == null) return;
	if (value.search(/^http:\/\/[A-Za-z0-9]+\.[A-Za-z0-9]+[\/=\?%\-&_~`@[\]\':+!]*([^<>\"\"])*$/) < 0)
	{
		alert('无效的图象地址');
		return;
	}
	if (bbsEditor.design)
		bbsEditor.cmd("insertimage", false, value);
	else
		bbsEditor.insert("<IMG src=\"" + value + "\" />");
}

function getDisabledTools()
{
	return disabledTools;
}
function mediaplay()
{
	if (getDisabledTools().indexOf('media') > -1)
	{
		alert('您没有权限插入视频!');
		return;
	}
	var value = prompt("请输入视频地址", "http://");
	if (value == null) return;
	if (value.search(/^http:\/\/[A-Za-z0-9]+\.[A-Za-z0-9]+[\/=\?%\-&_~`@[\]\':+!]*([^<>\"\"])*$/) < 0)
	{
		alert('无效的视频地址');
		return;
	}
	var obj = "[MP=490,350]$filename[/MP]";
	bbsEditor.insert(obj.replace("$filename", value));
}

function flash()
{
	if (getDisabledTools().indexOf('flash') > -1)
	{
		alert('您没有权限插入Flash!');
		return;
	}
	var value = prompt("请输入Flash地址", "http://");	
	if (value == null) return;
	if (value.search(/^http:\/\/[A-Za-z0-9]+\.[A-Za-z0-9]+[\/=\?%\-&_~`@[\]\':+!]*([^<>\"\"])*.swf$/) < 0)
	{
		alert('无效的Flash地址');
		return;
	}
	var obj = "[flash=490,350]$filename[/flash]";
	bbsEditor.insert(obj.replace("$filename", value));
}

function real()
{
	if (getDisabledTools().indexOf('media') > -1)
	{
		alert('您没有权限插入视频!');
		return;
	}
	var value = prompt("请输入RealPlay视频地址", "http://");
	if (value == null) return;
	if (value.search(/^http:\/\/[A-Za-z0-9]+\.[A-Za-z0-9]+[\/=\?%\-&_~`@[\]\':+!]*([^<>\"\"])*$/) < 0)
	{
		alert('无效的视频地址');
		return;
	}
	var obj = "[RM=490,350]$filename[/RM]";
	bbsEditor.insert(obj.replace("$filename", value));
}

function hide()
{
	if (getDisabledTools().indexOf('hide') > -1)
	{
		alert('您没有权限插入隐藏部分!');
		return;
	}
	bbsEditor.insert("[hide]$content[/hide]");
}

function quote()
{
	if (getDisabledTools().indexOf('quote') > -1)
	{
		alert('您没有权限使用引用内容!');
		return;
	}
	bbsEditor.insert("[quote]$content[/quote]");
	
}

function code()
{
	if (getDisabledTools().indexOf('code') > -1)
	{
		alert('您没有权限插入代码段!');
		return;
	}
	bbsEditor.insert("[code]$content[/code]");
}

function help()
{
	window.open("help.html","_blank", "height=700,width=600,top=0,left=0,toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,status=no");
}

function decrease()
{
	bbsEditor.resize(-50);
}

function increase()
{
	bbsEditor.resize(50);
}

var oy;
function dragstart()
{	
	oy = event.y;
}
function draging()
{
	bbsEditor.resize(event.y - oy);
	oy = event.y;
}
function emote(s)
{
	var em = "<IMG src=\"emotion/" + s + ".gif\" />";
	bbsEditor.editor.focus();
	bbsEditor.insert(em)
}

function onchangemode(obj)
{
	bbsEditor.switchMode();
	obj.src = bbsEditor.design ? "images/ubb/html.gif" : "images/ubb/design.gif";
}

function clearAllFormat()
{
	if (!bbsEditor.design)
	{
		bbsEditor.setHTML(bbsEditor.getText());
	}
	bbsEditor.editor_design.document.body.innerHTML = isIE ? bbsEditor.editor_design.document.body.innerText : bbsEditor.editor_design.document.body.textContent;
	bbsEditor.setText(bbsEditor.editor_design.document.body.innerHTML)
}

function doReset(bt)
{
	if (confirm('您确定要清除已填写的内容吗?'))
	{	
		bbsEditor.setContent(originContent);
		return true;
	}
	return false;
}

function popEmoteButtons()
{
	bbsEditor.editor.focus();
	window.open('choose_emote.aspx', 'emotions', 'width=285, height=242, resizable=0, status=0, scrollbars=0');
}

function addTitleHead(obj)
{
	if (obj.options.selectedIndex > 0 && obj.form.editor_title.value.length < 46 && len(obj.form.editor_title.value) < 64)
	{
		obj.form.editor_title.value = obj.options[obj.options.selectedIndex].text + obj.form.editor_title.value;
		obj.options.selectedIndex = 0;
	}
}


function topicIconHelper()
{
	var msg;
	msg  = '图标的意思依次为:\r\n\r\n';
	msg += '1、普通\r\n';
	msg += '2、汗……         \r\n';
	msg += '3、伤心\r\n';
	msg += '4、疑问\r\n';
	msg += '5、羡慕\r\n';
	msg += '6、偷笑中……\r\n';
	msg += '7、顽皮\r\n';
	alert(msg);
}

var postFlag = 0;
function onSubmitForm()
{
	if (postFlag == 0)
		return chkPost();
	else
		return chkPreview();
}
function chkPost()
{
	var f = document.forms['editor_form'];
	if (!f) f = document.forms['__aspnetForm'];
	if (!f) f = document.forms['aspnetForm'];
	bbsEditor.toSafeCode();
	if (f.editor_voteitems)
	{
		if (f.editor_voteitems.value.trim() == '')
		{
			alert('投票项目没有填写,如果不想发表投票,可以选择“发表主题”功能');
			f.editor_voteitems.focus();
			return false;
		}
		if (isNaN(f.editor_votedays.value))
		{
			alert('投票有效天数必须是个整数,0表示永不过期');
			f.editor_votedays.focus();
			return false;
		}
		if (isNaN(f.editor_voterequire.value))
		{
			alert('投票者积分要求必须是个整数,设置积分要求可防止一部分马甲行为');
			f.editor_voterequire.focus();
			return false;
		}
	}
	if (f.editor_title)
	{
		if (f.editor_title.value.trim() == '')
		{
			alert('标题必须填写');
			f.editor_title.focus();
			return false;
		}
		if (len(f.editor_title.value.length) > 50)
		{
			alert('标题不得超过50个英文字符或25个中文字符');
			f.editor_title.focus();
			return false;
		}
	}
	if (bbsEditor.isEmpty())
	{
		alert('帖子内容必须填写');
		bbsEditor.editor.focus();
		return false;
	}
	
	if (f.editor_browserequire)
	{
		if (isNaN(f.editor_browserequire.value) || f.editor_browserequire.value=='')
		{
			alert('帖子阅览的积分限制必须是数字');
			f.editor_browserequire.focus();
			return false;
		}	
	}
	
	if (f.editor_browsemoney)
	{
		if (isNaN(f.editor_browsemoney.value) || f.editor_browsemoney.value=='')
		{
			alert('帖子阅览的金钱限制必须是数字');
			f.editor_browsemoney.focus();
			return false;
		}	
	}
	if (f.editor_browserequire)
	{
		if (limitExp != 0 && parseInt(f.editor_browserequire.value) > limitExp)
		{
			alert('帖子阅览的积分超过限制数 ' + limitExp);
			f.editor_browserequire.focus();
			return false;
		}
	}

	if (f.editor_browsemoney)
	{
		if (limitMny != 0 && parseInt(f.editor_browsemoney.value) > limitMny)
		{
			alert('帖子阅览的金钱超过限制数 ' + limitMny);
			f.editor_browsemoney.focus();
			return false;
		}
	}

	
	if (contentSize != 0 && f.editor_content.value.length > contentSize)
	{
		alert("帖子内容超过了限制长度, 请删除掉一部分再提交。");
		return false;
	}
	
	f.send.disabled    = true;
	f.reset.disabled   = true;
	f.action = location.href;
	f.target = '_self';
	f.editor_content.value = replaceBadWords(bbsEditor.getContent()).replace(/<FONT>(.*)<\/FONT>/ig, "$1");;
	return true;
	//bbsEditor.submit();
}

function chkPreview()
{
	var f = document.forms['editor_form'];
	if (!f) f = document.forms['__aspnetForm'];
	if (!f) f = document.forms['aspnetForm'];
	bbsEditor.toSafeCode();
	if (f.editor_voteitems)
	{
		if (f.editor_voteitems.value.trim() == '')
		{
			alert('投票项目没有填写,如果不想发表投票,可以选择“发表主题”功能');
			f.editor_voteitems.focus();
			return false;
		}
	}
	if (f.editor_title)
	{
		if (f.editor_title.value.trim() == '')
		{
			alert('标题必须填写');
			f.editor_title.focus();
			return false;
		}
		if (len(f.editor_title.value) > 70 || f.editor_title.value.length > 50)
		{
			alert('标题不得超过50个英文字符或25个中文字符');
			f.editor_title.focus();
			return false;
		}
	}
	if (bbsEditor.isEmpty())
	{
		alert('帖子内容必须填写');
		bbsEditor.editor.focus();
		return false;
	}
	
	f.action = 'post_preview.aspx';
	f.target = '_blank';
	if (contentSize != 0 && f.editor_content.value.length > contentSize)
	{
		alert("帖子内容超过了限制长度, 请删除掉一部分再提交。");
		return false;
	}
	postFlag = 0;
	f.editor_content.value = replaceBadWords(bbsEditor.getContent()).replace(/<FONT>(.*)<\/FONT>/ig, "$1");;
	return true;
//	bbsEditor.submit();
}
function replaceBadWords(s)
{
	var arr = badWords.split('|');
	for (var i =0; i < arr.length; i++)
	{
		s = s.replace(arr[i], "");
	}
	return s;
}

function dopost()
{
	if (bbsEditor.editor_design.window.event)
	{
		if(bbsEditor.editor_design.window.event.ctrlKey && bbsEditor.editor_design.window.event.keyCode == 13)
		{
			var f = document.forms['editor_form'];
			if (!f) f = document.forms['__aspnetForm'];
			if (!f) f = document.forms['aspnetForm'];
			f.send.click();
			return false;
		}
	}
}

function calculateLeft()
{
	var l = 0;
	if (bbsEditor.design)
		l = contentSize - bbsEditor.getHTML().length;
	else
		l = contentSize - bbsEditor.getText().length;
	if (l <= 0)
	{
		alert('已经达到限制的长度,系统将自动截断。');
		if (bbsEditor.design)
		{
			bbsEditor.setHTML(bbsEditor.getHTML().substring(0, contentSize - 6));
		}
		else
		{
			bbsEditor.setText(bbsEditor.getText().substring(0, contentSize - 6));
		}
		return false;
	}
	return true;
}

function getOrignContent()
{
	bbsEditor.setHTML(bbsEditor.editor_html.value);
	originContent = bbsEditor.editor_html.value;
	bbsEditor.editor_html.onkeydown = function()
	{
		if (contentSize != 0)
		{
			if (!calculateLeft())
			{
				return false;
			}
		}
		
		return ctlent();
	}
	newRule();
	bbsEditor.editor_design.document.body.onkeydown = function(){
		if (contentSize != 0)
		{
			if (!calculateLeft())
			{
				return false;
			}
		}
		return dopost();
	}

}
function newRule(){

var head = bbsEditor.editor.document.getElementsByTagName('HEAD').item(0);
var style = bbsEditor.editor.document.createElement('link');
style.href = 'skin/'+getCurrentSkin()+'/module/editor.css';
style.rel = 'stylesheet';
style.type = 'text/css';
head.appendChild(style);
}

function getCurrentSkin()
{
	var str   = document.cookie;
	var start = str.indexOf("skin=") + 5;
	var end   = str.indexOf(";", start);
	return str.substring(start, end);
}

var codecount = 0;
var codehtml = new Array();
function codetag(text) {
//	text = text.replace(/<br[^\>]*>/ig, "\n");
//	text = text.replace(/^[\n\r]*([\s\S]+?)[\n\r]*$/ig, '$1');
//	text = text.replace(/<(\/|)[A-Za-z].*?>/ig, '');
  
    //text = htmlEncode(text);
    text = text.replace(/<P.*?>([\s\S]*?)<\/P>/ig, "$1<BR>");
	codehtml[codecount] = "[code]" + text + "[/code]";

	return "[\tUBB_CODE_" + (codecount++) + "\t]";
}

⌨️ 快捷键说明

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