diff --git a/README.md b/README.md index 91090be..16231da 100644 --- a/README.md +++ b/README.md @@ -41,11 +41,11 @@ ```html - - + + - - + + ``` 在需要显示评论的地方插入下述代码: diff --git a/dist/disqus.js b/dist/disqus.js index aff9088..c1fecd9 100644 --- a/dist/disqus.js +++ b/dist/disqus.js @@ -1,9 +1,6 @@ -"use strict";function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)} -/*! baiduTemplate | Verison 1.0.6 | BSD License */!function(a){var e="undefined"==typeof module?a.baidu=a.baidu||{}:module.exports;e.template=function(t,e){var s=function(){if(!a.document)return o._compile(t);var e=document.getElementById(t);if(e){if(o.cache[t])return o.cache[t];var s=/^(textarea|input)$/i.test(e.nodeName)?e.value:e.innerHTML;return o._compile(s)}return o._compile(t)}(),n=o._isObject(e)?s(e):s;return s=null,n};var o=e.template;o.versions=o.versions||[],o.versions.push("1.0.6"),o.cache={},o.LEFT_DELIMITER=o.LEFT_DELIMITER||"<%",o.RIGHT_DELIMITER=o.RIGHT_DELIMITER||"%>",o.ESCAPE=!0,o._encodeHTML=function(e){return String(e).replace(/&/g,"&").replace(//g,">").replace(/\\/g,"\").replace(/"/g,""").replace(/'/g,"'")},o._encodeReg=function(e){return String(e).replace(/([.*+?^=!:${}()|[\]/\\])/g,"\\$1")},o._encodeEventHTML=function(e){return String(e).replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'").replace(/\\\\/g,"\\").replace(/\\\//g,"/").replace(/\\n/g,"\n").replace(/\\r/g,"\r")},o._compile=function(e){var s="var _template_fun_array=[];\nvar fn=(function(__data__){\nvar _template_varName='';\nfor(name in __data__){\n_template_varName+=('var '+name+'=__data__[\"'+name+'\"];');\n};\neval(_template_varName);\n_template_fun_array.push('"+o._analysisStr(e)+"');\n_template_varName=null;\n})(_template_object);\nfn = null;\nreturn _template_fun_array.join('');\n";return new Function("_template_object",s)},o._isObject=function(e){return"function"==typeof e||!(!e||"object"!==_typeof(e))},o._analysisStr=function(e){var s=o.LEFT_DELIMITER,t=o.RIGHT_DELIMITER,n=o._encodeReg(s),a=o._encodeReg(t);return e=(e=String(e).replace(new RegExp("("+n+"[^"+a+"]*)//.*\n","g"),"$1").replace(new RegExp("\x3c!--.*?--\x3e","g"),"").replace(new RegExp(n+"\\*.*?\\*"+a,"g"),"").replace(new RegExp("[\\r\\t\\n]","g"),"").replace(new RegExp(n+"(?:(?!"+a+")[\\s\\S])*"+a+"|((?:(?!"+n+")[\\s\\S])+)","g"),function(e,s){var t="";if(s)for(t=s.replace(/\\/g,"\").replace(/'/g,"'");/<[^<]*?'[^<]*?>/g.test(t);)t=t.replace(/(<[^<]*?)'([^<]*?>)/g,"$1\r$2");else t=e;return t})).replace(new RegExp("("+n+"[\\s]*?var[\\s]*?.*?[\\s]*?[^;])[\\s]*?"+a,"g"),"$1;"+t).replace(new RegExp("("+n+":?[hvu]?[\\s]*?=[\\s]*?[^;|"+a+"]*?);[\\s]*?"+a,"g"),"$1"+t).split(s).join("\t"),e=(e=o.ESCAPE?e.replace(new RegExp("\\t=(.*?)"+a,"g"),"',typeof($1) === 'undefined'?'':baidu.template._encodeHTML($1),'"):e.replace(new RegExp("\\t=(.*?)"+a,"g"),"',typeof($1) === 'undefined'?'':$1,'")).replace(new RegExp("\\t:h=(.*?)"+a,"g"),"',typeof($1) === 'undefined'?'':baidu.template._encodeHTML($1),'").replace(new RegExp("\\t(?::=|-)(.*?)"+a,"g"),"',typeof($1)==='undefined'?'':$1,'").replace(new RegExp("\\t:u=(.*?)"+a,"g"),"',typeof($1)==='undefined'?'':encodeURIComponent($1),'").replace(new RegExp("\\t:v=(.*?)"+a,"g"),"',typeof($1)==='undefined'?'':baidu.template._encodeEventHTML($1),'").split("\t").join("');").split(t).join("_template_fun_array.push('").split("\r").join("\\'")}}(window), /*! - * DisqusJS | v0.1.1 + * DisqusJS | v0.1.4 * Author: SukkaW * Link: https://github.com/SukkaW/DisqusJS * License: GPL-3.0 - */ -function(){disqusjs.page=[],window.disqus_config=function(){this.page.url=disqusjs.config.url,this.page.identifier=disqusjs.config.identifier};var s=new XMLHttpRequest,n=function(e,s){try{localStorage.setItem(e,s)}catch(e){console.log(e),console.log("Failed to set localStorage item")}};Date.prototype.Format=function(e){var s={"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(e)&&(e=e.replace(RegExp.$1,(this.getFullYear()+"").substr(4-RegExp.$1.length))),s)new RegExp("("+t+")").test(e)&&(e=e.replace(RegExp.$1,1==RegExp.$1.length?s[t]:("00"+s[t]).substr((""+s[t]).length)));return e};var t=function(){var s=new Image,t=setTimeout(function(){s.onerror=s.onload=null,n("disqusjs_mode","dsqjs")},2e3);s.onerror=function(){clearTimeout(t),n("disqusjs_mode","dsqjs"),u()},s.onload=function(){clearTimeout(t);var e=setTimeout(function(){s.onerror=s.onload=null,n("disqusjs_mode","dsqjs")},2e3);s.onerror=function(){clearTimeout(e),n("disqusjs_mode","dsqjs"),u()},s.onload=function(){clearTimeout(e),n("disqusjs_mode","disqus"),u()},s.src="https://"+disqusjs.config.shortname+".disqus.com/favicon.ico?"+ +new Date},s.src="https://disqus.com/favicon.ico?"+ +new Date},a=function(){n("disqusjs_mode","dsqjs"),u()},o=function(){n("disqusjs_mode","disqus"),u()},i=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",r)},r=function(){document.getElementById("dsqjs-loading-dsqjs").classList.remove("dsqjs-hide"),document.getElementById("dsqjs-force-disqus").addEventListener("click",o),document.getElementById("dsqjs-reload-disqus").addEventListener("click",t);var e=disqusjs.config.api+"3.0/threads/list.json?forum="+disqusjs.config.shortname+"&thread=ident:"+disqusjs.config.identifier+"&api_key="+disqusjs.config.apikey;s.open("GET",e,!0),s.timeout=4e3,s.send(),s.onload=function(){if(200==this.status||304==this.status){var e=JSON.parse(this.responseText).response[0];disqusjs.page={id:e.id,title:e.title,isClosed:e.isClosed,length:e.posts},d()}},s.ontimeout=function(e){i()},s.onerror=function(e){i()}},d=function(){var e=disqusjs.config.api+"3.0/posts/list.json?forum="+disqusjs.config.shortname+"&thread="+disqusjs.page.id+"&api_key="+disqusjs.config.apikey;s.open("GET",e,!0),s.timeout=4e3,s.send(),s.onload=function(){if(200==this.status||304==this.status){var e=JSON.parse(this.responseText);0===e.code&&0'),s.authorEl='').concat(s.author.name,"")):(s.avatarEl=''),s.authorEl="".concat(s.author.name)),s.author.name===disqusjs.config.admin&&(s.authorEl+=''.concat(disqusjs.config.adminLabel,"")),e.children&&(e.nesting=1);var t='
  • ');t+=baidu.template(o,s),t+="".concat(function t(e){var n=e.nesting,s=e.children||[];if("null"!=typeof s){if(n<4)var a='