var minFontSize=1; var maxFontSize=4; // These variables are used to calculate the dimension of the choose color dialog // and choose font dialog. // They should be set according to the values used in the color.html and font.html files. var colorsPerRow = 4; var colorRows = 4; var colorCellWidth = 20; var colorCellHeight = 20; var numberOfFonts = 4; var fontCellHeight = 20; var fontDialogWidth = 400; function bold(oDiv) { oDiv.focus(); document.execCommand("Bold"); return; } function makeUnorderedList(oDiv) { oDiv.focus(); document.execCommand("InsertUnorderedList"); return; } function itallic(oDiv) { oDiv.focus(); document.execCommand("Italic"); return; } function left_justify(oDiv) { oDiv.focus(); document.execCommand("JustifyLeft"); return; } function center(oDiv) { oDiv.focus(); document.execCommand("JustifyCenter"); return; } function right_justify(oDiv) { oDiv.focus(); document.execCommand("JustifyRight"); return; } function font_up(oDiv) { oDiv.focus(); size = document.queryCommandValue("FontSize") +1 ; document.execCommand("FontSize", "false", size); return; } function font_down(oDiv) { oDiv.focus(); size = document.queryCommandValue("FontSize") -1 ; document.execCommand("FontSize", "false", size); return; } function setcolor(oDiv, fromExtern) { var filePath = "color.html"; if (!fromExtern) filePath = "htmledit/" + filePath; var color = ""; oDiv.focus(); var width = ((colorCellWidth*colorsPerRow)+70); var height = ((colorCellHeight*colorRows)+120) color = showModalDialog(filePath, "", "dialogHeight:" + height + "px;dialogWidth:" + width + "px;help:no;status:no;scroll:no"); if (!(color)) return; document.execCommand("ForeColor", "false", color); return; } function setfont(oDiv, fromExtern) { var filePath = "font.html"; if (!fromExtern) filePath = "htmledit/" + filePath; var font = ""; oDiv.focus(); var height = numberOfFonts*fontCellHeight + 120; font = showModalDialog(filePath , "", "dialogHeight:" + height + "px;dialogWidth:" + fontDialogWidth + "px;help:no;status:no;scroll:no;"); if (!(font)) return; document.execCommand("FontName", "false", font); return; } function display(oDiv) { alert(oDiv.innerHTML); return; } function fillTextarea() { var textareas = document.getElementsByTagName("textarea"); for (i=0;i', 'gi') ; converted = converted.replace(re, '
\n') ; currTextarea.value = converted; } } function fillDiv() { var divs = document.getElementsByTagName("div"); for (i=0;i' + preText + ''); return; } function insertImage(oDiv) { oDiv.focus(); document.execCommand("InsertImage", "true"); return; } function MM_findObj(n, d) { //v3.0 var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) { d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);} if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i"; html = replaceSubstring(html, newTag, iofm, iofm+fmatch.length); plusLength=newTag.length; } fmatch = getNonEmptyTagFirstMatch(html.substring(iofm + plusLength)); if (fmatch == "") return html; iofm = iofm + plusLength + html.substring(iofm + plusLength).indexOf(fmatch); } return html; } function unMakeWebMLLinks(html) { var fmatch = getNonEmptyTagFirstMatch(html); if (fmatch == "") return html; var iofm = html.indexOf(fmatch); while (iofm != -1) { var webmlsrc = getAttributeSubstring(fmatch , "webmlsrc"); var webmlhref = getAttributeSubstring(fmatch , "webmlhref"); var plusLength = fmatch.length; var newTag = fmatch; if (webmlhref != "") { var href = getAttributeSubstring(newTag , "href"); newTag = replaceSubstring(newTag, "", newTag.indexOf(webmlhref)-1, newTag.indexOf(webmlhref) + webmlhref.length); if (href != "") newTag = replaceSubstring(newTag, "href=" + getSafeAttributeValue(webmlhref), newTag.indexOf(href), newTag.indexOf(href) + href.length); html = replaceSubstring(html, newTag, iofm, iofm+plusLength); plusLength = newTag.length; } if (webmlsrc != "") { var src = getAttributeSubstring(newTag , "src"); newTag = replaceSubstring(newTag, "", newTag.indexOf(webmlsrc)-1, newTag.indexOf(webmlsrc) + webmlsrc.length); if (href != "") newTag = replaceSubstring(newTag, "src=" + getSafeAttributeValue(webmlsrc), newTag.indexOf(src), newTag.indexOf(src) + src.length); html = replaceSubstring(html, newTag, iofm, iofm + plusLength); plusLength = newTag.length; } fmatch = getNonEmptyTagFirstMatch(html.substring(iofm + plusLength)); if (fmatch == "") return html; iofm = iofm + plusLength + html.substring(iofm + plusLength).indexOf(fmatch); } return html; } function callExternEditor(textarea, baseURI) { var ret = showModalDialog(baseURI + "Resources/htmledit/edit.html", textarea, "dialogHeight:500px;dialogWidth:600px;help:no;status:no;scroll:no"); if (ret) textarea.value = ret; textarea.focus(); } function callExternEditor_simple(textarea) { var ret = showModalDialog("Resources/htmledit/edit_simple.html", textarea, "dialogHeight:500px;dialogWidth:600px;help:no;status:no;scroll:no"); if (ret) textarea.value = ret; textarea.focus(); } function firstMatch(sText, rExp) { return (sText.match(rExp) != null) ? sText.match(rExp)[0] : null; } function indexOfFirstMatch(sText,rExp) { return (sText.match(rExp) != null) ? sText.indexOf(sText.match(rExp)[0]) : -1; } function firstMatchLength(sText,rExp) { return (sText.match(rExp) != null) ? sText.match(rExp)[0].length : -1; } function replaceSubstring(sText, newString , fromIndex, toIndex) { sText = sText.substring(0,fromIndex) + newString + sText.substring(toIndex); return sText; } function getAttributeSubstring(tag, attr) { var re1 = new RegExp ('( [^\"\'= ]+[ ]*=[ ]*"[^\"]*")|( [^\"\'= ]+[ ]*=[ ]*\'[^\']*\')|( [^\"\'= ]+[ ]*=[ ]*[^ \"\'>]+)', 'gi') ; var iofm = indexOfFirstMatch(tag, re1); while (iofm != -1) { var fmatch = firstMatch(tag.substring(iofm), re1); if ((firstMatch(fmatch, new RegExp('[^ \"\'=]+', 'gi')) != null) && (firstMatch(fmatch, new RegExp('[^ \"\'=]+', 'gi')) == attr)) { return fmatch.substring(1); } iofm = (indexOfFirstMatch(tag.substring(iofm + fmatch.length), re1) != -1) ? indexOfFirstMatch(tag.substring(iofm + fmatch.length), re1) + iofm + fmatch.length : -1; } return ""; } function getTagFirstMatch(htmltext, tagname) { var tagRe = new RegExp( '<[ ]*' + tagname + '[ ]*((' + '( [^\"\'= ]+[ ]*=[ ]*"[^\"]*")|( [^\"\'= ]+[ ]*=[ ]*\'[^\']*\')|( [^\"\'= ]+[ ]*=[ ]*[^ \"\'>]+)' + ')[ ]*)*>' , 'gi'); var match = htmltext.match(tagRe); if (match != null) return match[0]; return ""; } function getNonEmptyTagFirstMatch(htmltext) { var tagRe = new RegExp( '<[ ]*' + '[^ \'\"=><]+' + '[ ]*((' + '( [^\"\'= ><]+[ ]*=[ ]*"[^\"]*")|( [^\"\'= ><]+[ ]*=[ ]*\'[^\']*\')|( [^\"\'= ><]+[ ]*=[ ]*[^ \"\'><]+)' + ')[ ]*)+>' , 'gi'); var match = htmltext.match(tagRe); if (match != null) return match[0]; return ""; } function getSafeAttributeValue(attrsubstring) { var safevalue = firstMatch(attrsubstring, new RegExp('"[^"]*"$|\'[^\']*\'$|[^ "\'=]*$', 'gi')); if (safevalue == null) return ""; if (!((safevalue.substring(0,1) == "'") || (safevalue.substring(0,1) == '"'))) { safevalue = '"' + safevalue + '"'; } return safevalue; }