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', () => {
$('.joe_detail__article p:empty').remove();
/* OK */
/*
*
* OK
*
*/
class JoeMtitle extends HTMLElement {
constructor() {
super();
@ -16,7 +26,11 @@ document.addEventListener('DOMContentLoaded', () => {
}
window.customElements.define('joe-mtitle', JoeMtitle);
/* OK */
/*
*
* OK
*
*/
class JoeDplayer extends HTMLElement {
constructor() {
super();
@ -33,7 +47,11 @@ document.addEventListener('DOMContentLoaded', () => {
}
window.customElements.define('joe-dplayer', JoeDplayer);
/* OK */
/*
*
* OK
*
*/
class JoeBilibili extends HTMLElement {
constructor() {
super();
@ -47,7 +65,11 @@ document.addEventListener('DOMContentLoaded', () => {
}
window.customElements.define('joe-bilibili', JoeBilibili);
/* OK */
/*
*
* OK
*
*/
class JoeMp3 extends HTMLElement {
constructor() {
super();
@ -62,9 +84,9 @@ document.addEventListener('DOMContentLoaded', () => {
}
render() {
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({
container: this.querySelector('span'),
container: getChildren(this, '_content'),
theme: this.options.theme,
autoplay: this.options.autoplay,
audio: [
@ -79,7 +101,11 @@ document.addEventListener('DOMContentLoaded', () => {
}
window.customElements.define('joe-mp3', JoeMp3);
/* OK */
/*
*
* OK
*
*/
class JoeMusic extends HTMLElement {
constructor() {
super();
@ -92,11 +118,11 @@ document.addEventListener('DOMContentLoaded', () => {
}
render() {
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 => {
const audio = await response.json();
new APlayer({
container: this.querySelector('span'),
container: getChildren(this, '_content'),
lrcType: 3,
theme: this.options.color,
autoplay: this.options.autoplay,
@ -107,7 +133,11 @@ document.addEventListener('DOMContentLoaded', () => {
}
window.customElements.define('joe-music', JoeMusic);
/* OK */
/*
*
* OK
*
*/
class JoeMlist extends HTMLElement {
constructor() {
super();
@ -120,11 +150,11 @@ document.addEventListener('DOMContentLoaded', () => {
}
render() {
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 => {
const audio = await response.json();
new APlayer({
container: this.querySelector('span'),
container: getChildren(this, '_content'),
lrcType: 3,
theme: this.options.color,
autoplay: this.options.autoplay,
@ -135,7 +165,11 @@ document.addEventListener('DOMContentLoaded', () => {
}
window.customElements.define('joe-mlist', JoeMlist);
/* OK */
/*
*
* OK
*
*/
class JoeAbtn extends HTMLElement {
constructor() {
super();
@ -155,7 +189,11 @@ document.addEventListener('DOMContentLoaded', () => {
}
window.customElements.define('joe-abtn', JoeAbtn);
/* OK */
/*
*
* OK
*
*/
class JoeAnote extends HTMLElement {
constructor() {
super();
@ -174,7 +212,11 @@ document.addEventListener('DOMContentLoaded', () => {
}
window.customElements.define('joe-anote', JoeAnote);
/* OK */
/*
*
* OK
*
*/
class JoeDotted extends HTMLElement {
constructor() {
super();
@ -187,7 +229,11 @@ document.addEventListener('DOMContentLoaded', () => {
}
window.customElements.define('joe-dotted', JoeDotted);
/* OK */
/*
*
* OK
*
*/
class JoeHide extends HTMLElement {
constructor() {
super();
@ -195,7 +241,7 @@ document.addEventListener('DOMContentLoaded', () => {
}
render() {
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 $header = document.querySelector('.joe_header');
if (!$comment || !$header) return;
@ -207,11 +253,15 @@ document.addEventListener('DOMContentLoaded', () => {
}
window.customElements.define('joe-hide', JoeHide);
/* OK */
/*
*
* OK
*
*/
class JoeCardDefault extends HTMLElement {
constructor() {
super();
const _temp = this.querySelector('._temp');
const _temp = getChildren(this, '_temp');
this.options = {
width: this.getAttribute('width') || '100%',
label: this.getAttribute('label') || '卡片标题',
@ -223,8 +273,8 @@ document.addEventListener('DOMContentLoaded', () => {
<div class="content">${this.options.content}</div>
</div>
`;
if (this.querySelector('._content')) {
this.querySelector('._content').innerHTML = htmlStr;
if (getChildren(this, '_content')) {
getChildren(this, '_content').innerHTML = htmlStr;
} else {
const span = document.createElement('span');
span.style.display = 'block';
@ -236,7 +286,11 @@ document.addEventListener('DOMContentLoaded', () => {
}
window.customElements.define('joe-card-default', JoeCardDefault);
/* OK */
/*
*
* OK
*
*/
class JoeMessage extends HTMLElement {
constructor() {
super();
@ -254,7 +308,11 @@ document.addEventListener('DOMContentLoaded', () => {
}
window.customElements.define('joe-message', JoeMessage);
/* OK */
/*
*
* OK
*
*/
class JoeProgress extends HTMLElement {
constructor() {
super();
@ -274,11 +332,15 @@ document.addEventListener('DOMContentLoaded', () => {
}
window.customElements.define('joe-progress', JoeProgress);
/* OK */
/*
*
* OK
*
*/
class JoeCallout extends HTMLElement {
constructor() {
super();
const _temp = this.querySelector('._temp');
const _temp = getChildren(this, '_temp');
this.options = {
color: this.getAttribute('color') || '#f0ad4e',
content: _temp.innerHTML.trim().replace(/^(<br>)|(<br>)$/g, '') || '标注内容'
@ -288,8 +350,8 @@ document.addEventListener('DOMContentLoaded', () => {
${this.options.content}
</div>
`;
if (this.querySelector('._content')) {
this.querySelector('._content').innerHTML = htmlStr;
if (getChildren(this, '_content')) {
getChildren(this, '_content').innerHTML = htmlStr;
} else {
const span = document.createElement('span');
span.style.display = 'block';
@ -301,11 +363,15 @@ document.addEventListener('DOMContentLoaded', () => {
}
window.customElements.define('joe-callout', JoeCallout);
/* OK */
/*
*
* OK
*
*/
class JoeTabs extends HTMLElement {
constructor() {
super();
const _temp = this.querySelector('._temp');
const _temp = getChildren(this, '_temp');
let _innerHTML = _temp.innerHTML.trim().replace(/^(<br>)|(<br>)$/g, '');
let navs = '';
let contents = '';
@ -319,8 +385,8 @@ document.addEventListener('DOMContentLoaded', () => {
<div class="bodys">${contents}</div>
</div>
`;
if (this.querySelector('._content')) {
this.querySelector('._content').innerHTML = htmlStr;
if (getChildren(this, '_content')) {
getChildren(this, '_content').innerHTML = htmlStr;
} else {
const span = document.createElement('span');
span.className = '_content';
@ -328,14 +394,14 @@ document.addEventListener('DOMContentLoaded', () => {
span.innerHTML = htmlStr;
this.appendChild(span);
}
this.querySelectorAll('.heads .item').forEach((item, index) => {
this.querySelectorAll('.heads > .item').forEach((item, index) => {
const label = item.getAttribute('label');
item.innerHTML = label;
item.addEventListener('click', () => {
this.querySelectorAll('.heads .item').forEach(_item => _item.classList.remove('active'));
this.querySelectorAll('.bodys .item').forEach(_item => (_item.style.display = 'none'));
if (this.querySelector(`.bodys .item[label="${label}"]`)) {
this.querySelector(`.bodys .item[label="${label}"]`).style.display = 'block';
this.querySelectorAll('.heads > .item').forEach(_item => _item.classList.remove('active'));
this.querySelectorAll('.bodys > .item').forEach(_item => (_item.style.display = 'none'));
if (this.querySelector(`.bodys > .item[label="${label}"]`)) {
this.querySelector(`.bodys > .item[label="${label}"]`).style.display = 'block';
}
item.classList.add('active');
});
@ -345,19 +411,23 @@ document.addEventListener('DOMContentLoaded', () => {
}
window.customElements.define('joe-tabs', JoeTabs);
/* OK */
/*
*
* OK
*
*/
class JoeCardList extends HTMLElement {
constructor() {
super();
const _temp = this.querySelector('._temp');
const _temp = getChildren(this, '_temp');
let _innerHTML = _temp.innerHTML.trim().replace(/^(<br>)|(<br>)$/g, '');
let content = '';
_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>`;
});
let htmlStr = `<div class="joe_detail__article-card_list">${content}</div>`;
if (this.querySelector('._content')) {
this.querySelector('._content').innerHTML = htmlStr;
if (getChildren(this, '_content')) {
getChildren(this, '_content').innerHTML = htmlStr;
} else {
const span = document.createElement('span');
span.className = '_content';
@ -369,11 +439,15 @@ document.addEventListener('DOMContentLoaded', () => {
}
window.customElements.define('joe-card-list', JoeCardList);
/* OK */
/*
*
* OK
*
*/
class JoeTimeline extends HTMLElement {
constructor() {
super();
const _temp = this.querySelector('._temp');
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) {
@ -386,8 +460,8 @@ document.addEventListener('DOMContentLoaded', () => {
`;
});
let htmlStr = `<div class="joe_detail__article-timeline">${content}</div>`;
if (this.querySelector('._content')) {
this.querySelector('._content').innerHTML = htmlStr;
if (getChildren(this, '_content')) {
getChildren(this, '_content').innerHTML = htmlStr;
} else {
const span = document.createElement('span');
span.className = '_content';
@ -395,7 +469,7 @@ document.addEventListener('DOMContentLoaded', () => {
span.innerHTML = htmlStr;
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';
item.style.borderColor = color;
});
@ -404,6 +478,7 @@ document.addEventListener('DOMContentLoaded', () => {
window.customElements.define('joe-timeline', JoeTimeline);
$('.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="<?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('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
}
}

View File

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

View File

@ -1,6 +1,6 @@
{
"name": "typecho-joe-next",
"version": "6.5.8",
"version": "6.5.9",
"description": "A Theme Of Typecho",
"main": "index.php",
"keywords": [

View File

@ -41,5 +41,5 @@
<script src="<?php $this->options->themeUrl('assets/cursor/' . $this->options->JCursorEffects); ?>" async></script>
<?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.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() ?>