var textContent; var lastSave; var cPRINT = 1; var cPREVIEW = 2; var cCUT = 3; var cCOPY = 4; var cPASTE = 5; var cBOLD = 6; var cITALIC = 7; var cUNDERLINE = 8; var cSTRIKETHRU = 9; var cSUBSCRIPT = 10; var cSUPERSCRIPT = 11; var cHX = 12; var cFONT_SIZE = 13; var cFONT_NAME = 14; var cFORE_COLOR = 15; var cBACK_COLOR = 16; var cOUTDENT = 17; var cINDENT = 18; var cLEFT = 19; var cCENTER = 20; var cRIGHT = 21; var cPARABUL = 22; var cPARANUM = 23; var cLINK = 24; var cIMAGE = 25; var editRange = null; function doSimpleAction(id,action){ // no check needed for these actions var editor = document.getElementById(id + "htmlbeditor").document; if ( action == cPRINT) { editor.execCommand("Print",1,""); return; } if ( action == cPREVIEW) { showPreview(id); return; } if (checkDoAction(id) == false) { return; } lastSave = null; switch (action){ case cPRINT: editor.execCommand("Print",1,""); break; case cPREVIEW: showPreview(id); break; case cCUT: editRange.execCommand("Cut"); break; case cCOPY: editRange.execCommand("Copy"); break; case cPASTE: editRange.execCommand("Paste"); break; case cBOLD: editRange.execCommand("Bold"); break; case cITALIC: editRange.execCommand("Italic"); break; case cUNDERLINE: editRange.execCommand("Underline"); break; case cSTRIKETHRU: editRange.execCommand("StrikeThrough"); break; case cSUBSCRIPT: editRange.execCommand("SubScript"); break; case cSUPERSCRIPT: editRange.execCommand("SuperScript"); break; case cOUTDENT: editRange.execCommand("Outdent"); break; case cINDENT: editRange.execCommand("Indent"); break; case cLEFT: editRange.execCommand("JustifyLeft"); break; case cCENTER: editRange.execCommand("JustifyCenter"); break; case cRIGHT: editRange.execCommand("JustifyRight"); break; case cPARABUL: editRange.execCommand("InsertUnorderedList"); break; case cPARANUM: editRange.execCommand("InsertOrderedList"); break; case cLINK: editRange.execCommand("CreateLink"); break; case cLINK: editRange.execCommand("CreateLink",1,""); break; case cIMAGE: editRange.execCommand("InsertImage",1,""); break; } save(id); } function doComplexAction(id,action,param) { if (checkDoAction(id) == false) { return; } lastSave = null; if (param == "NOP") { return; } switch (action){ case cHX: editRange.execCommand("FormatBlock", 1,param); break; case cFONT_SIZE: editRange.execCommand("FontSize", 1,param); break; case cFORE_COLOR: editRange.execCommand("ForeColor", 1,param); break; case cBACK_COLOR: editRange.execCommand("BackColor", 1,param); break; } save(id); } function checkDoAction(id) { if (lastSave != id) { return false; } if ( editRange == null) { return false; } return true; } function save(id) { lastSave = id; var x = document.getElementById(id); if(x!=null) x.value = document.getElementById(id + "htmlbeditor").innerHTML; editRange = document.getElementById(id + "htmlbeditor").document.selection.createRange(); if ( document.getElementById(id + "htmlbeditor").document.selection.createRange().parentElement().id == id + "htmlbeditor") { editRange = document.getElementById(id + "htmlbeditor").document.selection.createRange(); } } function save_userexit(id) { var x = document.getElementById(id + "_ADD"); if(x!=null) x.value = document.getElementById(id + "htmlbeditor").innerHTML; } function save_restore(id) { var x = document.getElementById(id + "_OLD"); if(x!=null) x.value = document.getElementById(id + "htmlbeditor").innerHTML; } var myWindow; var myId; function showPreview(id) { save(id); myId = id; var editor=document.getElementById(id + "htmlbeditor"); mywindow = window.open('prev_htmlbedit.html'); window.setTimeout("setContent()",50); } function setContent() { var x = document.getElementById(myId + "htmlbeditor"); if(x!=null) { try { mywindow.document.body.innerHTML = x.innerHTML; mywindow.document.close(); } catch(e) { window.setTimeout("setContent()",50); } } }