diff --git a/README.md b/README.md index 7217a67..7600613 100644 --- a/README.md +++ b/README.md @@ -47,12 +47,12 @@ ```html - - + + - - + + ``` 在需要显示评论的地方插入下述代码: diff --git a/dist/disqus.js b/dist/disqus.js index c1fecd9..5f33a50 100644 --- a/dist/disqus.js +++ b/dist/disqus.js @@ -1,6 +1,6 @@ /*! - * DisqusJS | v0.1.4 + * DisqusJS | v0.2.0 * Author: SukkaW * Link: https://github.com/SukkaW/DisqusJS * License: GPL-3.0 - */"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
'.concat(s.avatarEl,'
').concat(s.authorEl,'
').concat(s.message,"
")};s.map(function(s){var e=s.comment;e.author.profileUrl?(e.avatarEl=''),e.authorEl='').concat(e.author.name,"")):(e.avatarEl=''),e.authorEl="".concat(e.author.name)),s.isPrimary&&(e.authorEl+=''.concat(disqusjs.config.adminLabel,"")),s.children&&(s.nesting=1);var t='
  • ');t+=n(e),t+="".concat(function t(s){var i=s.nesting,e=s.children||[];if("null"!=typeof e){if(i<4)var a='