|
|
*/"use strict";!function(){disqusjs.page=[],window.disqus_config=function(){this.page.url=disqusjs.config.url,this.page.identifier=disqusjs.config.identifier};var e=new XMLHttpRequest,i=function(s,e){try{localStorage.setItem(s,e)}catch(s){console.log(s),console.log("Failed to set localStorage item")}};Date.prototype.Format=function(s){var e={"M+":this.getMonth()+1,"d+":this.getDate(),"h+":this.getHours(),"m+":this.getMinutes(),"s+":this.getSeconds(),"q+":Math.floor((this.getMonth()+3)/3),S:this.getMilliseconds()};for(var t in/(y+)/.test(s)&&(s=s.replace(RegExp.$1,(this.getFullYear()+"").substr(4-RegExp.$1.length))),e)new RegExp("("+t+")").test(s)&&(s=s.replace(RegExp.$1,1==RegExp.$1.length?e[t]:("00"+e[t]).substr((""+e[t]).length)));return s};var t=function(){var e=new Image,t=setTimeout(function(){e.onerror=e.onload=null,i("disqusjs_mode","dsqjs")},2e3);e.onerror=function(){clearTimeout(t),i("disqusjs_mode","dsqjs"),u()},e.onload=function(){clearTimeout(t);var s=setTimeout(function(){e.onerror=e.onload=null,i("disqusjs_mode","dsqjs")},2e3);e.onerror=function(){clearTimeout(s),i("disqusjs_mode","dsqjs"),u()},e.onload=function(){clearTimeout(s),i("disqusjs_mode","disqus"),u()},e.src="https://"+disqusjs.config.shortname+".disqus.com/favicon.ico?"+ +new Date},e.src="https://disqus.com/favicon.ico?"+ +new Date},a=function(){i("disqusjs_mode","dsqjs"),u()},n=function(){i("disqusjs_mode","disqus"),u()},o=function(){document.getElementById("dsqjs-load-error").classList.remove("dsqjs-hide"),document.getElementById("dsqjs-loading-dsqjs").classList.add("dsqjs-hide"),document.getElementById("dsqjs-reload").addEventListener("click",d)},d=function(){document.getElementById("dsqjs-loading-dsqjs").classList.remove("dsqjs-hide"),document.getElementById("dsqjs-force-disqus").addEventListener("click",n),document.getElementById("dsqjs-reload-disqus").addEventListener("click",t);var s=disqusjs.config.api+"3.0/threads/list.json?forum="+disqusjs.config.shortname+"&thread=ident:"+disqusjs.config.identifier+"&api_key="+disqusjs.config.apikey;e.open("GET",s,!0),e.timeout=4e3,e.send(),e.onload=function(){if(200==this.status||304==this.status){var s=JSON.parse(this.responseText).response;if(console.log(s.length),1===s.length){var e=s[0];disqusjs.page={id:e.id,title:e.title,isClosed:e.isClosed,length:e.posts},r()}else document.getElementById("dsqjs-thread-not-init").classList.remove("dsqjs-hide"),document.getElementById("dsqjs-init-thread").addEventListener("click",n)}},e.ontimeout=function(s){o()},e.onerror=function(s){o()}},r=function(){var s=disqusjs.config.api+"3.0/posts/list.json?forum="+disqusjs.config.shortname+"&thread="+disqusjs.page.id+"&api_key="+disqusjs.config.apikey;e.open("GET",s,!0),e.timeout=4e3,e.send(),e.onload=function(){if(200==this.status||304==this.status){var s=JSON.parse(this.responseText);0===s.code&&0<s.response.length?c(s.response):0===s.code&&0===s.response.length&&document.getElementById("dsqjs-no-comment").classList.remove("dsqjs-hide")}},e.ontimeout=function(s){o()},e.onerror=function(s){o()}},c=function(s){var e=[],n=[];s.forEach(function(s){(s.parent?n:e).push(s)});var t=e.map(function(s){return{comment:s,author:s.author.name,isPrimary:s.author.username===disqusjs.config.admin.toLowerCase(),children:function s(e){if(0===n.length)return null;var t=[];for(var i=0;i<n.length;i++){var a=n[i];a.parent===e&&t.unshift({comment:a,author:a.author.name,isPrimary:a.author.username===disqusjs.config.admin.toLowerCase(),children:s(+a.id)})}return t.length?t:null}(+s.id)}});l(t)},l=function(s){var n=function(s){return'<div class="dsqjs-item-container"><div class="dsqjs-avater">'.concat(s.avatarEl,'</div><div class="dsqjs-body"><header class="dsqjs-header"><span class="dsqjs-author">').concat(s.authorEl,'</span><span class="dsqjs-bullet"></span><span class="dsqjs-meta"><time>').concat(new Date(s.createdAt).Format("yyyy-MM-dd hh:mm:ss"),'</time></span></header><div class="dsqjs-content">').concat(s.message,"</div></div></div>")};s.map(function(s){var e=s.comment;e.author.profileUrl?(e.avatarEl='<a href="'.concat(e.author.profileUrl,'" target="_blank" rel="nofollow noopener noreferrer"><img src="').concat(e.author.avatar.cache,'"></a>'),e.authorEl='<a href="'.concat(e.author.profileUrl,'">').concat(e.author.name,"</a>")):(e.avatarEl='<img src="'.concat(e.author.avatar.cache,'">'),e.authorEl="".concat(e.author.name)),s.isPrimary&&(e.authorEl+='<span class="dsqjs-admin-badge">'.concat(disqusjs.config.adminLabel,"</span>")),s.children&&(s.nesting=1);var t='<li class="dsqjs-item" id="comment-'.concat(e.id,'">');t+=n(e),t+="".concat(function t(s){var i=s.nesting,e=s.children||[];if("null"!=typeof e){if(i<4)var a='<ul class="dsqjs-list dsqjs-children">';else a='<ul class="dsqjs-list">';return e.map(function(s){var e=s.comment;e.author.profileUrl?(e.avatarEl='<a href="'.concat(e.author.profileUrl,'" target="_blank" rel="nofollow noopener noreferrer"><img src="').concat(e.author.avatar.cache,'"></a>'),e.authorEl='<a href="'.concat(e.author.profileUrl,'">').concat(e.author.name,"</a>")):(e.avatarEl='<img src="'.concat(e.author.avatar.cache,'">'),e.authorEl="".concat(e.author.name)),s.isPrimary&&(e.authorEl+='<span class="dsqjs-admin-badge">'.concat(disqusjs.config.adminLabel,"</span>")),s.nesting=i+1,a+='<li class="dsqjs-item" id="comment-'.concat(e.id,'">'),a+=n(e),a+="".concat(t(s),"</li>")}),0!==(a+="</ul>").length?a:void 0}}(s),"</li>"),document.getElementById("dsqjs-list").insertAdjacentHTML("beforeend",t)})},u=function(){var s;document.getElementById("disqus_thread").innerHTML='<div id="dsqjs"><section class="dsqjs-action"></section><header></header><section class="dsqjs-info"><p id="dsqjs-load-disqus" class="dsqjs-message dsqjs-hide">评论完整模式加载中...如果长时间无法加载,请针对 disq.us | disquscdn.com | disqus.com 启用代理,或使用<a href="#disqus_thread" id="dsqjs-force-dsqjs">评论基础模式</a></p><p id="dsqjs-loading-dsqjs" class="dsqjs-message dsqjs-hide">你可能无法访问 Disqus,已启用评论基础模式。如需完整体验请针对 disq.us | disquscdn.com | disqus.com 启用代理并<a href="#disqus_thread" id="dsqjs-reload-disqus">尝试完整 Disqus 模式</a> | <a href="#disqus_thread" id="dsqjs-force-disqus">强制完整 Disqus 模式</a>。</p><p id="dsqjs-thread-not-init" class="dsqjs-message dsqjs-hide">该 Thread 并没有初始化,是否 <a href="#disqus_thread" id="dsqjs-init-thread">切换到完整 Disqus 模式</a> 进行初始化?</p><p id="dsqjs-load-error" class="dsqjs-message dsqjs-hide">评论基础模式出现错误,是否<a href="#disqus_thread" id="dsqjs-reload">重载</a>?</p><p id="dsqjs-no-comment" class="dsqjs-no-comment dsqjs-hide">这里冷冷清清的,一条评论都没有</p></section><section class="dsqjs-container" id="dsqjs-container"><ul id="dsqjs-list" class="dsqjs-list"></ul><div class="dsqjs-footer"><div class="dsqjs-footer-right">Powered by <a href="https://disqus.com" rel="nofollow noopener noreferrer" target="_blank">DISQUS</a> & <a href="https://github.com/SukkaW/DisqusJS">DisqusJS</a></div></div></section></div>',disqusjs.mode=(s="disqusjs_mode",localStorage.getItem(s)),"disqus"===disqusjs.mode?function(){var s=document;s.getElementById("dsqjs-load-disqus").classList.remove("dsqjs-hide"),s.getElementById("dsqjs-force-dsqjs").addEventListener("click",a);var e=s.createElement("script");e.src="https://"+disqusjs.config.shortname+".disqus.com/embed.js",e.setAttribute("data-timestamp",+new Date),(s.head||s.body).appendChild(e)}():"dsqjs"===disqusjs.mode?d():t()};u()}(); |