Jony/assets/js/joe.global.js

556 lines
34 KiB
JavaScript
Raw Normal View History

2021-01-24 15:27:05 +00:00
document.addEventListener('DOMContentLoaded', () => {
2021-03-02 03:03:51 +00:00
/* 初始化昼夜模式 */
{
if (localStorage.getItem('data-night')) {
$('.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');
}
$('.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');
} 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');
}
});
}
2021-01-25 03:29:51 +00:00
2021-03-02 03:03:51 +00:00
/* 动态背景 */
{
if (!Joe.IS_MOBILE && Joe.DYNAMIC_BACKGROUND !== 'off' && Joe.DYNAMIC_BACKGROUND && !Joe.WALLPAPER_BACKGROUND_PC) {
2021-05-07 02:26:04 +00:00
$.getScript(window.Joe.THEME_URL + `assets/backdrop/${Joe.DYNAMIC_BACKGROUND}`);
2021-03-02 03:03:51 +00:00
}
}
2021-01-25 04:30:39 +00:00
2021-03-02 03:03:51 +00:00
/* 搜索框弹窗 */
{
$('.joe_header__above-search .input').on('click', e => {
e.stopPropagation();
$('.joe_header__above-search .result').addClass('active');
});
$(document).on('click', function () {
$('.joe_header__above-search .result').removeClass('active');
});
}
2021-01-25 10:36:43 +00:00
2021-03-02 03:03:51 +00:00
/* 激活全局下拉框功能 */
{
$('.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);
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());
}
});
}
2021-01-23 08:15:02 +00:00
2021-03-02 03:03:51 +00:00
/* 激活全局返回顶部功能 */
{
2021-06-16 03:02:08 +00:00
let _debounce = null;
2021-03-02 03:03:51 +00:00
const handleScroll = () => ((document.documentElement.scrollTop || document.body.scrollTop) > 300 ? $('.joe_action_item.scroll').addClass('active') : $('.joe_action_item.scroll').removeClass('active'));
handleScroll();
2021-05-08 05:54:42 +00:00
$(document).on('scroll', () => {
2021-06-16 03:02:08 +00:00
clearTimeout(_debounce);
_debounce = setTimeout(handleScroll, 80);
2021-05-08 05:54:42 +00:00
});
2021-03-02 03:03:51 +00:00
$('.joe_action_item.scroll').on('click', () => window.scrollTo({ top: 0, behavior: 'smooth' }));
}
2021-02-04 09:31:58 +00:00
2021-03-02 03:03:51 +00:00
/* 激活侧边栏人生倒计时功能 */
{
2021-05-08 05:54:42 +00:00
if ($('.joe_aside__item.timelife').length) {
2021-03-02 03:03:51 +00:00
let timelife = [
{ 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 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 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 htmlStr = '';
timelife.forEach((item, index) => {
htmlStr += `
2021-01-24 15:27:05 +00:00
<div class="item">
<div class="title">
${item.title}
<span class="text">${item.num}</span>
${item.endTitle}
2021-01-23 15:32:27 +00:00
</div>
2021-01-24 15:27:05 +00:00
<div class="progress">
<div class="progress-bar">
<div class="progress-bar-inner progress-bar-inner-${index}" style="width: ${item.percent}"></div>
</div>
<div class="progress-percentage">${item.percent}</div>
</div>
2021-02-27 13:00:05 +00:00
</div>`;
2021-03-02 03:03:51 +00:00
});
$('.joe_aside__item.timelife .joe_aside__item-contain').html(htmlStr);
}
}
2021-01-22 05:03:35 +00:00
2021-03-02 03:03:51 +00:00
/* 激活侧边栏天气功能 */
{
2021-05-08 05:54:42 +00:00
if ($('.joe_aside__item.weather').length) {
2021-03-02 03:03:51 +00:00
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' };
2021-04-13 03:04:03 +00:00
window.WIDGET = { CONFIG: { layout: 2, width: '220', height: '270', background: style, dataColor: aqiColor[style], language: 'zh', key } };
$.getScript('https://widget.qweather.net/standard/static/js/he-standard-common.js?v=2.0');
2021-03-02 03:03:51 +00:00
}
}
2021-01-20 08:06:51 +00:00
2021-03-31 08:45:08 +00:00
/* 3d云标签 */
{
2021-05-08 05:54:42 +00:00
if ($('.joe_aside__item.tags').length) {
2021-03-31 08:45:08 +00:00
const entries = [];
const colors = ['#F8D800', '#0396FF', '#EA5455', '#7367F0', '#32CCBC', '#F6416C', '#28C76F', '#9F44D3', '#F55555', '#736EFE', '#E96D71', '#DE4313', '#D939CD', '#4C83FF', '#F072B6', '#C346C2', '#5961F9', '#FD6585', '#465EFB', '#FFC600', '#FA742B', '#5151E5', '#BB4E75', '#FF52E5', '#49C628', '#00EAFF', '#F067B4', '#F067B4', '#ff9a9e', '#00f2fe', '#4facfe', '#f093fb', '#6fa3ef', '#bc99c4', '#46c47c', '#f9bb3c', '#e8583d', '#f68e5f'];
const random = (min, max) => {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min + 1)) + min;
};
$('.joe_aside__item-contain .list li').each((i, item) => {
entries.push({
label: $(item).attr('data-label'),
url: $(item).attr('data-url'),
target: '_blank',
fontColor: colors[random(0, colors.length - 1)],
2021-04-01 05:58:02 +00:00
fontSize: 15
2021-03-31 08:45:08 +00:00
});
});
$('.joe_aside__item-contain .tag').svg3DTagCloud({
entries,
width: 220,
height: 220,
radius: '65%',
radiusMin: 75,
bgDraw: false,
fov: 800,
speed: 0.5,
fontWeight: 500
});
}
}
2021-04-14 04:36:24 +00:00
/* 侧边栏舔狗日记 */
{
2021-05-08 05:54:42 +00:00
if ($('.joe_aside__item.flatterer').length) {
2021-04-14 04:36:24 +00:00
const arr = ['你昨天晚上又没回我信息,我却看见你的游戏在线,在我再一次孜孜不倦的骚扰你的情况下,你终于跟我说了一句最长的话“**你他妈是不是有病**”,我又陷入了沉思,这一定有什么含义,我想了很久,你竟然提到了我的妈妈,原来你已经想得那么长远了,想和我结婚见我的父母,我太感动了,真的。那你现在在干嘛,我好想你,我妈妈说她也很喜欢你。', '今天我观战了一天你和别人打游戏,**你们玩的很开心**我给你发了200多条消息你说没流量就不回晚上发说说没有人爱你我连滚带爬评论了句有“我在”你把我拉黑了我给你打电话也无人接听。对不起我不该打扰你我求求你再给我一次当好友的机会吧', '我爸说再敢网恋就打断我的腿,幸好不是胳膊,这样我还能继续**和你打字聊天**,就算连胳膊也打断了,我的心里也会有你位置。', '你说你情侣头像是一个人用的,空间上锁是因为你不喜欢玩空间,情侣空间是和闺蜜开的,找你连麦时你说你在忙工作,每次聊天你都说在忙,你真是一个**上进的好女孩**,你真好,我好喜欢你!', '你跟他已经醒了吧?我今天捡垃圾挣了一百多,明天给你打过去。你快点休息吧,我明天叫你起床,给你点外卖买烟,给你点你最喜欢的奶茶。晚上我会继续去摆地摊的,你不用担心我,你床只有那么大睡不下三个。**你要好好照顾好自己,不要让他抢你被子**。我永远爱你!', '她三天没回我的消息了,在我孜孜不倦地骚扰下她终于舍得回我“**nmsl**”,我想这一定是有什么含义吧,噢!我恍然大悟原来是**尼美舒利颗粒**,她知道我有关节炎让我吃尼美舒利颗粒,她还是关心我的,但是又不想显现的那么热情。天啊!她好高冷,我好像更喜欢她了!', '你想我了吧?可以回我消息了吗?我买了万通筋骨贴,你**运动一个晚上腰很疼**吧?今晚早点回家,我炖了排骨汤,我永远在家等你。', '昨晚你和朋友打了一晚上游戏,你破天荒的给我看了战绩,虽然我看不懂但是我相信你一定是最厉害的、最棒的。我给你发了好多消息夸你,告诉你我多崇拜你,你回了我一句“**啥B**”我翻来覆去思考这是什么意思Sha[傻]噢你是说我傻那B就是Baby的意思了吧原来你是在叫我**傻宝**,这么宠溺的语气,我竟一时不敢相信,其实你也是喜欢我的对吧。', '今天我还是照常给你发消息,汇报日常工作,你终于回了我四个字:“**嗯嗯,好的。**”。你开始愿意敷衍我了,我太感动了,受宠若惊。我愿意天天给你发消息,就算你天天骂我,我也不觉得烦。', '你昨天晚上又没回我的消息,在我孜孜不倦的骚扰下,你终于舍得回我了,你说“**滚**”,这其中一定有什么含义,我想了很久,滚是三点水,这代表你对我的思念也如**滚滚流水**一样汹涌,我感动哭了,不知道你现在在干嘛,我很想你。', '听说你想要一套化妆品,我算了算,明天我去工地上**搬一天砖**就可以拿到200块钱再加上我上个月攒下来的零花钱刚好给你买一套迪奥。', '今天表白被拒绝了,她对我说能不能脱下裤子**撒泡尿照照自己**。当我脱下裤子,她咽了口水,说我们可以试一下。', '刚从派出所出来原因前几天14号情人节我想送你礼物我去偷东西的时候被抓了。我本来想反抗警察说了一句老实点别动我立刻就放弃了反抗因为我记得你说过你喜欢**老实人**。', '疫情不能出门现在是早上八点你肯定饿了吧我早起做好了早餐来到你小区保安大哥不让进我给你打了三个电话你终于接了**有病啊我还睡觉呢<EFBFBD>
const random = (min, max) => {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max - min + 1)) + min;
};
const toggle = () => {
2021-04-14 05:50:58 +00:00
$('.joe_aside__item.flatterer .content').html(arr[random(0, arr.length - 1)].replace(/\*\*(.*?)\*\*/g, '<mark>$1</mark>'));
2021-04-14 04:36:24 +00:00
$('.joe_aside__item.flatterer .content').attr('class', 'content type' + random(1, 6));
};
toggle();
$('.joe_aside__item.flatterer .change').on('click', () => toggle());
}
}
2021-03-02 03:03:51 +00:00
/* 激活Live2d人物 */
{
if (Joe.LIVE2D !== 'off' && Joe.LIVE2D) {
$.getScript('https://cdn.jsdelivr.net/npm/live2d-widget@3.1.4/lib/L2Dwidget.min.js', () => {
L2Dwidget.init({
model: { jsonPath: Joe.LIVE2D, scale: 1 },
mobile: { show: false },
display: { position: 'right', width: 160, height: 200, hOffset: 70, vOffset: 0 }
});
});
}
}
2021-01-25 10:36:43 +00:00
2021-03-02 03:03:51 +00:00
/* 评论框点击切换画图模式和文本模式 */
{
2021-05-08 05:54:42 +00:00
if ($('.joe_comment').length) {
$('.joe_comment__respond-type .item').on('click', function () {
$(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').attr('data-type', 'draw');
} else {
$('.joe_comment__respond-form .body .text').show().siblings().hide();
/* 设置表单格式为文字模式 */
$('.joe_comment__respond-form').attr('data-type', 'text');
}
});
}
2021-03-02 03:03:51 +00:00
}
2021-01-26 06:19:52 +00:00
2021-03-02 03:03:51 +00:00
/* 激活画图功能 */
{
2021-05-08 05:54:42 +00:00
if ($('#joe_comment_draw').length) {
2021-03-02 03:03:51 +00:00
/* 激活画板 */
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-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');
});
/* 更改画板的颜色 */
$('.joe_comment__respond-form .body .draw .color li').on('click', function () {
window.sketchpad.color = $(this).attr('data-color');
$(this).addClass('active').siblings().removeClass('active');
});
}
}
2021-01-26 06:19:52 +00:00
2021-03-02 03:03:51 +00:00
/* 重写评论功能 */
{
2021-05-08 05:54:42 +00:00
if ($('.joe_comment__respond').length) {
const respond = $('.joe_comment__respond');
/* 重写回复功能 */
$('.joe_comment__reply').on('click', function () {
/* 父级ID */
const coid = $(this).attr('data-coid');
/* 当前的项 */
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();
window.scrollTo({
top: item.offset().top - $('.joe_header').height() - 15,
behavior: 'smooth'
});
2021-03-02 03:03:51 +00:00
});
2021-05-08 05:54:42 +00:00
/* 重写取消回复功能 */
$('.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();
window.scrollTo({
top: $('.joe_comment').offset().top - $('.joe_header').height() - 15,
behavior: 'smooth'
});
2021-03-02 03:03:51 +00:00
});
2021-05-08 05:54:42 +00:00
}
2021-03-02 03:03:51 +00:00
}
2021-01-27 09:10:23 +00:00
2021-03-02 03:03:51 +00:00
/* 激活评论提交 */
{
2021-05-08 05:54:42 +00:00
if ($('.joe_comment').length) {
let isSubmit = false;
$('.joe_comment__respond-form').on('submit', function (e) {
e.preventDefault();
2021-05-22 10:10:06 +00:00
const action = $('.joe_comment__respond-form').attr('action') + '?time=' + +new Date();
2021-05-08 05:54:42 +00:00
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();
2021-05-20 01:27:35 +00:00
const _ = $(".joe_comment__respond-form input[name='_']").val();
2021-05-08 05:54:42 +00:00
const mail = $(".joe_comment__respond-form .head input[name='mail']").val();
2021-05-22 10:10:06 +00:00
const url = $(".joe_comment__respond-form .head input[name='url']").val();
2021-05-08 05:54:42 +00:00
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 + '}!} ';
2021-03-02 03:03:51 +00:00
}
2021-05-08 05:54:42 +00:00
if (isSubmit) return;
isSubmit = true;
$('.joe_comment__respond-form .foot .submit button').html('发送中...');
$.ajax({
2021-05-22 10:10:06 +00:00
url: action,
2021-05-08 05:54:42 +00:00
type: 'POST',
2021-05-22 10:10:06 +00:00
data: { author, mail, text, parent, url, _ },
2021-05-08 05:54:42 +00:00
dataType: 'text',
success(res) {
let arr = [],
str = '';
arr = $(res).contents();
Array.from(arr).forEach(_ => {
if (_.parentNode.className === 'container') str = _;
});
if (!/Joe/.test(res)) {
Qmsg.warning(str.textContent.trim() || '');
isSubmit = false;
$('.joe_comment__respond-form .foot .submit button').html('发表评论');
} else {
window.location.reload();
}
2021-05-16 14:10:36 +00:00
},
error() {
2021-05-20 01:27:35 +00:00
isSubmit = false;
2021-05-16 14:10:36 +00:00
$('.joe_comment__respond-form .foot .submit button').html('发表评论');
2021-05-20 01:27:35 +00:00
Qmsg.warning('发送失败!请刷新重试!');
2021-05-08 05:54:42 +00:00
}
});
2021-03-02 03:03:51 +00:00
});
2021-05-08 05:54:42 +00:00
}
2021-03-02 03:03:51 +00:00
}
2021-01-27 09:10:23 +00:00
2021-05-25 02:11:31 +00:00
/* 设置评论回复网址为新窗口打开 */
{
$('.comment-list__item .term .content .user .author a').each((index, item) => $(item).attr('target', '_blank'));
}
/* 格式化评论分页的hash值 */
{
$('.joe_comment .joe_pagination a').each((index, item) => {
const href = $(item).attr('href');
if (href && href.includes('#')) {
$(item).attr('href', href.replace('#comments', '?scroll=joe_comment'));
}
});
}
2021-03-02 03:03:51 +00:00
/* 切换标签显示不同的标题 */
{
if (Joe.DOCUMENT_TITLE) {
const TITLE = document.title;
document.addEventListener('visibilitychange', () => {
if (document.visibilityState === 'hidden') {
document.title = Joe.DOCUMENT_TITLE;
} else {
document.title = TITLE;
}
});
}
}
2021-02-10 15:24:59 +00:00
2021-03-02 03:03:51 +00:00
/* 小屏幕伸缩侧边栏 */
{
$('.joe_header__above-slideicon').on('click', function () {
/* 关闭搜索框 */
$('.joe_header__searchout').removeClass('active');
/* 处理开启关闭状态 */
if ($('.joe_header__slideout').hasClass('active')) {
$('body').css('overflow', '');
$('.joe_header__mask').removeClass('active slideout');
$('.joe_header__slideout').removeClass('active');
} else {
$('body').css('overflow', 'hidden');
$('.joe_header__mask').addClass('active slideout');
$('.joe_header__slideout').addClass('active');
}
});
}
2021-02-11 12:07:57 +00:00
2021-03-02 03:03:51 +00:00
/* 小屏幕搜索框 */
{
$('.joe_header__above-searchicon').on('click', function () {
/* 关闭侧边栏 */
$('.joe_header__slideout').removeClass('active');
/* 处理开启关闭状态 */
if ($('.joe_header__searchout').hasClass('active')) {
$('body').css('overflow', '');
$('.joe_header__mask').removeClass('active slideout');
$('.joe_header__searchout').removeClass('active');
} else {
$('body').css('overflow', 'hidden');
$('.joe_header__mask').addClass('active');
$('.joe_header__searchout').addClass('active');
}
});
}
2021-02-11 12:07:57 +00:00
2021-03-02 03:03:51 +00:00
/* 点击遮罩层关闭 */
{
$('.joe_header__mask').on('click', function () {
$('body').css('overflow', '');
$('.joe_header__mask').removeClass('active slideout');
$('.joe_header__searchout').removeClass('active');
$('.joe_header__slideout').removeClass('active');
});
}
2021-02-13 07:12:18 +00:00
2021-03-02 03:03:51 +00:00
/* 移动端侧边栏菜单手风琴 */
{
$('.joe_header__slideout-menu .current').parents('.panel-body').show().siblings('.panel').addClass('in');
$('.joe_header__slideout-menu .panel').on('click', function () {
const panelBox = $(this).parent().parent();
/* 清除全部内容 */
panelBox.find('.panel').not($(this)).removeClass('in');
panelBox.find('.panel-body').not($(this).siblings('.panel-body')).stop().hide('fast');
/* 激活当前的内容 */
$(this).toggleClass('in').siblings('.panel-body').stop().toggle('fast');
});
}
2021-02-15 05:26:39 +00:00
2021-03-02 03:03:51 +00:00
/* 初始化网站运行时间 */
{
const getRunTime = () => {
const birthDay = new Date(Joe.BIRTHDAY);
const today = +new Date();
const timePast = today - birthDay.getTime();
let day = timePast / (1000 * 24 * 60 * 60);
let dayPast = Math.floor(day);
let hour = (day - dayPast) * 24;
let hourPast = Math.floor(hour);
let minute = (hour - hourPast) * 60;
let minutePast = Math.floor(minute);
let second = (minute - minutePast) * 60;
let secondPast = Math.floor(second);
day = String(dayPast).padStart(2, 0);
hour = String(hourPast).padStart(2, 0);
minute = String(minutePast).padStart(2, 0);
second = String(secondPast).padStart(2, 0);
$('.joe_run__day').html(day);
$('.joe_run__hour').html(hour);
$('.joe_run__minute').html(minute);
$('.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)) {
getRunTime();
setInterval(getRunTime, 1000);
}
}
2021-02-19 07:08:07 +00:00
2021-03-02 03:03:51 +00:00
/* 初始化表情功能 */
{
2021-05-08 05:54:42 +00:00
if ($('.joe_owo__contain').length && $('.joe_owo__target').length) {
2021-03-02 03:03:51 +00:00
$.ajax({
2021-05-07 02:26:04 +00:00
url: window.Joe.THEME_URL + 'assets/json/joe.owo.json',
2021-03-26 07:27:06 +00:00
dataType: 'json',
2021-03-02 03:03:51 +00:00
success(res) {
let barStr = '';
let scrollStr = '';
for (let key in res) {
2021-05-07 02:26:04 +00:00
const item = res[key];
barStr += `<div class="item" data-type="${key}">${key}</div>`;
2021-03-02 03:03:51 +00:00
scrollStr += `
2021-05-07 02:26:04 +00:00
<ul class="scroll" data-type="${key}">
${item.map(_ => `<li class="item" data-text="${_.data}">${key === '颜文字' ? `${_.icon}` : `<img src="${window.Joe.THEME_URL + _.icon}" alt="${_.data}"/>`}</li>`).join('')}
2021-02-20 02:27:47 +00:00
</ul>
2021-02-27 13:00:05 +00:00
`;
2021-03-02 03:03:51 +00:00
}
$('.joe_owo__contain').html(`
2021-02-20 02:27:47 +00:00
<div class="seat">OωO</div>
<div class="box">
${scrollStr}
<div class="bar">${barStr}</div>
</div>
2021-02-27 13:00:05 +00:00
`);
2021-03-02 03:03:51 +00:00
$(document).on('click', function () {
$('.joe_owo__contain .box').stop().slideUp('fast');
});
$('.joe_owo__contain .seat').on('click', function (e) {
e.stopPropagation();
$(this).siblings('.box').stop().slideToggle('fast');
});
$('.joe_owo__contain .box .bar .item').on('click', function (e) {
e.stopPropagation();
$(this).addClass('active').siblings().removeClass('active');
2021-05-07 02:26:04 +00:00
const scrollIndx = '.joe_owo__contain .box .scroll[data-type="' + $(this).attr('data-type') + '"]';
2021-03-02 03:03:51 +00:00
$(scrollIndx).show().siblings('.scroll').hide();
});
$('.joe_owo__contain .scroll .item').on('click', function () {
const text = $(this).attr('data-text');
$('.joe_owo__target').insertContent(text);
});
$('.joe_owo__contain .box .bar .item').first().click();
}
});
}
}
2021-02-24 12:24:29 +00:00
2021-03-02 03:03:51 +00:00
/* 座右铭 */
{
let motto = Joe.MOTTO;
if (!motto) motto = '有钱终成眷属,没钱亲眼目睹';
if (motto.includes('http')) {
$.ajax({
url: motto,
dataType: 'text',
success: res => $('.joe_motto').html(res)
});
} else {
$('.joe_motto').html(motto);
}
}
2021-06-16 03:02:08 +00:00
2021-06-16 05:25:09 +00:00
/* 头部滚动 */
2021-06-16 03:02:08 +00:00
{
2021-06-16 05:25:09 +00:00
if (!window.Joe.IS_MOBILE) {
let flag = true;
const handleHeader = diffY => {
if (window.pageYOffset >= $('.joe_header').height() && diffY <= 0) {
if (flag) return;
$('.joe_header').addClass('active');
$('.joe_aside .joe_aside__item:last-child').css('top', $('.joe_header').height() - 60 + 15);
flag = true;
} else {
if (!flag) return;
$('.joe_header').removeClass('active');
$('.joe_aside .joe_aside__item:last-child').css('top', $('.joe_header').height() + 15);
flag = false;
}
};
let Y = window.pageYOffset;
handleHeader(Y);
let _last = Date.now();
document.addEventListener('scroll', () => {
let _now = Date.now();
if (_now - _last > 15) {
handleHeader(Y - window.pageYOffset);
Y = window.pageYOffset;
}
_last = _now;
});
}
2021-06-16 03:02:08 +00:00
}
2021-02-27 13:00:05 +00:00
});