chore: enable babel loose

renovate/pin-dependencies
SukkaW 6 years ago
parent 0bf5b7ed6f
commit 81d486ac8b

@ -39,7 +39,8 @@ gulp.task('minify-js', () => gulp.src('src/**/*.js')
.pipe(babel({ .pipe(babel({
"presets": [ "presets": [
["@babel/env", { ["@babel/env", {
"targets": configs.browsers "targets": configs.browsers,
"loose": true
}] }]
] ]
})) }))

@ -1,4 +1,4 @@
/* /**
* The variable used in DisqusJS * The variable used in DisqusJS
* *
* DisqusJS Mode * DisqusJS Mode
@ -13,6 +13,8 @@
* @param {string} disqusjs.config.url - The url of the page * @param {string} disqusjs.config.url - The url of the page
* @param {string} disqusjs.config.api - Where to get data * @param {string} disqusjs.config.api - Where to get data
* @param {string} disqusjs.config.apikey - The apikey used to request Disqus API * @param {string} disqusjs.config.apikey - The apikey used to request Disqus API
* @param {number} disqusjs.config.nesting - The max nesting level of Disqus comment
* @param {string} disqusjs.config.nocomment - The msg when there is no comment
* @param {string} disqusjs.config.admin - The disqus forum admin username * @param {string} disqusjs.config.admin - The disqus forum admin username
* @param {string} disqusjs.config.adminLabel - The disqus moderator badge text * @param {string} disqusjs.config.adminLabel - The disqus moderator badge text
* *
@ -290,7 +292,7 @@ function DisqusJS(config) {
// 获取评论列表 // 获取评论列表
getComment() getComment()
} else if (code === 0 && response.length !== 1) { } else if (data.code === 0 && data.response.length !== 1) {
// 当前页面可能还未初始化(需要创建 thread // 当前页面可能还未初始化(需要创建 thread
// Disqus API 的 threads/create 需要在服务端发起请求,不支持 AJAX Call // Disqus API 的 threads/create 需要在服务端发起请求,不支持 AJAX Call
msg('该 Thread 并没有初始化,是否切换至 <a id="dsqjs-force-disqus" class="dsqjs-msg-btn">完整 Disqus 模式</a> 进行初始化?') msg('该 Thread 并没有初始化,是否切换至 <a id="dsqjs-force-disqus" class="dsqjs-msg-btn">完整 Disqus 模式</a> 进行初始化?')
@ -441,13 +443,13 @@ function DisqusJS(config) {
} else if (data.code === 0 && data.response.length === 0) { } else if (data.code === 0 && data.response.length === 0) {
// 当前没有评论,显示提示信息 // 当前没有评论,显示提示信息
msg(`你可能无法访问 Disqus已启用评论基础模式。${htmlTpl.askForFull}`) msg(`你可能无法访问 Disqus已启用评论基础模式。${htmlTpl.askForFull}`)
$$('dsqjs-post-container').innerHTML = '<p class="dsqjs-no-comment" >这里冷冷清清的,一条评论都没有</p>' $$('dsqjs-post-container').innerHTML = `<p class="dsqjs-no-comment" >${disqusjs.config.nocomment}</p>`
$$('dsqjs-reload-disqus').addEventListener('click', checkDisqus); $$('dsqjs-reload-disqus').addEventListener('click', checkDisqus);
$$('dsqjs-force-disqus').addEventListener('click', useDsqjs); $$('dsqjs-force-disqus').addEventListener('click', useDsqjs);
} else { } else {
throw new Error; throw new Error;
} }
}).catch(getCommentError) }).catch(getCommentError);
} }
/* /*
@ -550,9 +552,9 @@ function DisqusJS(config) {
const removeDisqUs = (msg) => { const removeDisqUs = (msg) => {
const el = document.createElement('div'); const el = document.createElement('div');
el.innerHTML = msg; el.innerHTML = msg;
const aTag = div.getElementsByTagName('a'); const aTag = el.getElementsByTagName('a');
for (const i of aTag) { for (const i of aTag) {
const link = decodeURIComponent(a.href.replace(/https:\/\/disq.us\/url\?url=/g, '')).replace(/(.*):.+cuid=.*/, '$1'); const link = decodeURIComponent(i.href.replace(/https:\/\/disq.us\/url\?url=/g, '')).replace(/(.*):.+cuid=.*/, '$1');
i.href = link; i.href = link;
i.innerHTML = link; i.innerHTML = link;
@ -648,7 +650,8 @@ function DisqusJS(config) {
/* /*
* loadError() - 评论基础模式加载出现错误 * loadError() - 评论基础模式加载出现错误
*/ */
function loadError() { function loadError(err) {
console.log(err);
msg('评论基础模式加载失败,是否 <a id="dsqjs-reload-dsqjs" class="dsqjs-msg-btn">重载</a> 或 <a id="dsqjs-reload-disqus" class="dsqjs-msg-btn">尝试完整 Disqus 模式</a> ') msg('评论基础模式加载失败,是否 <a id="dsqjs-reload-dsqjs" class="dsqjs-msg-btn">重载</a> 或 <a id="dsqjs-reload-disqus" class="dsqjs-msg-btn">尝试完整 Disqus 模式</a> ')
$$('dsqjs-reload-dsqjs').addEventListener('click', loadDsqjs); $$('dsqjs-reload-dsqjs').addEventListener('click', loadDsqjs);
$$('dsqjs-reload-disqus').addEventListener('click', checkDisqus); $$('dsqjs-reload-disqus').addEventListener('click', checkDisqus);
@ -676,7 +679,8 @@ function DisqusJS(config) {
url: document.location.origin + document.location.pathname + document.location.search, url: document.location.origin + document.location.pathname + document.location.search,
title: document.title, title: document.title,
siteName: '', siteName: '',
nesting: parseInt(config.nesting) || 4 nesting: parseInt(config.nesting) || 4,
nocomment: '这里冷冷清清的,一条评论都没有'
}, config); }, config);
// 定义 disqusjs.page之后会填充 thread id、title 等数据 // 定义 disqusjs.page之后会填充 thread id、title 等数据

@ -73,7 +73,7 @@
float: left; float: left;
text-transform: capitalize; text-transform: capitalize;
font-size: 15px; font-size: 15px;
padding: 12px 0; padding: 12px 8px;
color: #656c7a; color: #656c7a;
display: block; display: block;
margin: 0 15px 0 0; margin: 0 15px 0 0;

Loading…
Cancel
Save