From 40676e55c2c4f12f29af46534bda45460f03a01f Mon Sep 17 00:00:00 2001 From: SukkaW Date: Tue, 9 Oct 2018 11:17:55 +0800 Subject: [PATCH] release 0.1.4 --- README.md | 8 ++++---- dist/disqus.js | 7 ++----- dist/disqusjs.css | 2 +- package.json | 2 +- src/disqus.js | 6 +++--- src/disqusjs.css | 2 +- 6 files changed, 12 insertions(+), 15 deletions(-) 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='
      ';else a='
        ';return s.map(function(e){var s=e.comment;s.author.profileUrl?(s.avatarEl=''),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.nesting=n+1,a+='
      • '),a+=baidu.template(o,s),a+="".concat(t(e),"
      • ")}),0!==(a+="
      ").length?a:void 0}}(e),""),document.getElementById("dsqjs-list").insertAdjacentHTML("beforeend",t)})},u=function(){var e;document.getElementById("disqus_thread").innerHTML='

      评论完整模式加载中...如果长时间无法加载,请针对 disq.us | disquscdn.com | disqus.com 启用代理,或使用评论基础模式

      你可能无法访问 Disqus,已启用评论基础模式。如需完整体验请针对 disq.us | disquscdn.com | disqus.com 启用代理并尝试使用完整 Disqus 模式 | 强制完整 Disqus 模式

      评论基础模式出现错误,是否重载

      这里冷冷清清的,一条评论都没有

        ',disqusjs.mode=(e="disqusjs_mode",localStorage.getItem(e)),"disqus"===disqusjs.mode?function(){var e=document;e.getElementById("dsqjs-load-disqus").classList.remove("dsqjs-hide"),e.getElementById("dsqjs-force-dsqjs").addEventListener("click",a);var s=e.createElement("script");s.src="https://"+disqusjs.config.shortname+".disqus.com/embed.js",s.setAttribute("data-timestamp",+new Date),(e.head||e.body).appendChild(s)}():"dsqjs"===disqusjs.mode?r():t()};u()}(); \ No newline at end of file + */"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='
          ';else a='
            ';return e.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.nesting=i+1,a+='
          • '),a+=n(e),a+="".concat(t(s),"
          • ")}),0!==(a+="
          ").length?a:void 0}}(s),""),document.getElementById("dsqjs-list").insertAdjacentHTML("beforeend",t)})},u=function(){var s;document.getElementById("disqus_thread").innerHTML='

          评论完整模式加载中...如果长时间无法加载,请针对 disq.us | disquscdn.com | disqus.com 启用代理,或使用评论基础模式

          你可能无法访问 Disqus,已启用评论基础模式。如需完整体验请针对 disq.us | disquscdn.com | disqus.com 启用代理并尝试完整 Disqus 模式 | 强制完整 Disqus 模式

          该 Thread 并没有初始化,是否 切换到完整 Disqus 模式 进行初始化?

          评论基础模式出现错误,是否重载

          这里冷冷清清的,一条评论都没有

            ',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()}(); \ No newline at end of file diff --git a/dist/disqusjs.css b/dist/disqusjs.css index 67bb24a..6c17d9d 100644 --- a/dist/disqusjs.css +++ b/dist/disqusjs.css @@ -1,5 +1,5 @@ /*! - * DisqusJS - Default Theme | v0.1.1 + * DisqusJS - Default Theme | v0.1.4 * Author: SukkaW * Link: https://github.com/SukkaW/DisqusJS * License: GPL-3.0 diff --git a/package.json b/package.json index af27462..0dadc25 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "disqusjs", - "version": "0.1.3", + "version": "0.1.4", "description": "Alternative DISQUS - Render comments components from Disqus API", "main": "dist/disqus.js", "scripts": { diff --git a/src/disqus.js b/src/disqus.js index 99e31db..4ebf4fa 100644 --- a/src/disqus.js +++ b/src/disqus.js @@ -1,5 +1,5 @@ -/*! - * DisqusJS | v0.1.1 +/* + * DisqusJS | v0.1.4 * Author: SukkaW * Link: https://github.com/SukkaW/DisqusJS * License: GPL-3.0 @@ -15,7 +15,7 @@ * disqusjs.config.shortname - The disqus shortname * disqusjs.config.identifier - The identifier of the page * disqusjs.config.url - The url of the page - * disqusjs.config,api - Where to get data + * disqusjs.config.api - Where to get data * disqusjs.config.apikey - The apikey used to request Disqus API * disqusjs.config.admin - The disqus forum admin username * disqusjs.config.adminLabel - The disqus moderator badge text diff --git a/src/disqusjs.css b/src/disqusjs.css index dd8c23a..45b3cfe 100644 --- a/src/disqusjs.css +++ b/src/disqusjs.css @@ -1,5 +1,5 @@ /*! - * DisqusJS - Default Theme | v0.1.1 + * DisqusJS - Default Theme | v0.1.4 * Author: SukkaW * Link: https://github.com/SukkaW/DisqusJS * License: GPL-3.0