/* * Solo - A small and beautiful blogging system written in Java. * Copyright (c) 2010-2019, b3log.org & hacpai.com * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ var Page=function(e){this.currentCommentId="",this.tips=e};$.extend(Page.prototype,{insertEmotions:function(r){var l=this;void 0===r&&(r=""),$("#emotions"+r+" span").click(function(){var e=$("#comment"+r),t=l._getCursorEndPosition(e[0]),a=this.title+" ",s=e[0].value;if(s=s.substring(0,t)+a+s.substring(t,s.length),$("#comment"+r).val(s),$.browser.msie){t-=s.split("\n").length-1;var i=e[0].createTextRange();i.collapse(!0),i.moveStart("character",t+a.length),i.select()}else e[0].setSelectionRange(t+a.length,t+a.length)})},_getCursorEndPosition:function(e){if(e.focus(),e.setSelectionRange)return e.selectionEnd;if(document.selection){var t=0,a=document.selection.createRange(),s=document.body.createTextRange();for(s.moveToElementText(e),a.getBookmark(),t=0;s.compareEndPoints("StartToStart",a)<0&&0!==a.moveStart("character",-1);t++)"\n"===e.value.charAt(t)&&t++;return t}},validateComment:function(e){if("true"===latkeConfig.isLoggedIn)return!((a=$("#comment"+e).val().replace(/(^\s*)|(\s*$)/g,"")).length<2||500")),$.ajax({url:latkeConfig.staticServePath+"/js/lib/SyntaxHighlighter/scripts/shCore.js",dataType:"script",cache:!0,success:function(){var a=[],s=!1;$(".article-body pre, .code-highlight pre").each(function(){var e=this.className.split(";")[0],t=e.substr(7,e.length-1);-1")),$.ajax({url:latkeConfig.staticServePath+"/js/lib/google-code-prettify/prettify.js",dataType:"script",cache:!0,success:function(){prettyPrint()}}),!1):(document.createStyleSheet?document.createStyleSheet(latkeConfig.staticServePath+"/js/lib/highlight.js-9.6.0/styles/default.css"):$("head").append($("")),void $.ajax({url:latkeConfig.staticServePath+"/js/lib/highlight.js-9.6.0/highlight.pack.js",dataType:"script",cache:!0,success:function(){hljs.initHighlighting.called=!1,hljs.initHighlighting()}}))},load:function(e){var t=this;t.insertEmotions(),t.parseLanguage(e&&e.language?e.language:void 0),$("#commentValidate").keypress(function(e){13===e.keyCode&&t.submitComment()}),$("#comment").keypress(function(e){13===e.keyCode&&e.ctrlKey&&t.submitComment()}),$("#captcha").click(function(){$(this).attr("src",latkeConfig.servePath+"/captcha.do?code="+Math.random())}),"true"!==latkeConfig.isLoggedIn&&($("#commentEmail").val(Cookie.readCookie("commentEmail")),$("#commentURL").val(Cookie.readCookie("commentURL")),$("#commentName").val(Cookie.readCookie("commentName")));try{JSON}catch(e){document.write('