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

📄 main.js

📁 这个论坛相当不错.asp编写.需要的可以
💻 JS
📖 第 1 页 / 共 3 页
字号:

if (Editor_bIsIE5){
	var IframeID=frames["Editor_Composition"];
}
else{
	var IframeID=document.getElementById("Editor_Composition").contentWindow;
	var Editor_bIsNC=true;
}
if (Editor_bLoad==false)
{
	Editor_InitDocument("Body","GB2312");
}
function Composition_init(){
	try{
	  Editor_Composition.document.body.onkeydown=new Function("return pressEnterKey()");
	}
	catch(e){
	  setTimeout("Composition_init()",500);//如果 Composition.document.body 还没有出现,重试
	}
}
function pressEnterKey(){
  if(Editor_Composition.event.keyCode==13 && Editor_Composition.event.ctrlKey){//高级模式下 CTRL+BR 提交
    CheckReply();
    theform.submit();
  }
}
function CheckReply()
{
  theform.Topic_Content.value=Editor_Composition.document.body.innerHTML;
  if (theform.Topic_Content.value=="")
  {
    alert("贴子内容不能为空!");
	Editor_Composition.focus();
	return false;
  }
  if (theform.Topic_Content.value.length>65536)
  {
    alert("内容太长!请将文章分成几部分录入。");
	return false;
  }
  return true;  
}
function CheckTopic()
{
  theform.Topic_Content.value=Editor_Composition.document.body.innerHTML;
  if (theform.Topic_Title.value=="")
  {
    alert("贴子标题不能为空!");
	theform.Topic_Title.focus();
	return false;
  }
  if (theform.Topic_Content.value=="")
  {
    alert("贴子内容不能为空!");
	Editor_Composition.focus();
	return false;
  }
  if (theform.Topic_Content.value.length>65536)
  {
    alert("内容太长!请将文章分成几部分录入。");
	return false;
  }
  return true;  
}
function InitDocument()
{
	Composition_init();
	IframeID.document.body.innerHTML=theform.Topic_Content.value;
	theform.Topic_Content.value="";
	IframeID.focus();
}
if (Editor_bIsNC){
document.write('<iframe width="260" height="165" id="colourPalette" src="editor/nc_selcolor.htm" style="visibility:hidden; position: absolute; left: 0px; top: 0px;" frameborder="0" scrolling="no" ></iframe>');
}
InitDocument();
//数据传递
function Editor_CopyData(hiddenid)
{
	document.Dvform.Submit.disabled=true;
	document.Dvform.Submit2.disabled=true;
	d = IframeID.document;
	if (Editor_bTextMode == 2)
	{
		cont = d.body.innerText;
	}else{
		cont = d.body.innerHTML;  
	}
	var ChekEmptyCode = Editor_ChekEmptyCode(cont);
	if (ChekEmptyCode == '' || ChekEmptyCode == null)
	{
		cont='';
	}
	else{
		cont = Editor_correctUrl(cont);
		if (Editor_filterScript)
		cont=Editor_FilterScript(cont);
	}
	document.getElementById(hiddenid).value = cont;
}

function Editor_PasteData()
{
	var regExp;
	cont = IframeID.document.body.innerHTML;
	regExp = /<[s|t][a-z]([^>]*)>/ig
	cont = cont.replace(regExp, '');
	regExp = /<\/[s|t][a-z]([^>]*)>/ig
	cont = cont.replace(regExp, '');
	IframeID.document.body.innerHTML = cont
}
//-------------------------------------

function putEmot(thenNo)
{
	var ToAdd = '['+thenNo+']';
	IframeID.document.body.innerHTML+=ToAdd;
	IframeID.focus();
}
function gopreview()
{
document.preview.Dvtitle.value=document.Dvform.topic.value;
document.preview.theBody.value=IframeID.document.body.innerHTML;
var popupWin = window.open('', 'preview_page', 'scrollbars=yes,width=750,height=450');
document.preview.submit()
}

//--------------------------------------------------------------------------------

function Editor_foreColor()
{
	if (!Editor_validateMode()) return;
	if (Editor_bIsIE5){
		var arr = showModalDialog("editor/selcolor.html", "", "dialogWidth:18.5em; dialogHeight:17.5em; status:0; help:0");
		if (arr != null) FormatText('forecolor', arr);
		else IframeID.focus();
	}else
		{
		FormatText('forecolor', '');
		//var arr = openEditScript('editor/nc_selcolor.htm',250,100)}
		}
}

function Editor_backColor()
{
	if (!Editor_validateMode()) return;
	if (Editor_bIsIE5)
	{
		var arr = showModalDialog("editor/selcolor.html", "", "dialogWidth:18.5em; dialogHeight:17.5em; status:0; help:0");
		if (arr != null) FormatText('backcolor', arr);
		else IframeID.focus();
	}else
		{
		FormatText('backcolor', '');
		}
}

