|
|
*/"use strict";!function(){var n=new XMLHttpRequest;function d(s,e){try{localStorage.setItem(s,e)}catch(s){console.log("Failed to set localStorage item")}}function e(){var e=new Image,t=setTimeout(function(){e.onerror=e.onload=null,d("disqusjs_mode","dsqjs"),r()},2e3);e.onerror=function(){clearTimeout(t),d("disqusjs_mode","dsqjs"),r()},e.onload=function(){clearTimeout(t);var s=setTimeout(function(){e.onerror=e.onload=null,d("disqusjs_mode","dsqjs"),r()},2e3);e.onerror=function(){clearTimeout(s),d("disqusjs_mode","dsqjs"),r()},e.onload=function(){clearTimeout(s),d("disqusjs_mode","disqus"),r()},e.src="https://".concat(disqusjs.config.shortname,".disqus.com/favicon.ico?").concat(+new Date)},e.src="https://disqus.com/favicon.ico?".concat(+new Date)}function t(){d("disqusjs_mode","dsqjs"),r()}function o(){d("disqusjs_mode","disqus"),r()}function i(){document.getElementById("dsqjs-loading-dsqjs").classList.remove("dsqjs-hide"),document.getElementById("dsqjs-load-error").classList.add("dsqjs-hide"),document.getElementById("dsqjs-force-disqus").addEventListener("click",o),document.getElementById("dsqjs-reload-disqus").addEventListener("click",e);var s="".concat(disqusjs.config.api,"3.0/threads/list.json?forum=").concat(disqusjs.config.shortname,"&thread=ident:").concat(disqusjs.config.identifier,"&api_key=").concat(disqusjs.config.apikey);n.open("GET",s,!0),n.timeout=4e3,n.send(),n.onload=function(){if(200===this.status||304===this.status){var s=JSON.parse(this.responseText).response;if(1===s.length){var e=s[0];disqusjs.page={id:e.id,title:e.title,isClosed:e.isClosed,length:e.posts},function e(s){s=s?"&cursor=".concat(s):"";var t="".concat(disqusjs.config.api,"3.0/posts/list.json?forum=").concat(disqusjs.config.shortname,"&thread=").concat(disqusjs.page.id).concat(s,"&api_key=").concat(disqusjs.config.apikey);n.open("GET",t,!0);n.timeout=4e3;n.send();n.onload=function(){if(200===this.status||304===this.status){var s=JSON.parse(this.responseText);0===s.code&&0<s.response.length?a(s.response):0===s.code&&0===s.response.length?document.getElementById("dsqjs-no-comment").classList.remove("dsqjs-hide"):c(),s.cursor.hasNext?(document.getElementById("dsqjs-load-more").classList.remove("dsqjs-hide"),document.getElementById("dsqjs-load-more").addEventListener("click",function(){e(s.cursor.next)})):document.getElementById("dsqjs-load-more").classList.add("dsqjs-hide")}else c()}}()}else document.getElementById("dsqjs-thread-not-init").classList.remove("dsqjs-hide"),document.getElementById("dsqjs-init-thread").addEventListener("click",o)}else c()}}function a(s){var e=[],o=[];s.forEach(function(s){(s.parent?o:e).push(s)}),function(s){function o(s){return s.comment.author.profileUrl?(s.comment.avatarEl='<a href="'.concat(s.comment.author.profileUrl,'" target="_blank" rel="nofollow noopener noreferrer"><img src="').concat(s.comment.author.avatar.cache,'"></a>'),s.comment.authorEl='<a href="'.concat(s.comment.author.profileUrl,'" target="_blank" rel="nofollow noopener noreferrer">').concat(s.comment.author.name,"</a>")):(s.comment.avatarEl='<img src="'.concat(s.comment.author.avatar.cache,'">'),s.comment.authorEl="".concat(s.comment.author.name)),s.isPrimary&&(s.comment.authorEl+='<span class="dsqjs-admin-badge">'.concat(disqusjs.config.adminLabel,"</span>")),s.children&&(s.nesting=1),s}function i(s){var e='<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(function(s){var e=s.getFullYear(),t=s.getMonth()+1;t=t<10?"0"+t:t;var n=s.getDate();n=n<10?"0"+n:n;var d=s.getHours()+8;d=d<10?"0"+d:d;var o=s.getMinutes();o=o<10?"0"+o:o;var i=s.getSeconds();return i=o<10?"0"+i:i,"".concat(e,"-").concat(t,"-").concat(n," ").concat(d,":").concat(o,":").concat(i)}(new Date(s.createdAt)),'</time></span></header><div class="dsqjs-content">').concat(s.message,"</div></div></div>");return e}s.map(function(s){s=o(s);var e='<li class="dsqjs-item" id="comment-'.concat(s.comment.id,'">').concat(i(s.comment)).concat(function e(s){var t=s.nesting,n=s.children||[];if(!n)return;var d=t<4?'<ul class="dsqjs-list dsqjs-children">':'<ul class="dsqjs-list">';d+=n.map(function(s){return(s=o(s)).nesting=t+1,'<li class="dsqjs-item" id="comment-'.concat(s.comment.id,'">').concat(i(s.comment)).concat(e(s),"</li>")});d+="</ul>";return 0!==d.length?d:void 0}(s),"</li>");document.getElementById("dsqjs-list").insertAdjacentHTML("beforeend",e)})}(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===o.length)return null;var t=[];for(var n=0;n<o.length;n++){var d=o[n];d.parent===e&&t.unshift({comment:d,author:d.author.name,isPrimary:d.author.username===disqusjs.config.admin.toLowerCase(),children:s(+d.id)})}return t.length?t:null}(+s.id)}}))}function c(){document.getElementById("dsqjs-load-error").classList.remove("dsqjs-hide"),document.getElementById("dsqjs-loading-dsqjs").classList.add("dsqjs-hide"),document.getElementById("dsqjs-reload").addEventListener("click",i)}function r(){if(window.disqusjs&&document.getElementById("disqus_thread")){disqusjs.page=[],window.disqus_config=function(){this.page.url=disqusjs.config.url,this.page.identifier=disqusjs.config.identifier};document.getElementById("disqus_thread").innerHTML='<div id="dsqjs"><section class="dsqjs-action"></section><section class="dsqjs-info"><p id="dsqjs-load-disqus" class="dsqjs-message dsqjs-hide">评论完整模式加载中...如果长时间无法加载,请针对 disq.us | disquscdn.com | disqus.com 启用代理,或使用<a id="dsqjs-force-dsqjs">评论基础模式</a></p><p id="dsqjs-loading-dsqjs" class="dsqjs-message dsqjs-hide">你可能无法访问 Disqus,已启用评论基础模式。如需完整体验请针对 disq.us | disquscdn.com | disqus.com 启用代理并<a id="dsqjs-reload-disqus">尝试完整 Disqus 模式</a> | <a id="dsqjs-force-disqus">强制完整 Disqus 模式</a>。</p><p id="dsqjs-thread-not-init" class="dsqjs-message dsqjs-hide">该 Thread 并没有初始化,是否 <a id="dsqjs-init-thread">切换到完整 Disqus 模式</a> 进行初始化?</p><p id="dsqjs-load-error" class="dsqjs-message dsqjs-hide">评论基础模式出现错误,是否<a 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><a id="dsqjs-load-more" class="dsqjs-load-more dsqjs-hide">加载更多评论</a><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",t);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?i():e()}var s}n.ontimeout=function(s){c()},n.onerror=function(s){c()},r(),window.disqusjs=window.disqusjs||{},window.disqusjs.load=r}(); |