diff --git a/dist/disqus.js b/dist/disqus.js new file mode 100644 index 0000000..33c7f25 --- /dev/null +++ b/dist/disqus.js @@ -0,0 +1,9 @@ +"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(o){var e="undefined"==typeof module?o.baidu=o.baidu||{}:module.exports;e.template=function(s,e){var t=function(){if(!o.document)return r._compile(s);var e=document.getElementById(s);if(e){if(r.cache[s])return r.cache[s];var t=/^(textarea|input)$/i.test(e.nodeName)?e.value:e.innerHTML;return r._compile(t)}return r._compile(s)}(),n=r._isObject(e)?t(e):t;return t=null,n};var r=e.template;r.versions=r.versions||[],r.versions.push("1.0.6"),r.cache={},r.LEFT_DELIMITER=r.LEFT_DELIMITER||"<%",r.RIGHT_DELIMITER=r.RIGHT_DELIMITER||"%>",r.ESCAPE=!0,r._encodeHTML=function(e){return String(e).replace(/&/g,"&").replace(//g,">").replace(/\\/g,"\").replace(/"/g,""").replace(/'/g,"'")},r._encodeReg=function(e){return String(e).replace(/([.*+?^=!:${}()|[\]/\\])/g,"\\$1")},r._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")},r._compile=function(e){var t="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('"+r._analysisStr(e)+"');\n_template_varName=null;\n})(_template_object);\nfn = null;\nreturn _template_fun_array.join('');\n";return new Function("_template_object",t)},r._isObject=function(e){return"function"==typeof e||!(!e||"object"!==_typeof(e))},r._analysisStr=function(e){var t=r.LEFT_DELIMITER,s=r.RIGHT_DELIMITER,n=r._encodeReg(t),o=r._encodeReg(s);return e=(e=String(e).replace(new RegExp("("+n+"[^"+o+"]*)//.*\n","g"),"$1").replace(new RegExp("\x3c!--.*?--\x3e","g"),"").replace(new RegExp(n+"\\*.*?\\*"+o,"g"),"").replace(new RegExp("[\\r\\t\\n]","g"),"").replace(new RegExp(n+"(?:(?!"+o+")[\\s\\S])*"+o+"|((?:(?!"+n+")[\\s\\S])+)","g"),function(e,t){var s="";if(t)for(s=t.replace(/\\/g,"\").replace(/'/g,"'");/<[^<]*?'[^<]*?>/g.test(s);)s=s.replace(/(<[^<]*?)'([^<]*?>)/g,"$1\r$2");else s=e;return s})).replace(new RegExp("("+n+"[\\s]*?var[\\s]*?.*?[\\s]*?[^;])[\\s]*?"+o,"g"),"$1;"+s).replace(new RegExp("("+n+":?[hvu]?[\\s]*?=[\\s]*?[^;|"+o+"]*?);[\\s]*?"+o,"g"),"$1"+s).split(t).join("\t"),e=(e=r.ESCAPE?e.replace(new RegExp("\\t=(.*?)"+o,"g"),"',typeof($1) === 'undefined'?'':baidu.template._encodeHTML($1),'"):e.replace(new RegExp("\\t=(.*?)"+o,"g"),"',typeof($1) === 'undefined'?'':$1,'")).replace(new RegExp("\\t:h=(.*?)"+o,"g"),"',typeof($1) === 'undefined'?'':baidu.template._encodeHTML($1),'").replace(new RegExp("\\t(?::=|-)(.*?)"+o,"g"),"',typeof($1)==='undefined'?'':$1,'").replace(new RegExp("\\t:u=(.*?)"+o,"g"),"',typeof($1)==='undefined'?'':encodeURIComponent($1),'").replace(new RegExp("\\t:v=(.*?)"+o,"g"),"',typeof($1)==='undefined'?'':baidu.template._encodeEventHTML($1),'").split("\t").join("');").split(s).join("_template_fun_array.push('").split("\r").join("\\'")}}(window), +/*! + * DisqusJS | v0.1.0 + * Author: SukkaW + * Link: https://github.com/SukkaW/DisqusJS + * License: GPL-3.0 + */ +disqusjs.page=[],window.disqus_config=function(){this.page.url=disqusjs.config.url,this.page.identifier=disqusjs.config.identifier};var xhr=new XMLHttpRequest;setLS=function(e,t){try{localStorage.setItem(e,t)}catch(e){console.log(e),console.log("Failed to set localStorage item")}},getLS=function(e){return localStorage.getItem(e)},Date.prototype.Format=function(e){var t={"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 s in/(y+)/.test(e)&&(e=e.replace(RegExp.$1,(this.getFullYear()+"").substr(4-RegExp.$1.length))),t)new RegExp("("+s+")").test(e)&&(e=e.replace(RegExp.$1,1==RegExp.$1.length?t[s]:("00"+t[s]).substr((""+t[s]).length)));return e},loadDisqus=function(){var e=document;e.getElementById("dsqjs-load-disqus").classList.remove("dsqjs-hide"),e.getElementById("dsqjs-force-dsqjs").addEventListener("click",forceDsqjs);var t=e.createElement("script");t.src="https://"+disqusjs.config.shortname+".disqus.com/embed.js",t.setAttribute("data-timestamp",+new Date),(e.head||e.body).appendChild(t)},checkDisqus=function(){var t=new Image,s=setTimeout(function(){t.onerror=t.onload=null,setLS("disqusjs_mode","dsqjs")},2e3);t.onerror=function(){clearTimeout(s),setLS("disqusjs_mode","dsqjs"),main()},t.onload=function(){clearTimeout(s);var e=setTimeout(function(){t.onerror=t.onload=null,setLS("disqusjs_mode","dsqjs")},2e3);t.onerror=function(){clearTimeout(e),setLS("disqusjs_mode","dsqjs"),main()},t.onload=function(){clearTimeout(e),setLS("disqusjs_mode","disqus"),main()},t.src="https://"+disqusjs.config.shortname+".disqus.com/favicon.ico?"+ +new Date},t.src="https://disqus.com/favicon.ico?"+ +new Date},forceDsqjs=function(){setLS("disqusjs_mode","dsqjs"),main()},forceDisqus=function(){setLS("disqusjs_mode","disqus"),main()},loadError=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",getThreadInfo)},getThreadInfo=function(){document.getElementById("dsqjs-loading-dsqjs").classList.remove("dsqjs-hide"),document.getElementById("dsqjs-force-disqus").addEventListener("click",forceDisqus);var e=disqusjs.config.api+"3.0/threads/list.json?forum="+disqusjs.config.shortname+"&thread=ident:"+disqusjs.config.identifier+"&api_key="+disqusjs.config.apikey;xhr.open("GET",e,!0),xhr.timeout=4e3,xhr.send(),xhr.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},getComment()}},xhr.ontimeout=function(e){loadError()},xhr.onerror=function(e){loadError()}},getComment=function(){var e=disqusjs.config.api+"3.0/posts/list.json?forum="+disqusjs.config.shortname+"&thread="+disqusjs.page.id+"&api_key="+disqusjs.config.apikey;xhr.open("GET",e,!0),xhr.timeout=4e3,xhr.send(),xhr.onload=function(){if(200==this.status||304==this.status){var e=JSON.parse(this.responseText);0===e.code&&getCommentList(e.response)}},xhr.ontimeout=function(e){console.log(e)},xhr.onerror=function(e){console.log(e)}},getCommentList=function(e){var t=[],r=[];e.forEach(function(e){(e.parent?r:t).push(e)});var s=t.map(function(e){return{comment:e,author:e.author.name,isPrimary:e.author.username===disqusjs.config.admin,children:function e(t){if(0===r.length)return null;var s=[];for(var n=0;n'),t.authorEl='').concat(t.author.name,"")):(t.avatarEl=''),t.authorEl="".concat(t.author.name)),e.nesting=s+1,n+='
  • '),n+=baidu.template(o,t),n+="".concat(childrenComments(e),"
  • ")}),0!==(n+="").length?n:void 0}});var t=e.comment;t.author.profileUrl?(t.avatarEl=''),t.authorEl='').concat(t.author.name,"")):(t.avatarEl=''),t.authorEl="".concat(t.author.name)),e.children&&(e.nesting=1);var s='
  • ');s+=baidu.template(o,t),s+="".concat(childrenComments(e),"
  • "),document.getElementById("dsqjs-list").insertAdjacentHTML("beforeend",s)})},main=function(){document.getElementById("disqus_thread").innerHTML='

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

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

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

      ',disqusjs.mode=getLS("disqusjs_mode"),"disqus"===disqusjs.mode?loadDisqus():"dsqjs"===disqusjs.mode?getThreadInfo():checkDisqus()},main(); \ No newline at end of file diff --git a/dist/disqusjs.css b/dist/disqusjs.css new file mode 100644 index 0000000..2aafca7 --- /dev/null +++ b/dist/disqusjs.css @@ -0,0 +1,6 @@ +/*! + * DisqusJS - Default Theme | v0.1.0 + * Author: SukkaW + * Link: https://github.com/SukkaW/DisqusJS + * License: GPL-3.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-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-load-error{text-align:center;margin-top:4px;margin-bottom:4px}#dsqjs .dsqjs-load-error a{margin-left:2px;margin-right:2px}.dsqjs-hide{display:none!important} \ No newline at end of file