Commit d5c41f5a authored by Van's avatar Van

🐛 #12743

parent d354f85e
...@@ -79,7 +79,7 @@ function miniAdmin () { ...@@ -79,7 +79,7 @@ function miniAdmin () {
'./src/main/webapp/js/admin/others.js', './src/main/webapp/js/admin/others.js',
'./src/main/webapp/js/admin/linkList.js', './src/main/webapp/js/admin/linkList.js',
'./src/main/webapp/js/admin/preference.js', './src/main/webapp/js/admin/preference.js',
'./src/main/webapp/js/admin/theme-list.js', './src/main/webapp/js/admin/themeList.js',
'./src/main/webapp/js/admin/pluginList.js', './src/main/webapp/js/admin/pluginList.js',
'./src/main/webapp/js/admin/userList.js', './src/main/webapp/js/admin/userList.js',
'./src/main/webapp/js/admin/categoryList.js', './src/main/webapp/js/admin/categoryList.js',
......
...@@ -233,7 +233,7 @@ $.extend(Admin.prototype, { ...@@ -233,7 +233,7 @@ $.extend(Admin.prototype, {
}, 6000) }, 6000)
$('#loadMsg').text('') $('#loadMsg').text('')
window.onbeforeunload = (event) => { window.onbeforeunload = function (event) {
if (window.location.hash === '#article/article') { if (window.location.hash === '#article/article') {
if (event) { if (event) {
event.returnValue = Label.editorLeaveLabel event.returnValue = Label.editorLeaveLabel
...@@ -244,7 +244,7 @@ $.extend(Admin.prototype, { ...@@ -244,7 +244,7 @@ $.extend(Admin.prototype, {
$(document).ajaxError(function (event, xhr, options, exc) { $(document).ajaxError(function (event, xhr, options, exc) {
if (xhr.status !== 200) { if (xhr.status !== 200) {
$('#tipMsg').text(xhr.status + ': '+ exc) $('#tipMsg').text(xhr.status + ': ' + exc)
} }
}) })
}, },
......
var Util={isArticlePage:function(e){var t=!0;return-1<e.indexOf(Label.servePath+"/tags/")&&(t=!1),-1<e.indexOf(Label.servePath+"/tags.html")&&(t=!1),-1<e.indexOf(Label.servePath+"/category/")&&(t=!1),-1<e.indexOf(Label.servePath+"/archives.html")&&(t=!1),-1<e.indexOf(Label.servePath+"/archives/")&&(t=!1),-1<e.indexOf(Label.servePath+"/links.html")&&(t=!1),e===Label.servePath&&(t=!1),/^[0-9]*$/.test(e.replace(Label.servePath+"/",""))&&(t=!1),t},initPjax:function(e){1===$("#pjax").length&&($.pjax({selector:"a",container:"#pjax",show:"",cache:!1,storage:!0,titleSuffix:"",filter:function(e){return e===Label.servePath+"/rss.xml"||-1<e.indexOf(Label.servePath+"/admin-index.do")||!(-1<e.indexOf(Label.servePath))},callback:function(){Util.parseMarkdown(),Util.parseLanguage(),e&&e()}}),NProgress.configure({showSpinner:!1}),$("#pjax").bind("pjax.start",function(){NProgress.start()}),$("#pjax").bind("pjax.end",function(){window.scroll(window.scrollX,0),NProgress.done()}))},previewImg:function(){$("body").on("click",".vditor-reset img",function(){$(this).hasClass("prevent")||window.open(this.src)})},addStyle:function(e,t){if(!document.getElementById(t)){var i=document.createElement("link");i.id=t,i.setAttribute("rel","stylesheet"),i.setAttribute("type","text/css"),i.setAttribute("href",e),document.getElementsByTagName("head")[0].appendChild(i)}},addScript:function(e,t){if(!document.getElementById(t)){var i=new XMLHttpRequest;i.open("GET",e,!1),i.setRequestHeader("Accept","text/javascript, application/javascript, application/ecmascript, application/x-ecmascript, */*; q=0.01"),i.send("");var n=document.createElement("script");n.id=t,n.type="text/javascript",n.text=i.responseText,document.getElementsByTagName("head")[0].appendChild(n)}},parseLanguage:function(){if(0!==$(".vditor-reset pre > code").length){Util.addStyle("https://cdn.jsdelivr.net/npm/highlight.js@9.15.6/styles/"+Label.hljsStyle+".min.css","vditorHljsStyle");var e=function(){hljs.initHighlighting.called=!1,hljs.initHighlighting(),$("pre > code").addClass("hljs")};Label.markedAvailable||("undefined"==typeof hljs?$.ajax({url:"https://cdn.jsdelivr.net/npm/vditor@1.2.5/src/assets/js/highlight.pack.js",dataType:"script",cache:!0,success:function(){e()}}):e())}},parseMarkdown:function(){var e=$(".vditor-reset").text();(0!==$(".vditor-reset pre > code").length||2<e.split("$").length||1<e.split("\\(").length&&1<e.split("\\)").length)&&(Util.addScript("https://cdn.jsdelivr.net/npm/vditor@1.2.5/dist/index.min.js","vditorScript"),Vditor.mermaidRender(document.body),Vditor.mathRender(document.body),Vditor.codeRender(document.body,Label.langLabel))},killIE:function(e){var t=navigator.userAgent.split("MSIE")[1];t&&(e||(e=7),parseFloat(t.split(";"))<=e&&function(){if(""===Cookie.readCookie("showKill"))try{var t="<div style='display: block; height: 100%; width: 100%; position: fixed; background-color: rgb(0, 0, 0); opacity: 0.6;filter: alpha(opacity=60); top: 0px;z-index:110'></div><iframe style='left:"+($(window).width()-781)/2+"px;z-index:120;top: "+($(window).height()-680)/2+"px; position: fixed; border: 0px none; width: 781px; height: 680px;' src='"+Label.servePath+"/kill-browser'></iframe>";$("body").append(t)}catch(e){t="<div style='display: block; height: 100%; width: 100%; position: fixed; background-color: rgb(0, 0, 0); opacity: 0.6;filter: alpha(opacity=60); top: 0px;z-index:110'></div><iframe style='left:10px;z-index:120;top: 0px; position: fixed; border: 0px none; width: 781px; height: 680px;' src='"+Label.servePath+"/kill-browser'></iframe>",document.body.innerHTML=document.body.innerHTML+t}}())},replaceEmString:function(e){var t=e.split("[em");if(1===t.length)return e;e=t[0];for(var i=1;i<t.length;i++){var n=t[i].substr(0,2);e+="<img width='20' src='"+Label.staticServePath+"/images/emotions/em"+n+".png' alt='"+Label["em"+n+"Label"]+"' title='"+Label["em"+n+"Label"]+"'/> "+t[i].substr(3)}return e},switchMobile:function(e){Cookie.createCookie("btouch_switch_toggle",e,365),setTimeout(function(){location.reload()},1250)},setTopBar:function(){var e=$("#top");if(1===e.length){var t=$("#showTop");t.click(function(){e.slideDown(),t.hide()}),$("#hideTop").click(function(){e.slideUp(),t.show()})}},goTop:function(){$("html, body").animate({scrollTop:0},800)},goBottom:function(e){e||(e=0),$("html, body").animate({scrollTop:$(document).height()-$(window).height()-e},800)},init:function(){Util.killIE(),Util.parseMarkdown(),Util.parseLanguage(),Util.initSW(),Util.previewImg(),Util.initDebugInfo()},initDebugInfo:function(){console.log("%cSolo%c\n 🎸一款小而美的博客系统,专为程序员设计。"+Label.version+" © "+(new Date).getFullYear(),"font-size:96px;color:#3b3e43","font-size:12px;color:rgba(0,0,0,0.38);")},initSW:function(){navigator.serviceWorker&&navigator.serviceWorker.register("/sw.js",{scope:"/"})},replaceSideEm:function(e){for(var t=0;t<e.length;t++){var i=$(e[t]);i.html(Util.replaceEmString(i.html()))}},buildTags:function(e){e=e||"tags";for(var t=["tags1","tags2","tags3","tags4","tags5"],i=$("#"+e+" b").get(),n=parseInt($("#"+e+" b").last().text()),o=Math.ceil(n/t.length),a=0;a<i.length;a++)for(var r=parseInt(i[a].innerHTML),s=0;s<t.length;s++)if(s*o<r&&r<=(s+1)*o){i[a].parentNode.className=t[s];break}$("#"+e).html($("#"+e+" li").get().sort(function(e,t){var i=$(e).find("span").text().toLowerCase(),n=$(t).find("span").text().toLowerCase();return i.localeCompare(n)}))},toDate:function(e,t){var i=new Date(e),n={"M+":i.getMonth()+1,"d+":i.getDate(),"H+":i.getHours(),"m+":i.getMinutes(),"s+":i.getSeconds(),"q+":Math.floor((i.getMonth()+3)/3),S:i.getMilliseconds()};for(var o in/(y+)/.test(t)&&(t=t.replace(RegExp.$1,(i.getFullYear()+"").substr(4-RegExp.$1.length))),n)new RegExp("("+o+")").test(t)&&(t=t.replace(RegExp.$1,1==RegExp.$1.length?n[o]:("00"+n[o]).substr((""+n[o]).length)));return t}};if(!Cookie)var Cookie={readCookie:function(e){for(var t=e+"=",i=document.cookie.split(";"),n=0;n<i.length;n++){for(var o=i[n];" "==o.charAt(0);)o=o.substring(1,o.length);if(0==o.indexOf(t))return decodeURIComponent(o.substring(t.length,o.length))}return""},eraseCookie:function(e){this.createCookie(e,"",-1)},createCookie:function(e,t,i){var n="";if(i){var o=new Date;o.setTime(o.getTime()+24*i*60*60*1e3),n="; expires="+o.toGMTString()}document.cookie=e+"="+encodeURIComponent(t)+n+"; path=/"}}; var Util={isArticlePage:function(e){var t=!0;return-1<e.indexOf(Label.servePath+"/tags/")&&(t=!1),-1<e.indexOf(Label.servePath+"/tags.html")&&(t=!1),-1<e.indexOf(Label.servePath+"/category/")&&(t=!1),-1<e.indexOf(Label.servePath+"/archives.html")&&(t=!1),-1<e.indexOf(Label.servePath+"/archives/")&&(t=!1),-1<e.indexOf(Label.servePath+"/links.html")&&(t=!1),e===Label.servePath&&(t=!1),/^[0-9]*$/.test(e.replace(Label.servePath+"/",""))&&(t=!1),t},initPjax:function(e){1===$("#pjax").length&&($.pjax({selector:"a",container:"#pjax",show:"",cache:!1,storage:!0,titleSuffix:"",filter:function(e){return e===Label.servePath+"/rss.xml"||-1<e.indexOf(Label.servePath+"/admin-index.do")||!(-1<e.indexOf(Label.servePath))},callback:function(){Util.parseMarkdown(),Util.parseLanguage(),e&&e()}}),NProgress.configure({showSpinner:!1}),$("#pjax").bind("pjax.start",function(){NProgress.start()}),$("#pjax").bind("pjax.end",function(){window.scroll(window.scrollX,0),NProgress.done()}))},previewImg:function(){$("body").on("click",".vditor-reset img",function(){$(this).hasClass("prevent")||window.open(this.src)})},addStyle:function(e,t){if(!document.getElementById(t)){var i=document.createElement("link");i.id=t,i.setAttribute("rel","stylesheet"),i.setAttribute("type","text/css"),i.setAttribute("href",e),document.getElementsByTagName("head")[0].appendChild(i)}},addScript:function(e,t){if(!document.getElementById(t)){var i=new XMLHttpRequest;i.open("GET",e,!1),i.setRequestHeader("Accept","text/javascript, application/javascript, application/ecmascript, application/x-ecmascript, */*; q=0.01"),i.send("");var n=document.createElement("script");n.id=t,n.type="text/javascript",n.text=i.responseText,document.getElementsByTagName("head")[0].appendChild(n)}},parseLanguage:function(){if(0!==$(".vditor-reset pre > code").length){Util.addStyle("https://cdn.jsdelivr.net/npm/highlight.js@9.15.6/styles/"+Label.hljsStyle+".min.css","vditorHljsStyle");var e=function(){hljs.initHighlighting.called=!1,hljs.initHighlighting()};Label.markedAvailable||("undefined"==typeof hljs?$.ajax({url:"https://cdn.jsdelivr.net/npm/vditor@1.2.5/src/assets/js/highlight.pack.js",dataType:"script",cache:!0,success:function(){e()}}):e())}},parseMarkdown:function(){var e=$(".vditor-reset").text();(0!==$(".vditor-reset pre > code").length||2<e.split("$").length||1<e.split("\\(").length&&1<e.split("\\)").length)&&(Util.addScript("https://cdn.jsdelivr.net/npm/vditor@1.2.5/dist/index.min.js","vditorScript"),Vditor.mermaidRender(document.body),Vditor.mathRender(document.body),Vditor.codeRender(document.body,Label.langLabel))},killIE:function(e){var t=navigator.userAgent.split("MSIE")[1];t&&(e||(e=7),parseFloat(t.split(";"))<=e&&function(){if(""===Cookie.readCookie("showKill"))try{var t="<div style='display: block; height: 100%; width: 100%; position: fixed; background-color: rgb(0, 0, 0); opacity: 0.6;filter: alpha(opacity=60); top: 0px;z-index:110'></div><iframe style='left:"+($(window).width()-781)/2+"px;z-index:120;top: "+($(window).height()-680)/2+"px; position: fixed; border: 0px none; width: 781px; height: 680px;' src='"+Label.servePath+"/kill-browser'></iframe>";$("body").append(t)}catch(e){t="<div style='display: block; height: 100%; width: 100%; position: fixed; background-color: rgb(0, 0, 0); opacity: 0.6;filter: alpha(opacity=60); top: 0px;z-index:110'></div><iframe style='left:10px;z-index:120;top: 0px; position: fixed; border: 0px none; width: 781px; height: 680px;' src='"+Label.servePath+"/kill-browser'></iframe>",document.body.innerHTML=document.body.innerHTML+t}}())},replaceEmString:function(e){var t=e.split("[em");if(1===t.length)return e;e=t[0];for(var i=1;i<t.length;i++){var n=t[i].substr(0,2);e+="<img width='20' src='"+Label.staticServePath+"/images/emotions/em"+n+".png' alt='"+Label["em"+n+"Label"]+"' title='"+Label["em"+n+"Label"]+"'/> "+t[i].substr(3)}return e},switchMobile:function(e){Cookie.createCookie("btouch_switch_toggle",e,365),setTimeout(function(){location.reload()},1250)},setTopBar:function(){var e=$("#top");if(1===e.length){var t=$("#showTop");t.click(function(){e.slideDown(),t.hide()}),$("#hideTop").click(function(){e.slideUp(),t.show()})}},goTop:function(){$("html, body").animate({scrollTop:0},800)},goBottom:function(e){e||(e=0),$("html, body").animate({scrollTop:$(document).height()-$(window).height()-e},800)},init:function(){Util.killIE(),Util.parseMarkdown(),Util.parseLanguage(),Util.initSW(),Util.previewImg(),Util.initDebugInfo()},initDebugInfo:function(){console.log("%cSolo%c\n 🎸一款小而美的博客系统,专为程序员设计。"+Label.version+" © "+(new Date).getFullYear(),"font-size:96px;color:#3b3e43","font-size:12px;color:rgba(0,0,0,0.38);")},initSW:function(){navigator.serviceWorker&&navigator.serviceWorker.register("/sw.js",{scope:"/"})},replaceSideEm:function(e){for(var t=0;t<e.length;t++){var i=$(e[t]);i.html(Util.replaceEmString(i.html()))}},buildTags:function(e){e=e||"tags";for(var t=["tags1","tags2","tags3","tags4","tags5"],i=$("#"+e+" b").get(),n=parseInt($("#"+e+" b").last().text()),o=Math.ceil(n/t.length),a=0;a<i.length;a++)for(var r=parseInt(i[a].innerHTML),s=0;s<t.length;s++)if(s*o<r&&r<=(s+1)*o){i[a].parentNode.className=t[s];break}$("#"+e).html($("#"+e+" li").get().sort(function(e,t){var i=$(e).find("span").text().toLowerCase(),n=$(t).find("span").text().toLowerCase();return i.localeCompare(n)}))},toDate:function(e,t){var i=new Date(e),n={"M+":i.getMonth()+1,"d+":i.getDate(),"H+":i.getHours(),"m+":i.getMinutes(),"s+":i.getSeconds(),"q+":Math.floor((i.getMonth()+3)/3),S:i.getMilliseconds()};for(var o in/(y+)/.test(t)&&(t=t.replace(RegExp.$1,(i.getFullYear()+"").substr(4-RegExp.$1.length))),n)new RegExp("("+o+")").test(t)&&(t=t.replace(RegExp.$1,1==RegExp.$1.length?n[o]:("00"+n[o]).substr((""+n[o]).length)));return t}};if(!Cookie)var Cookie={readCookie:function(e){for(var t=e+"=",i=document.cookie.split(";"),n=0;n<i.length;n++){for(var o=i[n];" "==o.charAt(0);)o=o.substring(1,o.length);if(0==o.indexOf(t))return decodeURIComponent(o.substring(t.length,o.length))}return""},eraseCookie:function(e){this.createCookie(e,"",-1)},createCookie:function(e,t,i){var n="";if(i){var o=new Date;o.setTime(o.getTime()+24*i*60*60*1e3),n="; expires="+o.toGMTString()}document.cookie=e+"="+encodeURIComponent(t)+n+"; path=/"}};
\ No newline at end of file \ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment