From 06516f57afb2062857d7b2a774a29ce54a4ea736 Mon Sep 17 00:00:00 2001 From: SukkaW Date: Sun, 21 Oct 2018 15:05:17 +0800 Subject: [PATCH] release 1.0.1 --- .npmignore | 3 +++ README.md | 8 ++++---- dist/disqus.js | 4 ++-- dist/disqusjs.css | 2 +- docs/index.html | 4 ++-- package.json | 2 +- 6 files changed, 13 insertions(+), 10 deletions(-) create mode 100644 .npmignore diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..912a432 --- /dev/null +++ b/.npmignore @@ -0,0 +1,3 @@ +src/index.html + +docs/ diff --git a/README.md b/README.md index 745474d..f465b38 100644 --- a/README.md +++ b/README.md @@ -45,12 +45,12 @@ ```html - - + + - - + + ``` #### 从 NPM 安装 diff --git a/dist/disqus.js b/dist/disqus.js index 2e15ef9..8a0d08d 100644 --- a/dist/disqus.js +++ b/dist/disqus.js @@ -1,6 +1,6 @@ /*! - * DisqusJS | v1.0.0 + * DisqusJS | v1.0.1 * Author: SukkaW * Link: https://github.com/SukkaW/DisqusJS * License: MIT - */"use strict";function DisqusJS(s){var n=function(s,e,n){var t=new XMLHttpRequest;t.open("GET",encodeURI(s),!0),t.onload=function(){if(200<=t.status&&t.status<300||304===t.status){var s=JSON.parse(t.responseText);e(s)}else i()},t.timeout=4500,t.ontimeout=function(s){n(s)},t.onerror=function(s){n(s)},t.send()},e=function(s,e){try{localStorage.setItem(s,e)}catch(s){}},c=function(s){s=Date.parse(new Date(s));var e=(s=new Date(s+288e5)).getFullYear(),n=s.getMonth()+1;n=n<10?"0".concat(n):n;var t=s.getDate();t=t<10?"0".concat(t):t;var a=s.getHours();a=a<10?"0".concat(a):a;var o=s.getMinutes();return o=o<10?"0".concat(o):o,"".concat(e,"-").concat(n,"-").concat(t," ").concat(a,":").concat(o)};function t(){var s=document,e=s.createElement("script");s.getElementById("disqus_thread").innerHTML='
评论完整模式加载中...如果长时间无法加载,请针对 disq.us | disquscdn.com | disqus.com 启用代理,或使用 评论基础模式
',s.getElementById("dsqjs-force-dsqjs").addEventListener("click",r),e.src="https://"+m.config.shortname+".disqus.com/embed.js",e.setAttribute("data-timestamp",+new Date),(s.head||s.body).appendChild(e)}function d(){for(var s=["disqus.com","".concat(m.config.shortname,".disqus.com")],t=0,a=0,o=function(){s.length===t&&t===a?l():s.length===t&&r()},e=0;e
    加载更多评论
    ',s.getElementById("dsqjs-msg").innerHTML='评论基础模式加载中。如需完整体验请针对 disq.us | disquscdn.com | disqus.com 启用代理并 尝试完整 Disqus 模式 | 强制完整 Disqus 模式。',s.getElementById("dsqjs-reload-disqus").addEventListener("click",d),s.getElementById("dsqjs-force-disqus").addEventListener("click",l);var e="".concat(m.config.api,"3.0/threads/list.json?forum=").concat(m.config.shortname,"&thread=ident:").concat(m.config.identifier,"&api_key=").concat(m.config.apikey);n(e,function(s){var e=document;if(0===s.code&&1===s.response.length){var n=s.response[0];m.page={id:n.id,title:n.title,isClosed:n.isClosed,length:n.posts},e.getElementById("dsqjs-comment-num").innerHTML=m.page.length,m.config.siteName&&(e.getElementById("dsqjs-site-name").innerHTML=m.config.siteName),t()}else 0===s.code&&1!==s.response.length?(e.getElementById("dsqjs-msg").innerHTML='该 Thread 并没有初始化,是否 切换到完整 Disqus 模式 进行初始化?',e.getElementById("dsqjs-force-disqus").addEventListener("click",l)):i()},function(s){i()})}();var t=function t(s){s=s?"&cursor=".concat(s):"";var e="".concat(m.config.api,"3.0/posts/list.json?forum=").concat(m.config.shortname,"&thread=").concat(m.page.id).concat(s,"&api_key=").concat(m.config.apikey);n(e,function(s){if(0===s.code&&0尝试完整 Disqus 模式 | 强制完整 Disqus 模式。',n.getElementById("dsqjs-header").classList.remove("dsqjs-hide"),n.getElementById("dsqjs-post-container").innerHTML='
    这里冷冷清清的,一条评论都没有
    '}else i()},function(s){i()})},a=function(s){var e=[],o=[];return s.forEach(function(s){(s.parent?o:e).push(s)}),e.map(function(s){return{comment:s,author:s.author.name,isPrimary:!!m.config.admin&&s.author.username===m.config.admin,children:function s(e){if(0===o.length)return null;for(var n=[],t=0;t'),s.comment.authorEl='")):(s.comment.avatarEl=''),s.comment.authorEl='")),m.config.adminLabel&&s.isPrimary&&(s.comment.authorEl+=''.concat(m.config.adminLabel,"")),s},i=function(s){var e,n,t;return'
    '.concat(s.avatarEl,'
    ').concat(s.authorEl,'
    ').concat((e=s.message,n=new RegExp(//gi),t=new RegExp(/href=\"(.+?)\"/gi),(e.match(n)||[]).map(function(s){s=s.match(t)[0].replace(/href=\"https:\/\/disq.us\/url\?url=/g,"").replace(/(.*)"/,"$1"),s=decodeURIComponent(s).replace(/(.*):(.*)/,"$1"),e=e.replace(n,'').concat(s,""))}),e.replace(/href=/g,'target="_blank" href=')),"
    ")},e="";(s=a(s)).map(function(s){s.children&&(s.nesting=1),s=o(s),e+='
  • ').concat(i(s.comment)).concat(function e(s){var n=s.nesting,t=s.children||[];if(t){var a=n<4?'
      ':'
        ';return a+=t.map(function(s){return(s=o(s)).nesting=n+1,'
      • ').concat(i(s.comment)).concat(e(s),"
      • ")}),0!==(a+="
      ").length?a:void 0}}(s),"")});var n=document;n.getElementById("dsqjs-header").classList.remove("dsqjs-hide"),n.getElementById("dsqjs-msg").innerHTML='你可能无法访问 Disqus,已启用评论基础模式。如需完整体验请针对 disq.us | disquscdn.com | disqus.com 启用代理并 尝试完整 Disqus 模式 | 强制完整 Disqus 模式。',n.getElementById("dsqjs-post-container").insertAdjacentHTML("beforeend",e),n.getElementById("dsqjs-reload-disqus").addEventListener("click",d),n.getElementById("dsqjs-force-disqus").addEventListener("click",l)}}function i(){var s=document;s.getElementById("dsqjs-msg").innerHTML='评论基础模式加载失败,是否 重载尝试完整 Disqus 模式 ?',s.getElementById("dsqjs-reload-dsqjs").addEventListener("click",a),s.getElementById("dsqjs-reload-disqus").addEventListener("click",d)}function r(){e("dsqjs_mode","dsqjs"),a()}function l(){e("dsqjs_mode","disqus"),t()}var o,m=[];m.config=s,m.config.api=m.config.api||"https://disqus.skk.moe/disqus/",m.config.identifier=m.config.identifier||document.location.origin+document.location.pathname+document.location.search,m.config.url=m.config.url||document.location.origin+document.location.pathname+document.location.search,m.page=[],window.disqus_config=function(){this.page.url=m.config.url,this.page.identifier=m.config.identifier},m.mode=(o="dsqjs_mode",localStorage.getItem(o)),"disqus"===m.mode?t():"dsqjs"===m.mode?a():d()} \ No newline at end of file + */"use strict";function DisqusJS(s){var n=function(s,e,n){var t=new XMLHttpRequest;t.open("GET",encodeURI(s),!0),t.onload=function(){if(200<=t.status&&t.status<300||304===t.status){var s=JSON.parse(t.responseText);e(s)}else i()},t.timeout=4500,t.ontimeout=function(s){n(s)},t.onerror=function(s){n(s)},t.send()},e=function(s,e){try{localStorage.setItem(s,e)}catch(s){}},c=function(s){s=Date.parse(new Date(s));var e=(s=new Date(s+288e5)).getFullYear(),n=s.getMonth()+1;n=n<10?"0".concat(n):n;var t=s.getDate();t=t<10?"0".concat(t):t;var a=s.getHours();a=a<10?"0".concat(a):a;var o=s.getMinutes();return o=o<10?"0".concat(o):o,"".concat(e,"-").concat(n,"-").concat(t," ").concat(a,":").concat(o)};function t(){var s=document,e=s.createElement("script");s.getElementById("disqus_thread").innerHTML='
      评论完整模式加载中...如果长时间无法加载,请针对 disq.us | disquscdn.com | disqus.com 启用代理,或使用 评论基础模式
      ',s.getElementById("dsqjs-force-dsqjs").addEventListener("click",r),e.src="https://"+m.config.shortname+".disqus.com/embed.js",e.setAttribute("data-timestamp",+new Date),(s.head||s.body).appendChild(e)}function d(){for(var s=["disqus.com","".concat(m.config.shortname,".disqus.com")],t=0,a=0,o=function(){s.length===t&&t===a?l():s.length===t&&r()},e=0;e
        加载更多评论
        ',s.getElementById("dsqjs-msg").innerHTML='评论基础模式加载中。如需完整体验请针对 disq.us | disquscdn.com | disqus.com 启用代理并 尝试完整 Disqus 模式 | 强制完整 Disqus 模式。',s.getElementById("dsqjs-reload-disqus").addEventListener("click",d),s.getElementById("dsqjs-force-disqus").addEventListener("click",l);var e="".concat(m.config.api,"3.0/threads/list.json?forum=").concat(m.config.shortname,"&thread=ident:").concat(m.config.identifier,"&api_key=").concat(m.config.apikey);n(e,function(s){var e=document;if(0===s.code&&1===s.response.length){var n=s.response[0];m.page={id:n.id,title:n.title,isClosed:n.isClosed,length:n.posts},e.getElementById("dsqjs-comment-num").innerHTML=m.page.length,m.config.siteName&&(e.getElementById("dsqjs-site-name").innerHTML=m.config.siteName),t()}else 0===s.code&&1!==s.response.length?(e.getElementById("dsqjs-msg").innerHTML='该 Thread 并没有初始化,是否 切换到完整 Disqus 模式 进行初始化?',e.getElementById("dsqjs-force-disqus").addEventListener("click",l)):i()},function(s){i()})}();var t=function t(s){s=s?"&cursor=".concat(s):"";var e="".concat(m.config.api,"3.0/posts/list.json?forum=").concat(m.config.shortname,"&thread=").concat(m.page.id).concat(s,"&api_key=").concat(m.config.apikey);n(e,function(s){if(0===s.code&&0尝试完整 Disqus 模式 | 强制完整 Disqus 模式。',n.getElementById("dsqjs-header").classList.remove("dsqjs-hide"),n.getElementById("dsqjs-post-container").innerHTML='
        这里冷冷清清的,一条评论都没有
        ',n.getElementById("dsqjs-reload-disqus").addEventListener("click",d),n.getElementById("dsqjs-force-disqus").addEventListener("click",l)}else i()},function(s){i()})},a=function(s){var e=[],o=[];return s.forEach(function(s){(s.parent?o:e).push(s)}),e.map(function(s){return{comment:s,author:s.author.name,isPrimary:!!m.config.admin&&s.author.username===m.config.admin,children:function s(e){if(0===o.length)return null;for(var n=[],t=0;t'),s.comment.authorEl='")):(s.comment.avatarEl=''),s.comment.authorEl='")),m.config.adminLabel&&s.isPrimary&&(s.comment.authorEl+=''.concat(m.config.adminLabel,"")),s},i=function(s){var e,n,t;return'
        '.concat(s.avatarEl,'
        ').concat(s.authorEl,'
        ').concat((e=s.message,n=new RegExp(//gi),t=new RegExp(/href=\"(.+?)\"/gi),(e.match(n)||[]).map(function(s){s=s.match(t)[0].replace(/href=\"https:\/\/disq.us\/url\?url=/g,"").replace(/(.*)"/,"$1"),s=decodeURIComponent(s).replace(/(.*):(.*)/,"$1"),e=e.replace(n,'').concat(s,""))}),e.replace(/href=/g,'target="_blank" href=')),"
        ")},e="";(s=a(s)).map(function(s){s.children&&(s.nesting=1),s=o(s),e+='
      • ').concat(i(s.comment)).concat(function e(s){var n=s.nesting,t=s.children||[];if(t){var a=n<4?'
          ':'
            ';return a+=t.map(function(s){return(s=o(s)).nesting=n+1,'
          • ').concat(i(s.comment)).concat(e(s),"
          • ")}),0!==(a+="
          ").length?a:void 0}}(s),"")});var n=document;n.getElementById("dsqjs-header").classList.remove("dsqjs-hide"),n.getElementById("dsqjs-msg").innerHTML='你可能无法访问 Disqus,已启用评论基础模式。如需完整体验请针对 disq.us | disquscdn.com | disqus.com 启用代理并 尝试完整 Disqus 模式 | 强制完整 Disqus 模式。',n.getElementById("dsqjs-post-container").insertAdjacentHTML("beforeend",e),n.getElementById("dsqjs-reload-disqus").addEventListener("click",d),n.getElementById("dsqjs-force-disqus").addEventListener("click",l)}}function i(){var s=document;s.getElementById("dsqjs-msg").innerHTML='评论基础模式加载失败,是否 重载尝试完整 Disqus 模式 ?',s.getElementById("dsqjs-reload-dsqjs").addEventListener("click",a),s.getElementById("dsqjs-reload-disqus").addEventListener("click",d)}function r(){e("dsqjs_mode","dsqjs"),a()}function l(){e("dsqjs_mode","disqus"),t()}var o,m=[];m.config=s,m.config.api=m.config.api||"https://disqus.skk.moe/disqus/",m.config.identifier=m.config.identifier||document.location.origin+document.location.pathname+document.location.search,m.config.url=m.config.url||document.location.origin+document.location.pathname+document.location.search,m.page=[],window.disqus_config=function(){this.page.url=m.config.url,this.page.identifier=m.config.identifier},m.mode=(o="dsqjs_mode",localStorage.getItem(o)),"disqus"===m.mode?t():"dsqjs"===m.mode?a():d()} \ No newline at end of file diff --git a/dist/disqusjs.css b/dist/disqusjs.css index 2207213..1c6d502 100644 --- a/dist/disqusjs.css +++ b/dist/disqusjs.css @@ -1,5 +1,5 @@ /*! - * DisqusJS - Default Theme | v1.0.0 + * DisqusJS - Default Theme | v1.0.1 * Author: SukkaW * Link: https://github.com/SukkaW/DisqusJS * License: MIT diff --git a/docs/index.html b/docs/index.html index ef05888..0f3ec36 100644 --- a/docs/index.html +++ b/docs/index.html @@ -11,7 +11,7 @@ - +