📄 editfunc.js
字号:
dvPortrait.style.left = (iX-380) + "px";
}else{
if(gIsIE)
dvPortrait.style.left = (iX-380) + "px";
else
dvPortrait.style.left = (iX-380) + "px";
}
dvPortrait.style.top = (iY-8) + "px";
dvPortrait.innerHTML = '<table width="100%" border="0" cellpadding="5" cellspacing="1" style="cursor:hand" bgcolor="black" ID="tbPortrait"><tr align="left" bgcolor="#f8f8f8" class="unnamed1" align="center" ID="trContent">'+ drawPortrats() +'</tr> </table>';
}
function fCheckIfColorBoard(obj){
if(obj.parentNode){
if(obj.parentNode.id == "dvForeColor") return true;
else return fCheckIfColorBoard(obj.parentNode);
}else{
return false;
}
}
function fCheckIfPortraitBoard(obj){
if(obj.parentNode){
if(obj.parentNode.id == "dvPortrait") return true;
else return fCheckIfPortraitBoard(obj.parentNode);
}else{
return false;
}
}
function fCheckIfFontFace(obj){
if(obj.parentNode){
if(obj.parentNode.id == "fontface") return true;
else return fCheckIfFontFace(obj.parentNode);
}else{
return false;
}
}
function fCheckIfFontSize(obj){
if(obj.parentNode){
if(obj.parentNode.id == "fontsize") return true;
else return fCheckIfFontSize(obj.parentNode);
}else{
return false;
}
}
function fImgOver(el){
if(el.tagName == "IMG"){
el.style.borderRight="1px #cccccc solid";
el.style.borderBottom="1px #cccccc solid";
}
}
function fImgMoveOut(el){
if(el.tagName == "IMG"){
el.style.borderRight="1px #F3F8FC solid";
el.style.borderBottom="1px #F3F8FC solid";
}
}
String.prototype.trim = function(){
return this.replace(/(^\s*)|(\s*$)/g, "");
}
function fSetBorderMouseOver(obj) {
obj.style.borderRight="1px solid #aaa";
obj.style.borderBottom="1px solid #aaa";
obj.style.borderTop="1px solid #fff";
obj.style.borderLeft="1px solid #fff";
/*var sd = document.getElementsByTagName("div");
for(i=0;i<sd.length;i++) {
sd[i].style.display = "none";
}*/
}
function fSetBorderMouseOut(obj) {
obj.style.border="none";
}
function fSetBorderMouseDown(obj) {
obj.style.borderRight="1px #F3F8FC solid";
obj.style.borderBottom="1px #F3F8FC solid";
obj.style.borderTop="1px #cccccc solid";
obj.style.borderLeft="1px #cccccc solid";
}
function fDisplayElement(element,displayValue) {
if(gIEVer<=5.01 && gIsIE){
if(element == "fontface"){
var sReturnValue = showModalDialog("FontFaceSelect.htm","", "font-family:Verdana; font-size:12; status:no; unadorned:yes; scroll:no; resizable:yes;dialogWidth:112px; dialogHeight:271px");;
format("fontname",sReturnValue);
}else{
var sReturnValue = showModalDialog("FontSizeSelect.htm","", "font-family:Verdana; font-size:12; status:no; unadorned:yes; scroll:no; resizable:yes;dialogWidth:130px; dialogHeight:250px");;
format("fontsize",sReturnValue);
}
return;
}
if(element == "fontface"){
var fontsize = document.getElementById("fontsize");
fontsize.style.display = "none";
}else if(element == "fontsize"){
var fontface = document.getElementById("fontface");
fontface.style.display = "none";
}
if ( typeof element == "string" )
element = document.getElementById(element);
if (element == null) return;
element.style.display = displayValue;
if(gIsIE){
var e = event;
}else{
var e = ev;
}
var iX = e.clientX;
var iY = e.clientY;
element.style.display = "";
element.style.left = (iX-40) + "px";
element.style.top = (iY-10) + "px";
return true;
}
function fSetModeTip(obj){
var x = f_GetX(obj);
var y = f_GetY(obj);
var dvModeTip = document.getElementById("dvModeTip");
if(!dvModeTip){
var dv = document.createElement("DIV");
dv.style.position = "absolute";
dv.style.top = (y+20) + "px";
dv.style.left = (x-40) + "px";
dv.style.zIndex = "999";
dv.style.fontSize = "12px";
dv.id = "dvModeTip";
dv.style.padding = "2 2 0 2px";
dv.style.border = "1px #000000 solid";
dv.style.backgroundColor = "#FFFFCC";
dv.style.height = "12px";
dv.innerHTML = "编辑源码";
document.body.appendChild(dv);
}else{
dvModeTip.style.display = "";
}
}
function fHideTip(){
document.getElementById("dvModeTip").style.display = "none";
}
function f_GetX(e)
{
var l=e.offsetLeft;
while(e=e.offsetParent){
l+=e.offsetLeft;
}
return l;
}
function f_GetY(e)
{
var t=e.offsetTop;
while(e=e.offsetParent){
t+=e.offsetTop;
}
return t;
}
function fHideMenu(){
var fontface = document.getElementById("fontface");
var fontsize = document.getElementById("fontsize");
fontface.style.display = "none";
fontsize.style.display = "none";
}
// 替换特殊字符
function HTMLEncode(text){
text = text.replace(/&/g, "&") ;
text = text.replace(/"/g, """) ;
text = text.replace(/</g, "<") ;
text = text.replace(/>/g, ">") ;
text = text.replace(/'/g, "’") ;
text = text.replace(/\ /g," ");
text = text.replace(/\n/g,"<br>");
text = text.replace(/\t/g," ");
return text;
}
//===============================================
// 单个过滤
// 输入参数:
// s_Content : 要转换的数据字符串
// s_Filter : 要过滤掉的单个格式
//===============================================
function DecodeFilter(html, filter){
switch(filter.toUpperCase()){
case "SCRIPT": // 去除所有客户端脚本javascipt,vbscript,jscript,js,vbs,event,...
html = execRE("</?script[^>]*>", "", html);
html = execRE("(javascript|jscript|vbscript|vbs):", "$1:", html);
html = execRE("on(mouse|exit|error|click|key)", "<I>on$1</I>", html);
html = execRE("&#", "<I>&#</I>", html);
break;
case "TABLE": // 去除表格<table><tr><td><th>
html = execRE("</?table[^>]*>", "", html);
html = execRE("</?tr[^>]*>", "", html);
html = execRE("</?th[^>]*>", "", html);
html = execRE("</?td[^>]*>", "", html);
break;
case "CLASS": // 去除样式类class=""
html = execRE("(<[^>]+) class=[^ |^>]*([^>]*>)", "$1 $2", html) ;
break;
case "STYLE": // 去除样式style=""
html = execRE("(<[^>]+) style=\"[^\"]*\"([^>]*>)", "$1 $2", html);
break;
case "XML": // 去除XML<?xml>
html = execRE("<\\?xml[^>]*>", "", html);
break;
case "NAMESPACE": // 去除命名空间<o:p></o:p>
html = execRE("<\/?[a-z]+:[^>]*>", "", html);
break;
case "FONT": // 去除字体<font></font>
html = execRE("</?font[^>]*>", "", html);
break;
case "MARQUEE": // 去除字幕<marquee></marquee>
html = execRE("</?marquee[^>]*>", "", html);
break;
case "OBJECT": // 去除对象<object><param><embed></object>
html = execRE("</?object[^>]*>", "", html);
html = execRE("</?param[^>]*>", "", html);
html = execRE("</?embed[^>]*>", "", html);
break;
default:
}
return html;
}
// ============================================
// 执行正则表达式替换
// ============================================
function execRE(re, rp, content) {
oReg = new RegExp(re, "ig");
r = content.replace(oReg, rp);
return r;
}
// 设置所属表单的提交或reset事件
function setLinkedField() {
if (! oLinkField) return ;
var oForm = oLinkField.form ;
if (!oForm) return ;
oForm.attachEvent("onsubmit", AttachSubmit);
oForm.attachEvent("onreset", AttachReset);
//增加点击提交事件副值
submitObjs=oLinkField.form.getElementsByTagName("input");
for(var i=0;i<submitObjs.length;i++)
{
if(submitObjs[i].type=="submit")
{
submitObjs[i].attachEvent("onclick",AttachSubmit);
}
}
}
// 提交表单
function AttachSubmit() {
var html = window.frames["HtmlEditor"].document.getElementsByTagName("BODY")[0].innerHTML;
if ( (html.toLowerCase() == "<p> </p>") || (html.toLowerCase() == "<p></p>") ){
html = "";
}
oLinkField.value = html
}
// 附加Reset事件
function AttachReset() {
window.frames["HtmlEditor"].document.getElementsByTagName("BODY")[0].innerHTML = oLinkField.value;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -