From c5fa6ee34791e08308a3a91f790c77d54b68010b Mon Sep 17 00:00:00 2001 From: SukkaW Date: Mon, 8 Oct 2018 22:22:33 +0800 Subject: [PATCH] feat: add disqusjs footer --- dist/disqus.js | 2 +- dist/disqusjs.css | 2 +- src/disqus.js | 11 +++++++++-- src/disqusjs.css | 17 ++++++++++++++++- 4 files changed, 27 insertions(+), 5 deletions(-) diff --git a/dist/disqus.js b/dist/disqus.js index dee93ae..3da654f 100644 --- a/dist/disqus.js +++ b/dist/disqus.js @@ -6,4 +6,4 @@ * 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 +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 diff --git a/dist/disqusjs.css b/dist/disqusjs.css index bb332f7..d97ab77 100644 --- a/dist/disqusjs.css +++ b/dist/disqusjs.css @@ -3,4 +3,4 @@ * Author: SukkaW * Link: https://github.com/SukkaW/DisqusJS * License: GPL-3.0 - */#dsqjs>*{margin:0;padding:0}#dsqjs .dsqjs-container *{margin:0;padding:0}#dsqjs .dsqjs-container{margin:20px 0 0}#dsqjs ul.dsqjs-list{list-style:none;list-style-type:none}#dsqjs .dsqjs-item-container{position:relative;margin-bottom:24px;-webkit-transition:all .2s ease-in-out;transition:all .2s ease-in-out}#dsqjs .dsqjs-item-container:after,#dsqjs .dsqjs-item-container:before{display:table;content:"";line-height:0;clear:both}#dsqjs .dsqjs-avater{margin-right:12px;float:left;position:relative;z-index:100;padding:0}#dsqjs a{text-decoration:none;color:#076dd0}#dsqjs .dsqjs-avater img{width:42px;height:42px;display:block;border-radius:4px}#dsqjs .dsqjs-body{overflow:hidden}#dsqjs .dsqjs-header{line-height:1;font-size:13px}#dsqjs .dsqjs-bullet{line-height:1.4;margin:0 4px}#dsqjs .dsqjs-bullet::after{color:#c2c6cc;content:"•"}#dsqjs .dsqjs-author{line-height:1;color:#2479cc;font-weight:700}#dsqjs .dsqjs-author .dsqjs-admin-badge{color:#fff;background:#687a86;padding:1px 3px;margin-left:4px;font-size:12px;line-height:1.1;font-weight:700;border-radius:3px;display:inline-block;position:relative;top:-1px;left:1px}#dsqjs .dsqjs-meta{font-size:12px;color:#656c7a}#dsqjs .dsqjs-content p:last-child{margin:0}#dsqjs .dsqjs-content p{font-size:15px;line-height:21px;margin:0 0 12px;word-wrap:break-word}#dsqjs .dsqjs-children>.dsqjs-item{margin-left:60px}#dsqjs .dsqjs-children .dsqjs-avater img{width:38px;height:38px}#dsqjs .dsqjs-message{text-align:center;margin-top:4px;margin-bottom:4px;font-size:14px}#dsqjs .dsqjs-no-comment{text-align:center;margin-top:8px;margin-bottom:4px;font-size:18px;font-weight:700}#dsqjs .dsqjs-message a{margin-left:2px;margin-right:2px}.dsqjs-hide{display:none!important} \ No newline at end of file + */#dsqjs>*{margin:0;padding:0}#dsqjs .dsqjs-container *{margin:0;padding:0}#dsqjs .dsqjs-container{margin:20px 0 0}#dsqjs ul.dsqjs-list{list-style:none;list-style-type:none}#dsqjs .dsqjs-item-container{position:relative;margin-bottom:24px;-webkit-transition:all .2s ease-in-out;transition:all .2s ease-in-out}#dsqjs .dsqjs-item-container:after,#dsqjs .dsqjs-item-container:before{display:table;content:"";line-height:0;clear:both}#dsqjs .dsqjs-avater{margin-right:12px;float:left;position:relative;z-index:100;padding:0}#dsqjs a{text-decoration:none;color:#076dd0}#dsqjs .dsqjs-avater img{width:42px;height:42px;display:block;border-radius:4px}#dsqjs .dsqjs-body{overflow:hidden}#dsqjs .dsqjs-header{line-height:1;font-size:13px}#dsqjs .dsqjs-bullet{line-height:1.4;margin:0 4px}#dsqjs .dsqjs-bullet::after{color:#c2c6cc;content:"•"}#dsqjs .dsqjs-author{line-height:1;color:#2479cc;font-weight:700}#dsqjs .dsqjs-author .dsqjs-admin-badge{color:#fff;background:#687a86;padding:1px 3px;margin-left:4px;font-size:12px;line-height:1.1;font-weight:700;border-radius:3px;display:inline-block;position:relative;top:-1px;left:1px}#dsqjs .dsqjs-meta{font-size:12px;color:#656c7a}#dsqjs .dsqjs-content p:last-child{margin:0}#dsqjs .dsqjs-content p{font-size:15px;line-height:21px;margin:0 0 12px;word-wrap:break-word}#dsqjs .dsqjs-children>.dsqjs-item{margin-left:60px}#dsqjs .dsqjs-children .dsqjs-avater img{width:38px;height:38px}#dsqjs .dsqjs-message{text-align:center;margin-top:4px;margin-bottom:4px;font-size:14px}#dsqjs .dsqjs-no-comment{text-align:center;margin-top:8px;margin-bottom:4px;font-size:18px;font-weight:700}#dsqjs .dsqjs-message a{margin-left:2px;margin-right:2px}.dsqjs-hide{display:none!important}#dsqjs .dsqjs-footer{width:100%;font-weight:700;font-size:14px;color:#555;opacity:.9}#dsqjs .dsqjs-footer .dsqjs-footer-right{text-align:right;float:right;line-height:1.5;padding-right:6px} \ No newline at end of file diff --git a/src/disqus.js b/src/disqus.js index 090d1e7..aeeebb9 100644 --- a/src/disqus.js +++ b/src/disqus.js @@ -614,10 +614,17 @@

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

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

            -
              +
              +
                + +
                */ - var disqusjsBaseTpl = `

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

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

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

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

                  `; + var disqusjsBaseTpl = `

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

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

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

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

                    `; document.getElementById('disqus_thread').innerHTML = disqusjsBaseTpl; disqusjs.mode = getLS('disqusjs_mode'); diff --git a/src/disqusjs.css b/src/disqusjs.css index 8984e3a..8803ed7 100644 --- a/src/disqusjs.css +++ b/src/disqusjs.css @@ -5,7 +5,7 @@ * License: GPL-3.0 */ -#dsqjs > * { +#dsqjs>* { margin: 0; padding: 0; } @@ -145,4 +145,19 @@ .dsqjs-hide { display: none !important; +} + +#dsqjs .dsqjs-footer { + width: 100%; + font-weight: 700; + font-size: 14px; + color: #555; + opacity: .9; +} + +#dsqjs .dsqjs-footer .dsqjs-footer-right { + text-align: right; + float: right; + line-height: 1.5; + padding-right: 6px; } \ No newline at end of file