This commit is contained in:
haoouba 2021-02-27 21:00:05 +08:00
parent baec17728e
commit 96085cc371
10 changed files with 288 additions and 240 deletions

File diff suppressed because one or more lines are too long

View File

@ -2128,6 +2128,23 @@
} }
} }
} }
&-mp3 {
.plyr {
max-width: 450px;
margin: 0 auto;
}
.plyr--audio{
box-shadow: var(--box-shadow);
background: var(--classD);
border-radius: 26px;
padding: 0 5px;
--plyr-audio-control-color: var(--routine);
.plyr__controls{
background: var(--classD);
}
}
}
} }
&__agree { &__agree {
display: flex; display: flex;

File diff suppressed because one or more lines are too long

View File

@ -403,6 +403,11 @@ html {
} }
} }
} }
&-mp3 {
.plyr {
max-width: 100%;
}
}
} }
} }
.joe_comment { .joe_comment {

View File

@ -1,96 +1,96 @@
document.addEventListener('DOMContentLoaded', () => { document.addEventListener('DOMContentLoaded', () => {
/* 公共修改地址栏URL函数 */ /* 公共修改地址栏URL函数 */
const changeURLArg = (url, arg, arg_val) => { const changeURLArg = (url, arg, arg_val) => {
let pattern = arg + '=([^&]*)' let pattern = arg + '=([^&]*)';
let replaceText = arg + '=' + arg_val let replaceText = arg + '=' + arg_val;
if (url.match(pattern)) { if (url.match(pattern)) {
let tmp = '/(' + arg + '=)([^&]*)/gi' let tmp = '/(' + arg + '=)([^&]*)/gi';
return url.replace(eval(tmp), replaceText) return url.replace(eval(tmp), replaceText);
} else { } else {
if (url.match('[?]')) { if (url.match('[?]')) {
return url + '&' + replaceText return url + '&' + replaceText;
} else { } else {
return url + '?' + replaceText return url + '?' + replaceText;
} }
} }
return url + '\n' + arg + '\n' + arg_val return url + '\n' + arg + '\n' + arg_val;
} };
/* 初始化昼夜模式 */ /* 初始化昼夜模式 */
{ {
if (localStorage.getItem('data-night')) { if (localStorage.getItem('data-night')) {
$('.joe_action_item.mode .icon-1').addClass('active') $('.joe_action_item.mode .icon-1').addClass('active');
$('.joe_action_item.mode .icon-2').removeClass('active') $('.joe_action_item.mode .icon-2').removeClass('active');
} else { } else {
$('html').removeAttr('data-night') $('html').removeAttr('data-night');
$('.joe_action_item.mode .icon-1').removeClass('active') $('.joe_action_item.mode .icon-1').removeClass('active');
$('.joe_action_item.mode .icon-2').addClass('active') $('.joe_action_item.mode .icon-2').addClass('active');
} }
$('.joe_action_item.mode').on('click', () => { $('.joe_action_item.mode').on('click', () => {
if (localStorage.getItem('data-night')) { if (localStorage.getItem('data-night')) {
$('.joe_action_item.mode .icon-1').removeClass('active') $('.joe_action_item.mode .icon-1').removeClass('active');
$('.joe_action_item.mode .icon-2').addClass('active') $('.joe_action_item.mode .icon-2').addClass('active');
$('html').removeAttr('data-night') $('html').removeAttr('data-night');
localStorage.removeItem('data-night') localStorage.removeItem('data-night');
} else { } else {
$('.joe_action_item.mode .icon-1').addClass('active') $('.joe_action_item.mode .icon-1').addClass('active');
$('.joe_action_item.mode .icon-2').removeClass('active') $('.joe_action_item.mode .icon-2').removeClass('active');
$('html').attr('data-night', 'night') $('html').attr('data-night', 'night');
localStorage.setItem('data-night', 'night') localStorage.setItem('data-night', 'night');
} }
}) });
} }
/* 动态背景 */ /* 动态背景 */
{ {
if (!Joe.IS_MOBILE && Joe.DYNAMIC_BACKGROUND !== 'off' && Joe.DYNAMIC_BACKGROUND && !Joe.WALLPAPER_BACKGROUND_PC) { if (!Joe.IS_MOBILE && Joe.DYNAMIC_BACKGROUND !== 'off' && Joe.DYNAMIC_BACKGROUND && !Joe.WALLPAPER_BACKGROUND_PC) {
$.getScript(`https://cdn.jsdelivr.net/gh/HaoOuBa/Joe@master/assets/backdrop/${Joe.DYNAMIC_BACKGROUND}`) $.getScript(`https://cdn.jsdelivr.net/gh/HaoOuBa/Joe@master/assets/backdrop/${Joe.DYNAMIC_BACKGROUND}`);
} }
} }
/* 搜索框弹窗 */ /* 搜索框弹窗 */
{ {
$('.joe_header__above-search .input').on('click', e => { $('.joe_header__above-search .input').on('click', e => {
e.stopPropagation() e.stopPropagation();
$('.joe_header__above-search .result').addClass('active') $('.joe_header__above-search .result').addClass('active');
}) });
$(document).on('click', function () { $(document).on('click', function () {
$('.joe_header__above-search .result').removeClass('active') $('.joe_header__above-search .result').removeClass('active');
}) });
$(document).on('scroll', function () { $(document).on('scroll', function () {
$('.joe_header__above-search .result').removeClass('active') $('.joe_header__above-search .result').removeClass('active');
}) });
} }
/* 激活全局下拉框功能 */ /* 激活全局下拉框功能 */
{ {
$('.joe_dropdown').each(function (index, item) { $('.joe_dropdown').each(function (index, item) {
const menu = $(this).find('.joe_dropdown__menu') const menu = $(this).find('.joe_dropdown__menu');
const trigger = $(item).attr('trigger') || 'click' const trigger = $(item).attr('trigger') || 'click';
const placement = $(item).attr('placement') || $(this).height() || 0 const placement = $(item).attr('placement') || $(this).height() || 0;
menu.css('top', placement) menu.css('top', placement);
if (trigger === 'hover') { if (trigger === 'hover') {
$(this).hover( $(this).hover(
() => $(this).addClass('active'), () => $(this).addClass('active'),
() => $(this).removeClass('active') () => $(this).removeClass('active')
) );
} else { } else {
$(this).on('click', function (e) { $(this).on('click', function (e) {
$(this).toggleClass('active') $(this).toggleClass('active');
$(document).one('click', () => $(this).removeClass('active')) $(document).one('click', () => $(this).removeClass('active'));
e.stopPropagation() e.stopPropagation();
}) });
menu.on('click', e => e.stopPropagation()) menu.on('click', e => e.stopPropagation());
} }
}) });
} }
/* 激活全局返回顶部功能 */ /* 激活全局返回顶部功能 */
{ {
const handleScroll = () => ((document.documentElement.scrollTop || document.body.scrollTop) > 300 ? $('.joe_action_item.scroll').addClass('active') : $('.joe_action_item.scroll').removeClass('active')) const handleScroll = () => ((document.documentElement.scrollTop || document.body.scrollTop) > 300 ? $('.joe_action_item.scroll').addClass('active') : $('.joe_action_item.scroll').removeClass('active'));
handleScroll() handleScroll();
$(window).on('scroll', () => handleScroll()) $(window).on('scroll', () => handleScroll());
$('.joe_action_item.scroll').on('click', () => window.scrollTo({ top: 0, behavior: 'smooth' })) $('.joe_action_item.scroll').on('click', () => window.scrollTo({ top: 0, behavior: 'smooth' }));
} }
/* 激活侧边栏人生倒计时功能 */ /* 激活侧边栏人生倒计时功能 */
@ -101,38 +101,38 @@ document.addEventListener('DOMContentLoaded', () => {
{ title: '这周已经过去', endTitle: '天', num: 0, percent: '0%' }, { title: '这周已经过去', endTitle: '天', num: 0, percent: '0%' },
{ title: '本月已经过去', endTitle: '天', num: 0, percent: '0%' }, { title: '本月已经过去', endTitle: '天', num: 0, percent: '0%' },
{ title: '今年已经过去', endTitle: '个月', num: 0, percent: '0%' } { title: '今年已经过去', endTitle: '个月', num: 0, percent: '0%' }
] ];
{ {
let nowDate = +new Date() let nowDate = +new Date();
let todayStartDate = new Date(new Date().toLocaleDateString()).getTime() let todayStartDate = new Date(new Date().toLocaleDateString()).getTime();
let todayPassHours = (nowDate - todayStartDate) / 1000 / 60 / 60 let todayPassHours = (nowDate - todayStartDate) / 1000 / 60 / 60;
let todayPassHoursPercent = (todayPassHours / 24) * 100 let todayPassHoursPercent = (todayPassHours / 24) * 100;
timelife[0].num = parseInt(todayPassHours) timelife[0].num = parseInt(todayPassHours);
timelife[0].percent = parseInt(todayPassHoursPercent) + '%' timelife[0].percent = parseInt(todayPassHoursPercent) + '%';
} }
{ {
let weeks = { 0: 7, 1: 1, 2: 2, 3: 3, 4: 4, 5: 5, 6: 6 } let weeks = { 0: 7, 1: 1, 2: 2, 3: 3, 4: 4, 5: 5, 6: 6 };
let weekDay = weeks[new Date().getDay()] let weekDay = weeks[new Date().getDay()];
let weekDayPassPercent = (weekDay / 7) * 100 let weekDayPassPercent = (weekDay / 7) * 100;
timelife[1].num = parseInt(weekDay) timelife[1].num = parseInt(weekDay);
timelife[1].percent = parseInt(weekDayPassPercent) + '%' timelife[1].percent = parseInt(weekDayPassPercent) + '%';
} }
{ {
let year = new Date().getFullYear() let year = new Date().getFullYear();
let date = new Date().getDate() let date = new Date().getDate();
let month = new Date().getMonth() + 1 let month = new Date().getMonth() + 1;
let monthAll = new Date(year, month, 0).getDate() let monthAll = new Date(year, month, 0).getDate();
let monthPassPercent = (date / monthAll) * 100 let monthPassPercent = (date / monthAll) * 100;
timelife[2].num = date timelife[2].num = date;
timelife[2].percent = parseInt(monthPassPercent) + '%' timelife[2].percent = parseInt(monthPassPercent) + '%';
} }
{ {
let month = new Date().getMonth() + 1 let month = new Date().getMonth() + 1;
let yearPass = (month / 12) * 100 let yearPass = (month / 12) * 100;
timelife[3].num = month timelife[3].num = month;
timelife[3].percent = parseInt(yearPass) + '%' timelife[3].percent = parseInt(yearPass) + '%';
} }
let htmlStr = '' let htmlStr = '';
timelife.forEach((item, index) => { timelife.forEach((item, index) => {
htmlStr += ` htmlStr += `
<div class="item"> <div class="item">
@ -147,20 +147,20 @@ document.addEventListener('DOMContentLoaded', () => {
</div> </div>
<div class="progress-percentage">${item.percent}</div> <div class="progress-percentage">${item.percent}</div>
</div> </div>
</div>` </div>`;
}) });
$('.joe_aside__item.timelife .joe_aside__item-contain').html(htmlStr) $('.joe_aside__item.timelife .joe_aside__item-contain').html(htmlStr);
} }
} }
/* 激活侧边栏天气功能 */ /* 激活侧边栏天气功能 */
{ {
if ($('.joe_aside__item.weather').length !== 0) { if ($('.joe_aside__item.weather').length !== 0) {
const key = $('.joe_aside__item.weather').attr('data-key') const key = $('.joe_aside__item.weather').attr('data-key');
const style = $('.joe_aside__item.weather').attr('data-style') const style = $('.joe_aside__item.weather').attr('data-style');
const aqiColor = { 1: 'FFFFFF', 2: '4A4A4A', 3: 'FFFFFF' } const aqiColor = { 1: 'FFFFFF', 2: '4A4A4A', 3: 'FFFFFF' };
window.WIDGET = { CONFIG: { layout: 2, width: '220', height: '270', background: style, dataColor: aqiColor[style], language: 'zh', key: key } } window.WIDGET = { CONFIG: { layout: 2, width: '220', height: '270', background: style, dataColor: aqiColor[style], language: 'zh', key: key } };
$.getScript('https://apip.weatherdt.com/standard/static/js/weather-standard.js?v=2.0') $.getScript('https://apip.weatherdt.com/standard/static/js/weather-standard.js?v=2.0');
} }
} }
@ -172,8 +172,8 @@ document.addEventListener('DOMContentLoaded', () => {
type: 'POST', type: 'POST',
data: { routeType: 'aside_ranking' }, data: { routeType: 'aside_ranking' },
success(res) { success(res) {
$('.joe_aside__item.ranking .joe_aside__item-title .text').html(res.title) $('.joe_aside__item.ranking .joe_aside__item-title .text').html(res.title);
let htmlStr = '' let htmlStr = '';
if (res.code === 1) { if (res.code === 1) {
res.data.forEach((item, index) => { res.data.forEach((item, index) => {
htmlStr += ` htmlStr += `
@ -181,20 +181,20 @@ document.addEventListener('DOMContentLoaded', () => {
<span class="sort">${index + 1}</span> <span class="sort">${index + 1}</span>
<a class="link" href="${item.url}" title="${item.title}" target="_blank" rel="noopener noreferrer nofollow">${item.title}</a> <a class="link" href="${item.url}" title="${item.title}" target="_blank" rel="noopener noreferrer nofollow">${item.title}</a>
</li> </li>
` `;
}) });
} else { } else {
htmlStr += `<li class="error">数据抓取异常!</li>` htmlStr += `<li class="error">数据抓取异常!</li>`;
} }
$('.joe_aside__item.ranking .joe_aside__item-contain').html(htmlStr) $('.joe_aside__item.ranking .joe_aside__item-contain').html(htmlStr);
} }
}) });
} }
} }
/* 设置侧边栏最后一个元素的高度 */ /* 设置侧边栏最后一个元素的高度 */
{ {
$('.joe_aside__item:last-child').css('top', $('.joe_header').height() + 15) $('.joe_aside__item:last-child').css('top', $('.joe_header').height() + 15);
} }
/* 激活Live2d人物 */ /* 激活Live2d人物 */
@ -205,132 +205,132 @@ document.addEventListener('DOMContentLoaded', () => {
model: { jsonPath: Joe.LIVE2D, scale: 1 }, model: { jsonPath: Joe.LIVE2D, scale: 1 },
mobile: { show: false }, mobile: { show: false },
display: { position: 'right', width: 160, height: 200, hOffset: 70, vOffset: 0 } display: { position: 'right', width: 160, height: 200, hOffset: 70, vOffset: 0 }
}) });
}) });
} }
} }
/* 计算页面滚动多少 */ /* 计算页面滚动多少 */
{ {
const calcProgress = () => { const calcProgress = () => {
let scrollTop = $(window).scrollTop() let scrollTop = $(window).scrollTop();
let documentHeight = $(document).height() let documentHeight = $(document).height();
let windowHeight = $(window).height() let windowHeight = $(window).height();
let progress = parseInt((scrollTop / (documentHeight - windowHeight)) * 100) let progress = parseInt((scrollTop / (documentHeight - windowHeight)) * 100);
if (progress <= 0) progress = 0 if (progress <= 0) progress = 0;
if (progress >= 100) progress = 100 if (progress >= 100) progress = 100;
$('.joe_header__below-progress').css('width', progress + '%') $('.joe_header__below-progress').css('width', progress + '%');
} };
calcProgress() calcProgress();
$(window).on('scroll', () => calcProgress()) $(window).on('scroll', () => calcProgress());
} }
/* 判断页面上是否有侧边栏 */ /* 判断页面上是否有侧边栏 */
{ {
const getAside = () => { const getAside = () => {
if ($('.joe_aside').length === 0) { if ($('.joe_aside').length === 0) {
$('body').addClass('noaside') $('body').addClass('noaside');
} else { } else {
$('body').removeClass('noaside') $('body').removeClass('noaside');
} }
} };
getAside() getAside();
$(window).on('resize', () => getAside()) $(window).on('resize', () => getAside());
} }
/* 评论框点击切换画图模式和文本模式 */ /* 评论框点击切换画图模式和文本模式 */
{ {
$('.joe_comment__respond-type .item').on('click', function () { $('.joe_comment__respond-type .item').on('click', function () {
$(this).addClass('active').siblings().removeClass('active') $(this).addClass('active').siblings().removeClass('active');
if ($(this).attr('data-type') === 'draw') { if ($(this).attr('data-type') === 'draw') {
$('.joe_comment__respond-form .body .draw').show().siblings().hide() $('.joe_comment__respond-form .body .draw').show().siblings().hide();
$('#joe_comment_draw').prop('width', $('.joe_comment__respond-form .body').width()) $('#joe_comment_draw').prop('width', $('.joe_comment__respond-form .body').width());
/* 设置表单格式为画图模式 */ /* 设置表单格式为画图模式 */
$('.joe_comment__respond-form').attr('data-type', 'draw') $('.joe_comment__respond-form').attr('data-type', 'draw');
} else { } else {
$('.joe_comment__respond-form .body .text').show().siblings().hide() $('.joe_comment__respond-form .body .text').show().siblings().hide();
/* 设置表单格式为文字模式 */ /* 设置表单格式为文字模式 */
$('.joe_comment__respond-form').attr('data-type', 'text') $('.joe_comment__respond-form').attr('data-type', 'text');
} }
}) });
} }
/* 激活画图功能 */ /* 激活画图功能 */
{ {
if ($('#joe_comment_draw').length !== 0) { if ($('#joe_comment_draw').length !== 0) {
/* 激活画板 */ /* 激活画板 */
window.sketchpad = new Sketchpad({ element: '#joe_comment_draw', height: 300, penSize: 5, color: '303133' }) window.sketchpad = new Sketchpad({ element: '#joe_comment_draw', height: 300, penSize: 5, color: '303133' });
/* 撤销上一步 */ /* 撤销上一步 */
$('.joe_comment__respond-form .body .draw .icon-undo').on('click', () => window.sketchpad.undo()) $('.joe_comment__respond-form .body .draw .icon-undo').on('click', () => window.sketchpad.undo());
/* 动画预览 */ /* 动画预览 */
$('.joe_comment__respond-form .body .draw .icon-animate').on('click', () => window.sketchpad.animate(10)) $('.joe_comment__respond-form .body .draw .icon-animate').on('click', () => window.sketchpad.animate(10));
/* 更改画板的线宽 */ /* 更改画板的线宽 */
$('.joe_comment__respond-form .body .draw .line li').on('click', function () { $('.joe_comment__respond-form .body .draw .line li').on('click', function () {
window.sketchpad.penSize = $(this).attr('data-line') window.sketchpad.penSize = $(this).attr('data-line');
$(this).addClass('active').siblings().removeClass('active') $(this).addClass('active').siblings().removeClass('active');
}) });
/* 更改画板的颜色 */ /* 更改画板的颜色 */
$('.joe_comment__respond-form .body .draw .color li').on('click', function () { $('.joe_comment__respond-form .body .draw .color li').on('click', function () {
window.sketchpad.color = $(this).attr('data-color') window.sketchpad.color = $(this).attr('data-color');
$(this).addClass('active').siblings().removeClass('active') $(this).addClass('active').siblings().removeClass('active');
}) });
} }
} }
/* 重写评论功能 */ /* 重写评论功能 */
{ {
const respond = $('.joe_comment__respond') const respond = $('.joe_comment__respond');
/* 重写回复功能 */ /* 重写回复功能 */
$('.joe_comment__reply').on('click', function () { $('.joe_comment__reply').on('click', function () {
/* 父级ID */ /* 父级ID */
const coid = $(this).attr('data-coid') const coid = $(this).attr('data-coid');
/* 当前的项 */ /* 当前的项 */
const item = $('#' + $(this).attr('data-id')) const item = $('#' + $(this).attr('data-id'));
/* 添加自定义属性表示父级ID */ /* 添加自定义属性表示父级ID */
respond.find('.joe_comment__respond-form').attr('data-coid', coid) respond.find('.joe_comment__respond-form').attr('data-coid', coid);
item.append(respond) item.append(respond);
$(".joe_comment__respond-type .item[data-type='text']").click() $(".joe_comment__respond-type .item[data-type='text']").click();
$('.joe_comment__cancle').show() $('.joe_comment__cancle').show();
window.scrollTo({ window.scrollTo({
top: item.offset().top - $('.joe_header').height() - 15, top: item.offset().top - $('.joe_header').height() - 15,
behavior: 'smooth' behavior: 'smooth'
}) });
}) });
/* 重写取消回复功能 */ /* 重写取消回复功能 */
$('.joe_comment__cancle').on('click', function () { $('.joe_comment__cancle').on('click', function () {
/* 移除自定义属性父级ID */ /* 移除自定义属性父级ID */
respond.find('.joe_comment__respond-form').removeAttr('data-coid') respond.find('.joe_comment__respond-form').removeAttr('data-coid');
$('.joe_comment__cancle').hide() $('.joe_comment__cancle').hide();
$('.joe_comment__title').after(respond) $('.joe_comment__title').after(respond);
$(".joe_comment__respond-type .item[data-type='text']").click() $(".joe_comment__respond-type .item[data-type='text']").click();
window.scrollTo({ window.scrollTo({
top: $('.joe_comment').offset().top - $('.joe_header').height() - 15, top: $('.joe_comment').offset().top - $('.joe_header').height() - 15,
behavior: 'smooth' behavior: 'smooth'
}) });
}) });
} }
/* 激活评论提交 */ /* 激活评论提交 */
{ {
let isSubmit = false let isSubmit = false;
$('.joe_comment__respond-form').on('submit', function (e) { $('.joe_comment__respond-form').on('submit', function (e) {
e.preventDefault() e.preventDefault();
const url = $('.joe_comment__respond-form').attr('action') const url = $('.joe_comment__respond-form').attr('action');
const type = $('.joe_comment__respond-form').attr('data-type') const type = $('.joe_comment__respond-form').attr('data-type');
const parent = $('.joe_comment__respond-form').attr('data-coid') const parent = $('.joe_comment__respond-form').attr('data-coid');
const author = $(".joe_comment__respond-form .head input[name='author']").val() const author = $(".joe_comment__respond-form .head input[name='author']").val();
const mail = $(".joe_comment__respond-form .head input[name='mail']").val() const mail = $(".joe_comment__respond-form .head input[name='mail']").val();
let text = $(".joe_comment__respond-form .body textarea[name='text']").val() let text = $(".joe_comment__respond-form .body textarea[name='text']").val();
if (author.trim() === '') return Qmsg.info('请输入昵称!') if (author.trim() === '') return Qmsg.info('请输入昵称!');
if (!/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/.test(mail)) return Qmsg.info('请输入正确的邮箱!') if (!/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/.test(mail)) return Qmsg.info('请输入正确的邮箱!');
if (type === 'text' && text.trim() === '') return Qmsg.info('请输入评论内容!') if (type === 'text' && text.trim() === '') return Qmsg.info('请输入评论内容!');
if (type === 'draw') { if (type === 'draw') {
const txt = $('#joe_comment_draw')[0].toDataURL('image/webp', 0.1) const txt = $('#joe_comment_draw')[0].toDataURL('image/webp', 0.1);
text = '{!{' + txt + '}!} ' text = '{!{' + txt + '}!} ';
} }
if (isSubmit) return if (isSubmit) return;
isSubmit = true isSubmit = true;
$('.joe_comment__respond-form .foot .submit button').html('发送中...') $('.joe_comment__respond-form .foot .submit button').html('发送中...');
$.ajax({ $.ajax({
url, url,
type: 'POST', type: 'POST',
@ -338,34 +338,34 @@ document.addEventListener('DOMContentLoaded', () => {
datatype: 'text', datatype: 'text',
success(res) { success(res) {
let arr = [], let arr = [],
str = '' str = '';
arr = $(res).contents() arr = $(res).contents();
Array.from(arr).forEach(_ => { Array.from(arr).forEach(_ => {
if (_.parentNode.className === 'container') str = _ if (_.parentNode.className === 'container') str = _;
}) });
if (!/Joe/.test(res)) { if (!/Joe/.test(res)) {
Qmsg.warning(str.textContent.trim() || '') Qmsg.warning(str.textContent.trim() || '');
isSubmit = false isSubmit = false;
$('.joe_comment__respond-form .foot .submit button').html('发表评论') $('.joe_comment__respond-form .foot .submit button').html('发表评论');
} else { } else {
window.location.href = changeURLArg(location.href, 'scroll', 'joe_comment') window.location.href = changeURLArg(location.href, 'scroll', 'joe_comment');
} }
} }
}) });
}) });
} }
/* 切换标签显示不同的标题 */ /* 切换标签显示不同的标题 */
{ {
if (Joe.DOCUMENT_TITLE) { if (Joe.DOCUMENT_TITLE) {
const TITLE = document.title const TITLE = document.title;
document.addEventListener('visibilitychange', () => { document.addEventListener('visibilitychange', () => {
if (document.visibilityState === 'hidden') { if (document.visibilityState === 'hidden') {
document.title = Joe.DOCUMENT_TITLE document.title = Joe.DOCUMENT_TITLE;
} else { } else {
document.title = TITLE document.title = TITLE;
} }
}) });
} }
} }
@ -373,87 +373,87 @@ document.addEventListener('DOMContentLoaded', () => {
{ {
$('.joe_header__above-slideicon').on('click', function () { $('.joe_header__above-slideicon').on('click', function () {
/* 关闭搜索框 */ /* 关闭搜索框 */
$('.joe_header__searchout').removeClass('active') $('.joe_header__searchout').removeClass('active');
/* 处理开启关闭状态 */ /* 处理开启关闭状态 */
if ($('.joe_header__slideout').hasClass('active')) { if ($('.joe_header__slideout').hasClass('active')) {
$('body').css('overflow', '') $('body').css('overflow', '');
$('.joe_header__mask').removeClass('active slideout') $('.joe_header__mask').removeClass('active slideout');
$('.joe_header__slideout').removeClass('active') $('.joe_header__slideout').removeClass('active');
} else { } else {
$('body').css('overflow', 'hidden') $('body').css('overflow', 'hidden');
$('.joe_header__mask').addClass('active slideout') $('.joe_header__mask').addClass('active slideout');
$('.joe_header__slideout').addClass('active') $('.joe_header__slideout').addClass('active');
} }
}) });
} }
/* 小屏幕搜索框 */ /* 小屏幕搜索框 */
{ {
$('.joe_header__above-searchicon').on('click', function () { $('.joe_header__above-searchicon').on('click', function () {
/* 关闭侧边栏 */ /* 关闭侧边栏 */
$('.joe_header__slideout').removeClass('active') $('.joe_header__slideout').removeClass('active');
/* 处理开启关闭状态 */ /* 处理开启关闭状态 */
if ($('.joe_header__searchout').hasClass('active')) { if ($('.joe_header__searchout').hasClass('active')) {
$('body').css('overflow', '') $('body').css('overflow', '');
$('.joe_header__mask').removeClass('active slideout') $('.joe_header__mask').removeClass('active slideout');
$('.joe_header__searchout').removeClass('active') $('.joe_header__searchout').removeClass('active');
} else { } else {
$('body').css('overflow', 'hidden') $('body').css('overflow', 'hidden');
$('.joe_header__mask').addClass('active') $('.joe_header__mask').addClass('active');
$('.joe_header__searchout').addClass('active') $('.joe_header__searchout').addClass('active');
} }
}) });
} }
/* 点击遮罩层关闭 */ /* 点击遮罩层关闭 */
{ {
$('.joe_header__mask').on('click', function () { $('.joe_header__mask').on('click', function () {
$('body').css('overflow', '') $('body').css('overflow', '');
$('.joe_header__mask').removeClass('active slideout') $('.joe_header__mask').removeClass('active slideout');
$('.joe_header__searchout').removeClass('active') $('.joe_header__searchout').removeClass('active');
$('.joe_header__slideout').removeClass('active') $('.joe_header__slideout').removeClass('active');
}) });
} }
/* 移动端侧边栏菜单手风琴 */ /* 移动端侧边栏菜单手风琴 */
{ {
$('.joe_header__slideout-menu .current').parents('.panel-body').show().siblings('.panel').addClass('in') $('.joe_header__slideout-menu .current').parents('.panel-body').show().siblings('.panel').addClass('in');
$('.joe_header__slideout-menu .panel').on('click', function () { $('.joe_header__slideout-menu .panel').on('click', function () {
const panelBox = $(this).parent().parent() const panelBox = $(this).parent().parent();
/* 清除全部内容 */ /* 清除全部内容 */
panelBox.find('.panel').not($(this)).removeClass('in') panelBox.find('.panel').not($(this)).removeClass('in');
panelBox.find('.panel-body').not($(this).siblings('.panel-body')).stop().hide('fast') panelBox.find('.panel-body').not($(this).siblings('.panel-body')).stop().hide('fast');
/* 激活当前的内容 */ /* 激活当前的内容 */
$(this).toggleClass('in').siblings('.panel-body').stop().toggle('fast') $(this).toggleClass('in').siblings('.panel-body').stop().toggle('fast');
}) });
} }
/* 初始化网站运行时间 */ /* 初始化网站运行时间 */
{ {
const getRunTime = () => { const getRunTime = () => {
const birthDay = new Date(Joe.BIRTHDAY) const birthDay = new Date(Joe.BIRTHDAY);
const today = +new Date() const today = +new Date();
const timePast = today - birthDay.getTime() const timePast = today - birthDay.getTime();
let day = timePast / (1000 * 24 * 60 * 60) let day = timePast / (1000 * 24 * 60 * 60);
let dayPast = Math.floor(day) let dayPast = Math.floor(day);
let hour = (day - dayPast) * 24 let hour = (day - dayPast) * 24;
let hourPast = Math.floor(hour) let hourPast = Math.floor(hour);
let minute = (hour - hourPast) * 60 let minute = (hour - hourPast) * 60;
let minutePast = Math.floor(minute) let minutePast = Math.floor(minute);
let second = (minute - minutePast) * 60 let second = (minute - minutePast) * 60;
let secondPast = Math.floor(second) let secondPast = Math.floor(second);
day = String(dayPast).padStart(2, 0) day = String(dayPast).padStart(2, 0);
hour = String(hourPast).padStart(2, 0) hour = String(hourPast).padStart(2, 0);
minute = String(minutePast).padStart(2, 0) minute = String(minutePast).padStart(2, 0);
second = String(secondPast).padStart(2, 0) second = String(secondPast).padStart(2, 0);
$('.joe_run__day').html(day) $('.joe_run__day').html(day);
$('.joe_run__hour').html(hour) $('.joe_run__hour').html(hour);
$('.joe_run__minute').html(minute) $('.joe_run__minute').html(minute);
$('.joe_run__second').html(second) $('.joe_run__second').html(second);
} };
if (Joe.BIRTHDAY && /(\d{4})\/(\d{1,2})\/(\d{1,2}) (\d{1,2})\:(\d{1,2})\:(\d{1,2})/.test(Joe.BIRTHDAY)) { if (Joe.BIRTHDAY && /(\d{4})\/(\d{1,2})\/(\d{1,2}) (\d{1,2})\:(\d{1,2})\:(\d{1,2})/.test(Joe.BIRTHDAY)) {
getRunTime() getRunTime();
setInterval(getRunTime, 1000) setInterval(getRunTime, 1000);
} }
} }
@ -463,15 +463,15 @@ document.addEventListener('DOMContentLoaded', () => {
$.ajax({ $.ajax({
url: 'https://cdn.jsdelivr.net/gh/HaoOuBa/Joe@master/assets/json/joe.owo.json', url: 'https://cdn.jsdelivr.net/gh/HaoOuBa/Joe@master/assets/json/joe.owo.json',
success(res) { success(res) {
let barStr = '' let barStr = '';
let scrollStr = '' let scrollStr = '';
for (let key in res) { for (let key in res) {
barStr += `<div class="item" data-index="${res[key].index}">${key}</div>` barStr += `<div class="item" data-index="${res[key].index}">${key}</div>`;
scrollStr += ` scrollStr += `
<ul class="scroll" data-index="${res[key].index}"> <ul class="scroll" data-index="${res[key].index}">
${res[key].container.map(_ => `<li class="item" data-text="${_.data}">${_.icon}</li>`).join('')} ${res[key].container.map(_ => `<li class="item" data-text="${_.data}">${_.icon}</li>`).join('')}
</ul> </ul>
` `;
} }
$('.joe_owo__contain').html(` $('.joe_owo__contain').html(`
<div class="seat">OωO</div> <div class="seat">OωO</div>
@ -479,44 +479,44 @@ document.addEventListener('DOMContentLoaded', () => {
${scrollStr} ${scrollStr}
<div class="bar">${barStr}</div> <div class="bar">${barStr}</div>
</div> </div>
`) `);
$(document).on('click', function () { $(document).on('click', function () {
$('.joe_owo__contain .box').stop().slideUp('fast') $('.joe_owo__contain .box').stop().slideUp('fast');
}) });
$('.joe_owo__contain .seat').on('click', function (e) { $('.joe_owo__contain .seat').on('click', function (e) {
e.stopPropagation() e.stopPropagation();
$(this).siblings('.box').stop().slideToggle('fast') $(this).siblings('.box').stop().slideToggle('fast');
}) });
$('.joe_owo__contain .box .bar .item').on('click', function (e) { $('.joe_owo__contain .box .bar .item').on('click', function (e) {
e.stopPropagation() e.stopPropagation();
$(this).addClass('active').siblings().removeClass('active') $(this).addClass('active').siblings().removeClass('active');
const scrollIndx = '.joe_owo__contain .box .scroll[data-index="' + $(this).attr('data-index') + '"]' const scrollIndx = '.joe_owo__contain .box .scroll[data-index="' + $(this).attr('data-index') + '"]';
$(scrollIndx).show().siblings('.scroll').hide() $(scrollIndx).show().siblings('.scroll').hide();
}) });
/* 点击表情,向文本框插入内容 */ /* 点击表情,向文本框插入内容 */
$('.joe_owo__contain .scroll .item').on('click', function () { $('.joe_owo__contain .scroll .item').on('click', function () {
const text = $(this).attr('data-text') const text = $(this).attr('data-text');
$('.joe_owo__target').insertContent(text) $('.joe_owo__target').insertContent(text);
}) });
/* 默认激活第一个 */ /* 默认激活第一个 */
$('.joe_owo__contain .box .bar .item').first().click() $('.joe_owo__contain .box .bar .item').first().click();
} }
}) });
} }
} }
/* 座右铭 */ /* 座右铭 */
{ {
let motto = Joe.MOTTO let motto = Joe.MOTTO;
if (!motto) motto = '有钱终成眷属,没钱亲眼目睹' if (!motto) motto = '有钱终成眷属,没钱亲眼目睹';
if (motto.includes('http')) { if (motto.includes('http')) {
$.ajax({ $.ajax({
url: motto, url: motto,
dataType: 'text', dataType: 'text',
success: res => $('.joe_motto').html(res) success: res => $('.joe_motto').html(res)
}) });
} else { } else {
$('.joe_motto').html(motto) $('.joe_motto').html(motto);
} }
} }
}) });

