更新
This commit is contained in:
parent
fd51c53b84
commit
767426a56d
File diff suppressed because one or more lines are too long
@ -1311,7 +1311,7 @@ html[data-night='night'] {
|
||||
margin: 0;
|
||||
}
|
||||
}
|
||||
a {
|
||||
a:not(.joe_detail__article-anote) {
|
||||
display: inline-block;
|
||||
line-height: 26px;
|
||||
color: var(--theme);
|
||||
@ -1653,6 +1653,53 @@ html[data-night='night'] {
|
||||
}
|
||||
}
|
||||
}
|
||||
&-anote {
|
||||
display: inline-block;
|
||||
color: #fff;
|
||||
height: 35px;
|
||||
line-height: 35px;
|
||||
transition: transform 0.35s, box-shadow 0.35s;
|
||||
&:hover {
|
||||
transform: translateY(-3px);
|
||||
box-shadow: 0 34px 20px -24px rgba(136, 161, 206, 0.3);
|
||||
}
|
||||
.icon {
|
||||
display: inline-block;
|
||||
vertical-align: top;
|
||||
width: 35px;
|
||||
height: 35px;
|
||||
text-align: center;
|
||||
background: rgba(0, 0, 0, 0.2);
|
||||
.fa {
|
||||
color: #fff;
|
||||
font-size: 15px;
|
||||
}
|
||||
}
|
||||
.content {
|
||||
display: inline-block;
|
||||
vertical-align: top;
|
||||
padding: 0 12px;
|
||||
max-width: 500px;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
&.secondary {
|
||||
background: #34495e;
|
||||
}
|
||||
&.success {
|
||||
background: #27ae60;
|
||||
}
|
||||
&.warning {
|
||||
background: #f39c12;
|
||||
}
|
||||
&.error {
|
||||
background: #e74c3c;
|
||||
}
|
||||
&.info {
|
||||
background: #3498db;
|
||||
}
|
||||
}
|
||||
}
|
||||
&__agree {
|
||||
display: flex;
|
||||
|
@ -2,78 +2,78 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
/* 初始化昼夜模式 */
|
||||
{
|
||||
if (localStorage.getItem('data-night')) {
|
||||
$('.joe_action_item.mode .icon-1').addClass('active')
|
||||
$('.joe_action_item.mode .icon-2').removeClass('active')
|
||||
$('.joe_action_item.mode .icon-1').addClass('active');
|
||||
$('.joe_action_item.mode .icon-2').removeClass('active');
|
||||
} else {
|
||||
$('html').removeAttr('data-night')
|
||||
$('.joe_action_item.mode .icon-1').removeClass('active')
|
||||
$('.joe_action_item.mode .icon-2').addClass('active')
|
||||
$('html').removeAttr('data-night');
|
||||
$('.joe_action_item.mode .icon-1').removeClass('active');
|
||||
$('.joe_action_item.mode .icon-2').addClass('active');
|
||||
}
|
||||
$('.joe_action_item.mode').on('click', () => {
|
||||
if (localStorage.getItem('data-night')) {
|
||||
$('.joe_action_item.mode .icon-1').removeClass('active')
|
||||
$('.joe_action_item.mode .icon-2').addClass('active')
|
||||
$('html').removeAttr('data-night')
|
||||
localStorage.removeItem('data-night')
|
||||
$('.joe_action_item.mode .icon-1').removeClass('active');
|
||||
$('.joe_action_item.mode .icon-2').addClass('active');
|
||||
$('html').removeAttr('data-night');
|
||||
localStorage.removeItem('data-night');
|
||||
} else {
|
||||
$('.joe_action_item.mode .icon-1').addClass('active')
|
||||
$('.joe_action_item.mode .icon-2').removeClass('active')
|
||||
$('html').attr('data-night', 'night')
|
||||
localStorage.setItem('data-night', 'night')
|
||||
$('.joe_action_item.mode .icon-1').addClass('active');
|
||||
$('.joe_action_item.mode .icon-2').removeClass('active');
|
||||
$('html').attr('data-night', 'night');
|
||||
localStorage.setItem('data-night', 'night');
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
/* 动态背景 */
|
||||
{
|
||||
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 => {
|
||||
e.stopPropagation()
|
||||
$('.joe_header__above-search .result').addClass('active')
|
||||
})
|
||||
e.stopPropagation();
|
||||
$('.joe_header__above-search .result').addClass('active');
|
||||
});
|
||||
$(document).on('click', function () {
|
||||
$('.joe_header__above-search .result').removeClass('active')
|
||||
})
|
||||
$('.joe_header__above-search .result').removeClass('active');
|
||||
});
|
||||
$(document).on('scroll', function () {
|
||||
$('.joe_header__above-search .result').removeClass('active')
|
||||
})
|
||||
$('.joe_header__above-search .result').removeClass('active');
|
||||
});
|
||||
}
|
||||
|
||||
/* 激活全局下拉框功能 */
|
||||
{
|
||||
$('.joe_dropdown').each(function (index, item) {
|
||||
const menu = $(this).find('.joe_dropdown__menu')
|
||||
const trigger = $(item).attr('trigger') || 'click'
|
||||
const placement = $(item).attr('placement') || $(this).height() || 0
|
||||
menu.css('top', placement)
|
||||
const menu = $(this).find('.joe_dropdown__menu');
|
||||
const trigger = $(item).attr('trigger') || 'click';
|
||||
const placement = $(item).attr('placement') || $(this).height() || 0;
|
||||
menu.css('top', placement);
|
||||
if (trigger === 'hover') {
|
||||
$(this).hover(
|
||||
() => $(this).addClass('active'),
|
||||
() => $(this).removeClass('active')
|
||||
)
|
||||
);
|
||||
} else {
|
||||
$(this).on('click', function (e) {
|
||||
$(this).toggleClass('active')
|
||||
$(document).one('click', () => $(this).removeClass('active'))
|
||||
e.stopPropagation()
|
||||
})
|
||||
menu.on('click', e => e.stopPropagation())
|
||||
$(this).toggleClass('active');
|
||||
$(document).one('click', () => $(this).removeClass('active'));
|
||||
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'))
|
||||
handleScroll()
|
||||
$(window).on('scroll', () => handleScroll())
|
||||
$('.joe_action_item.scroll').on('click', () => window.scrollTo({ top: 0, behavior: 'smooth' }))
|
||||
const handleScroll = () => ((document.documentElement.scrollTop || document.body.scrollTop) > 300 ? $('.joe_action_item.scroll').addClass('active') : $('.joe_action_item.scroll').removeClass('active'));
|
||||
handleScroll();
|
||||
$(window).on('scroll', () => handleScroll());
|
||||
$('.joe_action_item.scroll').on('click', () => window.scrollTo({ top: 0, behavior: 'smooth' }));
|
||||
}
|
||||
|
||||
/* 激活侧边栏人生倒计时功能 */
|
||||
@ -84,38 +84,38 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
{ title: '这周已经过去', endTitle: '天', num: 0, percent: '0%' },
|
||||
{ title: '本月已经过去', endTitle: '天', num: 0, percent: '0%' },
|
||||
{ title: '今年已经过去', endTitle: '个月', num: 0, percent: '0%' }
|
||||
]
|
||||
];
|
||||
{
|
||||
let nowDate = +new Date()
|
||||
let todayStartDate = new Date(new Date().toLocaleDateString()).getTime()
|
||||
let todayPassHours = (nowDate - todayStartDate) / 1000 / 60 / 60
|
||||
let todayPassHoursPercent = (todayPassHours / 24) * 100
|
||||
timelife[0].num = parseInt(todayPassHours)
|
||||
timelife[0].percent = parseInt(todayPassHoursPercent) + '%'
|
||||
let nowDate = +new Date();
|
||||
let todayStartDate = new Date(new Date().toLocaleDateString()).getTime();
|
||||
let todayPassHours = (nowDate - todayStartDate) / 1000 / 60 / 60;
|
||||
let todayPassHoursPercent = (todayPassHours / 24) * 100;
|
||||
timelife[0].num = parseInt(todayPassHours);
|
||||
timelife[0].percent = parseInt(todayPassHoursPercent) + '%';
|
||||
}
|
||||
{
|
||||
let weeks = { 0: 7, 1: 1, 2: 2, 3: 3, 4: 4, 5: 5, 6: 6 }
|
||||
let weekDay = weeks[new Date().getDay()]
|
||||
let weekDayPassPercent = (weekDay / 7) * 100
|
||||
timelife[1].num = parseInt(weekDay)
|
||||
timelife[1].percent = parseInt(weekDayPassPercent) + '%'
|
||||
let weeks = { 0: 7, 1: 1, 2: 2, 3: 3, 4: 4, 5: 5, 6: 6 };
|
||||
let weekDay = weeks[new Date().getDay()];
|
||||
let weekDayPassPercent = (weekDay / 7) * 100;
|
||||
timelife[1].num = parseInt(weekDay);
|
||||
timelife[1].percent = parseInt(weekDayPassPercent) + '%';
|
||||
}
|
||||
{
|
||||
let year = new Date().getFullYear()
|
||||
let date = new Date().getDate()
|
||||
let month = new Date().getMonth() + 1
|
||||
let monthAll = new Date(year, month, 0).getDate()
|
||||
let monthPassPercent = (date / monthAll) * 100
|
||||
timelife[2].num = date
|
||||
timelife[2].percent = parseInt(monthPassPercent) + '%'
|
||||
let year = new Date().getFullYear();
|
||||
let date = new Date().getDate();
|
||||
let month = new Date().getMonth() + 1;
|
||||
let monthAll = new Date(year, month, 0).getDate();
|
||||
let monthPassPercent = (date / monthAll) * 100;
|
||||
timelife[2].num = date;
|
||||
timelife[2].percent = parseInt(monthPassPercent) + '%';
|
||||
}
|
||||
{
|
||||
let month = new Date().getMonth() + 1
|
||||
let yearPass = (month / 12) * 100
|
||||
timelife[3].num = month
|
||||
timelife[3].percent = parseInt(yearPass) + '%'
|
||||
let month = new Date().getMonth() + 1;
|
||||
let yearPass = (month / 12) * 100;
|
||||
timelife[3].num = month;
|
||||
timelife[3].percent = parseInt(yearPass) + '%';
|
||||
}
|
||||
let htmlStr = ''
|
||||
let htmlStr = '';
|
||||
timelife.forEach((item, index) => {
|
||||
htmlStr += `
|
||||
<div class="item">
|
||||
@ -130,19 +130,19 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
</div>
|
||||
<div class="progress-percentage">${item.percent}</div>
|
||||
</div>
|
||||
</div>`
|
||||
})
|
||||
$('.joe_aside__item.timelife .joe_aside__item-contain').html(htmlStr)
|
||||
</div>`;
|
||||
});
|
||||
$('.joe_aside__item.timelife .joe_aside__item-contain').html(htmlStr);
|
||||
}
|
||||
}
|
||||
|
||||
/* 激活侧边栏天气功能 */
|
||||
{
|
||||
if ($('.joe_aside__item.weather').length !== 0) {
|
||||
const key = $('.joe_aside__item.weather').attr('data-key')
|
||||
const style = $('.joe_aside__item.weather').attr('data-style')
|
||||
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 } }
|
||||
const key = $('.joe_aside__item.weather').attr('data-key');
|
||||
const style = $('.joe_aside__item.weather').attr('data-style');
|
||||
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 } };
|
||||
}
|
||||
}
|
||||
|
||||
@ -154,8 +154,8 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
type: 'POST',
|
||||
data: { routeType: 'aside_ranking' },
|
||||
success(res) {
|
||||
$('.joe_aside__item.ranking .joe_aside__item-title .text').html(res.title)
|
||||
let htmlStr = ''
|
||||
$('.joe_aside__item.ranking .joe_aside__item-title .text').html(res.title);
|
||||
let htmlStr = '';
|
||||
if (res.code === 1) {
|
||||
res.data.forEach((item, index) => {
|
||||
htmlStr += `
|
||||
@ -163,20 +163,20 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
<span class="sort">${index + 1}</span>
|
||||
<a class="link" href="${item.url}" title="${item.title}" target="_blank" rel="noopener noreferrer nofollow">${item.title}</a>
|
||||
</li>
|
||||
`
|
||||
})
|
||||
`;
|
||||
});
|
||||
} 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人物 */
|
||||
@ -187,151 +187,151 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
model: { jsonPath: Joe.LIVE2D, scale: 1 },
|
||||
mobile: { show: false },
|
||||
display: { position: 'right', width: 160, height: 200, hOffset: 70, vOffset: 0 }
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/* 计算页面滚动多少 */
|
||||
{
|
||||
const calcProgress = () => {
|
||||
let scrollTop = $(window).scrollTop()
|
||||
let documentHeight = $(document).height()
|
||||
let windowHeight = $(window).height()
|
||||
let progress = parseInt((scrollTop / (documentHeight - windowHeight)) * 100)
|
||||
if (progress <= 0) progress = 0
|
||||
if (progress >= 100) progress = 100
|
||||
$('.joe_header__below-progress').css('width', progress + '%')
|
||||
}
|
||||
calcProgress()
|
||||
$(window).on('scroll', () => calcProgress())
|
||||
let scrollTop = $(window).scrollTop();
|
||||
let documentHeight = $(document).height();
|
||||
let windowHeight = $(window).height();
|
||||
let progress = parseInt((scrollTop / (documentHeight - windowHeight)) * 100);
|
||||
if (progress <= 0) progress = 0;
|
||||
if (progress >= 100) progress = 100;
|
||||
$('.joe_header__below-progress').css('width', progress + '%');
|
||||
};
|
||||
calcProgress();
|
||||
$(window).on('scroll', () => calcProgress());
|
||||
}
|
||||
|
||||
/* 评论框点击切换画图模式和文本模式 */
|
||||
{
|
||||
$('.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') {
|
||||
$('.joe_comment__respond-form .body .draw').show().siblings().hide()
|
||||
$('#joe_comment_draw').prop('width', $('.joe_comment__respond-form .body').width())
|
||||
$('.joe_comment__respond-form .body .draw').show().siblings().hide();
|
||||
$('#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 {
|
||||
$('.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) {
|
||||
/* 激活画板 */
|
||||
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 () {
|
||||
window.sketchpad.penSize = $(this).attr('data-line')
|
||||
$(this).addClass('active').siblings().removeClass('active')
|
||||
})
|
||||
window.sketchpad.penSize = $(this).attr('data-line');
|
||||
$(this).addClass('active').siblings().removeClass('active');
|
||||
});
|
||||
/* 更改画板的颜色 */
|
||||
$('.joe_comment__respond-form .body .draw .color li').on('click', function () {
|
||||
window.sketchpad.color = $(this).attr('data-color')
|
||||
$(this).addClass('active').siblings().removeClass('active')
|
||||
})
|
||||
window.sketchpad.color = $(this).attr('data-color');
|
||||
$(this).addClass('active').siblings().removeClass('active');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/* 重写评论功能 */
|
||||
{
|
||||
const respond = $('.joe_comment__respond')
|
||||
const respond = $('.joe_comment__respond');
|
||||
/* 重写回复功能 */
|
||||
$('.joe_comment__reply').on('click', function () {
|
||||
/* 父级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 */
|
||||
respond.find('.joe_comment__respond-form').attr('data-coid', coid)
|
||||
item.append(respond)
|
||||
$(".joe_comment__respond-type .item[data-type='text']").click()
|
||||
$('.joe_comment__cancle').show()
|
||||
respond.find('.joe_comment__respond-form').attr('data-coid', coid);
|
||||
item.append(respond);
|
||||
$(".joe_comment__respond-type .item[data-type='text']").click();
|
||||
$('.joe_comment__cancle').show();
|
||||
window.scrollTo({
|
||||
top: item.offset().top - $('.joe_header').height() - 15,
|
||||
behavior: 'smooth'
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
/* 重写取消回复功能 */
|
||||
$('.joe_comment__cancle').on('click', function () {
|
||||
/* 移除自定义属性父级ID */
|
||||
respond.find('.joe_comment__respond-form').removeAttr('data-coid')
|
||||
$('.joe_comment__cancle').hide()
|
||||
$('.joe_comment__title').after(respond)
|
||||
$(".joe_comment__respond-type .item[data-type='text']").click()
|
||||
respond.find('.joe_comment__respond-form').removeAttr('data-coid');
|
||||
$('.joe_comment__cancle').hide();
|
||||
$('.joe_comment__title').after(respond);
|
||||
$(".joe_comment__respond-type .item[data-type='text']").click();
|
||||
window.scrollTo({
|
||||
top: $('.joe_comment').offset().top - $('.joe_header').height() - 15,
|
||||
behavior: 'smooth'
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/* 激活评论提交 */
|
||||
{
|
||||
let isSubmit = false
|
||||
let isSubmit = false;
|
||||
$('.joe_comment__respond-form').on('submit', function (e) {
|
||||
e.preventDefault()
|
||||
const url = $('.joe_comment__respond-form').attr('action')
|
||||
const type = $('.joe_comment__respond-form').attr('data-type')
|
||||
const parent = $('.joe_comment__respond-form').attr('data-coid')
|
||||
const author = $(".joe_comment__respond-form .head input[name='author']").val()
|
||||
const mail = $(".joe_comment__respond-form .head input[name='mail']").val()
|
||||
let text = $(".joe_comment__respond-form .body textarea[name='text']").val()
|
||||
if (author.trim() === '') return alert('请输入用户名!')
|
||||
if (!/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/.test(mail)) return alert('请输入正确的邮箱!')
|
||||
if (type === 'text' && text.trim() === '') return alert('请输入评论内容!')
|
||||
e.preventDefault();
|
||||
const url = $('.joe_comment__respond-form').attr('action');
|
||||
const type = $('.joe_comment__respond-form').attr('data-type');
|
||||
const parent = $('.joe_comment__respond-form').attr('data-coid');
|
||||
const author = $(".joe_comment__respond-form .head input[name='author']").val();
|
||||
const mail = $(".joe_comment__respond-form .head input[name='mail']").val();
|
||||
let text = $(".joe_comment__respond-form .body textarea[name='text']").val();
|
||||
if (author.trim() === '') 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 === 'draw') {
|
||||
const txt = $('#joe_comment_draw')[0].toDataURL('image/webp', 0.1)
|
||||
text = '{!{' + txt + '}!} '
|
||||
const txt = $('#joe_comment_draw')[0].toDataURL('image/webp', 0.1);
|
||||
text = '{!{' + txt + '}!} ';
|
||||
}
|
||||
if (isSubmit) return
|
||||
isSubmit = true
|
||||
if (isSubmit) return;
|
||||
isSubmit = true;
|
||||
$.ajax({
|
||||
url,
|
||||
type: 'POST',
|
||||
data: { author, mail, text, parent },
|
||||
success(res) {
|
||||
let arr = [],
|
||||
str = ''
|
||||
arr = $(res).contents()
|
||||
str = '';
|
||||
arr = $(res).contents();
|
||||
Array.from(arr).forEach(_ => {
|
||||
if (_.parentNode.className === 'container') str = _
|
||||
})
|
||||
if (!/Joe/.test(res)) return alert(str.textContent.trim() || '')
|
||||
window.location.href = Joe.changeURLArg(location.href, 'scroll', 'joe_comment')
|
||||
if (_.parentNode.className === 'container') str = _;
|
||||
});
|
||||
if (!/Joe/.test(res)) return Qmsg.warning(str.textContent.trim() || '');
|
||||
window.location.href = Joe.changeURLArg(location.href, 'scroll', 'joe_comment');
|
||||
},
|
||||
complete: () => (isSubmit = false)
|
||||
})
|
||||
})
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
/* 切换标签显示不同的标题 */
|
||||
{
|
||||
if (Joe.DOCUMENT_TITLE) {
|
||||
const TITLE = document.title
|
||||
const TITLE = document.title;
|
||||
document.addEventListener('visibilitychange', () => {
|
||||
if (document.visibilityState === 'hidden') {
|
||||
document.title = Joe.DOCUMENT_TITLE
|
||||
document.title = Joe.DOCUMENT_TITLE;
|
||||
} else {
|
||||
document.title = TITLE
|
||||
document.title = TITLE;
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/* 懒加载 */
|
||||
new LazyLoad('.lazyload')
|
||||
})
|
||||
new LazyLoad('.lazyload');
|
||||
});
|
||||
|
@ -58,7 +58,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
|
||||
/* 设置文章内的链接为新窗口打开 */
|
||||
{
|
||||
$('.joe_detail__article a').each(function () {
|
||||
$('.joe_detail__article a:not(.joe_detail__article-anote)').each(function () {
|
||||
$(this).attr({ target: '_blank', rel: 'noopener noreferrer nofollow' });
|
||||
});
|
||||
}
|
||||
|
@ -3,25 +3,6 @@
|
||||
/* 过滤短代码 */
|
||||
require_once('short.php');
|
||||
|
||||
/* 过滤文章内容 */
|
||||
function _parseContent($post, $login)
|
||||
{
|
||||
/* 优先判断文章内是否有回复可见的内容 */
|
||||
$content = $post->content;
|
||||
if (preg_match('/\[hide\].{0,}\[\/hide\]/sSU', $content)) {
|
||||
$db = Typecho_Db::get();
|
||||
$hasComment = $db->fetchAll($db->select()->from('table.comments')->where('cid = ?', $post->cid)->where('mail = ?', $post->remember('mail', true))->limit(1));
|
||||
if ($hasComment || $login) {
|
||||
$content = preg_replace('/\[hide\](.{0,})\[\/hide\]/sSU', '$1', $content);
|
||||
} else {
|
||||
$content = preg_replace('/\[hide\](.{0,})\[\/hide\]/sSU', '<span class="joe_detail__article-hide block">此处内容作者设置了 <i>回复</i> 可见</span>', $content);
|
||||
}
|
||||
}
|
||||
$content = _parseShortCode($content);
|
||||
echo $content;
|
||||
}
|
||||
|
||||
|
||||
/* 过滤评论回复 */
|
||||
function _parseCommentReply($text)
|
||||
{
|
||||
|
@ -1,60 +1,71 @@
|
||||
<?php
|
||||
|
||||
function _parseShortCode($content)
|
||||
function _parseContent($post, $login)
|
||||
{
|
||||
/* 优先判断文章内是否有回复可见的内容 */
|
||||
$content = $post->content;
|
||||
if (preg_match('/\{hide\}.{0,}\{\/hide\}/sSU', $content)) {
|
||||
$db = Typecho_Db::get();
|
||||
$hasComment = $db->fetchAll($db->select()->from('table.comments')->where('cid = ?', $post->cid)->where('mail = ?', $post->remember('mail', true))->limit(1));
|
||||
if ($hasComment || $login) {
|
||||
$content = preg_replace('/\{hide\}(.{0,})\{\/hide\}/sSU', '$1', $content);
|
||||
} else {
|
||||
$content = preg_replace('/\{hide\}(.{0,})\{\/hide\}/sSU', '<span class="joe_detail__article-hide block">此处内容作者设置了 <i>回复</i> 可见</span>', $content);
|
||||
}
|
||||
}
|
||||
/* 过滤网易云音乐歌单 */
|
||||
if (preg_match('/\[music-list\s{0,}id="\d{0,}"\s{0,}\/\]/SU', $content)) {
|
||||
if (preg_match('/\{music-list\s{0,}id="\d{0,}"\s{0,}\/\}/SU', $content)) {
|
||||
$content = preg_replace(
|
||||
'/\[music-list\s{0,}id="(\d{0,})"\s{0,}\/]/SU',
|
||||
'/\{music-list\s{0,}id="(\d{0,})"\s{0,}\/\}/SU',
|
||||
'<iframe width="330" height="450" src="//music.163.com/outchain/player?type=0&id=$1&auto=0&height=430"></iframe>',
|
||||
$content
|
||||
);
|
||||
}
|
||||
/* 过滤网易云音乐单首歌 */
|
||||
if (preg_match('/\[music\s{0,}id="\d{0,}"\s{0,}\/\]/SU', $content)) {
|
||||
if (preg_match('/\{music\s{0,}id="\d{0,}"\s{0,}\/\}/SU', $content)) {
|
||||
$content = preg_replace(
|
||||
'/\[music\s{0,}id="(\d{0,})"\s{0,}\/\]/SU',
|
||||
'/\{music\s{0,}id="(\d{0,})"\s{0,}\/\}/SU',
|
||||
'<iframe width="330" height="86" src="//music.163.com/outchain/player?type=2&id=$1&auto=0&height=66"></iframe>',
|
||||
$content
|
||||
);
|
||||
}
|
||||
/* 过滤dplayer播放器 */
|
||||
if (preg_match('/\[dplayer\s{0,}src=".{0,}"\s{0,}\/\]/SU', $content)) {
|
||||
if (preg_match('/\{dplayer\s{0,}src=".{0,}"\s{0,}\/\}/sSU', $content)) {
|
||||
$player = Helper::options()->JCustomPlayer ? Helper::options()->JCustomPlayer : '/usr/themes/Joe/library/player.php?url=';
|
||||
$content = preg_replace(
|
||||
'/\[dplayer\s{0,}src="(.{0,})"\s{0,}\/\]/SU',
|
||||
'/\{dplayer\s{0,}src="(.{0,})"\s{0,}\/\}/sSU',
|
||||
'<iframe class="joe_detail__article-player block" allowfullscreen="true" src="' . $player . '$1"></iframe>',
|
||||
$content
|
||||
);
|
||||
}
|
||||
/* 过滤bilibili播放器 */
|
||||
if (preg_match('/\[bilibili\s{0,}bvid="\w{0,}"\s{0,}\/\]/SU', $content)) {
|
||||
if (preg_match('/\{bilibili\s{0,}bvid="\w{0,}"\s{0,}\/\}/sSU', $content)) {
|
||||
$content = preg_replace(
|
||||
'/\[bilibili\s{0,}bvid="(\w{0,})"\s{0,}\/\]/SU',
|
||||
'/\{bilibili\s{0,}bvid="(\w{0,})"\s{0,}\/\}/sSU',
|
||||
'<iframe class="joe_detail__article-player block" allowfullscreen="true" src="//player.bilibili.com/player.html?bvid=$1"></iframe>',
|
||||
$content
|
||||
);
|
||||
}
|
||||
/* 过滤完成任务勾选 */
|
||||
if (preg_match('/\[x\]/SU', $content)) {
|
||||
if (preg_match('/\{x\}/SU', $content)) {
|
||||
$content = preg_replace(
|
||||
'/\[x\]/SU',
|
||||
'/\{x\}/SU',
|
||||
'<input type="checkbox" class="joe_detail__article-checkbox" checked disabled></input>',
|
||||
$content
|
||||
);
|
||||
}
|
||||
/* 过滤未完成任务勾选 */
|
||||
if (preg_match('/\[\s{1}\]/SU', $content)) {
|
||||
if (preg_match('/\{\s{1}\}/SU', $content)) {
|
||||
$content = preg_replace(
|
||||
'/\[\s{1}\]/SU',
|
||||
'/\{\s{1}\}/SU',
|
||||
'<input type="checkbox" class="joe_detail__article-checkbox" disabled></input>',
|
||||
$content
|
||||
);
|
||||
}
|
||||
/* 过滤默认卡片 */
|
||||
if (preg_match('/\[card-default\s{0,}width=".{0,}"\s{0,}label=".{0,}"\].{0,}\[\/card-default\]/sSU', $content)) {
|
||||
if (preg_match('/\{card-default\s{0,}width=".{0,}"\s{0,}label=".{0,}"\s{0,}\}.{0,}\{\/card-default\}/sSU', $content)) {
|
||||
$content = preg_replace(
|
||||
'/\[card-default\s{0,}width="(.{0,})"\s{0,}label="(.{0,})"\](.{0,})\[\/card-default\]/sSU',
|
||||
'/\{card-default\s{0,}width="(.{0,})"\s{0,}label="(.{0,})"\s{0,}\}(.{0,})\{\/card-default\}/sSU',
|
||||
'<span class="joe_detail__article-card block" style="width: $1">
|
||||
<span class="title block">$2</span>
|
||||
<span class="content block">$3</span>
|
||||
@ -63,9 +74,9 @@ function _parseShortCode($content)
|
||||
);
|
||||
}
|
||||
/* 过滤消息提示 */
|
||||
if (preg_match('/\[message\s{0,}type="success|info|warning|error"\s{0,}\].{0,}\[\/message\]/sSU', $content)) {
|
||||
if (preg_match('/\{message\s{0,}type="success|info|warning|error"\s{0,}\}.{0,}\{\/message\}/sSU', $content)) {
|
||||
$content = preg_replace(
|
||||
'/\[message\s{0,}type="(success|info|warning|error)"\s{0,}\](.{0,})\[\/message\]/sSU',
|
||||
'/\{message\s{0,}type="(success|info|warning|error)"\s{0,}\}(.{0,})\{\/message\}/sSU',
|
||||
'<span class="joe_detail__article-message block $1">
|
||||
<span class="icon"></span>
|
||||
<span class="content">$2</span>
|
||||
@ -74,15 +85,24 @@ function _parseShortCode($content)
|
||||
);
|
||||
}
|
||||
/* 过滤居中标题 */
|
||||
if (preg_match('/\[mtitle\].{0,}\[\/mtitle\]/sSU', $content)) {
|
||||
if (preg_match('/\{mtitle\}.{0,}\{\/mtitle\}/sSU', $content)) {
|
||||
$content = preg_replace(
|
||||
'/\[mtitle\](.{0,})\[\/mtitle\]/sSU',
|
||||
'/\{mtitle\}(.{0,})\{\/mtitle\}/sSU',
|
||||
'<span class="joe_detail__article-mtitle">
|
||||
<span class="text">$1</span>
|
||||
</span>',
|
||||
$content
|
||||
);
|
||||
}
|
||||
|
||||
return $content;
|
||||
/* 过滤note button */
|
||||
if (preg_match('/\{anote\s{0,}icon=".{0,}"\s{0,}href=".{0,}"\s{0,}type="secondary|success|warning|error|info"\s{0,}}.{0,}\{\/anote\}/sSU', $content)) {
|
||||
$content = preg_replace(
|
||||
'/\{anote\s{0,}icon="(.{0,})"\s{0,}href="(.{0,})"\s{0,}type="(secondary|success|warning|error|info)"\s{0,}}(.{0,})\{\/anote\}/sSU',
|
||||
'<a class="joe_detail__article-anote $3" href="$2" target="_blank" rel="noopener noreferrer nofollow">
|
||||
<span class="icon"><i class="fa $1"></i></span><span class="content">$4</span>
|
||||
</a>',
|
||||
$content
|
||||
);
|
||||
}
|
||||
echo $content;
|
||||
}
|
||||
|
1
plugin/qmsg/qmsg.css
Normal file
1
plugin/qmsg/qmsg.css
Normal file
@ -0,0 +1 @@
|
||||
.qmsg.qmsg-wrapper{color:#909399;position:fixed;top:16px;left:0;z-index:9999;width:100%;pointer-events:none;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none;line-height:20px}.qmsg .qmsg-item{padding:8px;text-align:center;-webkit-animation-duration:0.3s;animation-duration:0.3s;position:relative}.qmsg .qmsg-item .qmsg-count{position:absolute;left:-4px;top:-4px;background-color:red;color:#fff;font-size:12px;text-align:center;border-radius:2px;min-width:16px;height:16px;line-height:16px;-webkit-animation-duration:0.3s;animation-duration:0.3s}.qmsg .qmsg-item:first-child{margin-top:-8px}.qmsg .qmsg-content{text-align:left;position:relative;display:inline-block;padding:10px 16px;background:#fff;border-radius:4px;box-shadow:0 4px 12px rgba(0,0,0,0.15);pointer-events:all;max-width:80%;min-width:80px}.qmsg .qmsg-content [class^='qmsg-content-']{display:flex;align-items:center}.qmsg .qmsg-content .qmsg-content-with-close{padding-right:20px}.qmsg .qmsg-icon{display:flex;align-items:center;margin-right:8px}.qmsg .qmsg-icon svg{vertical-align:unset;width:20px;height:20px}.qmsg .qmsg-content-info .qmsg-icon{color:#1890ff}.qmsg .qmsg-icon-close{position:absolute;top:11px;right:5px;padding:0;overflow:hidden;font-size:12px;line-height:22px;background-color:transparent;border:none;outline:none;cursor:pointer;color:rgba(0,0,0,0.45);transition:color 0.3s}.qmsg .qmsg-icon-close:hover>svg path{stroke:#555}.qmsg .animate-turn{-webkit-animation:MessageTurn 1s linear infinite;animation:MessageTurn 1s linear infinite}@-webkit-keyframes MessageTurn{0%{-webkit-transform:rotate(0deg)}25%{-webkit-transform:rotate(90deg)}50%{-webkit-transform:rotate(180deg)}75%{-webkit-transform:rotate(270deg)}100%{-webkit-transform:rotate(360deg)}}@keyframes MessageTurn{0%{-webkit-transform:rotate(0deg)}25%{-webkit-transform:rotate(90deg)}50%{-webkit-transform:rotate(180deg)}75%{-webkit-transform:rotate(270deg)}100%{-webkit-transform:rotate(360deg)}}@-webkit-keyframes MessageMoveOut{0%{max-height:150px;padding:8px;opacity:1}to{max-height:0;padding:0;opacity:0}}@keyframes MessageMoveOut{0%{max-height:150px;padding:8px;opacity:1}to{max-height:0;padding:0;opacity:0}}@-webkit-keyframes MessageMoveIn{0%{-webkit-transform:translateY(-100%);transform:translateY(-100%);-webkit-transform-origin:0 0;transform-origin:0 0;opacity:0}to{-webkit-transform:translateY(0);transform:translateY(0);-webkit-transform-origin:0 0;transform-origin:0 0;opacity:1}}@keyframes MessageMoveIn{0%{-webkit-transform:translateY(-100%);transform:translateY(-100%);-webkit-transform-origin:0 0;transform-origin:0 0;opacity:0}to{-webkit-transform:translateY(0);transform:translateY(0);-webkit-transform-origin:0 0;transform-origin:0 0;opacity:1}}@-webkit-keyframes MessageShake{0%,100%{-webkit-transform:translateX(0px);transform:translateX(0px);opacity:1}25%,75%{-webkit-transform:translateX(-4px);transform:translateX(-4px);opacity:0.75}50%{-webkit-transform:translateX(4px);transform:translateX(4px);opacity:0.25}}@keyframes MessageShake{0%,100%{-webkit-transform:translateX(0px);transform:translateX(0px);opacity:1}25%,75%{-webkit-transform:translateX(-4px);transform:translateX(-4px);opacity:0.75}50%{-webkit-transform:translateX(4px);transform:translateX(4px);opacity:0.25}}
|
1
plugin/qmsg/qmsg.js
Normal file
1
plugin/qmsg/qmsg.js
Normal file
File diff suppressed because one or more lines are too long
147
plugin/qmsg/qmsg.scss
Normal file
147
plugin/qmsg/qmsg.scss
Normal file
@ -0,0 +1,147 @@
|
||||
.qmsg.qmsg-wrapper {
|
||||
color: #909399;
|
||||
position: fixed;
|
||||
top: 16px;
|
||||
left: 0;
|
||||
z-index: 9999;
|
||||
width: 100%;
|
||||
pointer-events: none;
|
||||
user-select: none;
|
||||
line-height: 20px;
|
||||
}
|
||||
.qmsg .qmsg-item {
|
||||
padding: 8px;
|
||||
text-align: center;
|
||||
animation-duration: 0.3s;
|
||||
position: relative;
|
||||
}
|
||||
.qmsg .qmsg-item .qmsg-count {
|
||||
position: absolute;
|
||||
left: -4px;
|
||||
top: -4px;
|
||||
background-color: red;
|
||||
color: #fff;
|
||||
font-size: 12px;
|
||||
text-align: center;
|
||||
border-radius: 2px;
|
||||
min-width: 16px;
|
||||
height: 16px;
|
||||
line-height: 16px;
|
||||
animation-duration: 0.3s;
|
||||
}
|
||||
.qmsg .qmsg-item:first-child {
|
||||
margin-top: -8px;
|
||||
}
|
||||
.qmsg .qmsg-content {
|
||||
text-align: left;
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
padding: 10px 16px;
|
||||
background: #fff;
|
||||
border-radius: 4px;
|
||||
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
|
||||
pointer-events: all;
|
||||
max-width: 80%;
|
||||
min-width: 80px;
|
||||
}
|
||||
.qmsg .qmsg-content [class^='qmsg-content-'] {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
}
|
||||
.qmsg .qmsg-content .qmsg-content-with-close {
|
||||
padding-right: 20px;
|
||||
}
|
||||
.qmsg .qmsg-icon {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
margin-right: 8px;
|
||||
}
|
||||
.qmsg .qmsg-icon svg {
|
||||
vertical-align: unset;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
}
|
||||
.qmsg .qmsg-content-info .qmsg-icon {
|
||||
color: #1890ff;
|
||||
}
|
||||
.qmsg .qmsg-icon-close {
|
||||
position: absolute;
|
||||
top: 11px;
|
||||
right: 5px;
|
||||
padding: 0;
|
||||
overflow: hidden;
|
||||
font-size: 12px;
|
||||
line-height: 22px;
|
||||
background-color: transparent;
|
||||
border: none;
|
||||
outline: none;
|
||||
cursor: pointer;
|
||||
color: rgba(0, 0, 0, 0.45);
|
||||
transition: color 0.3s;
|
||||
}
|
||||
.qmsg .qmsg-icon-close:hover > svg path {
|
||||
stroke: #555;
|
||||
}
|
||||
.qmsg .animate-turn {
|
||||
animation: MessageTurn 1s linear infinite;
|
||||
}
|
||||
@keyframes MessageTurn {
|
||||
0% {
|
||||
-webkit-transform: rotate(0deg);
|
||||
}
|
||||
25% {
|
||||
-webkit-transform: rotate(90deg);
|
||||
}
|
||||
50% {
|
||||
-webkit-transform: rotate(180deg);
|
||||
}
|
||||
75% {
|
||||
-webkit-transform: rotate(270deg);
|
||||
}
|
||||
100% {
|
||||
-webkit-transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
@keyframes MessageMoveOut {
|
||||
0% {
|
||||
max-height: 150px;
|
||||
padding: 8px;
|
||||
opacity: 1;
|
||||
}
|
||||
to {
|
||||
max-height: 0;
|
||||
padding: 0;
|
||||
opacity: 0;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes MessageMoveIn {
|
||||
0% {
|
||||
transform: translateY(-100%);
|
||||
transform-origin: 0 0;
|
||||
opacity: 0;
|
||||
}
|
||||
to {
|
||||
transform: translateY(0);
|
||||
transform-origin: 0 0;
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes MessageShake {
|
||||
0%,
|
||||
100% {
|
||||
transform: translateX(0px);
|
||||
opacity: 1;
|
||||
}
|
||||
25%,
|
||||
75% {
|
||||
transform: translateX(-4px);
|
||||
opacity: 0.75;
|
||||
}
|
||||
50% {
|
||||
transform: translateX(4px);
|
||||
opacity: 0.25;
|
||||
}
|
||||
}
|
@ -63,6 +63,8 @@
|
||||
<link rel="stylesheet" href="https://apip.weatherdt.com/standard/static/css/weather-standard.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/font-awesome@4.7.0/css/font-awesome.min.css">
|
||||
<link rel="stylesheet" href="<?php $this->options->themeUrl('plugin/qmsg/qmsg.css'); ?>" />
|
||||
<link rel="stylesheet" href="<?php $this->options->themeUrl('assets/css/joe.normalize.css'); ?>">
|
||||
<link rel="stylesheet" href="<?php $this->options->themeUrl('assets/css/joe.global.css'); ?>">
|
||||
<!-- 全局公用JS(静态资源放在了CDN上,如果你的服务器带宽不够,请不要修改成本地,cdn采用jsdelivr放心不会失效) -->
|
||||
@ -71,6 +73,7 @@
|
||||
<script src="https://cdn.jsdelivr.net/gh/HaoOuBa/Joe@master/plugin/lazyload/joe.lazyload.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/gh/HaoOuBa/Joe@master/plugin/sketchpad/joe.sketchpad.js"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@3.5.7/dist/jquery.fancybox.min.js"></script>
|
||||
<script src="<?php $this->options->themeUrl('plugin/qmsg/qmsg.js'); ?>"></script>
|
||||
<script src="<?php $this->options->themeUrl('assets/js/joe.global.js'); ?>"></script>
|
||||
<!-- 异步加载的JS -->
|
||||
<script async src="https://apip.weatherdt.com/standard/static/js/weather-standard.js?v=2.0"></script>
|
||||
|
@ -1,8 +1,8 @@
|
||||
$(function () {
|
||||
$('#wmd-editarea textarea').attr('placeholder', '请输入文章内容...(支持图片粘贴上传)')
|
||||
$('#wmd-button-bar .wmd-edittab').remove()
|
||||
$('#wmd-button-row .wmd-spacer').remove()
|
||||
$('#wmd-button-row #wmd-code-button').remove()
|
||||
$('#wmd-editarea textarea').attr('placeholder', '请输入文章内容...(支持图片粘贴上传)');
|
||||
$('#wmd-button-bar .wmd-edittab').remove();
|
||||
$('#wmd-button-row .wmd-spacer').remove();
|
||||
$('#wmd-button-row #wmd-code-button').remove();
|
||||
|
||||
/* 增加自定义功能 */
|
||||
const items = [
|
||||
@ -80,66 +80,74 @@ $(function () {
|
||||
title: '居中标题',
|
||||
id: 'wmd-mtitle-button',
|
||||
svg: '<svg class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg"><path d="M921.6 460.8h-266.24c-20.48-61.44-76.8-102.4-143.36-102.4s-122.88 40.96-143.36 102.4H102.4c-30.72 0-51.2 20.48-51.2 51.2s20.48 51.2 51.2 51.2h266.24c20.48 61.44 76.8 102.4 143.36 102.4s122.88-40.96 143.36-102.4H921.6c30.72 0 51.2-20.48 51.2-51.2s-20.48-51.2-51.2-51.2z m-409.6 102.4c-30.72 0-51.2-20.48-51.2-51.2s20.48-51.2 51.2-51.2 51.2 20.48 51.2 51.2-20.48 51.2-51.2 51.2z" fill="#9b9b9b" p-id="11537"></path></svg>'
|
||||
},
|
||||
{
|
||||
title: '便条按钮',
|
||||
id: 'wmd-anote-button',
|
||||
svg: '<svg t="1612604897877" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="13842" width="20" height="20"><path d="M910.222222 227.555556a113.777778 113.777778 0 0 1 113.777778 113.777777v341.333334a113.777778 113.777778 0 0 1-113.777778 113.777777H113.777778a113.777778 113.777778 0 0 1-113.777778-113.777777V341.333333a113.777778 113.777778 0 0 1 113.777778-113.777777h796.444444z m0 56.888888H113.777778a56.888889 56.888889 0 0 0-56.888889 56.888889v341.333334a56.888889 56.888889 0 0 0 56.888889 56.888889h796.444444a56.888889 56.888889 0 0 0 56.888889-56.888889V341.333333a56.888889 56.888889 0 0 0-56.888889-56.888889zM282.225778 369.891556c25.486222 0 45.937778 5.831111 61.326222 17.521777 15.388444 11.662222 23.096889 29.326222 23.096889 52.963556 0 14.336-3.527111 26.624-10.552889 36.835555-7.025778 10.24-17.066667 18.119111-30.065778 23.694223v0.796444c17.521778 3.697778 30.805333 12.003556 39.822222 24.888889 9.016889 12.885333 13.539556 29.013333 13.539556 48.384 0 11.150222-1.991111 21.560889-5.973333 31.260444-3.982222 9.671111-10.24 18.062222-18.716445 25.088-8.504889 7.025778-19.370667 12.600889-32.654222 16.725334-13.283556 4.124444-29.070222 6.172444-47.388444 6.172444H144.042667v-284.330666h138.183111z m345.258666 0v43.008h-90.396444V654.222222h-49.777778v-241.322666h-89.998222v-43.008h230.172444z m83.626667 0l129.820445 209.464888h0.796444v-209.464888h47.388444V654.222222H836.551111l-129.422222-209.066666h-1.194667V654.222222h-47.388444v-284.330666H711.111111zM281.827556 524.8H193.820444v88.803556h88.007112c15.132444 0 26.88-3.925333 35.242666-11.747556 8.362667-7.822222 12.544-18.915556 12.544-33.251556 0-14.08-4.181333-24.888889-12.544-32.455111-8.362667-7.566222-20.110222-11.349333-35.242666-11.349333z m-6.769778-114.289778H193.820444v78.449778H275.057778c11.946667 0 21.902222-3.384889 29.866666-10.154667s11.946667-16.526222 11.946667-29.269333c0-14.336-3.584-24.433778-10.752-30.264889-7.168-5.831111-17.521778-8.760889-31.061333-8.760889z" p-id="13843" fill="#9b9b9b"></path></svg>'
|
||||
}
|
||||
]
|
||||
];
|
||||
|
||||
/* 用于设置插入到文章的短代码内容 */
|
||||
function getInsertTextById(id) {
|
||||
let str = ''
|
||||
let str = '';
|
||||
switch (id) {
|
||||
case 'wmd-hide-button':
|
||||
str = `\n\n[hide]${$('#text').selectionRange() ? $('#text').selectionRange() : '回复可见'}[/hide]\n\n`
|
||||
break
|
||||
str = `\n\n{hide}${$('#text').selectionRange() ? $('#text').selectionRange() : '回复可见'}{/hide}\n\n`;
|
||||
break;
|
||||
case 'wmd-mlist-button':
|
||||
str = `\n\n[music-list id="网易云歌单ID" /]\n\n`
|
||||
break
|
||||
str = `\n\n{music-list id="网易云歌单ID" /}\n\n`;
|
||||
break;
|
||||
case 'wmd-music-button':
|
||||
str = `\n\n[music id="网易云音乐ID" /]\n\n`
|
||||
break
|
||||
str = `\n\n{music id="网易云音乐ID" /}\n\n`;
|
||||
break;
|
||||
case 'wmd-bili-button':
|
||||
str = `\n\n[bilibili bvid="哔哩哔哩的Bvid" /]\n\n`
|
||||
break
|
||||
str = `\n\n{bilibili bvid="哔哩哔哩的Bvid" /}\n\n`;
|
||||
break;
|
||||
case 'wmd-dplayer-button':
|
||||
str = `\n\n[dplayer src="M3U8或MP4地址" /]\n\n`
|
||||
break
|
||||
str = `\n\n{dplayer src="M3U8或MP4地址" /}\n\n`;
|
||||
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
|
||||
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
|
||||
str = `\n\n# 一级标题\n## 二级标题\n### 三级标题\n#### 四级标题\n##### 五级标题\n###### 六级标题\n\n`;
|
||||
break;
|
||||
case 'wmd-table-button':
|
||||
str = `\n\n| 左对齐 | 右对齐 | 居中对齐 |\n| :-----| ----: | :----: |\n| 单元格 | 单元格 | 单元格 |\n\n`
|
||||
break
|
||||
str = `\n\n| 左对齐 | 右对齐 | 居中对齐 |\n| :-----| ----: | :----: |\n| 单元格 | 单元格 | 单元格 |\n\n`;
|
||||
break;
|
||||
case 'wmd-delete-button':
|
||||
str = `~~${$('#text').selectionRange() ? $('#text').selectionRange() : '删除线'}~~`
|
||||
break
|
||||
str = `~~${$('#text').selectionRange() ? $('#text').selectionRange() : '删除线'}~~`;
|
||||
break;
|
||||
case 'wmd-snippet-button':
|
||||
str = `\n\n\`\`\`php\necho 'Hello Joe';\n\`\`\`\n\n`
|
||||
break
|
||||
str = `\n\n\`\`\`php\necho 'Hello Joe';\n\`\`\`\n\n`;
|
||||
break;
|
||||
case 'wmd-code-button':
|
||||
str = ` \`${$('#text').selectionRange() ? $('#text').selectionRange() : '行内代码'}\` `
|
||||
break
|
||||
str = ` \`${$('#text').selectionRange() ? $('#text').selectionRange() : '行内代码'}\` `;
|
||||
break;
|
||||
case 'wmd-task-button':
|
||||
str = `[x] 任务已完成\n[ ] 任务未完成`
|
||||
break
|
||||
str = `{x} 任务已完成\n{ } 任务未完成`;
|
||||
break;
|
||||
case 'wmd-card-button':
|
||||
str = `\n\n[card-default width="100%" label="卡片标题"]${$('#text').selectionRange() ? $('#text').selectionRange() : '卡片内容'}[/card-default]\n\n`
|
||||
break
|
||||
str = `\n\n{card-default width="100%" label="卡片标题"}${$('#text').selectionRange() ? $('#text').selectionRange() : '卡片内容'}{/card-default}\n\n`;
|
||||
break;
|
||||
case 'wmd-message-button':
|
||||
str = `\n\n[message type="success|info|warning|error"]${$('#text').selectionRange() ? $('#text').selectionRange() : '提示内容'}[/message]\n\n`
|
||||
break
|
||||
str = `\n\n{message type="success|info|warning|error"}${$('#text').selectionRange() ? $('#text').selectionRange() : '提示内容'}{/message}\n\n`;
|
||||
break;
|
||||
case 'wmd-mtitle-button':
|
||||
str = `\n\n[mtitle]${$('#text').selectionRange() ? $('#text').selectionRange() : '居中标题'}[/mtitle]\n\n`
|
||||
break
|
||||
str = `\n\n{mtitle}${$('#text').selectionRange() ? $('#text').selectionRange() : '居中标题'}{/mtitle}\n\n`;
|
||||
break;
|
||||
case 'wmd-anote-button':
|
||||
str = `{anote icon="Font Awesome图标" href="跳转地址" type="secondary|success|warning|error|info"}${$('#text').selectionRange() ? $('#text').selectionRange() : '便条按钮'}{/anote}`;
|
||||
break;
|
||||
}
|
||||
return str
|
||||
return str;
|
||||
}
|
||||
|
||||
/* 此处无需修改 */
|
||||
items.forEach(_ => {
|
||||
let item = $(`<li class="wmd-button" id="${_.id}" title="${_.title}">${_.svg}</li>`)
|
||||
item.on('mousedown touchstart', () => $('#text').insertContent(getInsertTextById(_.id)))
|
||||
$('#wmd-button-row').append(item)
|
||||
})
|
||||
})
|
||||
let item = $(`<li class="wmd-button" id="${_.id}" title="${_.title}">${_.svg}</li>`);
|
||||
item.on('mousedown touchstart', () => $('#text').insertContent(getInsertTextById(_.id)));
|
||||
$('#wmd-button-row').append(item);
|
||||
});
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user