This commit is contained in:
haoouba 2021-04-22 20:31:55 +08:00
parent 6ca9359887
commit d6b807f60d
6 changed files with 444 additions and 369 deletions

View File

@ -1,7 +1,17 @@
/* 获取直属子元素 */
function getChildren(el, className) {
for (let item of el.children) if (item.className === className) return item;
return null;
}
document.addEventListener('DOMContentLoaded', () => { document.addEventListener('DOMContentLoaded', () => {
$('.joe_detail__article p:empty').remove(); $('.joe_detail__article p:empty').remove();
/* OK */ /*
*
* OK
*
*/
class JoeMtitle extends HTMLElement { class JoeMtitle extends HTMLElement {
constructor() { constructor() {
super(); super();
@ -16,7 +26,11 @@ document.addEventListener('DOMContentLoaded', () => {
} }
window.customElements.define('joe-mtitle', JoeMtitle); window.customElements.define('joe-mtitle', JoeMtitle);
/* OK */ /*
*
* OK
*
*/
class JoeDplayer extends HTMLElement { class JoeDplayer extends HTMLElement {
constructor() { constructor() {
super(); super();
@ -33,7 +47,11 @@ document.addEventListener('DOMContentLoaded', () => {
} }
window.customElements.define('joe-dplayer', JoeDplayer); window.customElements.define('joe-dplayer', JoeDplayer);
/* OK */ /*
*
* OK
*
*/
class JoeBilibili extends HTMLElement { class JoeBilibili extends HTMLElement {
constructor() { constructor() {
super(); super();
@ -47,7 +65,11 @@ document.addEventListener('DOMContentLoaded', () => {
} }
window.customElements.define('joe-bilibili', JoeBilibili); window.customElements.define('joe-bilibili', JoeBilibili);
/* OK */ /*
*
* OK
*
*/
class JoeMp3 extends HTMLElement { class JoeMp3 extends HTMLElement {
constructor() { constructor() {
super(); super();
@ -62,9 +84,9 @@ document.addEventListener('DOMContentLoaded', () => {
} }
render() { render() {
if (!this.options.url) return (this.innerHTML = '音频地址未填写!'); if (!this.options.url) return (this.innerHTML = '音频地址未填写!');
this.innerHTML = '<span style="display: block"></span>'; this.innerHTML = '<span style="display: block" class="_content"></span>';
new APlayer({ new APlayer({
container: this.querySelector('span'), container: getChildren(this, '_content'),
theme: this.options.theme, theme: this.options.theme,
autoplay: this.options.autoplay, autoplay: this.options.autoplay,
audio: [ audio: [
@ -79,7 +101,11 @@ document.addEventListener('DOMContentLoaded', () => {
} }
window.customElements.define('joe-mp3', JoeMp3); window.customElements.define('joe-mp3', JoeMp3);
/* OK */ /*
*
* OK
*
*/
class JoeMusic extends HTMLElement { class JoeMusic extends HTMLElement {
constructor() { constructor() {
super(); super();
@ -92,11 +118,11 @@ document.addEventListener('DOMContentLoaded', () => {
} }
render() { render() {
if (!this.options.id) return (this.innerHTML = '网易云歌曲ID未填写'); if (!this.options.id) return (this.innerHTML = '网易云歌曲ID未填写');
this.innerHTML = '<span style="display: block"></span>'; this.innerHTML = '<span style="display: block" class="_content"></span>';
fetch('https://api.i-meto.com/meting/api?server=netease&type=song&id=' + this.options.id).then(async response => { fetch('https://api.i-meto.com/meting/api?server=netease&type=song&id=' + this.options.id).then(async response => {
const audio = await response.json(); const audio = await response.json();
new APlayer({ new APlayer({
container: this.querySelector('span'), container: getChildren(this, '_content'),
lrcType: 3, lrcType: 3,
theme: this.options.color, theme: this.options.color,
autoplay: this.options.autoplay, autoplay: this.options.autoplay,
@ -107,7 +133,11 @@ document.addEventListener('DOMContentLoaded', () => {
} }
window.customElements.define('joe-music', JoeMusic); window.customElements.define('joe-music', JoeMusic);
/* OK */ /*
*
* OK
*
*/
class JoeMlist extends HTMLElement { class JoeMlist extends HTMLElement {
constructor() { constructor() {
super(); super();
@ -120,11 +150,11 @@ document.addEventListener('DOMContentLoaded', () => {
} }
render() { render() {
if (!this.options.id) return (this.innerHTML = '网易云歌单ID未填写'); if (!this.options.id) return (this.innerHTML = '网易云歌单ID未填写');
this.innerHTML = '<span style="display: block"></span>'; this.innerHTML = '<span style="display: block" class="_content"></span>';
fetch('https://api.i-meto.com/meting/api?server=netease&type=playlist&id=' + this.options.id).then(async response => { fetch('https://api.i-meto.com/meting/api?server=netease&type=playlist&id=' + this.options.id).then(async response => {
const audio = await response.json(); const audio = await response.json();
new APlayer({ new APlayer({
container: this.querySelector('span'), container: getChildren(this, '_content'),
lrcType: 3, lrcType: 3,
theme: this.options.color, theme: this.options.color,
autoplay: this.options.autoplay, autoplay: this.options.autoplay,
@ -135,7 +165,11 @@ document.addEventListener('DOMContentLoaded', () => {
} }
window.customElements.define('joe-mlist', JoeMlist); window.customElements.define('joe-mlist', JoeMlist);
/* OK */ /*
*
* OK
*
*/
class JoeAbtn extends HTMLElement { class JoeAbtn extends HTMLElement {
constructor() { constructor() {
super(); super();
@ -155,7 +189,11 @@ document.addEventListener('DOMContentLoaded', () => {
} }
window.customElements.define('joe-abtn', JoeAbtn); window.customElements.define('joe-abtn', JoeAbtn);
/* OK */ /*
*
* OK
*
*/
class JoeAnote extends HTMLElement { class JoeAnote extends HTMLElement {
constructor() { constructor() {
super(); super();
@ -174,7 +212,11 @@ document.addEventListener('DOMContentLoaded', () => {
} }
window.customElements.define('joe-anote', JoeAnote); window.customElements.define('joe-anote', JoeAnote);
/* OK */ /*
*
* OK
*
*/
class JoeDotted extends HTMLElement { class JoeDotted extends HTMLElement {
constructor() { constructor() {
super(); super();
@ -187,7 +229,11 @@ document.addEventListener('DOMContentLoaded', () => {
} }
window.customElements.define('joe-dotted', JoeDotted); window.customElements.define('joe-dotted', JoeDotted);
/* OK */ /*
*
* OK
*
*/
class JoeHide extends HTMLElement { class JoeHide extends HTMLElement {
constructor() { constructor() {
super(); super();
@ -195,7 +241,7 @@ document.addEventListener('DOMContentLoaded', () => {
} }
render() { render() {
this.innerHTML = '<span class="joe_detail__article-hide">此处内容作者设置了 <i>回复</i> 可见</span>'; this.innerHTML = '<span class="joe_detail__article-hide">此处内容作者设置了 <i>回复</i> 可见</span>';
this.$button = this.querySelector('i'); this.$button = this.querySelector('.joe_detail__article-hide > i');
const $comment = document.querySelector('.joe_comment'); const $comment = document.querySelector('.joe_comment');
const $header = document.querySelector('.joe_header'); const $header = document.querySelector('.joe_header');
if (!$comment || !$header) return; if (!$comment || !$header) return;
@ -207,11 +253,15 @@ document.addEventListener('DOMContentLoaded', () => {
} }
window.customElements.define('joe-hide', JoeHide); window.customElements.define('joe-hide', JoeHide);
/* OK */ /*
*
* OK
*
*/
class JoeCardDefault extends HTMLElement { class JoeCardDefault extends HTMLElement {
constructor() { constructor() {
super(); super();
const _temp = this.querySelector('._temp'); const _temp = getChildren(this, '_temp');
this.options = { this.options = {
width: this.getAttribute('width') || '100%', width: this.getAttribute('width') || '100%',
label: this.getAttribute('label') || '卡片标题', label: this.getAttribute('label') || '卡片标题',
@ -223,8 +273,8 @@ document.addEventListener('DOMContentLoaded', () => {
<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';
@ -236,7 +286,11 @@ document.addEventListener('DOMContentLoaded', () => {
} }
window.customElements.define('joe-card-default', JoeCardDefault); window.customElements.define('joe-card-default', JoeCardDefault);
/* OK */ /*
*
* OK
*
*/
class JoeMessage extends HTMLElement { class JoeMessage extends HTMLElement {
constructor() { constructor() {
super(); super();
@ -254,7 +308,11 @@ document.addEventListener('DOMContentLoaded', () => {
} }
window.customElements.define('joe-message', JoeMessage); window.customElements.define('joe-message', JoeMessage);
/* OK */ /*
*
* OK
*
*/
class JoeProgress extends HTMLElement { class JoeProgress extends HTMLElement {
constructor() { constructor() {
super(); super();
@ -274,11 +332,15 @@ document.addEventListener('DOMContentLoaded', () => {
} }
window.customElements.define('joe-progress', JoeProgress); window.customElements.define('joe-progress', JoeProgress);
/* OK */ /*
*
* OK
*
*/
class JoeCallout extends HTMLElement { class JoeCallout extends HTMLElement {
constructor() { constructor() {
super(); super();
const _temp = this.querySelector('._temp'); const _temp = getChildren(this, '_temp');
this.options = { this.options = {
color: this.getAttribute('color') || '#f0ad4e', color: this.getAttribute('color') || '#f0ad4e',
content: _temp.innerHTML.trim().replace(/^(<br>)|(<br>)$/g, '') || '标注内容' content: _temp.innerHTML.trim().replace(/^(<br>)|(<br>)$/g, '') || '标注内容'
@ -288,8 +350,8 @@ document.addEventListener('DOMContentLoaded', () => {
${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';
@ -301,11 +363,15 @@ document.addEventListener('DOMContentLoaded', () => {
} }
window.customElements.define('joe-callout', JoeCallout); window.customElements.define('joe-callout', JoeCallout);
/* OK */ /*
*
* OK
*
*/
class JoeTabs extends HTMLElement { class JoeTabs extends HTMLElement {
constructor() { constructor() {
super(); super();
const _temp = this.querySelector('._temp'); const _temp = getChildren(this, '_temp');
let _innerHTML = _temp.innerHTML.trim().replace(/^(<br>)|(<br>)$/g, ''); let _innerHTML = _temp.innerHTML.trim().replace(/^(<br>)|(<br>)$/g, '');
let navs = ''; let navs = '';
let contents = ''; let contents = '';
@ -319,8 +385,8 @@ document.addEventListener('DOMContentLoaded', () => {
<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';
@ -328,14 +394,14 @@ document.addEventListener('DOMContentLoaded', () => {
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');
}); });
@ -345,19 +411,23 @@ document.addEventListener('DOMContentLoaded', () => {
} }
window.customElements.define('joe-tabs', JoeTabs); window.customElements.define('joe-tabs', JoeTabs);
/* OK */ /*
*
* OK
*
*/
class JoeCardList extends HTMLElement { class JoeCardList extends HTMLElement {
constructor() { constructor() {
super(); super();
const _temp = this.querySelector('._temp'); const _temp = getChildren(this, '_temp');
let _innerHTML = _temp.innerHTML.trim().replace(/^(<br>)|(<br>)$/g, ''); let _innerHTML = _temp.innerHTML.trim().replace(/^(<br>)|(<br>)$/g, '');
let content = ''; let content = '';
_innerHTML.replace(/{card-list-item}([\s\S]*?){\/card-list-item}/g, function ($0, $1) { _innerHTML.replace(/{card-list-item}([\s\S]*?){\/card-list-item}/g, function ($0, $1) {
content += `<div class="item">${$1.trim().replace(/^(<br>)|(<br>)$/g, '')}</div>`; content += `<div class="item">${$1.trim().replace(/^(<br>)|(<br>)$/g, '')}</div>`;
}); });
let htmlStr = `<div class="joe_detail__article-card_list">${content}</div>`; let htmlStr = `<div class="joe_detail__article-card_list">${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';
@ -369,11 +439,15 @@ document.addEventListener('DOMContentLoaded', () => {
} }
window.customElements.define('joe-card-list', JoeCardList); window.customElements.define('joe-card-list', JoeCardList);
/* OK */ /*
*
* OK
*
*/
class JoeTimeline extends HTMLElement { class JoeTimeline extends HTMLElement {
constructor() { constructor() {
super(); super();
const _temp = this.querySelector('._temp'); const _temp = getChildren(this, '_temp');
let _innerHTML = _temp.innerHTML.trim().replace(/^(<br>)|(<br>)$/g, ''); let _innerHTML = _temp.innerHTML.trim().replace(/^(<br>)|(<br>)$/g, '');
let content = ''; let content = '';
_innerHTML.replace(/{timeline-item([^}]*)}([\s\S]*?){\/timeline-item}/g, function ($0, $1, $2) { _innerHTML.replace(/{timeline-item([^}]*)}([\s\S]*?){\/timeline-item}/g, function ($0, $1, $2) {
@ -386,8 +460,8 @@ document.addEventListener('DOMContentLoaded', () => {
`; `;
}); });
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';
@ -395,7 +469,7 @@ document.addEventListener('DOMContentLoaded', () => {
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;
}); });
@ -404,6 +478,7 @@ document.addEventListener('DOMContentLoaded', () => {
window.customElements.define('joe-timeline', JoeTimeline); window.customElements.define('joe-timeline', JoeTimeline);
$('.joe_detail__article p:empty').remove(); $('.joe_detail__article p:empty').remove();
/* /*
------------------------以下未测试------------------------------------------ ------------------------以下未测试------------------------------------------
*/ */

File diff suppressed because one or more lines are too long

View File

@ -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
} }
} }

View File

@ -2,7 +2,7 @@
/* 获取主题当前版本号 */ /* 获取主题当前版本号 */
function _getVersion() function _getVersion()
{ {
return "6.5.8"; return "6.5.9";
}; };
/* 判断是否是手机 */ /* 判断是否是手机 */

View File

@ -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": [

View File

@ -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() ?>