Html Compiler

\n" startCode += "" vHTML.value = startCode; writePage(); } function updatePage() { var vUpdate = document.getElementById("update");if(vUpdate.checked) { writePage(); } } function writePage() { var vPage = document.getElementById("htmlpage"); var vSave = document.getElementById("save"); // var vOpen = document.getElementById("open"); // var url = stringURL(); var url = HtmlCode(); url = editor.getSession().getValue(); // vPage.src = url; // vPage.src = url; var div=document.createElement("div"); div.id="code"; var main=document.getElementsByTagName("main")[0]; main.appendChild(div); div.innerHTML=url; var img=div.querySelectorAll("img"); if(img.length>0){ for (var i=0; i < img.length; i++) { var imgsrc_OLD=img[i].getAttribute("src"); // var check = ; if(!imgsrc_OLD.includes("https:")){ var imgsrc_NEW="/wp-content/uploads/html_images/"; var final=img[i].src=imgsrc_NEW+imgsrc_OLD; url=div.innerHTML; vPage.srcdoc = url; vSave.href = url; }else{ vPage.srcdoc = url; vSave.href = url; } } }else{ vPage.srcdoc = url; vSave.href = url; } div.style.display="none"; }// if(str.includes("Geeks"))function HtmlCode(){ // var vHTML = document.getElementById("html"); var vHTML = editor.getSession().getValue(); return vHTML.value; } writePage(); function Enter_(evento, object) { var keyCode = evento.keyCode || evento.which; if(keyCode == 9) { event.preventDefault(); var comeco = object.selectionStart; var fim = object.selectionEnd; object.value = object.value.substring(0, comeco) + "\t" + object.value.substring(fim); object.selectionStart = object.selectionEnd = comeco + 1; object.focus(); } if(keyCode == 13) { event.preventDefault(); var comeco = object.selectionStart; var fim = object.selectionEnd; var quebra = "\n"; var txtComeco = object.value.substring(0, comeco); var txtFim = object.value.substring(fim); var txtSplit = txtComeco.split(quebra); var txtUltimaLinha = txtSplit[txtSplit.length-1]; var nTabs = 0; var index = 0; while( txtUltimaLinha.charAt(index++) == "\t" ) { nTabs++; } object.value = txtComeco + "\n" + tab(nTabs) + txtFim; object.selectionStart = object.selectionEnd = comeco + nTabs + 1; object.focus(); } if(keyCode == 116) { event.preventDefault(); writePage(); } } function stringURL(html) { // var url = "data:text/html;charset=ISO-8859-1,"; var url = "data:text/html;charset=base64,"; var vHTML = document.getElementById("html"); if(!html) { html = vHTML.value; } else { vHTML.value = html; } url += escape(html); // console.log(url); return url; } function OpenFIle() { if(window.File && window.FileReader && window.FileList && window.Blob) { var arquivo = file.files[0].slice(); var leitor = new window.FileReader(); leitor.readAsBinaryString(arquivo); leitor.onloadend = function(){ stringURL(leitor.result); writePage(); } } else { alert("O seu navegador não possui suporte à API de arquivos.") } } function tab(num) { var i; var tab = ""; for(i=0; i < num; i++) { tab += "\t"; } console.log(tab); return tab; }// startPage(); // writePage();