其他案例
\n\n"; html_editor.getDoc().setValue(_html_code); }); $("#librep").click(function(){ $("#libs").modal("show"); }); $( "select" ).change(function() { const selectedValue = $(this).val(); const initialHtmlCode = html_editor.getValue(); const htmlScripts = { 'more': () => $("#libs").modal("show"), 'jq': " ', _libsrc + '
OSZAR »
'); } else { _editor_content = _libsrc + _editor_content; } html_editor.getDoc().setValue(_editor_content); } }); }); $("#save").click(function() { post_title = $("#post_title").val().trim(); var isnum = /^\d+$/.test(post_title); var isletter = /^[a-zA-Z]+$/.test(post_title); if( isnum ) { alert("请认真填写标题!"); } else if( isletter ) { alert("加点中文描述,大家更容易理解!"); }else if(post_title=="" || post_title.length<6) { alert("标题不能为空且不能少于6个字符……"); } else { var htmlSource = html_editor.getValue(), cssSource = css_editor.getValue(), jsSource = js_editor.getValue(), post_content = ''; if(htmlSource!='' || jsSource!='' || cssSource!='') { $.post("/savecode.php", {post_title:post_title, html: htmlSource, js: jsSource, css:cssSource,filename: ""}, function(data){ if(data.errno) { alert(data.msg) } else { $("#save").prop('disabled',false); alert(data.msg) window.location.href = data.url } }, "json"); } else { alert("请输入你要展示的代码……"); } } }); html_editor.setSize('100%','100%'); js_editor.setSize('100%', '100%'); css_editor.setSize('100%','100%'); function submitTryit() { // 基础模板 var html = html_editor.getValue(), css = css_editor.getValue(), js = js_editor.getValue(), src = html; if (html) { var patternHtmlTag = /]*)>/im; var array_matches_html_tag = patternHtmlTag.exec(src); if (array_matches_html_tag) { src = src.replace('', ''); } var patternHead = /]*>((.|[\n\r])*)<\/head>/im var array_matches_head = patternHead.exec(src); var patternBodyTag = /]*)>/im; var array_matches_body_tag = patternBodyTag.exec(src); if (array_matches_body_tag) { src = src.replace('', ''); } } //console.log(css); if (css.indexOf('\n'; if (array_matches_head) { src = src.replace('', css + ''); } else if (array_matches_body_tag) { src = src.replace('
OSZAR »
', css + '
OSZAR »
'); } else { src += css; } } // Javascript if(js) { js = '\n ', js + '
OSZAR »
'); }else { src += js; } } text = src; var ifr = document.createElement("iframe"); ifr.setAttribute("frameborder", "0"); ifr.setAttribute("id", "iframeResult"); document.getElementById("output").innerHTML = ""; document.getElementById("output").appendChild(ifr); var ifrw = (ifr.contentWindow) ? ifr.contentWindow: (ifr.contentDocument.document) ? ifr.contentDocument.document: ifr.contentDocument; ifrw.document.open(); ifrw.document.write(text); ifrw.document.close(); autodivheight(); } submitTryit(); window.addEventListener("resize", autodivheight); function autodivheight(){ var winHeight=0; if (window.innerHeight) { winHeight = window.innerHeight; } else if ((document.body) && (document.body.clientHeight)) { winHeight = document.body.clientHeight; } //通过深入Document内部对body进行检测,获取浏览器窗口高度 if (document.documentElement && document.documentElement.clientHeight) { winHeight = document.documentElement.clientHeight; } height = height = (winHeight - 60) * 0.86; document.getElementById("splitContainer").style.height= height +"px"; }
OSZAR »