★★★/g, ">") ;
text = text.replace(/'/g, "") ;
text = text.replace(/\ /g," ");
text = text.replace(/\n/g," ");
text = text.replace(/\t/g," ");
return text;
}
// 插入特殊对象
function insert(what) {
if (!validateMode()) return;
eWebEditor.focus();
var sel = eWebEditor.document.selection.createRange();
switch(what){
case "excel": // 插入EXCEL表格
insertHTML("");
break;
case "nowdate": // 插入当前系统日期
var d = new Date();
insertHTML(d.toLocaleDateString());
break;
case "nowtime": // 插入当前系统时间
var d = new Date();
insertHTML(d.toLocaleTimeString());
break;
case "br": // 插入换行符
insertHTML(" ")
break;
case "code": // 代码片段样式
insertHTML('
以下是代码片段: '+HTMLEncode(sel.text)+'
');
break;
case "quote": // 引用片段样式
insertHTML('
以下是引用片段: '+HTMLEncode(sel.text)+'
');
break;
case "big": // 字体变大
insertHTML("" + sel.text + "");
break;
case "small": // 字体变小
insertHTML("" + sel.text + "");
break;
default:
alert("错误参数调用!");
break;
}
sel=null;
}
// 显示或隐藏指导方针
var borderShown = config.ShowBorder;
function showBorders() {
if (!validateMode()) return;
var allForms = eWebEditor.document.body.getElementsByTagName("FORM");
var allInputs = eWebEditor.document.body.getElementsByTagName("INPUT");
var allTables = eWebEditor.document.body.getElementsByTagName("TABLE");
var allLinks = eWebEditor.document.body.getElementsByTagName("A");
// 表单
for (a=0; a < allForms.length; a++) {
if (borderShown == "0") {
allForms[a].runtimeStyle.border = "1px dotted #FF0000"
} else {
allForms[a].runtimeStyle.cssText = ""
}
}
// Input Hidden类
for (b=0; b < allInputs.length; b++) {
if (borderShown == "0") {
if (allInputs[b].type.toUpperCase() == "HIDDEN") {
allInputs[b].runtimeStyle.border = "1px dashed #000000"
allInputs[b].runtimeStyle.width = "15px"
allInputs[b].runtimeStyle.height = "15px"
allInputs[b].runtimeStyle.backgroundColor = "#FDADAD"
allInputs[b].runtimeStyle.color = "#FDADAD"
}
} else {
if (allInputs[b].type.toUpperCase() == "HIDDEN")
allInputs[b].runtimeStyle.cssText = ""
}
}
// 表格
for (i=0; i < allTables.length; i++) {
if (borderShown == "0") {
allTables[i].runtimeStyle.border = "1px dotted #BFBFBF"
} else {
allTables[i].runtimeStyle.cssText = ""
}
allRows = allTables[i].rows
for (y=0; y < allRows.length; y++) {
allCellsInRow = allRows[y].cells
for (x=0; x < allCellsInRow.length; x++) {
if (borderShown == "0") {
allCellsInRow[x].runtimeStyle.border = "1px dotted #BFBFBF"
} else {
allCellsInRow[x].runtimeStyle.cssText = ""
}
}
}
}
// 链接 A
for (a=0; a < allLinks.length; a++) {
if (borderShown == "0") {
if (allLinks[a].href.toUpperCase() == "") {
allLinks[a].runtimeStyle.borderBottom = "1px dashed #000000"
}
} else {
allLinks[a].runtimeStyle.cssText = ""
}
}
if (borderShown == "0") {
borderShown = "1"
} else {
borderShown = "0"
}
scrollUp()
}
// 返回页面最上部
function scrollUp() {
eWebEditor.scrollBy(0,0);
}
// 缩放操作
var nCurrZoomSize = 100;
var aZoomSize = new Array(10, 25, 50, 75, 100, 150, 200, 500);
function doZoom(size) {
eWebEditor.document.body.runtimeStyle.zoom = size + "%";
nCurrZoomSize = size;
}
// 拼写检查
function spellCheck(){
ShowDialog('dialog/spellcheck.htm', 300, 220, true)
}
// 查找替换
function findReplace(){
ShowDialog('dialog/findreplace.htm', 320, 165, true)
}
// 相对(absolute)或绝对位置(static)
function absolutePosition(){
var objReference = null;
var RangeType = eWebEditor.document.selection.type;
if (RangeType != "Control") return;
var selectedRange = eWebEditor.document.selection.createRange();
for (var i=0; i=300){
obj.height=height+size;
}
break;
}
}
}
// 热点链接
function mapEdit(){
if (!validateMode()) return;
var b = false;
if (eWebEditor.document.selection.type == "Control") {
var oControlRange = eWebEditor.document.selection.createRange();
if (oControlRange(0).tagName.toUpperCase() == "IMG") {
b = true;
}
}
if (!b){
alert("热点链接只能作用于图片");
return;
}
window.open("dialog/map.htm", 'mapEdit'+sLinkFieldName, 'toolbar=no,location=no,directories=no,status=not,menubar=no,scrollbars=no,resizable=yes,width=450,height=300');
}
// 上传文件成功返回原文件名、保存后的文件名、保存后的路径文件名,提供接口
function addUploadFile(originalFileName, saveFileName, savePathFileName){
doInterfaceUpload(sLinkOriginalFileName, originalFileName);
doInterfaceUpload(sLinkSaveFileName, saveFileName);
doInterfaceUpload(sLinkSavePathFileName, savePathFileName);
}
// 文件上传成功接口操作
function doInterfaceUpload(strLinkName, strValue){
if (strValue=="") return;
if (strLinkName){
var objLinkUpload = parent.document.getElementsByName(strLinkName)[0];
if (objLinkUpload){
if (objLinkUpload.value!=""){
objLinkUpload.value = objLinkUpload.value + "|";
}
objLinkUpload.value = objLinkUpload.value + strValue;
objLinkUpload.fireEvent("onchange");
}
}
}
// 大文件内容自动拆分
function splitTextField(objField, html) {
var strFieldName = objField.name;
var objForm = objField.form;
var objDocument = objField.document;
objField.value = html;
//表单限制值设定,限制值是102399,考虑到中文设为一半
var FormLimit = 50000 ;
// 再次处理时,先赋空值
for (var i=1;i FormLimit) {
objField.value = html.substr(0, FormLimit) ;
html = html.substr(FormLimit) ;
while (html.length > 0) {
var objTEXTAREA = objDocument.createElement("TEXTAREA") ;
objTEXTAREA.name = strFieldName ;
objTEXTAREA.style.display = "none" ;
objTEXTAREA.value = html.substr(0, FormLimit) ;
objForm.appendChild(objTEXTAREA) ;
html = html.substr(FormLimit) ;
}
}
}
// 远程上传
function remoteUpload() {
if (sCurrMode=="TEXT") return;
var objField = document.getElementsByName("eWebEditor_UploadText")[0];
splitTextField(objField, getHTML());
divProcessing.style.top = (document.body.clientHeight-parseFloat(divProcessing.style.height))/2;
divProcessing.style.left = (document.body.clientWidth-parseFloat(divProcessing.style.width))/2;
divProcessing.style.display = "";
eWebEditor_UploadForm.submit();
}
// 远程上传完成
function remoteUploadOK() {
divProcessing.style.display = "none";
}
// 修正Undo/Redo
var history = new Object;
history.data = [];
history.position = 0;
history.bookmark = [];
// 保存历史
function saveHistory() {
if (bEditMode){
if (history.data[history.position] != eWebEditor.document.body.innerHTML){
var nBeginLen = history.data.length;
var nPopLen = history.data.length - history.position;
for (var i=1; i 0){
eWebEditor.document.body.innerHTML = history.data[--history.position];
setHistoryCursor();
}
// redo
} else {
if (history.position < history.data.length -1){
eWebEditor.document.body.innerHTML = history.data[++history.position];
setHistoryCursor();
}
}
}
// 设置当前书签
function setHistoryCursor() {
if (history.bookmark[history.position]){
r = eWebEditor.document.body.createTextRange()
if (history.bookmark[history.position] != "[object]"){
if (r.moveToBookmark(history.bookmark[history.position])){
r.collapse(false);
r.select();
}
}
}
}
// End Undo / Redo Fix
// 工具栏事件发生
function doToolbar(){
if (bEditMode){
saveHistory();
}
} 返回 | 删除 | 回复