SEP_PADDING = 5 HANDLE_PADDING = 7 var yToolbars = new Array(); var YInitialized = false; helpstat = false; stprompt = true; basic = false; function thelp(swtch){ if (swtch == 1){ basic = false; stprompt = false; helpstat = true; } else if (swtch == 0) { helpstat = false; stprompt = false; basic = true; } else if (swtch == 2) { helpstat = false; basic = false; stprompt = true; } } function document.onreadystatechange() { if (YInitialized) return; YInitialized = true; var i, s, curr; for (i=0; i"); Composition.document.close() Composition.document.designMode="On" } function InitBtn(btn) { btn.onmouseover = BtnMouseOver; btn.onmouseout = BtnMouseOut; btn.onmousedown = BtnMouseDown; btn.onmouseup = BtnMouseUp; btn.ondragstart = YCancelEvent; btn.onselectstart = YCancelEvent; btn.onselect = YCancelEvent; btn.YUSERONCLICK = btn.onclick; btn.onclick = YCancelEvent; btn.YINITIALIZED = true; return true; } function InitTB(y) { y.TBWidth = 0; if (! PopulateTB(y)) return false; y.style.posWidth = y.TBWidth; return true; } function YCancelEvent() { event.returnValue=false; event.cancelBubble=true; return false; } function BtnMouseOver() { if (event.srcElement.tagName !="IMG") return false; var image = event.srcElement; var element = image.parentElement; if (image.className =="Ico") element.className ="BtnMouseOverUp"; else if (image.className =="IcoDown") element.className ="BtnMouseOverDown"; event.cancelBubble = true; } function BtnMouseOut() { if (event.srcElement.tagName !="IMG") { event.cancelBubble = true; return false; } var image = event.srcElement; var element = image.parentElement; yRaisedElement = null; element.className ="Btn"; image.className ="Ico"; event.cancelBubble = true; } function BtnMouseDown() { if (event.srcElement.tagName !="IMG") { event.cancelBubble = true; event.returnValue=false; return false; } var image = event.srcElement; var element = image.parentElement; element.className ="BtnMouseOverDown"; image.className ="IcoDown"; event.cancelBubble = true; event.returnValue=false; return false; } function BtnMouseUp() { if (event.srcElement.tagName !="IMG") { event.cancelBubble = true; return false; } var image = event.srcElement; var element = image.parentElement; if (element.YUSERONCLICK) eval(element.YUSERONCLICK + "anonymous()"); element.className ="BtnMouseOverUp"; image.className ="Ico"; event.cancelBubble = true; return false; } function PopulateTB(y) { var i, elements, element; elements = y.children; for (i=0; i TotalLen) TotalLen = TB.TBWidth; } var PrevTB; var LastStart = 0; var RelTop = 0; var LastWid, CurrWid; var TB = yToolbars[0]; TB.style.posTop = 0; TB.style.posLeft = 0; var Start = TB.TBWidth; for (i = 1 ; i < yToolbars.length ; i++) { PrevTB = TB; TB = yToolbars[i]; CurrWid = TB.TBWidth; if ((Start + CurrWid) > ScrWid) { Start = 0; LastWid = TotalLen - LastStart; } else { LastWid = PrevTB.TBWidth; RelTop -= TB.offsetHeight; } TB.style.posTop = RelTop; TB.style.posLeft = Start; PrevTB.style.width = LastWid; LastStart = Start; Start += CurrWid; } TB.style.width = TotalLen - LastStart; i--; TB = yToolbars[i]; var TBInd = TB.sourceIndex; var A = TB.document.all; var item; for (i in A) { item = A.item(i); if (! item) continue; if (! item.style) continue; if (item.sourceIndex <= TBInd) continue; if (item.style.position =="absolute") continue; item.style.posTop = RelTop; } } function DoLayout() { LayoutTBs(); } function validateMode() { if (! bTextMode) return true; alert("请取消“使用 HTML 语法书写”选项再使用系统编辑功能!"); Composition.focus(); return false; } function format1(what,opt) { if (opt=="removeFormat") { what=opt; opt=null; } if (opt==null) Composition.document.execCommand(what); else Composition.document.execCommand(what,"",opt); pureText = false; Composition.focus(); } function format(what,opt) { if (!validateMode()) return; format1(what,opt); } function setMode(newMode) { bTextMode = newMode; var cont; if (bTextMode) { cleanHtml(); cleanHtml(); cont=Composition.document.body.innerHTML; Composition.document.body.innerText=cont; } else { cont=Composition.document.body.innerText; Composition.document.body.innerHTML=cont; } Composition.focus(); } function getEl(sTag,start) { while ((start!=null) && (start.tagName!=sTag)) start = start.parentElement; return start; } function UserDialog(what) { if (!validateMode()) return; Composition.document.execCommand(what, true); pureText = false; Composition.focus(); } function foreColor() { if (! validateMode()) return; var arr = showModalDialog("selcolor.htm", "", "dialogWidth:18.5em; dialogHeight:17.5em; status:0"); if (arr != null) format('forecolor', arr); else Composition.focus(); } function fortable() { if (! validateMode()) return; var arr = showModalDialog("table.htm", "", "dialogWidth:18.5em; dialogHeight:11.5em; status:0"); if (arr != null){ var ss; ss=arr.split("*") row=ss[0]; col=ss[1]; var string; string=""; for(i=1;i<=row;i++){ string=string+""; for(j=1;j<=col;j++){ string=string+""; } string=string+""; } string=string+"
"; content=Composition.document.body.innerHTML; content=content+string; Composition.document.body.innerHTML=content; } else Composition.focus(); } function cleanHtml() { var fonts = Composition.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 getPureHtml() { var str =""; var paras = Composition.document.body.all.tags("P"); if (paras.length > 0) { for (var i=paras.length-1; i >= 0; i--) str = paras[i].innerHTML + "\n" + str; } else { str = Composition.document.body.innerHTML; } return str; } var bLoad=false var pureText=true var bodyTag="" var bTextMode=false public_description=new Editor function Editor() { this.put_HtmlMode=setMode; this.put_value=putText; this.get_value=getText; } function getText() { if (bTextMode) return Composition.document.body.innerText; else { cleanHtml(); cleanHtml(); return Composition.document.body.innerHTML; } } function putText(v) { if (bTextMode) Composition.document.body.innerText = v; else Composition.document.body.innerHTML = v; } function InitDocument() { Composition.document.open(); Composition.document.write(bodyTag); Composition.document.close(); bLoad=true; } function doSelectClick(str, el) { var Index = el.selectedIndex; if (Index != 0){ el.selectedIndex = 0; if (el.id =="specialtype") specialtype(el.options[Index].value); else format(str,el.options[Index].value); } } var bIsIE5 = navigator.userAgent.indexOf("IE 5") > -1; var edit; var RangeType; function specialtype(Mark){ var strHTML; if (bIsIE5) selectRange(); if (RangeType =="Text"){ strHTML ="<" + Mark + ">" + edit.text + ""; edit.pasteHTML(strHTML); Composition.focus(); edit.select(); } } function selectRange(){ edit = Composition.document.selection.createRange(); RangeType = Composition.document.selection.type; } function rm() { if (helpstat) { alert("realplay\n播放realplay文件.\n用法: [rm=宽度, 高度]文件地址[/rm]"); } else if (basic) { AddTxt="[rm=500,350][/rm]"; AddText(AddTxt); } else { txt2=prompt("视频的宽度,高度","500,350"); if (txt2!=null) { txt=prompt("视频文件的地址","请输入"); if (txt!=null) { if (txt2=="") { AddTxt="[rm=500,350]"+txt; AddText(AddTxt); AddTxt="[/rm]"; AddText(AddTxt); } else { AddTxt="[rm="+txt2+"]"+txt; AddText(AddTxt); AddTxt="[/rm]"; AddText(AddTxt); } } } } } function mp() { if (helpstat) { alert("Media Player\n播放Media Player文件.\n用法: [mp=宽度, 高度]文件地址[/mp]"); } else if (basic) { AddTxt="[mp=500,350][/mp]"; AddText(AddTxt); } else { txt2=prompt("视频的宽度,高度","500,350"); if (txt2!=null) { txt=prompt("视频文件的地址","请输入"); if (txt!=null) { if (txt2=="") { AddTxt="[mp=500,350]"+txt; AddText(AddTxt); AddTxt="[/mp]"; AddText(AddTxt); } else { AddTxt="[mp="+txt2+"]"+txt; AddText(AddTxt); AddTxt="[/mp]"; AddText(AddTxt); } } } } } function qt() { if (helpstat) { alert("QuickTime\n播放QuickTime文件.\n用法: [qt=宽度, 高度]文件地址[/qt]"); } else if (basic) { AddTxt="[qt=500,350][/qt]"; AddText(AddTxt); } else { txt2=prompt("视频的宽度,高度","500,350"); if (txt2!=null) { txt=prompt("视频文件的地址","请输入"); if (txt!=null) { if (txt2=="") { AddTxt="[qt=500,350]"+txt; AddText(AddTxt); AddTxt="[/qt]"; AddText(AddTxt); } else { AddTxt="[qt="+txt2+"]"+txt; AddText(AddTxt); AddTxt="[/qt]"; AddText(AddTxt); } } } } } function sk() { if (helpstat) { alert("Shockwave\n插入Shockwave文件.\n用法: [dir=宽度, 高度]文件地址[/dir]"); } else if (basic) { AddTxt="[dir=500,350][/dir]"; AddText(AddTxt); } else { txt2=prompt("Shockwave文件的宽度,高度","500,350"); if (txt2!=null) { txt=prompt("Shockwave文件的地址","请输入地址"); if (txt!=null) { if (txt2=="") { AddTxt="[dir=500,350]"+txt; AddText(AddTxt); AddTxt="[/dir]"; AddText(AddTxt); } else { AddTxt="[dir="+txt2+"]"+txt; AddText(AddTxt); AddTxt="[/dir]"; AddText(AddTxt); } } } } } function flash() { if (helpstat){ alert("Flash 动画\n插入 Flash 动画.\n用法: [flash]Flash 文件的地址[/flash]"); } else if (basic) { AddTxt="[flash][/flash]"; AddText(AddTxt); } else { txt=prompt("Flash 文件的地址","http://"); if (txt!=null) { AddTxt="[flash]"+txt; AddText(AddTxt); AddTxt="[/flash]"; AddText(AddTxt); } } } function AddText(NewCode) { content=Composition.document.body.innerHTML; content=content+NewCode; Composition.document.body.innerHTML=content; } function help() { var helpmess; helpmess="---------------帮助系统---------------\r\n\r\n"+ "1.本系统支持任意贴图,可以再网上随便复制图像,然后粘贴\r\n\r\n"+ "文档中,系统会自动帮您转换成为正常路径\r\n\r\n"+ "3.本系统支持ubb语法。可以使用ubb.\r\n\r\n"+ "4.本系统可以支持文件上传,可能有时会慢一些,请耐心等待.\r\n\r\n"+ "5.出处和标题不能超过128个字符,若超过则自动截断."; alert(helpmess); }