”;
html_editor.getDoc().setValue(_html_script_code + _inithtmlcode);
}else if(_thisvar == 'bs3') {
_html_script_code = "<link rel="stylesheet" href="https://cdn.staticfile.net/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
讯享网
”;
讯享网 html_editor.getDoc().setValue(_html_script_code + _inithtmlcode);
}else if(_thisvar == 'bs4') {
_html_script_code = "<link rel="stylesheet" href="https://cdn.staticfile.net/twitter-bootstrap/4.6.0/css/bootstrap.min.css">
”;
html_editor.getDoc().setValue(_html_script_code + _inithtmlcode);
}else if(_thisvar == 'ag') {
_html_script_code = "
”;
讯享网 html_editor.getDoc().setValue(_html_script_code + _inithtmlcode);
}else if(_thisvar == 'vue2') {
_html_script_code = "
”;
html_editor.getDoc().setValue(_html_script_code + _inithtmlcode);
}else if(_thisvar == 'vue3') {
_html_script_code = "
”;
讯享网 html_editor.getDoc().setValue(_html_script_code + _inithtmlcode);
}else if(_thisvar == 'fa') {
_html_script_code = "<link rel="stylesheet" href="https://cdn.staticfile.net/font-awesome/4.7.0/css/font-awesome.min.css">
”;
html_editor.getDoc().setValue(_html_script_code + _inithtmlcode);
}
});
});
$(‘#libs’).on(‘hidden.bs.modal’, function () {
讯享网$("#sel1 option:first-child").attr('selected', true); $("#sel1 option:last-child").attr('selected', false); $("#libs-table tr").removeClass("success");
})
$(“#filter”).keyup(function() {
_search_value = $(this).val();
//https://api.staticfile.net/libraries
//https://api.cdnjs.com/libraries
$.get('https://api.staticfile.net/libraries',{search:_search_value,fields:"homepage"},function(data) {
var _val_tr ='';
$("#fa-spinner").show();
$.each(data.results, function(i, item) {
if(i < 10) {
_val_tr += '<tr><td>'+item.name+' </td><td>'+item.latest+'</td><td> </td></tr>';
} else {
return false;
};
});
if(_val_tr) {
$("#libs-table").html('<tr><th>库名</th><th>地址</th><th>插入</th></tr>' + _val_tr);
}
$("#fa-spinner").hide();
});
}); $( document ).ajaxComplete(function() {
讯享网$("tr").not(':first').hover(
function () {
if(!$(this).hasClass("success")) {
$(this).addClass("warning");
}
},
function () {
$(this).removeClass("warning");
}
);
$("tr").not(':first').click(function() {
if(!$(this).hasClass("success")) {
_editor_content = html_editor.getValue();
$(this).addClass("success")
$(this).removeClass("warning");
_libsrc = $(this).find("td").eq(1).text();
if(_editor_content.indexOf(_libsrc) !== -1 ) {
return;
}
if( _libsrc.indexOf('.js')!==-1 ){
_libsrc = '
’;
} else if(_libsrc.indexOf('.css')!==-1) { _libsrc = '<link rel="stylesheet" href="https://c.runoob.com/front-end/61/'+_libsrc+'">
’;
讯享网 } patternBody = /<body[^>]*>((.|[
])*)/im;
array_matches_body = patternBody.exec(_editor_content); patternHead = /<head[^>]*>((.|[
])*)/im;

讯享网 array_matches_head = patternHead.exec(_editor_content);
if(array_matches_head) {
_editor_content = _editor_content.replace('</head>', _libsrc + '</head>');
} else if(array_matches_body) {
_editor_content = _editor_content.replace('</body>', _libsrc + '</body>');
} 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 = /<html([^>]*)>/im;
var array_matches_html_tag = patternHtmlTag.exec(src);
if (array_matches_html_tag) {
src = src.replace('<html>', '<html ' + array_matches_html_tag[1] + '>');
}
var patternHead = /<head[^>]*>((.|[
])*)/im
var array_matches_head = patternHead.exec(src); var patternBodyTag = /<body([^>]*)>/im; var array_matches_body_tag = patternBodyTag.exec(src); if (array_matches_body_tag) { src = src.replace('<body>', '<body ' + array_matches_body_tag[1] + '>'); } } //console.log(css); if (css.indexOf('
’;
讯享网 if (array_matches_head) { src = src.replace('</head>', css + '</head>'); } else if (array_matches_body_tag) { src = src.replace('</body>', css + '</body>'); } else { src += css; } } // Javascript if(js) { js = '
’;
if (array_matches_body_tag) { src = src.replace('</body>', js + '</body>'); }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";
}

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容,请联系我们,一经查实,本站将立刻删除。
如需转载请保留出处:https://51itzy.com/kjqy/199103.html