text: function monitor_system_status(){$.ajax({type:"get",dataType:"json",url:"/api/systemstatus",success:function(e,t){if(0==e.errorcode){var e=e.data;$(".cpu-per").html(e.cpu_per+"%"),$(".ram-per").html(e.ram_per+"%"),$(".net-conn").html(e.net_conn),$(".os-start").html(e.os_start)}}}),setTimeout(monitor_system_status,6e4)}function change_theme(){$(".color").on("click",function(e){var t=$(e.target).attr("color");$.cookie("theme",t,{expires:30}),$.ajax({type:"post",dataType:"json",url:"/useropt",data:JSON.stringify({opt:"update-theme",data:{theme:t}}),success:function(e,t){0==e.errorcode?$.notify("主题保存成功"):e.errorcode==-3&&$("#loginModal").modal("toggle")}}),$("#theme").attr("href","/assets/css/index."+t+".css")})}function set_theme(){var e=$.cookie("theme");e&&$("#theme").attr("href","/assets/css/index."+e+".css")}function change_image_preview(){$inputFileElm=$(this);var e=document.getElementById("avatar-cropper"),t=document.getElementById("avatar-file"),a=t.value.substring(t.value.lastIndexOf(".")+1).toLowerCase();if("png"!=a&&"jpg"!=a&&"jpeg"!=a)return void alert("文件必须为图片！");if(t.size>3072e3)return void alert("上传图片不要超过3000KB");if(document.all){t.select();var o=document.selection.createRange().text,n=/msie 6/i.test(navigator.userAgent);n?e.src=o:(e.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod='image',src=\""+o+'")',e.src="data:image/gif;base64,R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==")}else{var r=t.files[0],i=new FileReader;i.readAsDataURL(r),i.onload=function(t){e.src=t.target.result,$(e).cropper("reset").cropper("replace",t.target.result)}}$inputFileElm.val("")}function html5Reader(e){var t=e.files[0],a=new FileReader;a.readAsDataURL(t),a.onload=function(e){var t=document.getElementById("avatar-cropper");t.src=this.result}}function show_hide_cate_nav(){$(".card-header-all-bt, .card-header:after").mouseenter(function(e){$(".card-header-all").fadeIn(500)}),$(".card-header-all").parent().mouseleave(function(e){$(".card-header-all").css("display","none")}),$(".all-cate-card .card-block").mouseenter(function(e){$(".card-header-all").css("display","none")})}function post_new_show_hide_cate(){}function show_hide_emoji_list(){$("#emoji-btn").on("mousedown",function(e){$("#summernote").summernote("saveRange")}).on("click",function(e){e.preventDefault(),e.stopPropagation(),$("#emoji-list").css("display","block")})}function show_hide_emoji_list_medium(){$("#emoji-btn").on("click",function(e){e.preventDefault(),e.stopPropagation(),$("#emoji-list").css("display","block")})}function add_action_emoji_img_medium(){$("#emoji-list img.emoji").on("click",function(e){var t=$("#mediumeditor");t.append('<img src="'+e.target.src+'" class="emoji">')})}function add_action_emoji_char_medium(){$("#emoji-list li.emoji").on("click",function(e){var t=$("#mediumeditor");t.append('<span class="emoji">'+window.emojiJSON[e.target.attributes.em.value].char+"</span>")})}function load_emoji_medium(){for(var e=["smile","blush","grin","heart_eyes","relaxed","sweat_smile","joy","flushed","confused","unamused","sob","cold_sweat","sweat","scream","sleepy","mask"],t=0;t<e.length;t++)$("#emoji-list").append('<img class="emoji" src="/assets/images/emoji/basic/'+e[t]+'.png">');add_action_emoji_img_medium(),$.getJSON("/assets/images/emoji/emojis.json",function(e){window.emojiJSON=e,$("#emoji-list").append('<li class="emoji" em="heart">'+emojiJSON.heart.char+"</li>"),add_action_emoji_char_medium()})}function load_font_avatar(){var e=["#FF5722","#CDDC39","#61C5FF","#2196F3"];$(".post-avatar a span").each(function(t,a){var o=e[Math.floor(Math.random()*e.length)];$(a).css("background-color",o)})}function getFriendlyTime(e){if(e=e.replace("-","/"),e=e.replace("-","/"),!e)return"biu...";var t=Date.now()-Date.parse(e),a=6e4,o=36e5,n=864e5,r=6048e5,i=2592e6,c=31536e6;return t<2*a?"A moment ago":t<o?Math.floor(t/a)+" mins ago":t<n?1==Math.floor(t/o)?"an hour ago":Math.floor(t/o)+" hrs ago":t<r?1==Math.floor(t/n)?"yesterday":Math.floor(t/n)+" days ago":t<i?1==Math.floor(t/r)?"last week":Math.floor(t/r)+" weeks ago":t<c?1==Math.floor(t/i)?"last month":Math.floor(t/i)+" months ago":1==Math.floor(t/c)?"an year ago":Math.floor(t/c)+" yrs ago"}function replate_friendly_time(){$(".friendly-time").each(function(e,t){$(t).html(getFriendlyTime($(t).html()))})}function extractDomain(e){var t;return t=e.indexOf("://")>-1?e.split("/")[2]:e.split("/")[0]}function get_websocket_url(e){$.ajax({type:"get",dataType:"json",url:"/api/websocketurl",success:function(t){if(0==t.errorcode){var a=t.data.url;"."==a&&(a=extractDomain(window.location.href)),e(a),console.log("get websocket url success. and start websocket.")}else 0!=t.errorcode&&console.log("get websocket url error.")}})}function start_system_monitor_websocket(e){function t(e){console.log("Connected to WebSocket server.")}function a(e){console.log("Disconnected")}function o(e){var t=JSON.parse(e.data).data;$(".cpu-per").html(t.cpu_per+"%"),$(".ram-per").html(t.ram_per+"%"),$(".net-conn").html(t.net_conn),$(".os-start").html(t.os_start)}function n(e){console.log("Error occured: "+e.data)}var r="ws://"+e+"/api/systemstatuswebsocket";sys_websocket=new WebSocket(r),sys_websocket.onopen=function(e){t(e)},sys_websocket.onclose=function(e){a(e)},sys_websocket.onmessage=function(e){o(e)},sys_websocket.onerror=function(e){n(e)}}function init_tiny_nav(){var e=location.href,t=url("?filter",e);$(".tiny-nav .nav-item a").each(function(e){var a=url("?filter",$(this).attr("href"));return t||"all"!=a?a==t?void $(this).addClass("transition active"):void 0:void $(this).addClass("transition active")})}$(document).on("mouseover",".dropdown",function(){$(this).find(".dropdown-menu").show()}),$(document).on("mouseout",".dropdown",function(){$(this).find(".dropdown-menu").hide()}),$(".upload-avatar").on("click",function(e){e.preventDefault();var t=$("#avatar-cropper").cropper("getCroppedCanvas",{width:200,height:200}).toDataURL();$.ajax({type:"post",dataType:"json",url:"/useropt",data:JSON.stringify({opt:"update-avatar",data:{avatar:t.split(",")[1]}}),success:function(e,t){0==e.errorcode?($.notify("头像更换成功"),window.location.reload()):1==e.errorcode&&alert(e.txt)}})});var $this,$ajaxUrl="";$.fn.pasteUploadImage=function(e){$this=$(this),$host=e,$this.on("paste",function(e){console.log("paste...");var t,a,o,n;if(o=e.originalEvent,o.clipboardData&&o.clipboardData.items&&(a=isImage(o)))return e.preventDefault(),t=getFilename(o)||"image.png",n="{{"+t+"(uploading...)}}",pasteText(n),uploadFile(a.getAsFile(),t)}),$this.on("drop",function(e){console.log("drop...");var t,a,o,n;if(o=e.originalEvent,o.dataTransfer&&o.dataTransfer.files&&(a=isImageForDrop(o)))return e.preventDefault(),t=o.dataTransfer.files[0].name||"image.png",n="{{"+t+"(uploading...)}}",pasteText(n),uploadFile(a,t)})},pasteText=function(e){var t,a,o,n,r;return n=$this[0].selectionStart,o=$this[0].selectionEnd,r=$this.val().length,a=$this.val().substring(0,n),t=$this.val().substring(o,r),$this.val(a+e+t),$this.get(0).setSelectionRange(n+e.length,o+e.length),$this.trigger("input")},isImage=function(e){var t,a;for(t=0;t<e.clipboardData.items.length;){if(a=e.clipboardData.items[t],a.type.indexOf("image")!==-1)return a;t++}return!1},isImageForDrop=function(e){var t,a;for(t=0;t<e.dataTransfer.files.length;){if(a=e.dataTransfer.files[t],a.type.indexOf("image")!==-1)return a;t++}return!1},getFilename=function(e){var t;return window.clipboardData&&window.clipboardData.getData?t=window.clipboardData.getData("Text"):e.clipboardData&&e.clipboardData.getData&&(t=e.clipboardData.getData("text/plain")),t=t.split("\r"),t[0]},getMimeType=function(e,t){var a=e.type,o=t.substring(t.lastIndexOf(".")+1);return a!="image/"+o?"image/"+o:a},uploadFile=function(e,t){var a=new FormData;a.append("imageFile",e),a.append("mimeType",getMimeType(e,t)),$.ajax({url:$ajaxUrl,data:a,type:"post",processData:!1,contentType:!1,dataType:"json",xhrFields:{withCredentials:!0},success:function(e){return e.success?insertToTextArea(t,e.message):replaceLoadingTest(t)},error:function(e,a){replaceLoadingTest(t),console.log(e.responseText)}})},insertToTextArea=function(e,t){return $this.val(function(a,o){return o.replace("{{"+e+"(uploading...)}}","!["+e+"]("+t+")\n")})},replaceLoadingTest=function(e){return $this.val(function(t,a){return a.replace("{{"+e+"(uploading...)}}",e+"\n")})},$("#loginModal [type='submit']").on("click",function(e){return e.preventDefault(),$.ajax({type:"post",dataType:"json",url:"/login",data:{username:$("#loginModal #username").val(),password:$("#loginModal #password").val(),captcha:$("#loginModal #captcha").val()},success:function(e,t){if($(".loading").hide(),$("#loginModal .captcha").click(),0==e.errorcode){e.data;$.notify("登陆成功"),window.location.reload()}else e.errorcode==-3?($.notify(e.txt),$("#captcha").val("")):0!=e.errorcode&&$.notify(e.txt)}}),1}),$(".captcha").on("click",function(e){e.preventDefault();var t=$(e.currentTarget).attr("src");""==t&&(t="/utils/captcha");var a=t.indexOf("?");a!=-1&&(t=t.substring(0,a)),t=t+"?id="+Math.random(1).toString(),$(e.currentTarget).attr("src",t)}),$(document).click(function(e){$(".chat-container").is(":hidden")||$("#emoji-list").is(":hidden")||$("#emoji-list").hide()}),$(document).ready(function(){change_theme(),load_font_avatar()}),$(".dropdown-menu").on("click",function(e){console.log("dropdown-menu.click"),$(e.currentTarget).is(":hidden")||$(e.currentTarget).hide()}),window.url=function(){function e(){return new RegExp(/(.*?)\.?([^\.]*?)\.?(com|net|org|biz|ws|in|me|co\.uk|co|org\.uk|ltd\.uk|plc\.uk|me\.uk|edu|mil|br\.com|cn\.com|eu\.com|hu\.com|no\.com|qc\.com|sa\.com|se\.com|se\.net|us\.com|uy\.com|ac|co\.ac|gv\.ac|or\.ac|ac\.ac|af|am|as|at|ac\.at|co\.at|gv\.at|or\.at|asn\.au|com\.au|edu\.au|org\.au|net\.au|id\.au|be|ac\.be|adm\.br|adv\.br|am\.br|arq\.br|art\.br|bio\.br|cng\.br|cnt\.br|com\.br|ecn\.br|eng\.br|esp\.br|etc\.br|eti\.br|fm\.br|fot\.br|fst\.br|g12\.br|gov\.br|ind\.br|inf\.br|jor\.br|lel\.br|med\.br|mil\.br|net\.br|nom\.br|ntr\.br|odo\.br|org\.br|ppg\.br|pro\.br|psc\.br|psi\.br|rec\.br|slg\.br|tmp\.br|tur\.br|tv\.br|vet\.br|zlg\.br|br|ab\.ca|bc\.ca|mb\.ca|nb\.ca|nf\.ca|ns\.ca|nt\.ca|on\.ca|pe\.ca|qc\.ca|sk\.ca|yk\.ca|ca|cc|ac\.cn|com\.cn|edu\.cn|gov\.cn|org\.cn|bj\.cn|sh\.cn|tj\.cn|cq\.cn|he\.cn|nm\.cn|ln\.cn|jl\.cn|hl\.cn|js\.cn|zj\.cn|ah\.cn|gd\.cn|gx\.cn|hi\.cn|sc\.cn|gz\.cn|yn\.cn|xz\.cn|sn\.cn|gs\.cn|qh\.cn|nx\.cn|xj\.cn|tw\.cn|hk\.cn|mo\.cn|cn|cx|cz|de|dk|fo|com\.ec|tm\.fr|com\.fr|asso\.fr|presse\.fr|fr|gf|gs|co\.il|net\.il|ac\.il|k12\.il|gov\.il|muni\.il|ac\.in|co\.in|org\.in|ernet\.in|gov\.in|net\.in|res\.in|is|it|ac\.jp|co\.jp|go\.jp|or\.jp|ne\.jp|ac\.kr|co\.kr|go\.kr|ne\.kr|nm\.kr|or\.kr|li|lt|lu|asso\.mc|tm\.mc|com\.mm|org\.mm|net\.mm|edu\.mm|gov\.mm|ms|nl|no|nu|pl|ro|org\.ro|store\.ro|tm\.ro|firm\.ro|www\.ro|arts\.ro|rec\.ro|info\.ro|nom\.ro|nt\.ro|se|si|com\.sg|org\.sg|net\.sg|gov\.sg|sk|st|tf|ac\.th|co\.th|go\.th|mi\.th|net\.th|or\.th|tm|to|com\.tr|edu\.tr|gov\.tr|k12\.tr|net\.tr|org\.tr|com\.tw|org\.tw|net\.tw|ac\.uk|uk\.com|uk\.net|gb\.com|gb\.net|vg|sh|kz|ch|info|ua|gov|name|pro|ie|hk|com\.hk|org\.hk|net\.hk|edu\.hk|us|tk|cd|by|ad|lv|eu\.lv|bz|es|jp|cl|ag|mobi|eu|co\.nz|org\.nz|net\.nz|maori\.nz|iwi\.nz|io|la|md|sc|sg|vc|tw|travel|my|se|tv|pt|com\.pt|edu\.pt|asia|fi|com\.ve|net\.ve|fi|org\.ve|web\.ve|info\.ve|co\.ve|tel|im|gr|ru|net\.ru|org\.ru|hr|com\.hr|ly|xyz)$/)}function t(e){return decodeURIComponent(e.replace(/\+/g," "))}function a(e,t){var a=e.charAt(0),o=t.split(a);return a===e?o:(e=parseInt(e.substring(1),10),o[e<0?o.length+e:e-1])}function o(e,a){for(var o=e.charAt(0),n=a.split("&"),r=[],i={},c=[],s=e.substring(1),l=0,u=n.length;l<u;l++)if(r=n[l].match(/(.*?)=(.*)/),r||(r=[n[l],n[l],""]),""!==r[1].replace(/\s/g,"")){if(r[2]=t(r[2]||""),s===r[1])return r[2];c=r[1].match(/(.*)\[([0-9]+)\]/),c?(i[c[1]]=i[c[1]]||[],i[c[1]][c[2]]=r[2]):i[r[1]]=r[2]}return o===e?i:i[s]}return function(t,n){var r,i={};if("tld?"===t)return e();if(n=n||window.location.toString(),!t)return n;if(t=t.toString(),r=n.match(/^mailto:([^\/].+)/))i.protocol="mailto",i.email=r[1];else{if((r=n.match(/(.*?)\/#\!(.*)/))&&(n=r[1]+r[2]),(r=n.match(/(.*?)#(.*)/))&&(i.hash=r[2],n=r[1]),i.hash&&t.match(/^#/))return o(t,i.hash);if((r=n.match(/(.*?)\?(.*)/))&&(i.query=r[2],n=r[1]),i.query&&t.match(/^\?/))return o(t,i.query);if((r=n.match(/(.*?)\:?\/\/(.*)/))&&(i.protocol=r[1].toLowerCase(),n=r[2]),(r=n.match(/(.*?)(\/.*)/))&&(i.path=r[2],n=r[1]),i.path=(i.path||"").replace(/^([^\/])/,"/$1").replace(/\/$/,""),t.match(/^[\-0-9]+$/)&&(t=t.replace(/^([^\/])/,"/$1")),t.match(/^\//))return a(t,i.path.substring(1));if(r=a("/-1",i.path.substring(1)),r&&(r=r.match(/(.*?)\.(.*)/))&&(i.file=r[0],i.filename=r[1],i.fileext=r[2]),(r=n.match(/(.*)\:([0-9]+)$/))&&(i.port=r[2],n=r[1]),(r=n.match(/(.*?)@(.*)/))&&(i.auth=r[1],n=r[2]),i.auth&&(r=i.auth.match(/(.*)\:(.*)/),i.user=r?r[1]:i.auth,i.pass=r?r[2]:void 0),i.hostname=n.toLowerCase(),"."===t.charAt(0))return a(t,i.hostname);e()&&(r=i.hostname.match(e()),r&&(i.tld=r[3],i.domain=r[2]?r[2]+"."+r[3]:void 0,i.sub=r[1]||void 0)),i.port=i.port||("https"===i.protocol?"443":"80"),i.protocol=i.protocol||("443"===i.port?"https":"http")}return t in i?i[t]:"{}"===t?i:void 0}}(),"undefined"!=typeof jQuery&&jQuery.extend({url:function(e,t){return window.url(e,t)}});