function Editor_correctUrl(cont)
{
	var regExp;
	var url=location.href.substring(0,location.href.lastIndexOf("/")+1);
	cont=Editor_rCode(cont,location.href+"#","#");
	cont=Editor_rCode(cont,url,"");
	//regExp = /<a.*href=\"(.*)\"[^>]*>/gi;
	regExp = /<(a[^>]*) href=([^ |>]*)([^>]*)/gi
	cont = cont.replace(regExp, "<$1 href=$2 target=\"_blank\" ") ;
	return cont;
}
function Editor_cleanHtml()
{
	if (Editor_bIsIE5){
	var fonts = IframeID.document.body.all.tags("FONT");
	}else{
	var fonts = IframeID.document.getElementsByTagName("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 Editor_getPureHtml()
{
	var str = "";
	//var paras = IframeID.document.body.all.tags("P");
	//var paras = IframeID.document.getElementsByTagName("p");
	//if (paras.length > 0){
	  //for	(var i=paras.length-1; i >= 0; i--) str= paras[i].innerHTML + "\n" + str;
	//} else {
	str = IframeID.document.body.innerHTML;
	//}
	str=Editor_correctUrl(str);
	return str;
}

function FormatUrl(html)
{
	var regExp = /<a.*href=\"(.*)\"[^>]*>/gi;
	html = html.replace(regExp,"<a href=$1 target=\"_blank\" >")
  return html;
}


function Editor_getEl(sTag,start)
{
	while ((start!=null) && (start.tagName!=sTag)) start = start.parentElement;
	return start;
}

//选择内容替换文本
function Editor_InsertSymbol(str1)
{
	IframeID.focus();
	if (Editor_bIsIE5) Editor_selectRange();
	Editor_edit.pasteHTML(str1);
}


//选择事件
function Editor_selectRange(){
	Editor_selection =	IframeID.document.selection;
	Editor_edit		=	Editor_selection.createRange();
	Editor_RangeType =	Editor_selection.type;
}

//应用html
function Editor_specialtype(Mark1, Mark2){
	var strHTML;
	if (Editor_bIsIE5){
		Editor_selectRange();
		if (Editor_RangeType == "Text"){
			if (Mark2==null)
			{
				strHTML = "<" + Mark1 + ">" + Editor_edit.htmlText + "</" + Mark1 + ">"; 
			}else{
				strHTML = Mark1 + Editor_edit.htmlText +  Mark2; 
			}
			Editor_edit.pasteHTML(strHTML);
			IframeID.focus();
			Editor_edit.select();
		}
		else{window.alert("请选择相应内容!")}	
	}
	else{
		if (Mark2==null)
		{
		strHTML	=	"<" + Mark1 + ">" + IframeID.document.body.innerHTML + "</" + Mark1 + ">"; 
		}else{
		strHTML = Mark1 + IframeID.document.body.innerHTML +  Mark2; 
		}
		IframeID.document.body.innerHTML=strHTML
		IframeID.focus();
	}
}

// 修改编辑栏高度
function Editor_Size(num)
{
	var obj=document.getElementById("Editor_Container");
	if (parseInt(obj.offsetHeight)+num>=200) {
		//alert(obj.offsetHeight)
		obj.height = (parseInt(obj.offsetHeight) + num);
	}
	if (num>0)
	{
		obj.width="80%";
	}
}

function Editor_getText()
{
	if (Editor_bTextMode==2)
		return IframeID.document.body.innerText;
	else
	{
		Editor_cleanHtml();
		return IframeID.document.body.innerHTML;
	}
}

function Editor_putText(v)
{
	if (Editor_bTextMode==2)
		IframeID.document.body.innerText = v;
	else
		IframeID.document.body.innerHTML = v;
}
function Editor_doSelectClick(str, el)
{
	var Index = el.selectedIndex;
	if (Index != 0){
		el.selectedIndex = 0;
		FormatText(str,el.options[Index].value);
	}
}
//查找配对字符出现次数,没有结果为0
function TabCheck(word,str){
	var tp=0
	chktp=str.search(word);
	if (chktp!=-1)
	{
	eval("var tp=\""+str+"\".match("+word+").length")
	}
	return tp;
}

function Editor_help()
{
	showModalDialog("editor/help.html", "", "dialogWidth:13.5em; dialogHeight:12.5em; status:0; help:0");
}

function openEditScript(url, width, height){
	var Win = window.open(url,"openEditScript",'width=' + width + ',height=' + height + ',resizable=1,scrollbars=yes,menubar=no,status=no' );
}

//广告标记
function Editor_View()
{
	if (Editor_bTextMode==2) {
		cont=IframeID.document.body.innerText;
	} else {
		cont=IframeID.document.body.innerHTML;
	}
	cont=Editor_correctUrl(cont);
	bodyTag="<html><head><style type=text/css>.quote{margin:5px 20px;border:1px solid #CCCCCC;padding:5px; background:#F3F3F3 }\nbody{boder:0px}.HtmlCode{margin:5px 20px;border:1px solid #CCCCCC;padding:5px;background:#FDFDDF;font-size:14px;font-family:Tahoma;font-style : oblique;line-height : normal ;font-weight:bold;}\nbody{boder:0px}</style></head><BODY bgcolor=\"#FFFFFF\" >";
	if (Editor_filterScript)
	cont=Editor_FilterScript(cont);
	cont=Editor_rCode(cont,"\\[Editor_ad]","<img src='images/pic_ad.jpg' vspace=10 hspace=10 align=left border=1 title='Advertising'>");
	cont=Editor_rCode(cont,"\\[Editor_page]","<br><br><hr size=2 width=95% align=left>&nbsp; <font color=red face='Tahoma,Arail' size=2><b>Next Page ...</b></font><br><hr size=2 width=95% align=left>");
	preWin=window.open('preview','','left=0,top=0,width=550,height=400,resizable=1,scrollbars=1, status=1, toolbar=1, menubar=0');
	preWin.document.open();
	preWin.document.write(bodyTag);
	preWin.document.write(cont);
	preWin.document.close();
	preWin.document.title="Preview";
	preWin.document.charset=Editor_charset;
}

//Colour pallete top offset
function getOffsetTop(elm) {
	var mOffsetTop = elm.offsetTop;
	var mOffsetParent = elm.offsetParent;
	while(mOffsetParent){
		mOffsetTop += mOffsetParent.offsetTop;
		mOffsetParent = mOffsetParent.offsetParent;
	}
	return mOffsetTop;
}

//Colour pallete left offset
function getOffsetLeft(elm) {
	var mOffsetLeft = elm.offsetLeft;
	var mOffsetParent = elm.offsetParent;
	while(mOffsetParent) {
		mOffsetLeft += mOffsetParent.offsetLeft;
		mOffsetParent = mOffsetParent.offsetParent;
	}
	return mOffsetLeft;
}

//Function to hide colour pallete
function hideColourPallete() {
	document.getElementById("colourPalette").style.visibility="hidden";
}


//------------------------------------------------------

function Editor_forswf()
{
	var arr = showModalDialog("editor/swf.htm", "", "dialogWidth:30em; dialogHeight:10em; status:0; help:0");
	if (arr != null){
		var ss;
		ss=arr.split("*")
		path=ss[0];
		row=ss[1];
		col=ss[2];
		var string;
		string="<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000'  codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=5,0,0,0' width="+row+" height="+col+"><param name=movie value="+path+"><param name=quality value=high><embed src="+path+" pluginspage='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash' type='application/x-shockwave-flash' width="+row+" height="+col+"></embed></object>"
		//string="[flash="+row+","+col+"]"+path+"[/flash]"
		IframeID.document.body.innerHTML+=string;
	}
	else IframeID.focus();
}

function Editor_forwmv()
{
	var arr = showModalDialog("editor/wmv.htm", "", "dialogWidth:30em; dialogHeight:13em; status:0; help:0");
	
	if (arr != null){
		var ss;
		ss=arr.split("*")
		path=ss[0];
		autostart=ss[1];
		width=ss[2];
		height=ss[3];
		ran=rand();
		var string;
		var ubbstring;
		string="<object align=center classid=CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95 hspace=5 vspace=5 width="+ width +" height="+ height +"><param name=Filename value="+ path +"><param name=ShowStatusBar value=1><embed type=application/x-oleobject codebase=http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701 flename=mp src="+ path +"  width="+ width +" height="+ height +"></embed></object>";
		string="<EMBED id=MediaPlayer"+ran+" src="+ path +" width="+ width +" height="+ height +" autostart=\""+ autostart +"\" loop=\"false\"></EMBED><p></p>";
		//string="[MP="+ width +","+ height +","+ autostart +"]"+ path +"[/MP]";
		IframeID.document.body.innerHTML+=string;
	}
	else IframeID.focus();
}

function rand() {
	return parseInt((1000)*Math.random()+1);
}

function Editor_forrm()
{
	var arr = showModalDialog("editor/rm.htm", "", "dialogWidth:30em; dialogHeight:13em; status:0; help:0");
	
	if (arr != null)
	{
		var ss;
		ss = arr.split("*")
		path = ss[0];
		row = ss[1];
		col = ss[2];
		autostart = ss[3];
		ran = rand();
		var string;
		string="<object classid='clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA' width='"+row+"' height='"+col+"'><param name='CONTROLS' value='ImageWindow'><param name='CONSOLE' value='Clip'><param name='AUTOSTART' value='"+ autostart +"'><param name=src value="+path+"></object><br><object classid='clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA'  width="+row+" height=64><param name='CONTROLS' value='ControlPanel,StatusBar'><param name='CONSOLE' value='Clip'></object>";
		//string = "[RM="+ row +","+ col +","+ autostart +"]"+ path +"[/RM]";
		IframeID.document.body.innerHTML+=string;
	}
	else IframeID.focus();
}

//图片与链接事件

⌨️ 快捷键说明

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