📄 opencms_edithtml.js
字号:
else if ("bgcolor" == elem && args2["bgcolor"] != null) {
range.bgColor = args2["bgcolor"];
}
}
}
}
}
else {
InsertTable();
}
}
/* Checks if tablerow- or tablecell-element is selected in the DHTML Editor */
function checkTableElSelection(type)
{
var editor = document.all.EDIT_HTML;
var sel = editor.DOM.selection;
var sel2 = null;
var args1 = new Array();
cursorPos=sel.createRange();
// there should be no selection !
if (sel.type == 'None') {
var elt = cursorPos.parentElement();
// find next TD or TR
while (elt) {
if (elt.tagName == type) {
break;
}
elt = elt.parentElement;
}
if (elt) {
// don't select document area
if (elt.id != editor.id) {
// get all attributes
var eltheight = elt.getAttribute("height", 0);
var eltwidth = elt.getAttribute("width", 0);
var eltalign = elt.getAttribute("align", 0);
var eltvAlign = elt.getAttribute("vAlign", 0);
var eltbgColor = elt.getAttribute("bgColor", 0);
var eltborderColor = elt.getAttribute("borderColor", 0);
// set arguments for dialog
if(eltbgColor != null && eltbgColor != "undefined" && eltbgColor.length > 0) {
args1["bgColor"] = eltbgColor;
} else {
args1["bgColor"] = "";
}
if(eltborderColor != null && eltborderColor != "undefined" && eltborderColor.length > 0) {
args1["borderColor"] = eltborderColor;
} else {
args1["borderColor"] = "";
}
if(eltheight != null && eltheight.length > 0) {
args1["height"] = eltheight;
} else {
args1["height"] = "";
}
if(eltwidth != null && eltwidth.length > 0) {
args1["width"] = eltwidth;
} else {
args1["width"] = "";
}
if(eltalign != null && eltalign.length > 0) {
args1["align"] = eltalign;
} else {
args1["align"] = "";
}
if(eltvAlign != null && eltvAlign.length > 0) {
args1["vAlign"] = eltvAlign;
} else {
args1["vAlign"] = "";
}
args1["title"] = type;
// call dialog
args2 = showModalDialog( "edit_html_changetable_el.html", args1,"font-family:Verdana; font-size:12; dialogWidth:50em; dialogHeight:32em");
// args == null if cancel button was pressed
if (args2 != null) {
// clear all attributes
elt.removeAttribute("bgColor", 0);
elt.removeAttribute("borderColor", 0);
elt.removeAttribute("height", 0);
elt.removeAttribute("width", 0);
elt.removeAttribute("align", 0);
elt.removeAttribute("vAlign", 0);
// get values from dialog and set attributes of table element
for ( elem in args2 ) {
if ("bgColor" == elem && args2["bgColor"] != null) {
elt.setAttribute("bgColor", args2["bgColor"]);
} else if ("borderColor" == elem && args2["borderColor"] != null) {
elt.borderColor = args2["borderColor"];
} else if ("height" == elem && args2["height"] != null) {
elt.height = args2["height"];
} else if ("width" == elem && args2["width"] != null) {
elt.width = args2["width"];
} else if ("align" == elem && args2["align"] != null) {
elt.align = args2["align"];
} else if ("vAlign" == elem && args2["vAlign"] != null) {
elt.vAlign = args2["vAlign"];
}
}
}
} else {
// id of found element == id of Editor, so cursor is not inside table
args1["error_notable"] = "true";
showModalDialog( "edit_html_changetable_el.html", args1,"font-family:Verdana; font-size:12; dialogWidth:50em; dialogHeight:32em");
}
} else {
// no parent found with tag.name == TR or TD
args1["error_notable"] = "true";
showModalDialog( "edit_html_changetable_el.html", args1,"font-family:Verdana; font-size:12; dialogWidth:50em; dialogHeight:32em");
}
} else {
// text or picture or control selected
args1["error_selection"] = "true";
showModalDialog( "edit_html_changetable_el.html", args1,"font-family:Verdana; font-size:12; dialogWidth:50em; dialogHeight:32em");
}
}
/* Builds a new table */
function InsertTable()
{
var pVar = document.all.ObjTableInfo;
var args = new Array();
var arr = null;
document.all.ObjTableInfo.TableAttrs =" ";
document.all.ObjTableInfo.CellAttrs =" ";
<!-- Preset values for the Table Dialog. Data is stored in an array that is submitted to the dialog -->
args["NumRows"] = document.all.ObjTableInfo.NumRows;
args["NumCols"] = document.all.ObjTableInfo.NumCols;
args["TableAttrs"] =document.all.ObjTableInfo.TableAttrs;
args["CellAttrs"] = document.all.ObjTableInfo.CellAttrs;
args["Caption"] = document.all.ObjTableInfo.Caption;
args["BorderLineWidth"] = 1;
args["CellSpacing"] = 1;
args["CellPadding"] = 1;
args["TableAlignment"] = "left";
args["TableWidth"]=100;
args["TableHeight"]=100;
args["TableWidthMode"]="%";
args["TableHeightMode"]="%";
arr = null;
<!-- Call the "addtable" dialog and receive its results in the arr array -->
arr = showModalDialog( "edit_html_newtable.html",
args,
"font-family:Verdana; font-size:12; dialogWidth:50em; dialogHeight:40em");
if (arr != null)
{
<!-- Initialize table object. Values from the arr array are processed for creating the Control call -->
for ( elem in arr )
{
if ("NumRows" == elem && arr["NumRows"] != null)
{
document.all.ObjTableInfo.NumRows = arr["NumRows"];
}
else if ("NumCols" == elem && arr["NumCols"] != null)
{
document.all.ObjTableInfo.NumCols = arr["NumCols"];
}
else if ("BorderLineWidth" == elem)
{
document.all.ObjTableInfo.TableAttrs = document.all.ObjTableInfo.TableAttrs + "border="+arr["BorderLineWidth"]+" ";
}
else if ("CellSpacing" == elem)
{
document.all.ObjTableInfo.TableAttrs = document.all.ObjTableInfo.TableAttrs + "cellspacing="+arr["CellSpacing"]+" ";
}
else if ("CellPadding" == elem)
{
document.all.ObjTableInfo.TableAttrs = document.all.ObjTableInfo.TableAttrs + "cellpadding="+arr["CellPadding"]+" ";
}
else if ("TableWidth" == elem)
{
if(arr["TableWidthSelected"] == "TRUE")
{
document.all.ObjTableInfo.TableAttrs = document.all.ObjTableInfo.TableAttrs + "width="+arr["TableWidth"];
if(arr["TableWidthMode"] == "%")
{
document.all.ObjTableInfo.TableAttrs = document.all.ObjTableInfo.TableAttrs +"% "
}
else
{
document.all.ObjTableInfo.TableAttrs = document.all.ObjTableInfo.TableAttrs +" "
}
}
}
else if ("TableHeight" == elem)
{
if(arr["TableHeigthSelected"] == "TRUE")
{
document.all.ObjTableInfo.TableAttrs = document.all.ObjTableInfo.TableAttrs + "height="+arr["TableHeight"];
if(arr["TableHeightMode"] == "%")
{
document.all.ObjTableInfo.TableAttrs = document.all.ObjTableInfo.TableAttrs +"% "
}
else
{
document.all.ObjTableInfo.TableAttrs = document.all.ObjTableInfo.TableAttrs +" "
}
}
}
else if ("TableAlignment" == elem)
{
document.all.ObjTableInfo.CellAttrs = document.all.ObjTableInfo.CellAttrs + "align="+arr["TableAlignment"]+" ";
}
else if ("TableColor" == elem)
{
if(arr["TableColorSelected"] == "TRUE")
{
document.all.ObjTableInfo.TableAttrs = document.all.ObjTableInfo.TableAttrs + "bgcolor="+arr["TableColor"];
}
}
else if ("Caption" == elem)
{
document.all.ObjTableInfo.Caption = arr["Caption"];
}
}
document.all.EDIT_HTML.ExecCommand(DECMD_INSERTTABLE, OLECMDEXECOPT_DODEFAULT, pVar);
}
}
function DECMD_HYPERLINK_onclick()
{
EDITOR.EDIT_HTML.ExecCommand(DECMD_HYPERLINK,OLECMDEXECOPT_PROMPTUSER);
EDITOR.EDIT_HTML.focus();
}
function DECMD_IMAGE_onclick()
{
EDITOR.EDIT_HTML.ExecCommand(DECMD_IMAGE,OLECMDEXECOPT_PROMPTUSER);
makeImageLinks();
EDITOR.EDIT_HTML.focus();
}
function DECMD_HYPERLINK_NODIALOG_onclick()
{
EDITOR.EDIT_HTML.ExecCommand(DECMD_HYPERLINK,OLECMDEXECOPT_DONTPROMPTUSER, EDITOR.URL.value);
EDITOR.EDIT_HTML.focus();
}
// sends URL string from seperate browser window to a hidden field within the opener document
function sendURLString(destFormName,destFieldName,strURL){
var obj1='top.window.opener.self.document.'+ destFormName;
var obj2='top.window.opener.self.document.'+ destFormName +'.'+ destFieldName;
if (eval(obj1) && eval(obj2)) {
eval(obj2 +'.value="'+strURL+'"');
top.window.opener.doEditHTML(45);
}
}
var foundstyles = new Array();
function setStyles(i, name) {
foundstyles[i] = name;
}
function resetStyles() {
var sel = document.all.BLOCK;
for (i=0; i<foundstyles.length; i++) {
sel.options[i] = new Option(foundstyles[i], foundstyles[i]);
}
}
function initStyles() {
getStyles();
resetStyles();
}
/***********************************************************/
/* Delete all empty <a>-Tags
/***********************************************************/
function deleteEmptyATags()
{
var allLinks = EDITOR.EDIT_HTML.DOM.all.tags("A");
var allImgLinks;
for(var i = 0; i < allLinks.length; i++)
{
if (allLinks[i].innerText == "")
{
allImgLinks = allLinks[i].all.tags("IMG");
if (allImgLinks.length == 0)
allLinks[i].removeNode();
}
}
}
/***********************************************************/
/* Replace absolute Image-Path by relative Path.Example,
/* http://10.0.0.0:8080/system/test -> /system/test
/***********************************************************/
function makeImageLinks()
{
var systemPath = getSystemPath();
var col = document.EDIT_HTML.DOM.all.tags("img");
var i;
for (i=0; i<col.length; i++)
{
var el = col[i];
var href = el.getAttribute("src");
href = href.replace(systemPath, "");
el.setAttribute("src", href);
// el.removeAttribute("style");
}
}
/***********************************************************/
/* Get the IP-adress of the page
/***********************************************************/
function getSystemPath()
{
var systemPath="";
var localURL=document.URL;
var n;
n = localURL.indexOf("://", 0);
if (n<0) return systemPath;
n = localURL.indexOf("/", n+3);
if (n<0) n = localURL.length;
systemPath = localURL.substring(0, n);
return systemPath;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -