更新
This commit is contained in:
parent
6ca9359887
commit
d6b807f60d
@ -1,268 +1,326 @@
|
|||||||
document.addEventListener('DOMContentLoaded', () => {
|
/* 获取直属子元素 */
|
||||||
$('.joe_detail__article p:empty').remove();
|
function getChildren(el, className) {
|
||||||
|
for (let item of el.children) if (item.className === className) return item;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
/* OK */
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
class JoeMtitle extends HTMLElement {
|
$('.joe_detail__article p:empty').remove();
|
||||||
constructor() {
|
|
||||||
super();
|
/*
|
||||||
this.innerHTML = `
|
*
|
||||||
|
* OK
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class JoeMtitle extends HTMLElement {
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
this.innerHTML = `
|
||||||
<span class="joe_detail__article-mtitle">
|
<span class="joe_detail__article-mtitle">
|
||||||
<span class="text">
|
<span class="text">
|
||||||
${this.getAttribute('title') || '默认标题'}
|
${this.getAttribute('title') || '默认标题'}
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
window.customElements.define('joe-mtitle', JoeMtitle);
|
window.customElements.define('joe-mtitle', JoeMtitle);
|
||||||
|
|
||||||
/* OK */
|
/*
|
||||||
class JoeDplayer extends HTMLElement {
|
*
|
||||||
constructor() {
|
* OK
|
||||||
super();
|
*
|
||||||
this.options = {
|
*/
|
||||||
src: this.getAttribute('src'),
|
class JoeDplayer extends HTMLElement {
|
||||||
player: this.getAttribute('player')
|
constructor() {
|
||||||
};
|
super();
|
||||||
this.render();
|
this.options = {
|
||||||
}
|
src: this.getAttribute('src'),
|
||||||
render() {
|
player: this.getAttribute('player')
|
||||||
if (this.options.src) this.innerHTML = `<iframe allowfullscreen="true" class="joe_detail__article-player" src="${this.options.player + this.options.src}"></iframe>`;
|
};
|
||||||
else this.innerHTML = '播放地址未填写!';
|
this.render();
|
||||||
}
|
}
|
||||||
}
|
render() {
|
||||||
window.customElements.define('joe-dplayer', JoeDplayer);
|
if (this.options.src) this.innerHTML = `<iframe allowfullscreen="true" class="joe_detail__article-player" src="${this.options.player + this.options.src}"></iframe>`;
|
||||||
|
else this.innerHTML = '播放地址未填写!';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
window.customElements.define('joe-dplayer', JoeDplayer);
|
||||||
|
|
||||||
/* OK */
|
/*
|
||||||
class JoeBilibili extends HTMLElement {
|
*
|
||||||
constructor() {
|
* OK
|
||||||
super();
|
*
|
||||||
this.bvid = this.getAttribute('bvid');
|
*/
|
||||||
this.render();
|
class JoeBilibili extends HTMLElement {
|
||||||
}
|
constructor() {
|
||||||
render() {
|
super();
|
||||||
if (this.bvid) this.innerHTML = `<iframe allowfullscreen="true" class="joe_detail__article-player" src="//player.bilibili.com/player.html?bvid=${this.bvid}"></iframe>`;
|
this.bvid = this.getAttribute('bvid');
|
||||||
else this.innerHTML = 'Bvid未填写!';
|
this.render();
|
||||||
}
|
}
|
||||||
}
|
render() {
|
||||||
window.customElements.define('joe-bilibili', JoeBilibili);
|
if (this.bvid) this.innerHTML = `<iframe allowfullscreen="true" class="joe_detail__article-player" src="//player.bilibili.com/player.html?bvid=${this.bvid}"></iframe>`;
|
||||||
|
else this.innerHTML = 'Bvid未填写!';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
window.customElements.define('joe-bilibili', JoeBilibili);
|
||||||
|
|
||||||
/* OK */
|
/*
|
||||||
class JoeMp3 extends HTMLElement {
|
*
|
||||||
constructor() {
|
* OK
|
||||||
super();
|
*
|
||||||
this.options = {
|
*/
|
||||||
name: this.getAttribute('name'),
|
class JoeMp3 extends HTMLElement {
|
||||||
url: this.getAttribute('url'),
|
constructor() {
|
||||||
theme: this.getAttribute('theme') || '#1989fa',
|
super();
|
||||||
cover: this.getAttribute('cover'),
|
this.options = {
|
||||||
autoplay: this.getAttribute('autoplay') ? true : false
|
name: this.getAttribute('name'),
|
||||||
};
|
url: this.getAttribute('url'),
|
||||||
this.render();
|
theme: this.getAttribute('theme') || '#1989fa',
|
||||||
}
|
cover: this.getAttribute('cover'),
|
||||||
render() {
|
autoplay: this.getAttribute('autoplay') ? true : false
|
||||||
if (!this.options.url) return (this.innerHTML = '音频地址未填写!');
|
};
|
||||||
this.innerHTML = '<span style="display: block"></span>';
|
this.render();
|
||||||
new APlayer({
|
}
|
||||||
container: this.querySelector('span'),
|
render() {
|
||||||
theme: this.options.theme,
|
if (!this.options.url) return (this.innerHTML = '音频地址未填写!');
|
||||||
autoplay: this.options.autoplay,
|
this.innerHTML = '<span style="display: block" class="_content"></span>';
|
||||||
audio: [
|
new APlayer({
|
||||||
{
|
container: getChildren(this, '_content'),
|
||||||
url: this.options.url,
|
theme: this.options.theme,
|
||||||
name: this.options.name,
|
autoplay: this.options.autoplay,
|
||||||
cover: this.options.cover
|
audio: [
|
||||||
}
|
{
|
||||||
]
|
url: this.options.url,
|
||||||
});
|
name: this.options.name,
|
||||||
}
|
cover: this.options.cover
|
||||||
}
|
}
|
||||||
window.customElements.define('joe-mp3', JoeMp3);
|
]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
window.customElements.define('joe-mp3', JoeMp3);
|
||||||
|
|
||||||
/* OK */
|
/*
|
||||||
class JoeMusic extends HTMLElement {
|
*
|
||||||
constructor() {
|
* OK
|
||||||
super();
|
*
|
||||||
this.options = {
|
*/
|
||||||
id: this.getAttribute('id'),
|
class JoeMusic extends HTMLElement {
|
||||||
color: this.getAttribute('color') || '#1989fa',
|
constructor() {
|
||||||
autoplay: this.getAttribute('autoplay') ? true : false
|
super();
|
||||||
};
|
this.options = {
|
||||||
this.render();
|
id: this.getAttribute('id'),
|
||||||
}
|
color: this.getAttribute('color') || '#1989fa',
|
||||||
render() {
|
autoplay: this.getAttribute('autoplay') ? true : false
|
||||||
if (!this.options.id) return (this.innerHTML = '网易云歌曲ID未填写!');
|
};
|
||||||
this.innerHTML = '<span style="display: block"></span>';
|
this.render();
|
||||||
fetch('https://api.i-meto.com/meting/api?server=netease&type=song&id=' + this.options.id).then(async response => {
|
}
|
||||||
const audio = await response.json();
|
render() {
|
||||||
new APlayer({
|
if (!this.options.id) return (this.innerHTML = '网易云歌曲ID未填写!');
|
||||||
container: this.querySelector('span'),
|
this.innerHTML = '<span style="display: block" class="_content"></span>';
|
||||||
lrcType: 3,
|
fetch('https://api.i-meto.com/meting/api?server=netease&type=song&id=' + this.options.id).then(async response => {
|
||||||
theme: this.options.color,
|
const audio = await response.json();
|
||||||
autoplay: this.options.autoplay,
|
new APlayer({
|
||||||
audio
|
container: getChildren(this, '_content'),
|
||||||
});
|
lrcType: 3,
|
||||||
});
|
theme: this.options.color,
|
||||||
}
|
autoplay: this.options.autoplay,
|
||||||
}
|
audio
|
||||||
window.customElements.define('joe-music', JoeMusic);
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
window.customElements.define('joe-music', JoeMusic);
|
||||||
|
|
||||||
/* OK */
|
/*
|
||||||
class JoeMlist extends HTMLElement {
|
*
|
||||||
constructor() {
|
* OK
|
||||||
super();
|
*
|
||||||
this.options = {
|
*/
|
||||||
id: this.getAttribute('id'),
|
class JoeMlist extends HTMLElement {
|
||||||
color: this.getAttribute('color') || '#1989fa',
|
constructor() {
|
||||||
autoplay: this.getAttribute('autoplay') ? true : false
|
super();
|
||||||
};
|
this.options = {
|
||||||
this.render();
|
id: this.getAttribute('id'),
|
||||||
}
|
color: this.getAttribute('color') || '#1989fa',
|
||||||
render() {
|
autoplay: this.getAttribute('autoplay') ? true : false
|
||||||
if (!this.options.id) return (this.innerHTML = '网易云歌单ID未填写!');
|
};
|
||||||
this.innerHTML = '<span style="display: block"></span>';
|
this.render();
|
||||||
fetch('https://api.i-meto.com/meting/api?server=netease&type=playlist&id=' + this.options.id).then(async response => {
|
}
|
||||||
const audio = await response.json();
|
render() {
|
||||||
new APlayer({
|
if (!this.options.id) return (this.innerHTML = '网易云歌单ID未填写!');
|
||||||
container: this.querySelector('span'),
|
this.innerHTML = '<span style="display: block" class="_content"></span>';
|
||||||
lrcType: 3,
|
fetch('https://api.i-meto.com/meting/api?server=netease&type=playlist&id=' + this.options.id).then(async response => {
|
||||||
theme: this.options.color,
|
const audio = await response.json();
|
||||||
autoplay: this.options.autoplay,
|
new APlayer({
|
||||||
audio
|
container: getChildren(this, '_content'),
|
||||||
});
|
lrcType: 3,
|
||||||
});
|
theme: this.options.color,
|
||||||
}
|
autoplay: this.options.autoplay,
|
||||||
}
|
audio
|
||||||
window.customElements.define('joe-mlist', JoeMlist);
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
window.customElements.define('joe-mlist', JoeMlist);
|
||||||
|
|
||||||
/* OK */
|
/*
|
||||||
class JoeAbtn extends HTMLElement {
|
*
|
||||||
constructor() {
|
* OK
|
||||||
super();
|
*
|
||||||
this.options = {
|
*/
|
||||||
icon: this.getAttribute('icon') || '',
|
class JoeAbtn extends HTMLElement {
|
||||||
color: this.getAttribute('color') || '#ff6800',
|
constructor() {
|
||||||
href: this.getAttribute('href') || '#',
|
super();
|
||||||
radius: this.getAttribute('radius') || '17.5px',
|
this.options = {
|
||||||
content: this.getAttribute('content') || '多彩按钮'
|
icon: this.getAttribute('icon') || '',
|
||||||
};
|
color: this.getAttribute('color') || '#ff6800',
|
||||||
this.innerHTML = `
|
href: this.getAttribute('href') || '#',
|
||||||
|
radius: this.getAttribute('radius') || '17.5px',
|
||||||
|
content: this.getAttribute('content') || '多彩按钮'
|
||||||
|
};
|
||||||
|
this.innerHTML = `
|
||||||
<a class="joe_detail__article-abtn" style="background: ${this.options.color}; border-radius: ${this.options.radius}" href="${this.options.href}" target="_blank" rel="noopener noreferrer nofollow">
|
<a class="joe_detail__article-abtn" style="background: ${this.options.color}; border-radius: ${this.options.radius}" href="${this.options.href}" target="_blank" rel="noopener noreferrer nofollow">
|
||||||
<span class="icon"><i class="${this.options.icon} fa"></i></span><span class="content">${this.options.content}</span>
|
<span class="icon"><i class="${this.options.icon} fa"></i></span><span class="content">${this.options.content}</span>
|
||||||
</a>
|
</a>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
window.customElements.define('joe-abtn', JoeAbtn);
|
window.customElements.define('joe-abtn', JoeAbtn);
|
||||||
|
|
||||||
/* OK */
|
/*
|
||||||
class JoeAnote extends HTMLElement {
|
*
|
||||||
constructor() {
|
* OK
|
||||||
super();
|
*
|
||||||
this.options = {
|
*/
|
||||||
icon: this.getAttribute('icon') || 'fa-download',
|
class JoeAnote extends HTMLElement {
|
||||||
href: this.getAttribute('href') || '#',
|
constructor() {
|
||||||
type: /^secondary$|^success$|^warning$|^error$|^info$/.test(this.getAttribute('type')) ? this.getAttribute('type') : 'secondary',
|
super();
|
||||||
content: this.getAttribute('content') || '标签按钮'
|
this.options = {
|
||||||
};
|
icon: this.getAttribute('icon') || 'fa-download',
|
||||||
this.innerHTML = `
|
href: this.getAttribute('href') || '#',
|
||||||
|
type: /^secondary$|^success$|^warning$|^error$|^info$/.test(this.getAttribute('type')) ? this.getAttribute('type') : 'secondary',
|
||||||
|
content: this.getAttribute('content') || '标签按钮'
|
||||||
|
};
|
||||||
|
this.innerHTML = `
|
||||||
<a class="joe_detail__article-anote ${this.options.type}" href="${this.options.href}" target="_blank" rel="noopener noreferrer nofollow">
|
<a class="joe_detail__article-anote ${this.options.type}" href="${this.options.href}" target="_blank" rel="noopener noreferrer nofollow">
|
||||||
<span class="icon"><i class="fa ${this.options.icon}"></i></span><span class="content">${this.options.content}</span>
|
<span class="icon"><i class="fa ${this.options.icon}"></i></span><span class="content">${this.options.content}</span>
|
||||||
</a>
|
</a>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
window.customElements.define('joe-anote', JoeAnote);
|
window.customElements.define('joe-anote', JoeAnote);
|
||||||
|
|
||||||
/* OK */
|
/*
|
||||||
class JoeDotted extends HTMLElement {
|
*
|
||||||
constructor() {
|
* OK
|
||||||
super();
|
*
|
||||||
this.startColor = this.getAttribute('startColor') || '#ff6c6c';
|
*/
|
||||||
this.endColor = this.getAttribute('endColor') || '#1989fa';
|
class JoeDotted extends HTMLElement {
|
||||||
this.innerHTML = `
|
constructor() {
|
||||||
|
super();
|
||||||
|
this.startColor = this.getAttribute('startColor') || '#ff6c6c';
|
||||||
|
this.endColor = this.getAttribute('endColor') || '#1989fa';
|
||||||
|
this.innerHTML = `
|
||||||
<span class="joe_detail__article-dotted" style="background-image: repeating-linear-gradient(-45deg, ${this.startColor} 0, ${this.startColor} 20%, transparent 0, transparent 25%, ${this.endColor} 0, ${this.endColor} 45%, transparent 0, transparent 50%)"></span>
|
<span class="joe_detail__article-dotted" style="background-image: repeating-linear-gradient(-45deg, ${this.startColor} 0, ${this.startColor} 20%, transparent 0, transparent 25%, ${this.endColor} 0, ${this.endColor} 45%, transparent 0, transparent 50%)"></span>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
window.customElements.define('joe-dotted', JoeDotted);
|
window.customElements.define('joe-dotted', JoeDotted);
|
||||||
|
|
||||||
/* OK */
|
/*
|
||||||
class JoeHide extends HTMLElement {
|
*
|
||||||
constructor() {
|
* OK
|
||||||
super();
|
*
|
||||||
this.render();
|
*/
|
||||||
}
|
class JoeHide extends HTMLElement {
|
||||||
render() {
|
constructor() {
|
||||||
this.innerHTML = '<span class="joe_detail__article-hide">此处内容作者设置了 <i>回复</i> 可见</span>';
|
super();
|
||||||
this.$button = this.querySelector('i');
|
this.render();
|
||||||
const $comment = document.querySelector('.joe_comment');
|
}
|
||||||
const $header = document.querySelector('.joe_header');
|
render() {
|
||||||
if (!$comment || !$header) return;
|
this.innerHTML = '<span class="joe_detail__article-hide">此处内容作者设置了 <i>回复</i> 可见</span>';
|
||||||
this.$button.addEventListener('click', () => {
|
this.$button = this.querySelector('.joe_detail__article-hide > i');
|
||||||
const top = $comment.offsetTop - $header.offsetHeight - 15;
|
const $comment = document.querySelector('.joe_comment');
|
||||||
window.scrollTo({ top, behavior: 'smooth' });
|
const $header = document.querySelector('.joe_header');
|
||||||
});
|
if (!$comment || !$header) return;
|
||||||
}
|
this.$button.addEventListener('click', () => {
|
||||||
}
|
const top = $comment.offsetTop - $header.offsetHeight - 15;
|
||||||
window.customElements.define('joe-hide', JoeHide);
|
window.scrollTo({ top, behavior: 'smooth' });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
window.customElements.define('joe-hide', JoeHide);
|
||||||
|
|
||||||
/* OK */
|
/*
|
||||||
class JoeCardDefault extends HTMLElement {
|
*
|
||||||
constructor() {
|
* OK
|
||||||
super();
|
*
|
||||||
const _temp = this.querySelector('._temp');
|
*/
|
||||||
this.options = {
|
class JoeCardDefault extends HTMLElement {
|
||||||
width: this.getAttribute('width') || '100%',
|
constructor() {
|
||||||
label: this.getAttribute('label') || '卡片标题',
|
super();
|
||||||
content: _temp.innerHTML.trim().replace(/^(<br>)|(<br>)$/g, '') || '卡片内容'
|
const _temp = getChildren(this, '_temp');
|
||||||
};
|
this.options = {
|
||||||
const htmlStr = `
|
width: this.getAttribute('width') || '100%',
|
||||||
|
label: this.getAttribute('label') || '卡片标题',
|
||||||
|
content: _temp.innerHTML.trim().replace(/^(<br>)|(<br>)$/g, '') || '卡片内容'
|
||||||
|
};
|
||||||
|
const htmlStr = `
|
||||||
<div class="joe_detail__article-card_default" style="width: ${this.options.width}">
|
<div class="joe_detail__article-card_default" style="width: ${this.options.width}">
|
||||||
<div class="title">${this.options.label}</div>
|
<div class="title">${this.options.label}</div>
|
||||||
<div class="content">${this.options.content}</div>
|
<div class="content">${this.options.content}</div>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
if (this.querySelector('._content')) {
|
if (getChildren(this, '_content')) {
|
||||||
this.querySelector('._content').innerHTML = htmlStr;
|
getChildren(this, '_content').innerHTML = htmlStr;
|
||||||
} else {
|
} else {
|
||||||
const span = document.createElement('span');
|
const span = document.createElement('span');
|
||||||
span.style.display = 'block';
|
span.style.display = 'block';
|
||||||
span.className = '_content';
|
span.className = '_content';
|
||||||
span.innerHTML = htmlStr;
|
span.innerHTML = htmlStr;
|
||||||
this.appendChild(span);
|
this.appendChild(span);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
window.customElements.define('joe-card-default', JoeCardDefault);
|
window.customElements.define('joe-card-default', JoeCardDefault);
|
||||||
|
|
||||||
/* OK */
|
/*
|
||||||
class JoeMessage extends HTMLElement {
|
*
|
||||||
constructor() {
|
* OK
|
||||||
super();
|
*
|
||||||
this.options = {
|
*/
|
||||||
type: /^success$|^info$|^warning$|^error$/.test(this.getAttribute('type')) ? this.getAttribute('type') : 'info',
|
class JoeMessage extends HTMLElement {
|
||||||
content: this.getAttribute('content') || '消息内容'
|
constructor() {
|
||||||
};
|
super();
|
||||||
this.innerHTML = `
|
this.options = {
|
||||||
|
type: /^success$|^info$|^warning$|^error$/.test(this.getAttribute('type')) ? this.getAttribute('type') : 'info',
|
||||||
|
content: this.getAttribute('content') || '消息内容'
|
||||||
|
};
|
||||||
|
this.innerHTML = `
|
||||||
<span class="joe_detail__article-message ${this.options.type}">
|
<span class="joe_detail__article-message ${this.options.type}">
|
||||||
<span class="icon"></span>
|
<span class="icon"></span>
|
||||||
<span class="content">${this.options.content}</span>
|
<span class="content">${this.options.content}</span>
|
||||||
</span>
|
</span>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
window.customElements.define('joe-message', JoeMessage);
|
window.customElements.define('joe-message', JoeMessage);
|
||||||
|
|
||||||
/* OK */
|
/*
|
||||||
class JoeProgress extends HTMLElement {
|
*
|
||||||
constructor() {
|
* OK
|
||||||
super();
|
*
|
||||||
this.options = {
|
*/
|
||||||
percentage: /^\d{1,3}%$/.test(this.getAttribute('percentage')) ? this.getAttribute('percentage') : '50%',
|
class JoeProgress extends HTMLElement {
|
||||||
color: this.getAttribute('color') || '#ff6c6c'
|
constructor() {
|
||||||
};
|
super();
|
||||||
this.innerHTML = `
|
this.options = {
|
||||||
|
percentage: /^\d{1,3}%$/.test(this.getAttribute('percentage')) ? this.getAttribute('percentage') : '50%',
|
||||||
|
color: this.getAttribute('color') || '#ff6c6c'
|
||||||
|
};
|
||||||
|
this.innerHTML = `
|
||||||
<span class="joe_detail__article-progress">
|
<span class="joe_detail__article-progress">
|
||||||
<span class="strip">
|
<span class="strip">
|
||||||
<span class="percent" style="width: ${this.options.percentage}; background: ${this.options.color};"></span>
|
<span class="percent" style="width: ${this.options.percentage}; background: ${this.options.color};"></span>
|
||||||
@ -270,164 +328,181 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
<span class="percentage">${this.options.percentage}</span>
|
<span class="percentage">${this.options.percentage}</span>
|
||||||
</span>
|
</span>
|
||||||
`;
|
`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
window.customElements.define('joe-progress', JoeProgress);
|
window.customElements.define('joe-progress', JoeProgress);
|
||||||
|
|
||||||
/* OK */
|
/*
|
||||||
class JoeCallout extends HTMLElement {
|
*
|
||||||
constructor() {
|
* OK
|
||||||
super();
|
*
|
||||||
const _temp = this.querySelector('._temp');
|
*/
|
||||||
this.options = {
|
class JoeCallout extends HTMLElement {
|
||||||
color: this.getAttribute('color') || '#f0ad4e',
|
constructor() {
|
||||||
content: _temp.innerHTML.trim().replace(/^(<br>)|(<br>)$/g, '') || '标注内容'
|
super();
|
||||||
};
|
const _temp = getChildren(this, '_temp');
|
||||||
const htmlStr = `
|
this.options = {
|
||||||
|
color: this.getAttribute('color') || '#f0ad4e',
|
||||||
|
content: _temp.innerHTML.trim().replace(/^(<br>)|(<br>)$/g, '') || '标注内容'
|
||||||
|
};
|
||||||
|
const htmlStr = `
|
||||||
<div class="joe_detail__article-callout" style="border-left-color: ${this.options.color};">
|
<div class="joe_detail__article-callout" style="border-left-color: ${this.options.color};">
|
||||||
${this.options.content}
|
${this.options.content}
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
if (this.querySelector('._content')) {
|
if (getChildren(this, '_content')) {
|
||||||
this.querySelector('._content').innerHTML = htmlStr;
|
getChildren(this, '_content').innerHTML = htmlStr;
|
||||||
} else {
|
} else {
|
||||||
const span = document.createElement('span');
|
const span = document.createElement('span');
|
||||||
span.style.display = 'block';
|
span.style.display = 'block';
|
||||||
span.className = '_content';
|
span.className = '_content';
|
||||||
span.innerHTML = htmlStr;
|
span.innerHTML = htmlStr;
|
||||||
this.appendChild(span);
|
this.appendChild(span);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
window.customElements.define('joe-callout', JoeCallout);
|
window.customElements.define('joe-callout', JoeCallout);
|
||||||
|
|
||||||
/* OK */
|
/*
|
||||||
class JoeTabs extends HTMLElement {
|
*
|
||||||
constructor() {
|
* OK
|
||||||
super();
|
*
|
||||||
const _temp = this.querySelector('._temp');
|
*/
|
||||||
let _innerHTML = _temp.innerHTML.trim().replace(/^(<br>)|(<br>)$/g, '');
|
class JoeTabs extends HTMLElement {
|
||||||
let navs = '';
|
constructor() {
|
||||||
let contents = '';
|
super();
|
||||||
_innerHTML.replace(/{tabs-pane([^}]*)}([\s\S]*?){\/tabs-pane}/g, function ($0, $1, $2) {
|
const _temp = getChildren(this, '_temp');
|
||||||
navs += `<div class="item" ${$1}></div>`;
|
let _innerHTML = _temp.innerHTML.trim().replace(/^(<br>)|(<br>)$/g, '');
|
||||||
contents += `<div style="display: none" class="item" ${$1}>${$2.trim().replace(/^(<br>)|(<br>)$/g, '')}</div>`;
|
let navs = '';
|
||||||
});
|
let contents = '';
|
||||||
let htmlStr = `
|
_innerHTML.replace(/{tabs-pane([^}]*)}([\s\S]*?){\/tabs-pane}/g, function ($0, $1, $2) {
|
||||||
|
navs += `<div class="item" ${$1}></div>`;
|
||||||
|
contents += `<div style="display: none" class="item" ${$1}>${$2.trim().replace(/^(<br>)|(<br>)$/g, '')}</div>`;
|
||||||
|
});
|
||||||
|
let htmlStr = `
|
||||||
<div class="joe_detail__article-tabs">
|
<div class="joe_detail__article-tabs">
|
||||||
<div class="heads">${navs}</div>
|
<div class="heads">${navs}</div>
|
||||||
<div class="bodys">${contents}</div>
|
<div class="bodys">${contents}</div>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
if (this.querySelector('._content')) {
|
if (getChildren(this, '_content')) {
|
||||||
this.querySelector('._content').innerHTML = htmlStr;
|
getChildren(this, '_content').innerHTML = htmlStr;
|
||||||
} else {
|
} else {
|
||||||
const span = document.createElement('span');
|
const span = document.createElement('span');
|
||||||
span.className = '_content';
|
span.className = '_content';
|
||||||
span.style.display = 'block';
|
span.style.display = 'block';
|
||||||
span.innerHTML = htmlStr;
|
span.innerHTML = htmlStr;
|
||||||
this.appendChild(span);
|
this.appendChild(span);
|
||||||
}
|
}
|
||||||
this.querySelectorAll('.heads .item').forEach((item, index) => {
|
this.querySelectorAll('.heads > .item').forEach((item, index) => {
|
||||||
const label = item.getAttribute('label');
|
const label = item.getAttribute('label');
|
||||||
item.innerHTML = label;
|
item.innerHTML = label;
|
||||||
item.addEventListener('click', () => {
|
item.addEventListener('click', () => {
|
||||||
this.querySelectorAll('.heads .item').forEach(_item => _item.classList.remove('active'));
|
this.querySelectorAll('.heads > .item').forEach(_item => _item.classList.remove('active'));
|
||||||
this.querySelectorAll('.bodys .item').forEach(_item => (_item.style.display = 'none'));
|
this.querySelectorAll('.bodys > .item').forEach(_item => (_item.style.display = 'none'));
|
||||||
if (this.querySelector(`.bodys .item[label="${label}"]`)) {
|
if (this.querySelector(`.bodys > .item[label="${label}"]`)) {
|
||||||
this.querySelector(`.bodys .item[label="${label}"]`).style.display = 'block';
|
this.querySelector(`.bodys > .item[label="${label}"]`).style.display = 'block';
|
||||||
}
|
}
|
||||||
item.classList.add('active');
|
item.classList.add('active');
|
||||||
});
|
});
|
||||||
if (index === 0) item.click();
|
if (index === 0) item.click();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
window.customElements.define('joe-tabs', JoeTabs);
|
window.customElements.define('joe-tabs', JoeTabs);
|
||||||
|
|
||||||
/* OK */
|
/*
|
||||||
class JoeCardList extends HTMLElement {
|
*
|
||||||
constructor() {
|
* OK
|
||||||
super();
|
*
|
||||||
const _temp = this.querySelector('._temp');
|
*/
|
||||||
let _innerHTML = _temp.innerHTML.trim().replace(/^(<br>)|(<br>)$/g, '');
|
class JoeCardList extends HTMLElement {
|
||||||
let content = '';
|
constructor() {
|
||||||
_innerHTML.replace(/{card-list-item}([\s\S]*?){\/card-list-item}/g, function ($0, $1) {
|
super();
|
||||||
content += `<div class="item">${$1.trim().replace(/^(<br>)|(<br>)$/g, '')}</div>`;
|
const _temp = getChildren(this, '_temp');
|
||||||
});
|
let _innerHTML = _temp.innerHTML.trim().replace(/^(<br>)|(<br>)$/g, '');
|
||||||
let htmlStr = `<div class="joe_detail__article-card_list">${content}</div>`;
|
let content = '';
|
||||||
if (this.querySelector('._content')) {
|
_innerHTML.replace(/{card-list-item}([\s\S]*?){\/card-list-item}/g, function ($0, $1) {
|
||||||
this.querySelector('._content').innerHTML = htmlStr;
|
content += `<div class="item">${$1.trim().replace(/^(<br>)|(<br>)$/g, '')}</div>`;
|
||||||
} else {
|
});
|
||||||
const span = document.createElement('span');
|
let htmlStr = `<div class="joe_detail__article-card_list">${content}</div>`;
|
||||||
span.className = '_content';
|
if (getChildren(this, '_content')) {
|
||||||
span.style.display = 'block';
|
getChildren(this, '_content').innerHTML = htmlStr;
|
||||||
span.innerHTML = htmlStr;
|
} else {
|
||||||
this.appendChild(span);
|
const span = document.createElement('span');
|
||||||
}
|
span.className = '_content';
|
||||||
}
|
span.style.display = 'block';
|
||||||
}
|
span.innerHTML = htmlStr;
|
||||||
window.customElements.define('joe-card-list', JoeCardList);
|
this.appendChild(span);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
window.customElements.define('joe-card-list', JoeCardList);
|
||||||
|
|
||||||
/* OK */
|
/*
|
||||||
class JoeTimeline extends HTMLElement {
|
*
|
||||||
constructor() {
|
* OK
|
||||||
super();
|
*
|
||||||
const _temp = this.querySelector('._temp');
|
*/
|
||||||
let _innerHTML = _temp.innerHTML.trim().replace(/^(<br>)|(<br>)$/g, '');
|
class JoeTimeline extends HTMLElement {
|
||||||
let content = '';
|
constructor() {
|
||||||
_innerHTML.replace(/{timeline-item([^}]*)}([\s\S]*?){\/timeline-item}/g, function ($0, $1, $2) {
|
super();
|
||||||
content += `
|
const _temp = getChildren(this, '_temp');
|
||||||
|
let _innerHTML = _temp.innerHTML.trim().replace(/^(<br>)|(<br>)$/g, '');
|
||||||
|
let content = '';
|
||||||
|
_innerHTML.replace(/{timeline-item([^}]*)}([\s\S]*?){\/timeline-item}/g, function ($0, $1, $2) {
|
||||||
|
content += `
|
||||||
<div class="item">
|
<div class="item">
|
||||||
<div class="tail"></div>
|
<div class="tail"></div>
|
||||||
<div class="circle" ${$1}></div>
|
<div class="circle" ${$1}></div>
|
||||||
<div class="content">${$2.trim().replace(/^(<br>)|(<br>)$/g, '')}</div>
|
<div class="content">${$2.trim().replace(/^(<br>)|(<br>)$/g, '')}</div>
|
||||||
</div>
|
</div>
|
||||||
`;
|
`;
|
||||||
});
|
});
|
||||||
let htmlStr = `<div class="joe_detail__article-timeline">${content}</div>`;
|
let htmlStr = `<div class="joe_detail__article-timeline">${content}</div>`;
|
||||||
if (this.querySelector('._content')) {
|
if (getChildren(this, '_content')) {
|
||||||
this.querySelector('._content').innerHTML = htmlStr;
|
getChildren(this, '_content').innerHTML = htmlStr;
|
||||||
} else {
|
} else {
|
||||||
const span = document.createElement('span');
|
const span = document.createElement('span');
|
||||||
span.className = '_content';
|
span.className = '_content';
|
||||||
span.style.display = 'block';
|
span.style.display = 'block';
|
||||||
span.innerHTML = htmlStr;
|
span.innerHTML = htmlStr;
|
||||||
this.appendChild(span);
|
this.appendChild(span);
|
||||||
}
|
}
|
||||||
this.querySelectorAll('.joe_detail__article-timeline .item .circle').forEach((item, index) => {
|
this.querySelectorAll('.joe_detail__article-timeline > .item > .circle').forEach((item, index) => {
|
||||||
const color = item.getAttribute('color') || '#19be6b';
|
const color = item.getAttribute('color') || '#19be6b';
|
||||||
item.style.borderColor = color;
|
item.style.borderColor = color;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
window.customElements.define('joe-timeline', JoeTimeline);
|
window.customElements.define('joe-timeline', JoeTimeline);
|
||||||
|
|
||||||
$('.joe_detail__article p:empty').remove();
|
$('.joe_detail__article p:empty').remove();
|
||||||
/*
|
|
||||||
|
/*
|
||||||
------------------------以下未测试------------------------------------------
|
------------------------以下未测试------------------------------------------
|
||||||
*/
|
*/
|
||||||
/* 点击复制 */
|
/* 点击复制 */
|
||||||
class JoeCopy extends HTMLElement {
|
class JoeCopy extends HTMLElement {
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
this.options = {
|
this.options = {
|
||||||
text: this.getAttribulte('text') || '默认文本',
|
text: this.getAttribulte('text') || '默认文本',
|
||||||
content: this.innerHTML.trim().replace(/^(<br>)|(<br>)$/g, '') || '点击复制'
|
content: this.innerHTML.trim().replace(/^(<br>)|(<br>)$/g, '') || '点击复制'
|
||||||
};
|
};
|
||||||
this.render();
|
this.render();
|
||||||
}
|
}
|
||||||
get template() {
|
get template() {
|
||||||
return `<span class="joe_detail__article-copy">${this.options.content}</span>`;
|
return `<span class="joe_detail__article-copy">${this.options.content}</span>`;
|
||||||
}
|
}
|
||||||
render() {
|
render() {
|
||||||
this.innerHTML = this.template;
|
this.innerHTML = this.template;
|
||||||
this.event();
|
this.event();
|
||||||
}
|
}
|
||||||
event() {
|
event() {
|
||||||
this.$copy = this.querySelector('.joe_detail__article-copy');
|
this.$copy = this.querySelector('.joe_detail__article-copy');
|
||||||
new ClipboardJS(this.$copy, { text: () => this.options.text }).on('success', () => Qmsg.success('复制成功!'));
|
new ClipboardJS(this.$copy, { text: () => this.options.text }).on('success', () => Qmsg.success('复制成功!'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
window.customElements.define('joe-copy', JoeCopy);
|
window.customElements.define('joe-copy', JoeCopy);
|
||||||
});
|
});
|
||||||
|
2
assets/js/joe.short.min.js
vendored
2
assets/js/joe.short.min.js
vendored
File diff suppressed because one or more lines are too long
@ -67,7 +67,7 @@ class Editor
|
|||||||
<script src="https://cdn.jsdelivr.net/npm/typecho-joe-next@6.2.4/plugin/prism/prism.min.js"></script>
|
<script src="https://cdn.jsdelivr.net/npm/typecho-joe-next@6.2.4/plugin/prism/prism.min.js"></script>
|
||||||
<script src="<?php Helper::options()->themeUrl('typecho/write/js/joe.parse.min.js?v=2021042217') ?>"></script>
|
<script src="<?php Helper::options()->themeUrl('typecho/write/js/joe.parse.min.js?v=2021042217') ?>"></script>
|
||||||
<script src="<?php Helper::options()->themeUrl('typecho/write/js/joe.write.chunk.js?v=2021042217') ?>"></script>
|
<script src="<?php Helper::options()->themeUrl('typecho/write/js/joe.write.chunk.js?v=2021042217') ?>"></script>
|
||||||
<script src="<?php Helper::options()->themeUrl('assets/js/joe.short.min.js?v=2021042217') ?>"></script>
|
<script src="<?php Helper::options()->themeUrl('assets/js/joe.short.min.js?v=2021042220') ?>"></script>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
/* 获取主题当前版本号 */
|
/* 获取主题当前版本号 */
|
||||||
function _getVersion()
|
function _getVersion()
|
||||||
{
|
{
|
||||||
return "6.5.8";
|
return "6.5.9";
|
||||||
};
|
};
|
||||||
|
|
||||||
/* 判断是否是手机 */
|
/* 判断是否是手机 */
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "typecho-joe-next",
|
"name": "typecho-joe-next",
|
||||||
"version": "6.5.8",
|
"version": "6.5.9",
|
||||||
"description": "A Theme Of Typecho",
|
"description": "A Theme Of Typecho",
|
||||||
"main": "index.php",
|
"main": "index.php",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
|
@ -41,5 +41,5 @@
|
|||||||
<script src="<?php $this->options->themeUrl('assets/cursor/' . $this->options->JCursorEffects); ?>" async></script>
|
<script src="<?php $this->options->themeUrl('assets/cursor/' . $this->options->JCursorEffects); ?>" async></script>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<script src="<?php $this->options->themeUrl('assets/js/joe.global.min.js?v=2021042217'); ?>"></script>
|
<script src="<?php $this->options->themeUrl('assets/js/joe.global.min.js?v=2021042217'); ?>"></script>
|
||||||
<script src="<?php $this->options->themeUrl('assets/js/joe.short.min.js?v=2021042217'); ?>"></script>
|
<script src="<?php $this->options->themeUrl('assets/js/joe.short.min.js?v=2021042220'); ?>"></script>
|
||||||
<?php $this->options->JCustomHeadEnd() ?>
|
<?php $this->options->JCustomHeadEnd() ?>
|
Loading…
Reference in New Issue
Block a user