Commit ede792ea authored by Liang Ding's avatar Liang Ding

fixed #12516

parent 5b94de10
......@@ -238,22 +238,29 @@ var Util = {
killIE: function (ieVersion) {
var addKillPanel = function () {
if (Cookie.readCookie("showKill") === "") {
var left = ($(window).width() - 781) / 2,
top1 = ($(window).height() - 680) / 2;
$("body").append("<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:" + left + "px;z-index:120;top: " + top1 + "px; position: fixed; border: 0px none; width: 781px; height: 680px;' src='" + latkeConfig.servePath + "/kill-browser'></iframe>");
try {
var left = ($(window).width() - 781) / 2,
top1 = ($(window).height() - 680) / 2;
var killIEHTML = "<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:" + left + "px;z-index:120;top: " + top1 + "px; position: fixed; border: 0px none; width: 781px; height: 680px;' src='" + latkeConfig.servePath + "/kill-browser'></iframe>";
$("body").append(killIEHTML)
} catch (e) {
var left = 10,
top1 = 0;
var killIEHTML = "<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:" + left + "px;z-index:120;top: " + top1 + "px; position: fixed; border: 0px none; width: 781px; height: 680px;' src='" + latkeConfig.servePath + "/kill-browser'></iframe>";
document.body.innerHTML = document.body.innerHTML + killIEHTML
}
}
};
if ($.browser.msie) {
// kill IE6 and IE7
if ($.browser.version === "6.0" || $.browser.version === "7.0") {
addKillPanel();
var ua = navigator.userAgent.split('MSIE')[1]
if (ua) {
if (!ieVersion) {
ieVersion = 7
}
if (ieVersion) {
if (parseFloat($.browser.version) <= ieVersion){
addKillPanel();
}
if (parseFloat(ua.split(';')) <= ieVersion){
addKillPanel();
}
}
},
......
var Util={htmlDecode:function(code){var div=document.createElement("div");div.innerHTML=decodeURIComponent(code);return div.innerText},_isArticlePage:function(href){var isArticle=true;if(href.indexOf(latkeConfig.servePath+"/tags/")>-1){isArticle=false}if(href.indexOf(latkeConfig.servePath+"/tags.html")>-1){isArticle=false}if(href.indexOf(latkeConfig.servePath+"/category/")>-1){isArticle=false}if(href.indexOf(latkeConfig.servePath+"/archives.html")>-1){isArticle=false}if(href.indexOf(latkeConfig.servePath+"/archives/")>-1){isArticle=false}if(href.indexOf(latkeConfig.servePath+"/links.html")>-1){isArticle=false}if(href===latkeConfig.servePath){isArticle=false}if(/^[0-9]*$/.test(href.replace(latkeConfig.servePath+"/",""))){isArticle=false}return isArticle},initPjax:function(cb,articelCB){if($("#pjax").length===1){$.pjax({selector:"a",container:"#pjax",show:"",cache:false,storage:true,titleSuffix:"",filter:function(href){if(href.indexOf("data:image")>-1){return true}return Util._isArticlePage(href)},callback:function(){cb()}});NProgress.configure({showSpinner:false});$("#pjax").bind("pjax.start",function(){NProgress.start()});$("#pjax").bind("pjax.end",function(){NProgress.done()});return}if($("#pjaxArticle").length===1){$.pjax({selector:"a",container:"#pjaxArticle",show:"",cache:false,storage:true,titleSuffix:"",filter:function(href){if(href.indexOf("data:image")>-1){return true}return !Util._isArticlePage(href)},callback:function(){articelCB()}});NProgress.configure({showSpinner:false});$("#pjaxArticle").bind("pjax.start",function(){NProgress.start()});$("#pjaxArticle").bind("pjax.end",function(){NProgress.done()});return}},parseMarkdown:function(className){var hasMathJax=false;var hasFlow=false;var className=className||"article-body";$("."+className).each(function(){$(this).find("p").each(function(){if($(this).text().split("$").length>2||($(this).text().split("\\(").length>1&&$(this).text().split("\\)").length>1)){hasMathJax=true;return false}});if($(this).find("code.lang-flow, code.language-flow").length>0){hasFlow=true;return false}});if(hasMathJax){var initMathJax=function(){MathJax.Hub.Config({tex2jax:{inlineMath:[["$","$"],["\\(","\\)"]],displayMath:[["$$","$$"]],processEscapes:true,processEnvironments:true,skipTags:["pre","code","script"]}});MathJax.Hub.Typeset()};if(typeof MathJax!=="undefined"){initMathJax()}else{$.ajax({method:"GET",url:"https://cdn.staticfile.org/MathJax/MathJax-2.6-latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML&_=1473258780393",dataType:"script",cache:true}).done(function(){initMathJax()})}}if(hasFlow){var initFlow=function(){$("."+className+" code.lang-flow, ."+className+" code.language-flow").each(function(index){var $it=$(this);var id="symFlow"+(new Date()).getTime()+index;$it.hide();var diagram=flowchart.parse($.trim($it.text()));$it.parent().after('<div style="text-align: center" id="'+id+'"></div>');diagram.drawSVG(id);$it.parent().remove();$("#"+id).find("svg").height("auto").width("auto")})};if(typeof(flowchart)!=="undefined"){initFlow()}else{$.ajax({method:"GET",url:latkeConfig.staticServePath+"/js/lib/flowchart/flowchart.min.js",dataType:"script",cache:true}).done(function(){initFlow()})}}},isLoggedIn:function(){if(($("#admin").length===1&&$("#admin").data("login"))||latkeConfig.isLoggedIn==="true"){return true}else{return false}},getUserName:function(){if($("#adminName").length===1){return $("#adminName").text()}else{return latkeConfig.userName}},error:function(){$("#tipMsg").text("Error: "+arguments[0]+" File: "+arguments[1]+"\nLine: "+arguments[2]+" please report this issue on https://github.com/b3log/solo/issues/new");$("#loadMsg").text("")},killIE:function(ieVersion){var addKillPanel=function(){if(Cookie.readCookie("showKill")===""){var left=($(window).width()-781)/2,top1=($(window).height()-680)/2;$("body").append("<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:"+left+"px;z-index:120;top: "+top1+"px; position: fixed; border: 0px none; width: 781px; height: 680px;' src='"+latkeConfig.servePath+"/kill-browser'></iframe>")}};if($.browser.msie){if($.browser.version==="6.0"||$.browser.version==="7.0"){addKillPanel()}if(ieVersion){if(parseFloat($.browser.version)<=ieVersion){addKillPanel()}}}},replaceEmString:function(str){var commentSplited=str.split("[em");if(commentSplited.length===1){return str}str=commentSplited[0];for(var j=1;j<commentSplited.length;j++){var key=commentSplited[j].substr(0,2);str+="<img width='20' src='"+latkeConfig.staticServePath+"/images/emotions/em"+key+".png' alt='"+Label["em"+key+"Label"]+"' title='"+Label["em"+key+"Label"]+"'/> "+commentSplited[j].substr(3)}return str},proessURL:function(url){if(!/^\w+:\/\//.test(url)){url="http://"+url}return url},switchMobile:function(skin){Cookie.createCookie("btouch_switch_toggle",skin,365);setTimeout(function(){location.reload()},1250)},setTopBar:function(){var $top=$("#top");if($top.length===1){var $showTop=$("#showTop");$showTop.click(function(){$top.slideDown();$showTop.hide()});$("#hideTop").click(function(){$top.slideUp();$showTop.show()})}},goTop:function(){$("html, body").animate({scrollTop:0},800)},goBottom:function(bottom){if(!bottom){bottom=0}var wHeight=$("body").height()>$(document).height()?$("body").height():$(document).height();window.scrollTo(0,wHeight-$(window).height()-bottom)},init:function(){Util.killIE();Util.setTopBar();Util.parseMarkdown()},replaceSideEm:function(comments){for(var i=0;i<comments.length;i++){var $comment=$(comments[i]);$comment.html(Util.replaceEmString($comment.html()))}},buildTags:function(id){id=id||"tags";var classes=["tags1","tags2","tags3","tags4","tags5"],bList=$("#"+id+" b").get();var max=parseInt($("#"+id+" b").last().text());var distance=Math.ceil(max/classes.length);for(var i=0;i<bList.length;i++){var num=parseInt(bList[i].innerHTML);for(var j=0;j<classes.length;j++){if(num>j*distance&&num<=(j+1)*distance){bList[i].parentNode.className=classes[j];break}}}$("#"+id).html($("#"+id+" li").get().sort(function(a,b){var valA=$(a).find("span").text().toLowerCase();var valB=$(b).find("span").text().toLowerCase();return valA.localeCompare(valB)}))},toDate:function(time,format){var dateTime=new Date(time);var o={"M+":dateTime.getMonth()+1,"d+":dateTime.getDate(),"H+":dateTime.getHours(),"m+":dateTime.getMinutes(),"s+":dateTime.getSeconds(),"q+":Math.floor((dateTime.getMonth()+3)/3),S:dateTime.getMilliseconds()};if(/(y+)/.test(format)){format=format.replace(RegExp.$1,(dateTime.getFullYear()+"").substr(4-RegExp.$1.length))}for(var k in o){if(new RegExp("("+k+")").test(format)){format=format.replace(RegExp.$1,RegExp.$1.length==1?o[k]:("00"+o[k]).substr((""+o[k]).length))}}return format},getWinHeight:function(){if(window.innerHeight){return window.innerHeight}if(document.compatMode==="CSS1Compat"){return window.document.documentElement.clientHeight}return window.document.body.clientHeight}};if(!Cookie){var Cookie={readCookie:function(name){var nameEQ=name+"=";var ca=document.cookie.split(";");for(var i=0;i<ca.length;i++){var c=ca[i];while(c.charAt(0)==" "){c=c.substring(1,c.length)}if(c.indexOf(nameEQ)==0){return decodeURIComponent(c.substring(nameEQ.length,c.length))}}return""},eraseCookie:function(name){this.createCookie(name,"",-1)},createCookie:function(name,value,days){var expires="";if(days){var date=new Date();date.setTime(date.getTime()+(days*24*60*60*1000));expires="; expires="+date.toGMTString()}document.cookie=name+"="+encodeURIComponent(value)+expires+"; path=/"}}};
\ No newline at end of file
var Util={htmlDecode:function(code){var div=document.createElement("div");div.innerHTML=decodeURIComponent(code);return div.innerText},_isArticlePage:function(href){var isArticle=true;if(href.indexOf(latkeConfig.servePath+"/tags/")>-1){isArticle=false}if(href.indexOf(latkeConfig.servePath+"/tags.html")>-1){isArticle=false}if(href.indexOf(latkeConfig.servePath+"/category/")>-1){isArticle=false}if(href.indexOf(latkeConfig.servePath+"/archives.html")>-1){isArticle=false}if(href.indexOf(latkeConfig.servePath+"/archives/")>-1){isArticle=false}if(href.indexOf(latkeConfig.servePath+"/links.html")>-1){isArticle=false}if(href===latkeConfig.servePath){isArticle=false}if(/^[0-9]*$/.test(href.replace(latkeConfig.servePath+"/",""))){isArticle=false}return isArticle},initPjax:function(cb,articelCB){if($("#pjax").length===1){$.pjax({selector:"a",container:"#pjax",show:"",cache:false,storage:true,titleSuffix:"",filter:function(href){if(href.indexOf("data:image")>-1){return true}return Util._isArticlePage(href)},callback:function(){cb()}});NProgress.configure({showSpinner:false});$("#pjax").bind("pjax.start",function(){NProgress.start()});$("#pjax").bind("pjax.end",function(){NProgress.done()});return}if($("#pjaxArticle").length===1){$.pjax({selector:"a",container:"#pjaxArticle",show:"",cache:false,storage:true,titleSuffix:"",filter:function(href){if(href.indexOf("data:image")>-1){return true}return !Util._isArticlePage(href)},callback:function(){articelCB()}});NProgress.configure({showSpinner:false});$("#pjaxArticle").bind("pjax.start",function(){NProgress.start()});$("#pjaxArticle").bind("pjax.end",function(){NProgress.done()});return}},parseMarkdown:function(className){var hasMathJax=false;var hasFlow=false;var className=className||"article-body";$("."+className).each(function(){$(this).find("p").each(function(){if($(this).text().split("$").length>2||($(this).text().split("\\(").length>1&&$(this).text().split("\\)").length>1)){hasMathJax=true;return false}});if($(this).find("code.lang-flow, code.language-flow").length>0){hasFlow=true;return false}});if(hasMathJax){var initMathJax=function(){MathJax.Hub.Config({tex2jax:{inlineMath:[["$","$"],["\\(","\\)"]],displayMath:[["$$","$$"]],processEscapes:true,processEnvironments:true,skipTags:["pre","code","script"]}});MathJax.Hub.Typeset()};if(typeof MathJax!=="undefined"){initMathJax()}else{$.ajax({method:"GET",url:"https://cdn.staticfile.org/MathJax/MathJax-2.6-latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML&_=1473258780393",dataType:"script",cache:true}).done(function(){initMathJax()})}}if(hasFlow){var initFlow=function(){$("."+className+" code.lang-flow, ."+className+" code.language-flow").each(function(index){var $it=$(this);var id="symFlow"+(new Date()).getTime()+index;$it.hide();var diagram=flowchart.parse($.trim($it.text()));$it.parent().after('<div style="text-align: center" id="'+id+'"></div>');diagram.drawSVG(id);$it.parent().remove();$("#"+id).find("svg").height("auto").width("auto")})};if(typeof(flowchart)!=="undefined"){initFlow()}else{$.ajax({method:"GET",url:latkeConfig.staticServePath+"/js/lib/flowchart/flowchart.min.js",dataType:"script",cache:true}).done(function(){initFlow()})}}},isLoggedIn:function(){if(($("#admin").length===1&&$("#admin").data("login"))||latkeConfig.isLoggedIn==="true"){return true}else{return false}},getUserName:function(){if($("#adminName").length===1){return $("#adminName").text()}else{return latkeConfig.userName}},error:function(){$("#tipMsg").text("Error: "+arguments[0]+" File: "+arguments[1]+"\nLine: "+arguments[2]+" please report this issue on https://github.com/b3log/solo/issues/new");$("#loadMsg").text("")},killIE:function(ieVersion){var addKillPanel=function(){if(Cookie.readCookie("showKill")===""){try{var left=($(window).width()-781)/2,top1=($(window).height()-680)/2;var killIEHTML="<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:"+left+"px;z-index:120;top: "+top1+"px; position: fixed; border: 0px none; width: 781px; height: 680px;' src='"+latkeConfig.servePath+"/kill-browser'></iframe>";$("body").append(killIEHTML)}catch(e){var left=10,top1=0;var killIEHTML="<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:"+left+"px;z-index:120;top: "+top1+"px; position: fixed; border: 0px none; width: 781px; height: 680px;' src='"+latkeConfig.servePath+"/kill-browser'></iframe>";document.body.innerHTML=document.body.innerHTML+killIEHTML}}};var ua=navigator.userAgent.split("MSIE")[1];if(ua){if(!ieVersion){ieVersion=7}if(parseFloat(ua.split(";"))<=ieVersion){addKillPanel()}}},replaceEmString:function(str){var commentSplited=str.split("[em");if(commentSplited.length===1){return str}str=commentSplited[0];for(var j=1;j<commentSplited.length;j++){var key=commentSplited[j].substr(0,2);str+="<img width='20' src='"+latkeConfig.staticServePath+"/images/emotions/em"+key+".png' alt='"+Label["em"+key+"Label"]+"' title='"+Label["em"+key+"Label"]+"'/> "+commentSplited[j].substr(3)}return str},proessURL:function(url){if(!/^\w+:\/\//.test(url)){url="http://"+url}return url},switchMobile:function(skin){Cookie.createCookie("btouch_switch_toggle",skin,365);setTimeout(function(){location.reload()},1250)},setTopBar:function(){var $top=$("#top");if($top.length===1){var $showTop=$("#showTop");$showTop.click(function(){$top.slideDown();$showTop.hide()});$("#hideTop").click(function(){$top.slideUp();$showTop.show()})}},goTop:function(){$("html, body").animate({scrollTop:0},800)},goBottom:function(bottom){if(!bottom){bottom=0}var wHeight=$("body").height()>$(document).height()?$("body").height():$(document).height();window.scrollTo(0,wHeight-$(window).height()-bottom)},init:function(){Util.killIE();Util.setTopBar();Util.parseMarkdown()},replaceSideEm:function(comments){for(var i=0;i<comments.length;i++){var $comment=$(comments[i]);$comment.html(Util.replaceEmString($comment.html()))}},buildTags:function(id){id=id||"tags";var classes=["tags1","tags2","tags3","tags4","tags5"],bList=$("#"+id+" b").get();var max=parseInt($("#"+id+" b").last().text());var distance=Math.ceil(max/classes.length);for(var i=0;i<bList.length;i++){var num=parseInt(bList[i].innerHTML);for(var j=0;j<classes.length;j++){if(num>j*distance&&num<=(j+1)*distance){bList[i].parentNode.className=classes[j];break}}}$("#"+id).html($("#"+id+" li").get().sort(function(a,b){var valA=$(a).find("span").text().toLowerCase();var valB=$(b).find("span").text().toLowerCase();return valA.localeCompare(valB)}))},toDate:function(time,format){var dateTime=new Date(time);var o={"M+":dateTime.getMonth()+1,"d+":dateTime.getDate(),"H+":dateTime.getHours(),"m+":dateTime.getMinutes(),"s+":dateTime.getSeconds(),"q+":Math.floor((dateTime.getMonth()+3)/3),S:dateTime.getMilliseconds()};if(/(y+)/.test(format)){format=format.replace(RegExp.$1,(dateTime.getFullYear()+"").substr(4-RegExp.$1.length))}for(var k in o){if(new RegExp("("+k+")").test(format)){format=format.replace(RegExp.$1,RegExp.$1.length==1?o[k]:("00"+o[k]).substr((""+o[k]).length))}}return format},getWinHeight:function(){if(window.innerHeight){return window.innerHeight}if(document.compatMode==="CSS1Compat"){return window.document.documentElement.clientHeight}return window.document.body.clientHeight}};if(!Cookie){var Cookie={readCookie:function(name){var nameEQ=name+"=";var ca=document.cookie.split(";");for(var i=0;i<ca.length;i++){var c=ca[i];while(c.charAt(0)==" "){c=c.substring(1,c.length)}if(c.indexOf(nameEQ)==0){return decodeURIComponent(c.substring(nameEQ.length,c.length))}}return""},eraseCookie:function(name){this.createCookie(name,"",-1)},createCookie:function(name,value,days){var expires="";if(days){var date=new Date();date.setTime(date.getTime()+(days*24*60*60*1000));expires="; expires="+date.toGMTString()}document.cookie=name+"="+encodeURIComponent(value)+expires+"; path=/"}}};
\ 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