[$] Pr1v473 xHeEl B4ckD00RzZ [$]
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="../style/editor.css" rel="stylesheet" type="text/css">
<link href="../style/istoolbar.css" rel="stylesheet" type="text/css">
<script language="javascript" src="../istoolbar.js"></script>
<script>
var sLangDir=parent.oUtil.langDir;
document.write("<scr"+"ipt src='../language/"+sLangDir+"/source_html.js'></scr"+"ipt>");
</script>
<script>writeTitle()</script>
<script>
var iconOffsetTop = -75;
var sBaseHREF="";
function init()
{
var idSource = document.getElementById("idSource").contentWindow;
var doc = idSource.document;
doc.open();
doc.write("<html><head><head><body></body></html>");
doc.close();
}
function doCmd(sCmd,sOption)
{
var idSource = document.getElementById("idSource").contentWindow;
idSource.document.execCommand(sCmd, false, sOption);
}
function bodyOnLoad()
{
setupToolbar();loadTxt();init();
var oEditor=parent.oUtil.oEditor;
//base handling
sHTML=parent.getOuterHTML(oEditor.document.documentElement);
var arrTmp=sHTML.match(/<BASE([^>]*)>/ig);
if(arrTmp!=null)sBaseHREF=arrTmp[0];
var arrBase = oEditor.document.getElementsByTagName("BASE");
if (arrBase.length != null) {
for(var i=0; i<arrBase.length; i++) {
arrBase[i].parentNode.removeChild(arrBase[i]);
}
}
//~~~~~~~~~~~~~
sHTML=recur(oEditor.document.documentElement,"");
//restore doctype (if any) & html
var obj = parent.oUtil.obj;
sHTMLDocType=obj.docType;
if(sHTMLDocType!="")
{
//sHTMLDocType=sHTMLDocType.replace(/DOCTYPE/g,"doctype");
sHTMLDocType=sHTMLDocType.replace(/</g,"<");
sHTMLDocType=sHTMLDocType.replace(/>/g,">");
sHTMLDocType="<font color='#000000'>"+sHTMLDocType+"</font>";
}
else sHTMLDocType="";
sHTMLOpenTag=obj.html;
sHTMLOpenTag=sHTMLOpenTag.replace(/HTML/g,"html");
sHTMLOpenTag=sHTMLOpenTag.replace(/</g,"<");
sHTMLOpenTag=sHTMLOpenTag.replace(/>/g,">");
sHTMLOpenTag="<font color='#000000'>"+sHTMLOpenTag+"</font>";
sHTMLCloseTag= "<font color='#000000'></html></font>";
//construct
if(sHTMLDocType!="")
sHTML = sHTMLDocType + "<br>" + sHTMLOpenTag + sHTML + "<br>" + sHTMLCloseTag;
else
sHTML = sHTMLOpenTag + sHTML + "<br>" + sHTMLCloseTag;
sHTML = sHTML.replace(/<br class="innova" \/>/gi, "");
//Display
var idSource = document.getElementById("idSource").contentWindow;
var sourceDocBody = idSource.document.body;
//remove all child
sourceDocBody.innerHTML = "";
sourceDocBody.innerHTML = sHTML;
sourceDocBody.style.cssText="overflow-x:scroll;overflow-y:scroll;white-space:nowrap";
sourceDocBody.clearAttributes;
sourceDocBody.style.marginTop='4';
sourceDocBody.style.marginLeft='10';
sourceDocBody.style.fontFamily='Tahoma';
sourceDocBody.style.fontSize='11px';
sourceDocBody.style.color='black';
sourceDocBody.style.background='white';
//idSource.document.addEventListener("keydown", new Function("doKeyPress(arguments[0])"), false);
doWrap()
idSource.document.designMode="on";
idSource.focus();
}
function doKeyPress(evt)
{
/*
if (evt.keyCode==13)
{
var thisSel = document.selection.createRange();
thisSel.pasteHTML('<br>');
evt.cancelBubble = true;
evt.returnValue = false;
thisSel.select();
thisSel.moveEnd("character", 1);
thisSel.moveStart("character", 1);
thisSel.collapse(false);
return false;
idSource.focus();
}
if (evt.ctrlKey)
{
if(evt.keyCode==65)doCmd("SelectAll");
}
*/
}
function doUpdate()
{
parent.oUtil.obj.saveForUndo();
var obj = parent.oUtil.obj;
var idSource = document.getElementById("idSource").contentWindow;
var range = idSource.document.body.ownerDocument.createRange();
range.selectNodeContents(idSource.document.body);
var sHTML = range.toString();
sHTML = sHTML.replace(/>\s+</gi, "><"); //replace space between tag
sHTML = sHTML.replace(/\r/gi, ""); //replace space between tag
sHTML = sHTML.replace(/(<br>)\s+/gi, "$1"); //replace space between BR and text
sHTML = sHTML.replace(/(<br\s*\/>)\s+/gi, "$1"); //replace space between BR and text
//sHTML = sHTML.replace(/\s+(<)/gi, "$1"); //replace space between BR and text
//sHTML = sHTML.replace(/(>)\s+/gi, "$1"); //replace space between BR and text
//base otomatis akan diposisikan di dlm head
var sHTML = sBaseHREF+sHTML;
sHTML = sHTML.replace(/\s+/gi, " "); //replace spaces with space
obj.putHTML(sHTML);//tdk menggunakan loadHTML() krn loadHTML() hanya utk first load.
}
/************************
HTML to XHTML (formatted)
************************/
function lineBreak2(tag) //[0]<TAG>[1]text[2]</TAG>
{
arrReturn = ["<br>","",""];
if( tag=="A"||tag=="B"||tag=="CITE"||tag=="CODE"||tag=="EM"||
tag=="FONT"||tag=="I"||tag=="SMALL"||tag=="STRIKE"||tag=="BIG"||
tag=="STRONG"||tag=="SUB"||tag=="SUP"||tag=="U"||tag=="SAMP"||
tag=="S"||tag=="VAR"||tag=="BASEFONT"||tag=="KBD"||tag=="TT"||tag=="SPAN"||tag=="IMG")
arrReturn=["","",""];
if( tag=="TEXTAREA"||tag=="TABLE"||tag=="THEAD"||tag=="TBODY"||
tag=="TR"||tag=="OL"||tag=="UL"||tag=="DIR"||tag=="MENU"||
tag=="FORM"||tag=="SELECT"||tag=="MAP"||tag=="DL"||tag=="HEAD"||
tag=="BODY"||tag=="HTML")
arrReturn=["<br>","","<br>"];
if( tag=="STYLE"||tag=="SCRIPT")
arrReturn=["<br>","",""];
if(tag=="BR"||tag=="HR")
arrReturn=["","<br>",""];
return arrReturn;
}
function fixAttr(s)
{
s = String(s).replace(/&/g, "&amp;");//harus di awal
s = String(s).replace(/</g, "&lt;");
//s = String(s).replace(/>/g, "&gt;");//tdk apa2
s = String(s).replace(/"/g, "&quot;");
//s = String(s).replace(/'/g, "&apos;");//tdk apa2
return s;
}
function fixVal(s)
{
s = String(s).replace(/&/g, "&amp;");//harus di awal
s = String(s).replace(/</g, "&lt;");
var x = escape(s);
x = unescape(x.replace(/\%A0/gi, "-*REPL*-"));
s = x.replace(/-\*REPL\*-/gi, " ");
return s;
}
function recur(oEl,sTab)
{
var sHTML="";
for(var i=0;i<oEl.childNodes.length;i++)
{
var oNode=oEl.childNodes[i];
if(oNode.nodeType==1)//tag
{
var sTagName = oNode.nodeName;
if(sTagName=="BR" && oNode.className=="innova") continue;
if(sTagName=="LINK" && oNode.id=="tmp_xxinnova") continue;
var bDoNotProcess=false;
if(sTagName.substring(0,1)=="/")
{
bDoNotProcess=true;//do not process
}
else
{
/*** tabs ***/
var sT= sTab;
sHTML+= lineBreak2(sTagName)[0];
if(lineBreak2(sTagName)[0] !="") sHTML+= sT;//If new line, use base Tabs
/************/
}
if(bDoNotProcess)
{
;//do not process
}
else if(sTagName=="OBJECT" || sTagName=="EMBED")
{
s=parent.getOuterHTML(oNode);
s=s.replace(/\"[^\"]*\"/ig,function(x){
x=x.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/'/g, "'").replace(/\s+/ig,"#_#").replace(/&amp;/gi,"&");
return x});
s=s.replace(/<([^ >]*)/ig,function(x){return x.toLowerCase()})
s=s.replace(/ ([^=]+)=([^"' >]+)/ig," $1=\"$2\"");//new
s=s.replace(/ ([^=]+)=/ig,function(x){return x.toLowerCase()});
s=s.replace(/#_#/ig," ");
s=s.replace(/<param([^>]*)>/ig,"\n<param$1 />").replace(/\/ \/>$/ig," \/>");//no closing tag
if(sTagName=="EMBED")
if(oNode.innerHTML=="")
s=s.replace(/>$/ig," \/>").replace(/\/ \/>$/ig,"\/>");//no closing tag
s=s.replace(/<param name=\"Play\" value=\"0\" \/>/,"<param name=\"Play\" value=\"-1\" \/>")
s=s.replace(/</gi, "<");
/*** format ***/ //selThis
sHTML+="<span style='color:#555555;background:#f7f7f7'><pre style='font-family:tahoma;margin-top:0px;margin-bottom:0px;'>"+s+"</pre></span>";
/**************/
}
else if(sTagName=="TITLE")
{
//s="<title>"+oNode.innerHTML+"</title>";
/*** format ***/
sHTML+="<font color='#0000cc'><<\/font><font color='#8b4513'>title</font>"+
"<font color='#0000cc'>><\/font>" + oNode.innerHTML +
"<font color='#0000cc'></</font><font color='#8b4513'>title</font>"+
"<font color='#0000cc'>></font>";
/**************/
}
else
{
if(sTagName=="AREA")
{
var sCoords=oNode.coords;
var sShape=oNode.shape;
}
var oNode2=oNode.cloneNode(false);//hasil: <tag..>..</tag>
s=parent.getOuterHTML(oNode2).replace(/<\/[^>]*>/,"");//hasil: <tag..>
if(sTagName=="STYLE")//hasil: <tag..>..
{
var arrTmp=s.match(/<[^>]*>/ig);
s=arrTmp[0];//hasil: <tag..>
}
s=s.replace(/\"[^\"]*\"/ig,function(x){
//x=x.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/'/g, "'").replace(/\s+/ig,"#_#");
x=x.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/\s+/ig,"#_#");
return x});
s=s.replace(/<([^ >]*)/ig,function(x){return x.toLowerCase()})
s=s.replace(/ ([^=]+)=([^" >]+)/ig," $1=\"$2\"");
s=s.replace(/ ([^=]+)=/ig,function(x){return x.toLowerCase()});
s=s.replace(/#_#/ig," ");
//single attribute
s=s.replace(/(<hr[^>]*)(noshade="")/ig,"$1noshade=\"noshade\"");
s=s.replace(/(<input[^>]*)(checked="")/ig,"$1checked=\"checked\"");
s=s.replace(/(<select[^>]*)(multiple="")/ig,"$1multiple=\"multiple\"");
s=s.replace(/(<option[^>]*)(selected="")/ig,"$1selected=\"true\"");
s=s.replace(/(<input[^>]*)(readonly="")/ig,"$1readonly=\"readonly\"");
s=s.replace(/(<input[^>]*)(disabled="")/ig,"$1disabled=\"disabled\"");
s=s.replace(/(<td[^>]*)(nowrap="" )/ig,"$1nowrap=\"nowrap\" ");
s=s.replace(/(<td[^>]*)(nowrap=""\>)/ig,"$1nowrap=\"nowrap\"\>");
s=s.replace(/ contenteditable=\"true\"/ig,"");
if(sTagName=="AREA")
{
s=s.replace(/ coords=\"0,0,0,0\"/ig," coords=\""+sCoords+"\"");
s=s.replace(/ shape=\"RECT\"/ig," shape=\""+sShape+"\"");
}
var bClosingTag=true;
if(sTagName=="IMG"||sTagName=="BR"||
sTagName=="AREA"||sTagName=="HR"||
sTagName=="INPUT"||sTagName=="BASE"||
sTagName=="LINK"||sTagName=="META")//no closing tag
{
s=s.replace(/>$/ig," \/>").replace(/\/ \/>$/ig,"\/>");//no closing tag
bClosingTag=false;
}
//sSelThis="";//selThis
//if(oElement==oNode)sSelThis=" selThis='selThis'"
/*** format ***/ //selThis
//sA1="<span"+sSelThis+"><font color='#0000cc'><<\/font><font color='#8b4513'>"
sA1="<span><font color='#0000cc'><<\/font><font color='#8b4513'>"
sA2="<\/font>"
sA3="<font color='#0000cc'>><\/font>"
sA4="<font color='#0000cc'>/><\/font>"
s=s.replace(/<([^ >]*)([^ \/>]*)/ig,sA1+"$1"+sA2+"$2");
//s=s.replace(/\/>$/ig,sA4);//if there is no closing tag
s=s.replace(/>$/ig,sA3);
/**************/
sHTML+=s;
if(!bClosingTag)sHTML+="</span>";//selThis
/*** tabs ***/
if(sTagName!="TEXTAREA")sHTML+= lineBreak2(sTagName)[1];
if(sTagName!="TEXTAREA")if(lineBreak2(sTagName)[1] !="") sHTML+= sT;//If new line, use base Tabs
/************/
if(bClosingTag)
{
/*** CONTENT ***/
s=parent.getOuterHTML(oNode);
if(sTagName=="SCRIPT")
{
s = s.replace(/<script([^>]*)>[\n+\s+\t+]*/ig,"<script$1>");//clean spaces
s = s.replace(/[\n+\s+\t+]*<\/script>/ig,"<\/script>");//clean spaces
s = s.replace(/<script([^>]*)>\/\/<!\[CDATA\[/ig,"");
s = s.replace(/\/\/\]\]><\/script>/ig,"");
s = s.replace(/<script([^>]*)>/ig,"");
s = s.replace(/<\/script>/ig,"");
s = s.replace(/^\s+/,'').replace(/\s+$/,'');
/*** format ***/
sHTML+="<div><span style='color:#828282;'>//<![CDATA[<pre style='font-family:tahoma;margin-top:0px;margin-bottom:0px;'>"+s+"</pre>//]]></span></div>";
/**************/
}
if(sTagName=="STYLE")
{
s = s.replace(/<style([^>]*)>[\n+\s+\t+]*/ig,"<style$1>");//clean spaces
s = s.replace(/[\n+\s+\t+]*<\/style>/ig,"<\/style>");//clean spaces
s = s.replace(/<style([^>]*)><!--/ig,"");
s = s.replace(/--><\/style>/ig,"");
s = s.replace(/<style([^>]*)>/ig,"");
s = s.replace(/<\/style>/ig,"");
s = s.replace(/^\s+/,"").replace(/\s+$/,"");
/*** format ***/
sHTML+="<div><span style='color:#828282;'><!--<pre style='font-family:tahoma;margin-top:0px;margin-bottom:0px;'>"+s+"</pre>--></span></div>";
/**************/
}
if(sTagName=="DIV"||sTagName=="P")
{
if(oNode.innerHTML==""||oNode.innerHTML==" ")
{
sHTML+="&nbsp;";
}
else sHTML+=recur(oNode,sT+" ");
}
else
if (sTagName == "STYLE" || sTagName=="SCRIPT")
{
//do nothing
}
else
{
sHTML+=recur(oNode,sT+" ");
}
/*** tabs ***/
if(sTagName!="TEXTAREA")sHTML+= lineBreak2(sTagName)[2];
if(sTagName!="TEXTAREA")if(lineBreak2(sTagName)[2] !="") sHTML+= sT;//If new line, use base Tabs
/************/
/*** format ***/ //selThis
sHTML+="<font color='#0000cc'></</font><font color='#8b4513'>" + sTagName.toLowerCase() + "</font><font color='#0000cc'>></font></span>";
/**************/
}
}
}
else if(oNode.nodeType==3)//text
{
sHTML+= fixVal(oNode.nodeValue).replace(/^[\t\r\n\v\f]*/, "").replace(/[\t\r\n\v\f]*$/, "");
}
else if(oNode.nodeType==8)
{
if(parent.getOuterHTML(oNode).substring(0,2)=="<"+"%")
{//server side script
sTmp=(parent.getOuterHTML(oNode).substring(2))
sTmp=sTmp.substring(0,sTmp.length-2)
sTmp=sTmp.replace(/^\s+/,"").replace(/\s+$/,"");
sHTML+= "<div><span style='background:yellow'><%<pre style='font-family:tahoma;margin-top:0px;margin-bottom:0px;'>"+sTmp+"</pre>%></span></div>";
}
else
{//comments
sTmp=oNode.nodeValue;
sTmp = sTmp.replace(/^\s+/,"").replace(/\s+$/,"");
sHTML+= "<div><span style='color:#828282;'><!--<pre style='font-family:tahoma;margin-top:0px;margin-bottom:0px;'>"+sTmp+"</pre>--></span></div>";
}
}
else
{
;//Not Processed
}
}
return sHTML;
}
function doWrap()
{
var inpWrap = document.getElementById("inpWrap");
if(inpWrap.checked==true)
{
//Wrap Text
idSource.document.body.style.whiteSpace="normal";
}
else
{
idSource.document.body.style.whiteSpace="nowrap";
}
}
//*******************
function setupToolbar()
{
var obj = parent.oUtil.obj;
var tb=new ISToolbar("srcEdt");
tb.onClick=function(id) {tbAction(tb, id);};
tb.iconPath="../"+obj.iconPath;
tb.btnWidth=obj.iconWidth;
tb.btnHeight=obj.iconHeight;
//tb.addButton("btnCut","btnCut.gif",getTxt("Cut"));
//tb.addButton("btnCopy","btnCopy.gif",getTxt("Copy"));
//tb.addButton("btnPaste","btnPaste.gif",getTxt("Paste"));
//tb.addSeparator();
tb.addButton("btnUndo","btnUndo.gif",getTxt("Undo"));
tb.addButton("btnRedo","btnRedo.gif",getTxt("Redo"));
tb.addSeparator();
tb.addButton("btnSearch","btnSearch.gif",getTxt("Search"));
document.getElementById("idToolbar").innerHTML=tb.render();
}
function tbAction(tb, id)
{
switch(id)
{
case "btnCut": doCmd('Cut'); break;
case "btnCopy": doCmd('Copy'); break;
case "btnPaste": doCmd('Paste'); break;
case "btnUndo": doCmd('Undo'); break;
case "btnRedo": doCmd('Redo'); break;
case "btnSearch": modelessDialogShow('search2.htm',375,163); break;
}
}
//*******************
function modelessDialogShow(url,width,height)
{
parent.modelessDialogShow(parent.oUtil.scriptPath+url, width,height,window);
}
</script>
</head>
<body style="overflow:hidden;margin:0;background: #f4f4f4;">
<table width="100%" height="100%" align="center" cellpadding="0" cellspacing="0">
<tr>
<td id="idToolbar">
</td>
</tr>
<tr>
<tr>
<td style="height:100%">
<iframe style="width:100%;height:100%;" frameborder="no" name="idSource" id="idSource"></iframe>
</td>
</tr>
<tr>
<td class="dialogFooter" align="right" valign="right" style="padding-top:10px;">
<table cellpadding=0 cellspacing=0>
<td width="100%">
<input type="checkbox" ID="inpWrap" NAME="inpWrap" onclick="doWrap()" checked> <span id="txtLang" name="txtLang">Wrap Text</span>
</td>
<td>
<input type="button" name="btnCancel" id="btnCancel" value="cancel" onclick="self.close()" class="inpBtn" onmouseover="this.className='inpBtnOver';" onmouseout="this.className='inpBtnOut'">
</td>
<td>
<input type="button" name="btnApply" id="btnApply" value="apply" onclick="doUpdate();bodyOnLoad()" class="inpBtn" onmouseover="this.className='inpBtnOver';" onmouseout="this.className='inpBtnOut'">
</td>
<td>
<input type="button" name="btnOk" id="btnOk" value=" ok " onclick="doUpdate();self.close()" class="inpBtn" onmouseover="this.className='inpBtnOver';" onmouseout="this.className='inpBtnOut'">
</td>
</table>
</td>
</tr>
</table>
</body>
</html>