View File

@ -198,6 +198,11 @@ document.addEventListener('DOMContentLoaded', () => {
$('.joe_detail__article-video .episodes .item').first().click(); $('.joe_detail__article-video .episodes .item').first().click();
} }
} }
/* mp3播放器 */
{
$('.joe_mp3__player').each((index, item) => new Plyr(item, { settings: [], iconUrl: 'https://cdn.jsdelivr.net/npm/plyr@3.6.4/dist/plyr.svg' }));
}
}); });
/* 写在load事件里为了解决图片未加载完成滚动距离获取会不准确的问题 */ /* 写在load事件里为了解决图片未加载完成滚动距离获取会不准确的问题 */

View File

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

View File

@ -151,5 +151,16 @@ function _parseContent($post, $login)
)); ));
} }
/* 过滤MP3音乐 */
if (strpos($content, '{mp3') !== false) {
$content = preg_replace_callback(
'/\{mp3\s*src="(.*)"\s*\/\}/sSU',
function ($matches) {
return '<span class="joe_detail__article-mp3 block"><audio class="joe_mp3__player" src="' . $matches[1] . '" controls></audio></span>';
},
$content
);
}
echo $content; echo $content;
} }

View File

@ -27,6 +27,7 @@
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3.5.7/dist/jquery.fancybox.min.css" /> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3.5.7/dist/jquery.fancybox.min.css" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/animate.css@3.7.2/animate.min.css" /> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/animate.css@3.7.2/animate.min.css" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css"> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/plyr@3.6.4/dist/plyr.min.css">
<script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/HaoOuBa/Joe@master/plugin/scroll/joe.scroll.js"></script> <script src="https://cdn.jsdelivr.net/gh/HaoOuBa/Joe@master/plugin/scroll/joe.scroll.js"></script>
<script src="https://cdn.jsdelivr.net/npm/lazysizes@5.3.0/lazysizes.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/lazysizes@5.3.0/lazysizes.min.js"></script>
@ -34,6 +35,7 @@
<script src="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3.5.7/dist/jquery.fancybox.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3.5.7/dist/jquery.fancybox.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/HaoOuBa/Joe@master/plugin/qmsg/qmsg.js"></script> <script src="https://cdn.jsdelivr.net/gh/HaoOuBa/Joe@master/plugin/qmsg/qmsg.js"></script>
<script src="https://cdn.jsdelivr.net/gh/HaoOuBa/Joe@master/assets/js/joe.extend.js"></script> <script src="https://cdn.jsdelivr.net/gh/HaoOuBa/Joe@master/assets/js/joe.extend.js"></script>
<script src="https://cdn.jsdelivr.net/npm/plyr@3.6.4/dist/plyr.min.js"></script>
<script src="<?php $this->options->themeUrl('assets/js/joe.global.js?update=20210224'); ?>"></script> <script src="<?php $this->options->themeUrl('assets/js/joe.global.js?update=20210224'); ?>"></script>
<script async src="https://cdn.jsdelivr.net/gh/HaoOuBa/Joe@master/plugin/smooth/joe.smooth.js"></script> <script async src="https://cdn.jsdelivr.net/gh/HaoOuBa/Joe@master/plugin/smooth/joe.smooth.js"></script>
<?php if ($this->options->JCursorEffects && $this->options->JCursorEffects !== 'off') : ?> <?php if ($this->options->JCursorEffects && $this->options->JCursorEffects !== 'off') : ?>

