1 Star 0 Fork 6

dengkuanchina/blog

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
new_preview.html 1.58 KB
一键复制 编辑 原始数据 按行查看 历史
梦海澜心 提交于 2017-12-10 11:42 +08:00 . M1
<html>
<head>
<meta charset="utf-8">
<meta name="_csrf" th:content="${_csrf.token}" />
<meta name="_csrf_header" th:content="${_csrf.headerName}" />
<style>
body {
margin: 0;
padding: 0;
word-wrap: break-word;
}
</style>
</head>
<body>
<div id="article-content">
<div id="preview" ></div>
</div>
<script type="text/javascript" th:src="@{/static/jquery/jquery.min.js}"></script>
<script type="text/javascript" th:src="@{/static/prettify/prettify.js}"></script>
<script type="text/javascript">
$(function(){
$("#preview").on("click","a",function(e){
e.preventDefault();
});
});
function renderCode(){
var p = false;
$("pre").each(function(){
var me = $(this);
if(me.hasClass('prettyprint prettyprinted'))
return true;
if(me.find('code').length == 0)
return true;
else{
p = true;
me.addClass("prettyprint");
}
});
if(p)
prettyPrint();
}
function setPreview(preview){
$("#preview").html(preview);
renderCode();
}
function setStyle(style){
//清除所有样式
$("head").find('link[type="text/css"]').remove();
$("head").find('style').remove();
var csses = style.csses.split('\n');
if(csses.length > 0){
for(var i=0;i<csses.length;i++){
var css = $.trim(csses[i]);
$("head").append($("<link rel='stylesheet' href='"+css+"' type='text/css' media='screen' />"));
}
}
if($.trim(style.styles) != ""){
$('head').append('<style>'+style.styles+'</style>')
}
$("#article-content").removeClass();
if(style.preview != "" ){
$("#article-content").addClass(style.preview);
}
}
</script>
</body>
</html>
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/dengkuanchina/blog.git
git@gitee.com:dengkuanchina/blog.git
dengkuanchina
blog
blog
v6.3

搜索帮助