更新
This commit is contained in:
parent
a24bb0c2e4
commit
1586b5473e
@ -1,9 +1,8 @@
|
|||||||
/* 搜索页面需要用到的JS */
|
/* 搜索页面需要用到的JS */
|
||||||
console.time('Archive.js执行时长');
|
|
||||||
document.addEventListener('DOMContentLoaded', () => {
|
document.addEventListener('DOMContentLoaded', () => {
|
||||||
/* 激活列表特效 */
|
/* 激活列表特效 */
|
||||||
{
|
{
|
||||||
const wow = $('.joe_archive__list').attr('data-wow');
|
const wow = $('.joe_archive__list').attr('data-wow')
|
||||||
if (wow !== 'off' && wow)
|
if (wow !== 'off' && wow)
|
||||||
new WOW({
|
new WOW({
|
||||||
boxClass: 'wow',
|
boxClass: 'wow',
|
||||||
@ -12,7 +11,6 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
mobile: true,
|
mobile: true,
|
||||||
live: true,
|
live: true,
|
||||||
scrollContainer: null
|
scrollContainer: null
|
||||||
}).init();
|
}).init()
|
||||||
}
|
}
|
||||||
console.timeEnd('Archive.js执行时长');
|
})
|
||||||
});
|
|
||||||
|
@ -2,79 +2,78 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
/* 初始化昼夜模式 */
|
/* 初始化昼夜模式 */
|
||||||
{
|
{
|
||||||
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' }))
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 激活侧边栏人生倒计时功能 */
|
/* 激活侧边栏人生倒计时功能 */
|
||||||
@ -85,38 +84,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">
|
||||||
@ -131,19 +130,19 @@ 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 } }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,8 +154,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 += `
|
||||||
@ -164,20 +163,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人物 */
|
||||||
@ -188,147 +187,151 @@ 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())
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 评论框点击切换画图模式和文本模式 */
|
/* 评论框点击切换画图模式和文本模式 */
|
||||||
{
|
{
|
||||||
$('.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
|
||||||
$('.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 alert('请输入用户名!');
|
if (author.trim() === '') return alert('请输入用户名!')
|
||||||
if (!/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/.test(mail)) return alert('请输入正确的邮箱!');
|
if (!/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/.test(mail)) return alert('请输入正确的邮箱!')
|
||||||
if (type === 'text' && text.trim() === '') return alert('请输入评论内容!');
|
if (type === 'text' && text.trim() === '') return alert('请输入评论内容!')
|
||||||
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
|
||||||
|
isSubmit = true
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url,
|
url,
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
data: { author, mail, text, parent },
|
data: { author, mail, text, parent },
|
||||||
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)) return alert(str.textContent.trim() || '');
|
if (!/Joe/.test(res)) return alert(str.textContent.trim() || '')
|
||||||
window.location.href = Joe.changeURLArg(location.href, 'scroll', 'joe_comment');
|
window.location.href = Joe.changeURLArg(location.href, 'scroll', 'joe_comment')
|
||||||
}
|
},
|
||||||
});
|
complete: () => (isSubmit = false)
|
||||||
});
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 切换标签显示不同的标题 */
|
/* 切换标签显示不同的标题 */
|
||||||
{
|
{
|
||||||
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
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 懒加载 */
|
/* 懒加载 */
|
||||||
new LazyLoad('.lazyload');
|
new LazyLoad('.lazyload')
|
||||||
});
|
})
|
||||||
|
@ -17,7 +17,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
});
|
});
|
||||||
$('.joe_wallpaper__type-list').on('click', '.item', function () {
|
$('.joe_wallpaper__type-list').on('click', '.item', function () {
|
||||||
const cid = $(this).attr('data-cid');
|
const cid = $(this).attr('data-cid');
|
||||||
if (queryData.cid === cid || isLoading) return;
|
if (isLoading) return;
|
||||||
window.scrollTo({ top: 0, behavior: 'smooth' });
|
window.scrollTo({ top: 0, behavior: 'smooth' });
|
||||||
$(this).addClass('active').siblings().removeClass('active');
|
$(this).addClass('active').siblings().removeClass('active');
|
||||||
queryData.cid = cid;
|
queryData.cid = cid;
|
||||||
|
246
plugin/prism/prism.js
Normal file
246
plugin/prism/prism.js
Normal file
File diff suppressed because one or more lines are too long
@ -1,7 +1,8 @@
|
|||||||
$(function () {
|
$(function () {
|
||||||
$('#wmd-editarea textarea').attr('placeholder', '请输入文章内容...(支持图片粘贴上传)');
|
$('#wmd-editarea textarea').attr('placeholder', '请输入文章内容...(支持图片粘贴上传)')
|
||||||
$('#wmd-button-bar .wmd-edittab').remove();
|
$('#wmd-button-bar .wmd-edittab').remove()
|
||||||
$('#wmd-button-row .wmd-spacer').remove();
|
$('#wmd-button-row .wmd-spacer').remove()
|
||||||
|
$('#wmd-button-row #wmd-code-button').remove()
|
||||||
|
|
||||||
/* 增加自定义功能 */
|
/* 增加自定义功能 */
|
||||||
const items = [
|
const items = [
|
||||||
@ -29,36 +30,76 @@ $(function () {
|
|||||||
title: 'DPlayer视频',
|
title: 'DPlayer视频',
|
||||||
id: 'wmd-dplayer-button',
|
id: 'wmd-dplayer-button',
|
||||||
svg: '<svg class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"><path d="M858.88 244.48h-182.016l61.184-61.184a25.6 25.6 0 0 0-36.096-36.096l-97.536 97.28h-182.528l-97.28-97.28a25.6 25.6 0 0 0-36.352 0 25.6 25.6 0 0 0 0 36.096l61.184 61.184h-181.76a25.6 25.6 0 0 0-25.6 25.6v490.752a25.6 25.6 0 0 0 25.6 25.6h691.2a25.6 25.6 0 0 0 25.6-25.6V270.08a25.6 25.6 0 0 0-25.6-25.6z m-25.6 490.752h-640V295.68h640zM743.68 832.256h-460.8a25.6 25.6 0 0 0 0 51.2h460.8a25.6 25.6 0 1 0 0-51.2z" p-id="46595" fill="#9b9b9b"></path><path d="M439.808 623.104a25.6 25.6 0 0 0 12.8 3.584 25.6 25.6 0 0 0 12.8-3.584l171.008-98.56a25.6 25.6 0 0 0 0-44.544l-171.008-98.56a25.6 25.6 0 0 0-38.4 22.016v197.632a25.6 25.6 0 0 0 12.8 22.016z m38.4-175.104l94.208 54.272-94.208 54.272z" p-id="46596" 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="M858.88 244.48h-182.016l61.184-61.184a25.6 25.6 0 0 0-36.096-36.096l-97.536 97.28h-182.528l-97.28-97.28a25.6 25.6 0 0 0-36.352 0 25.6 25.6 0 0 0 0 36.096l61.184 61.184h-181.76a25.6 25.6 0 0 0-25.6 25.6v490.752a25.6 25.6 0 0 0 25.6 25.6h691.2a25.6 25.6 0 0 0 25.6-25.6V270.08a25.6 25.6 0 0 0-25.6-25.6z m-25.6 490.752h-640V295.68h640zM743.68 832.256h-460.8a25.6 25.6 0 0 0 0 51.2h460.8a25.6 25.6 0 1 0 0-51.2z" p-id="46595" fill="#9b9b9b"></path><path d="M439.808 623.104a25.6 25.6 0 0 0 12.8 3.584 25.6 25.6 0 0 0 12.8-3.584l171.008-98.56a25.6 25.6 0 0 0 0-44.544l-171.008-98.56a25.6 25.6 0 0 0-38.4 22.016v197.632a25.6 25.6 0 0 0 12.8 22.016z m38.4-175.104l94.208 54.272-94.208 54.272z" p-id="46596" fill="#9b9b9b"></path></svg>'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'HTML代码',
|
||||||
|
id: 'wmd-html-button',
|
||||||
|
svg: '<svg class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"><path d="M832 832V320l-192-192H256c-38.4 0-64 25.6-64 64v640c0 38.4 25.6 64 64 64h512c32 0 64-25.6 64-64zM614.4 192L768 352V832H256V192h358.4z" fill="#9b9b9b"></path><path d="M550.4 403.2c-12.8 0-25.6 6.4-32 19.2l-51.2 204.8c-6.4 12.8 6.4 25.6 19.2 32h6.4c12.8 0 19.2-6.4 25.6-19.2l51.2-204.8c6.4-12.8-6.4-25.6-19.2-32zM409.6 441.6c-6.4-12.8-25.6-12.8-38.4 0L300.8 512c-12.8 12.8-12.8 25.6 0 38.4l70.4 70.4c6.4 6.4 12.8 6.4 19.2 6.4 6.4 0 12.8 0 19.2-6.4 12.8-12.8 12.8-25.6 0-38.4l-51.2-51.2 51.2-51.2c12.8-12.8 12.8-32 0-38.4zM665.6 441.6c-12.8-12.8-25.6-12.8-38.4 0s-12.8 25.6 0 38.4l51.2 51.2-51.2 51.2c-12.8 12.8-12.8 25.6 0 38.4 6.4 6.4 12.8 6.4 19.2 6.4s12.8 0 19.2-6.4l70.4-70.4c12.8-12.8 12.8-25.6 0-38.4l-70.4-70.4z" p-id="36741" fill="#9b9b9b"></path></svg>'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: 'H1 ~ H6标题',
|
||||||
|
id: 'wmd-title-button',
|
||||||
|
svg: '<svg class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"><path d="M896 128v768H128V128h768z m-64 64H192v640h640V192z m-85.333333 85.333333v85.333334h-192v384h-85.333334V362.666667h-192v-85.333334h469.333334z" fill="#9b9b9b"></path></svg>'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '表格',
|
||||||
|
id: 'wmd-table-button',
|
||||||
|
svg: '<svg class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"><path d="M872 394c4.4 0 8-3.6 8-8v-60c0-4.4-3.6-8-8-8H708V152c0-4.4-3.6-8-8-8h-64c-4.4 0-8 3.6-8 8v166H400V152c0-4.4-3.6-8-8-8h-64c-4.4 0-8 3.6-8 8v166H152c-4.4 0-8 3.6-8 8v60c0 4.4 3.6 8 8 8h168v236H152c-4.4 0-8 3.6-8 8v60c0 4.4 3.6 8 8 8h168v166c0 4.4 3.6 8 8 8h64c4.4 0 8-3.6 8-8V706h228v166c0 4.4 3.6 8 8 8h64c4.4 0 8-3.6 8-8V706h164c4.4 0 8-3.6 8-8v-60c0-4.4-3.6-8-8-8H708V394h164zM628 630H400V394h228v236z" p-id="71062" fill="#9b9b9b"></path></svg>'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '删除线',
|
||||||
|
id: 'wmd-delete-button',
|
||||||
|
svg: '<svg class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"><path d="M926.95196533 468.96875H566.87011719a1576.88964844 1576.88964844 0 0 0-29.77597047-5.65493774c-14.98645019-2.73312378-20.92318726-3.86114502-29.02615355-5.46707154-48.34259033-9.42379761-77.46514893-18.84759521-100.64849854-32.2281189-33.07351685-19.31643677-49.18798828-45.5171814-49.18798828-80.19415283 0-34.86978149 14.32397461-63.79870606 41.46405029-83.87072753 26.76187133-19.79104614 64.83444214-30.25469971 110.06652833-30.25469971 51.64178467 0 91.50897217 13.57498169 118.55099487 40.33602905 13.75872802 13.57003784 23.84417724 30.24975586 29.96960449 49.5670166 1.22360229 3.86526489 2.63589477 9.42379761 4.05395507 16.77694703 0.84622192 4.5236206 4.900177 7.72558594 9.32656861 7.72558593h68.60742188c5.2734375 0 9.51608276-4.33493042 9.51608276-9.51608276v-0.94345093c-0.65835571-6.40969849-1.22360229-11.40216065-1.88607788-15.07873535-6.87936401-40.99438477-26.38449097-76.99136352-56.25769043-103.94192505-41.84060669-38.16897583-103.37997437-58.24017334-177.82608033-58.24017335-68.13363648 0-129.48019409 17.05627442-172.73886108 47.96520997-24.12515258 17.3421936-42.78488159 38.82650757-55.22277832 63.79788208-12.72299195 25.53826904-19.12774658 55.03820801-19.12774659 87.54730225 0 27.80172729 5.36901855 51.3616333 16.30316163 72.09118652 7.81704712 14.79776001 18.46939087 27.80255127 32.13171387 39.58209228H97.66024781c-4.14541626 0-7.53607177 3.39065552-7.53607179 7.53689576v56.54196166c0 4.15036011 3.3914795 7.5418396 7.53607179 7.54183961h408.2415161c1.97836304 0.37738037 3.67163086 0.75476074 5.55853272 1.13214111 29.11761474 5.83868408 46.65014648 9.79623413 62.76379395 14.32397461 21.67300415 6.12460328 38.26126099 12.53018188 52.01916504 20.26071167 33.73764038 19.0362854 50.22949219 46.36422729 50.22949219 83.86990357 0 33.26385498-14.60906982 62.95166016-41.0907898 83.68203735-28.74105835 22.52416992-71.24414063 34.30371094-122.97903442 34.30371093-41.181427 0-76.04626465-8.01068115-103.8496399-23.55908203-27.42352295-15.3597107-46.27111817-37.50650024-56.26098632-65.49691773-0.7498169-2.0706482-1.60098266-4.900177-2.54525758-8.48034667-1.12719727-4.14541626-4.99163818-7.0680542-9.13705443-7.0680542H265.49975586c-5.27838135 0-9.51525879 4.33493042-9.51525879 9.52102662v0.93933105c0.18869018 2.16705323 0.37738037 3.96166992 0.56607056 5.3739624 6.12460328 45.98684693 28.55236816 83.68203735 66.62411499 111.9526062C367.55889893 834.13946533 430.03759766 851.47753906 503.9225769 851.47753906c79.34710693 0 145.87893677-18.65972901 192.43185425-53.99752807 23.55990601-17.80773925 41.65274048-39.76583862 53.80966187-65.02313232 12.24920654-25.53826904 18.56167602-54.56442261 18.56167602-86.22647096 0-29.96878052-5.46212768-55.03244018-16.77200317-76.71038818-5.46624756-10.55593872-12.3447876-20.26071167-20.54498291-29.02615356h195.5423584c4.15036011 0 7.54101562-3.3914795 7.54101562-7.53689576v-56.54278564c0.00082398-4.05395508-3.38983154-7.44543457-7.54019165-7.44543457z m0 0" p-id="78474" fill="#9b9b9b"></path></svg>'
|
||||||
|
},
|
||||||
|
{
|
||||||
|
title: '代码段',
|
||||||
|
id: 'wmd-snippet-button',
|
||||||
|
svg: '<svg class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"><path d="M768 128a128 128 0 0 1 128 128v512a128 128 0 0 1-128 128H256a128 128 0 0 1-128-128V256a128 128 0 0 1 128-128h512z m0 64H256a64 64 0 0 0-63.84 59.2L192 256v512a64 64 0 0 0 59.2 63.84L256 832h512a64 64 0 0 0 63.84-59.2L832 768V256a64 64 0 0 0-59.2-63.84L768 192z m-205.92 136.064a32 32 0 0 1 21.344 36.8l-0.96 3.616-94.88 288a32 32 0 0 1-61.76-16.416l0.96-3.616 94.88-288a32 32 0 0 1 40.416-20.384z m-183.68 35.36a32 32 0 0 1 8.608 41.44l-2.24 3.36-77.28 103.04 77.312 103.04a32 32 0 0 1-3.36 42.24l-3.04 2.56a32 32 0 0 1-42.208-3.296l-2.592-3.072-91.712-122.24a32 32 0 0 1-2.304-34.88l2.304-3.52 91.712-122.24a32 32 0 0 1 44.8-6.4z m267.2 0a32 32 0 0 1 42.208 3.36l2.624 3.04 91.68 122.24 2.304 3.52a32 32 0 0 1 0 31.36l-2.304 3.52-91.68 122.24-2.624 3.104a32 32 0 0 1-38.816 5.536l-3.36-2.24-3.072-2.56a32 32 0 0 1-5.568-38.848l2.24-3.36 77.28-103.072-77.28-103.04-2.24-3.36a32 32 0 0 1 8.64-41.44z" p-id="86024" fill="#9b9b9b"></path></svg>'
|
||||||
}
|
}
|
||||||
];
|
]
|
||||||
|
|
||||||
/* 用于设置插入到文章的短代码内容 */
|
/* 用于设置插入到文章的短代码内容 */
|
||||||
function getInsertTextById(id) {
|
function getInsertTextById(id) {
|
||||||
let str = '';
|
let str = ''
|
||||||
switch (id) {
|
switch (id) {
|
||||||
case 'wmd-hide-button':
|
case 'wmd-hide-button':
|
||||||
str = `\n\n[hide]${$('#text').selectionRange() ? $('#text').selectionRange() : '回复可见'}[/hide]\n\n`;
|
str = `\n\n[hide]${$('#text').selectionRange() ? $('#text').selectionRange() : '回复可见'}[/hide]\n\n`
|
||||||
break;
|
break
|
||||||
case 'wmd-mlist-button':
|
case 'wmd-mlist-button':
|
||||||
str = `\n\n[music-list id="网易云歌单ID" /]\n\n`;
|
str = `\n\n[music-list id="网易云歌单ID" /]\n\n`
|
||||||
break;
|
break
|
||||||
case 'wmd-music-button':
|
case 'wmd-music-button':
|
||||||
str = `\n\n[music id="网易云音乐ID" /]\n\n`;
|
str = `\n\n[music id="网易云音乐ID" /]\n\n`
|
||||||
break;
|
break
|
||||||
case 'wmd-bili-button':
|
case 'wmd-bili-button':
|
||||||
str = `\n\n[bilibili bvid="哔哩哔哩的Bvid" /]\n\n`;
|
str = `\n\n[bilibili bvid="哔哩哔哩的Bvid" /]\n\n`
|
||||||
break;
|
break
|
||||||
case 'wmd-dplayer-button':
|
case 'wmd-dplayer-button':
|
||||||
str = `\n\n[dplayer src="M3U8或MP4地址" /]\n\n`;
|
str = `\n\n[dplayer src="M3U8或MP4地址" /]\n\n`
|
||||||
break;
|
break
|
||||||
|
case 'wmd-html-button':
|
||||||
|
str = `\n\n!!!\n<span class="test">Hello Joe</span>\n<style>\n .test { color: #ff6800 }\n</style>\n!!!\n\n`
|
||||||
|
break
|
||||||
|
case 'wmd-title-button':
|
||||||
|
str = `\n\n# 一级标题\n## 二级标题\n### 三级标题\n#### 四级标题\n##### 五级标题\n###### 六级标题\n\n`
|
||||||
|
break
|
||||||
|
case 'wmd-table-button':
|
||||||
|
str = `\n\n| 左对齐 | 右对齐 | 居中对齐 |\n| :-----| ----: | :----: |\n| 单元格 | 单元格 | 单元格 |\n\n`
|
||||||
|
break
|
||||||
|
case 'wmd-delete-button':
|
||||||
|
str = `~~${$('#text').selectionRange() ? $('#text').selectionRange() : '删除线'}~~`
|
||||||
|
break
|
||||||
|
case 'wmd-snippet-button':
|
||||||
|
str = `\n\n\`\`\`php\necho 'Hello Joe';\n\`\`\`\n\n`
|
||||||
|
break
|
||||||
}
|
}
|
||||||
return str;
|
return str
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 此处无需修改 */
|
/* 此处无需修改 */
|
||||||
items.forEach(_ => {
|
items.forEach(_ => {
|
||||||
let item = $(`<li class="wmd-button" id="${_.id}" title="${_.title}">${_.svg}</li>`);
|
let item = $(`<li class="wmd-button" id="${_.id}" title="${_.title}">${_.svg}</li>`)
|
||||||
item.on('mousedown touchstart', () => $('#text').insertContent(getInsertTextById(_.id)));
|
item.on('mousedown touchstart', () => $('#text').insertContent(getInsertTextById(_.id)))
|
||||||
$('#wmd-button-row').append(item);
|
$('#wmd-button-row').append(item)
|
||||||
});
|
})
|
||||||
});
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user