View File

@ -97,6 +97,11 @@ $(function () {
title: '点击复制', title: '点击复制',
id: 'wmd-copy-button', id: 'wmd-copy-button',
svg: '<svg class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"><path d="M817.521 690.221h-50.921v-356.441c0-40.735-35.644-76.38-76.38-76.38h-356.441v-50.921h356.441c71.289 0 127.3 56.012 127.3 127.3v356.441z" p-id="2048" fill="#9b9b9b"></path><path d="M639.3 817.521h-356.441c-40.735 0-76.38-35.644-76.38-76.38v-356.441c0-40.735 35.644-76.38 76.38-76.38h356.441c40.735 0 76.38 35.644 76.38 76.38v356.441c0 40.735-35.644 76.38-76.38 76.38zM282.859 359.241c-15.277 0-25.461 10.185-25.461 25.46v356.441c0 15.277 10.185 25.461 25.461 25.461h356.441c15.277 0 25.46-10.185 25.46-25.461v-356.441c0-15.277-10.185-25.46-25.46-25.46h-356.441z" p-id="2049" fill="#9b9b9b"></path></svg>' svg: '<svg class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"><path d="M817.521 690.221h-50.921v-356.441c0-40.735-35.644-76.38-76.38-76.38h-356.441v-50.921h356.441c71.289 0 127.3 56.012 127.3 127.3v356.441z" p-id="2048" fill="#9b9b9b"></path><path d="M639.3 817.521h-356.441c-40.735 0-76.38-35.644-76.38-76.38v-356.441c0-40.735 35.644-76.38 76.38-76.38h356.441c40.735 0 76.38 35.644 76.38 76.38v356.441c0 40.735-35.644 76.38-76.38 76.38zM282.859 359.241c-15.277 0-25.461 10.185-25.461 25.46v356.441c0 15.277 10.185 25.461 25.461 25.461h356.441c15.277 0 25.46-10.185 25.46-25.461v-356.441c0-15.277-10.185-25.46-25.46-25.46h-356.441z" p-id="2049" fill="#9b9b9b"></path></svg>'
},
{
title: '插入音乐',
id: 'wmd-mp3-button',
svg: '<svg class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"><path d="M806.848 262.144v0.064l6.272 5.76a19.2 19.2 0 0 1-26.24 28.032 6044.48 6044.48 0 0 0-72.96-67.2l-3.648-3.328c-21.376-19.392-39.232-35.2-52.224-46.144a282.432 282.432 0 0 0-16.32-13.056c-1.216-0.896-2.048-1.408-1.792-1.344a14.848 14.848 0 0 0 7.296 1.472 18.944 18.944 0 0 0 18.368-18.816v153.6l-19.2-19.2h172.8V896H300.8a95.872 95.872 0 0 1-96-95.872V128.448h364.8a19.2 19.2 0 0 1 0 38.4H224l19.2-19.2v652.48a57.472 57.472 0 0 0 57.6 57.472h499.2l-19.2 19.2V301.12l19.2 19.2H627.2V147.648c0-10.688 8.576-19.456 19.264-19.648a20.672 20.672 0 0 1 9.856 2.24 51.072 51.072 0 0 1 7.872 4.928c6.4 4.736 12.544 9.664 18.56 14.848 18.048 15.36 35.84 31.04 53.376 47.04l3.648 3.328c22.464 20.48 44.864 41.024 67.072 61.76zM243.2 473.408v0.448H896v326.208H128V473.856h76.8v-0.448h38.4z m458.048 72.768c-17.024 0-30.912 4.608-41.6 14.336l-1.472 1.28c-10.496 9.6-16.384 22.592-17.728 39.04h25.984a35.84 35.84 0 0 1 10.496-24.064c5.76-5.312 14.08-8 24.512-8 10.24 0 18.24 2.176 23.616 7.04a26.24 26.24 0 0 1 7.552 19.968 25.472 25.472 0 0 1-8.32 20.16c-5.312 4.608-13.312 7.04-24.064 7.04h-12.352v19.968h12.608c11.456 0 20.224 2.432 26.048 7.296 6.336 4.864 9.472 12.416 9.472 22.592 0 8.768-3.2 15.808-8.96 21.696a38.208 38.208 0 0 1-27.008 9.728 35.136 35.136 0 0 1-24.832-8.768c-7.296-6.336-10.944-15.36-11.456-27.008h-26.752c1.472 19.456 8.32 34.304 20.48 44.48 10.688 9.024 25.024 13.632 42.752 13.632 18.56 0 33.856-5.312 45.504-15.552a51.584 51.584 0 0 0 16.512-39.424 36.8 36.8 0 0 0-8.704-25.28 48.512 48.512 0 0 0-23.36-14.336c18.944-6.336 28.672-19.2 28.672-38.208a43.328 43.328 0 0 0-15.552-35.008c-10.688-8.512-24.576-12.608-42.048-12.608z m-403.2 3.392h-31.424V723.2h26.496V599.168h0.96l53.312 124.032h22.848l53.248-124.032h0.96V723.2h26.496V549.568h-31.36l-60.288 139.072h-0.768l-60.544-139.072z m258.944 0H484.992V723.2h26.56v-67.584h44.992c41.6 0 62.464-17.792 62.464-53.312 0-35.2-20.672-52.736-62.016-52.736z m-2.176 22.592c12.864 0 22.4 2.432 28.48 7.296 6.08 4.416 9.216 12.16 9.216 22.848 0 10.752-3.2 18.56-8.96 23.36-6.144 4.864-15.616 7.296-28.736 7.296h-43.264v-60.8h43.264z" p-id="14012" fill="#9b9b9b"></path></svg>'
} }
]; ];
@ -158,6 +163,9 @@ $(function () {
case 'wmd-copy-button': case 'wmd-copy-button':
str = `{copy text="文本文本"}${$('#text').selectionRange() ? $('#text').selectionRange() : '点击复制'}{/copy}`; str = `{copy text="文本文本"}${$('#text').selectionRange() ? $('#text').selectionRange() : '点击复制'}{/copy}`;
break; break;
case 'wmd-mp3-button':
str = `\n\n{mp3 src="音乐地址" /}\n\n`;
break;
} }
return str; return str;
} }