jQuery.fn.extend({
    delayLoading: function(a) {
        a = jQuery.extend({
            defaultImg: "",
            errorImg: "",
            imgSrcAttr: "src",
            setImg: "originalSrc",
            beforehand: 0,
            event: "scroll",
            duration: "normal",
            container: window,
            success: function() {},
            error: function() {}
        }, a || {});
        if (a.errorImg === undefined || a.errorImg === null || a.errorImg === "") {
            a.errorImg = a.defaultImg
        }
        var e = $(this);
        $("img[" + a.imgSrcAttr + "]").each(function() {
            $(this).attr(a.setImg, $(this).attr(a.imgSrcAttr));
            $(this).attr("src", a.defaultImg)
        });
        function g(d) {
            var b, c;
            if (a.container === undefined || a.container === window) {
                b = $(window).scrollTop();
                c = $(window).height() + $(window).scrollTop()
            } else {
                b = $(a.container).offset().top;
                c = $(a.container).offset().top + $(a.container).height()
            }
            return d.offset().top + d.height() + a.beforehand >= b && c >= d.offset().top - a.beforehand
        }
        function h(d) {
            var b, c;
            if (a.container === undefined || a.container === window) {
                b = $(window).scrollLeft();
                c = $(window).width() + $(window).scrollLeft()
            } else {
                b = $(a.container).offset().left;
                c = $(a.container).offset().left + $(a.container).width()
            }
            return d.offset().left + d.width() + a.beforehand >= b && c >= d.offset().left - a.beforehand
        }
        function f() {
            e.filter("img[" + a.setImg + "]").each(function(d, b) {
                if ($(b).attr(a.setImg) !== undefined && $(b).attr(a.setImg) !== null && $(b).attr(a.setImg) !== "" && g($(b)) && h($(b))) {
                    var c = new Image;
                    c.onload = function() {
                        $(b).attr("src", c.src);
                        a.duration !== 0 && $(b).hide().fadeIn(a.duration);
                        $(b).removeAttr(a.setImg);
                        a.success($(b))
                    };
                    c.onerror = function() {
                        $(b).attr("src", a.errorImg);
                        $(b).removeAttr(a.setImg);
                        a.error($(b))
                    };
                    c.src = $(b).attr(a.setImg)
                }
            })
        }
        f();
        $(a.container).bind(a.event, function() {
            f()
        })
    }
});
// 自动夜间模式
document.addEventListener('DOMContentLoaded', () => {
	/* 获取本篇文章百度收录情况 */
	{
		setTimeout(function(){
			$.ajax({
				url: quanjuurl + 'inc/huiyuan.php?tese=shoulu',
				type: 'POST',
				dataType: 'json',
				data: { site: window.location.href },
				success(res) {
					if (res.data && res.data === '已收录') {
						$('#Joe_Baidu_Record').css('color', '#67C23A');
						$('#Joe_Baidu_Record').html('已收录');
					} else {
						if (BaiDuToken) {/* 如果填写了Token，则自动推送给百度 */
							$('#Joe_Baidu_Record').html('<span style="color: #E6A23C">未收录，推送中...</span>');
							const _timer = setTimeout(function () {
								$.ajax({
									url: quanjuurl + 'inc/huiyuan.php?tese=tuisong',
									type: 'POST',
									dataType: 'json',
									data: {
										domain: window.location.protocol + '//' + window.location.hostname,
										url: encodeURI(window.location.href)
									},
									success(res) {
										if (res.data.error) {
											$('#Joe_Baidu_Record').html('<span style="color: #F56C6C">推送失败，请检查！</span>');
										} else {
											$('#Joe_Baidu_Record').html('<span style="color: #67C23A">推送成功！</span>');
										}
									}
								});
								clearTimeout(_timer);
							}, 1000);
						} else {
							const url = `https://ziyuan.baidu.com/linksubmit/url?sitename=${encodeURI(window.location.href)}`;
							$('#Joe_Baidu_Record').html(`<a target="_blank" href="${url}" rel="noopener noreferrer nofollow" style="color: #F56C6C">未收录，提交收录</a>`);
						}
					}
				}
			});
		},4000)
	}
    {
        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');
            }
        });
    }
    /* 动态背景 */
    {
        if (!Joe.IS_MOBILE && Joe.DYNAMIC_BACKGROUND !== 'off' && Joe.DYNAMIC_BACKGROUND && !Joe.WALLPAPER_BACKGROUND_PC) {
            $.getScript(window.Joe.THEME_URL + `assets/backdrop/${Joe.DYNAMIC_BACKGROUND}`);
        }
    }
    /* 搜索框弹窗 */
    {
        $('.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');
        });
        const handle = () => {
            if ($('.joe_header__above-search .result').hasClass('active')) $('.joe_header__above-search .result').removeClass('active');
        };
        $(document).on('scroll', () => {
            if (window.requestAnimationFrame) window.requestAnimationFrame(handle);
            else handle();
        });
    }
    /* 激活全局下拉框功能 */
    {
        $('.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());
            }
        });
    }
    /* 激活全局返回顶部功能 */
    {
        const handleScroll = () => ((document.documentElement.scrollTop || document.body.scrollTop) > 300 ? $('.joe_action_item.scroll').addClass('active') : $('.joe_action_item.scroll').removeClass('active'));
        handleScroll();
        $(document).on('scroll', () => {
            if (window.requestAnimationFrame) window.requestAnimationFrame(handleScroll);
            else handleScroll();
        });
        $('.joe_action_item.scroll').on('click', () => window.scrollTo({
            top: 0,
            behavior: 'smooth'
        }));
    }
    /* 激活侧边栏人生倒计时功能 */
    {
        if ($('.joe_aside__item.timelife').length) {
            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 += `
						<div class="item">
							<div class="title">
								${item.title}
								<span class="text">${item.num}</span>
								${item.endTitle}
							</div>
							<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>
						</div>`;
            });
            $('.joe_aside__item.timelife .joe_aside__item-contain').html(htmlStr);
        }
    }
    /* 设置侧边栏最后一个元素的高度 */
    {
        $('.joe_aside__item:last-child').css('top', $('.joe_header').height() + 15);
    }
    /* 侧边栏舔狗日记 */
    {
        if ($('.joe_aside__item.flatterer').length) {
			$.getJSON(quanjuurl + "inc/huiyuan.php?weiyu=shuzu",function (arr) {
				const random = (min, max) => {
					min = Math.ceil(min);
					max = Math.floor(max);
					return Math.floor(Math.random() * (max - min + 1)) + min;
				};
				const toggle = () => {
					$('.joe_aside__item.flatterer .content').html(arr[random(0, arr.length - 1)].replace(/\*\*(.*?)\*\*/g, '<mark>$1</mark>'));
					$('.joe_aside__item.flatterer .content').attr('class', 'content type' + random(1, 6));
				};
				toggle();
				$('.joe_aside__item.flatterer .change').on('click', () => toggle());
			});
        }
    }
    /* 评论框点击切换画图模式和文本模式 */
    {
        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');
					$('#fa_button').html('<button type="button" id="comment_submit" onclick="comment_post(1)">发表评论</button>');
                } else {
                    $('.joe_comment__respond-form .body .text').show().siblings().hide();
                    /* 设置表单格式为文字模式 */
                    $('.joe_comment__respond-form').attr('data-type', 'text');
					$('#fa_button').html('<button type="button" id="commentfatit" onclick="comment_post();">发表评论</button>');
                }
            });
        }
    }
    /* 激活画图功能 */
    {
        if ($('#joe_comment_draw').length) {
            /* 激活画板 */
            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');
            });
        }
    }
	/* 重写评论功能 */
	{
		if ($('.joe_comment__respond').length) {
			const respond = $('.joe_comment__respond');
			/* 重写回复功能 */
			$('.joe_comment__reply').on('click', function () {
				/* 父级ID */
				const coid = $(this).attr('data-coid');
				document.getElementById("comment_submit").value = 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'
				});
			});
			/* 重写取消回复功能 */
			$('.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'
				});
			});
		}
	}
    /* 小屏幕伸缩侧边栏 */
    {
        $('.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');
            }
        });
    }
    /* 小屏幕搜索框 */
    {
        $('.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');
            }
        });
    }
    /* 点击遮罩层关闭 */
    {
        $('.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');
        });
    }
    /* 移动端侧边栏菜单手风琴 */
    {
        $('.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');
        });
    }
    /* 初始化网站运行时间 */
    {
        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);
        }
    }
    /* 初始化表情功能 */
    {
        if ($('.joe_owo__contain').length && $('.joe_owo__target').length) {
            $.ajax({
                url: window.Joe.THEME_URL + 'assets/json/joe.owo.json',
                dataType: 'json',
                success(res) {
                    let barStr = '';
                    let scrollStr = '';
                    for (let key in res) {
                        const item = res[key];
                        barStr += `<div class="item" data-type="${key}">${key}</div>`;
                        scrollStr += `
                            <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('')}
                            </ul>
                        `;
                    }
                    $('.joe_owo__contain').html(`
                        <div class="seat">OωO</div>
                        <div class="box">
                            ${scrollStr}
                            <div class="bar">${barStr}</div>
                        </div>
                    `);
                    $(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');
                        const scrollIndx = '.joe_owo__contain .box .scroll[data-type="' + $(this).attr('data-type') + '"]';
                        $(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();
                }
            });
        }
    }
	/* 头部滚动 */
	{
		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;
			});
		}
	}
});;
//joe.extend.min.js
(function(e){e.fn.extend({insertContent:function(t,n){var a=e(this)[0];if(document.selection){this.focus();var s=document.selection.createRange();s.text=t,this.focus(),s.moveStart("character",-i);var c=s.text.length;if(2==arguments.length){var i=a.value.length;s.moveEnd("character",c+n),n<=0?s.moveStart("character",c-2*n-t.length):s.moveStart("character",c-n-t.length),s.select()}}else if(a.selectionStart||"0"==a.selectionStart){var o=a.selectionStart,r=a.selectionEnd,l=a.scrollTop;a.value=a.value.substring(0,o)+t+a.value.substring(r,a.value.length),this.focus(),a.selectionStart=o+t.length,a.selectionEnd=o+t.length,a.scrollTop=l,2==arguments.length&&(a.setSelectionRange(o-n,a.selectionEnd+n),this.focus())}else this.value+=t,this.focus()},selectionRange:function(e,t){var n="",a=this[0];if(void 0===e)n=/input|textarea/i.test(a.tagName)&&/firefox/i.test(navigator.userAgent)?a.value.substring(a.selectionStart,a.selectionEnd):document.selection?document.selection.createRange().text:document.getSelection().toString();else{if(!/input|textarea/.test(a.tagName.toLowerCase()))return!1;if(void 0===t&&(t=e),a.setSelectionRange)a.setSelectionRange(e,t),this.focus();else{var s=a.createTextRange();s.move("character",e),s.moveEnd("character",t-e),s.select()}}return void 0===e?n:this}})})(jQuery);
//点赞
$(document).on('click', '.slzanpd', function() {
    var a = $(this),
        id = a.data('slzanpd');
        $.post('', {
            plugin: 'slzanpd',
            action: 'slzan',
            id: id
        }, function(b) {
            a.find('span').html(b);
        })
});
//搜藏
function em_soucang(id) {
    $.ajax({
        url: quanjuurl + "inc/huiyuan.php?shoucang=tianjia",
        type: "post",
        data: {id: id},
        dataType: "TEXT",
        success: function(result) {
			if(result == '收藏成功'){
				$('#joe_detail__count-created').html('<button class="but"><i class="fa fa-folder-o"></i>已收藏</button>');
			}
            xtip.msg(result);
        }
    })
}
function weiyu_gengduo(id) {
    $.ajax({
        url: quanjuurl + "inc/huiyuan.php?weiyu=json",
        type: "post",
        data: {page:id},
        dataType: "json",
        success: function(result) {
			if(result.weiyu == null){
				xtip.msg('歇会吧，没有了！');
			}else{
				var arr = result.weiyu;
				var content = $("#weiyu_lieiao").html();
				for(var i=0;i<arr.length;i++){
					var content = content+'<li class="joe_journal__item animated wow"data-wow-delay="0.2s"data-cid="9"data-clikes="6"style="visibility: visible; animation-delay: 0.2s;"><p class="joe_journal_date"><svg t="1643062512088"class="icon"viewBox="0 0 1024 1024"version="1.1"p-id="7185"width="20"height="20"><path d="M841 822c-0.7 0.6-69 55.2-207.2-3.8-163.5-69.7-288.8-1.7-294 1.2-12.2 6.8-16.6 22.2-9.8 34.4 6.8 12.2 22.2 16.6 34.4 9.8 1.1-0.6 108.6-58.9 249.5 1.2 54.7 23.3 101 31.2 138.8 31.2 77 0 118.1-32.9 120.6-35 10.8-8.9 12.3-24.9 3.3-35.6-8.9-10.8-24.8-12.3-35.6-3.4zM529.3 488.7c-9.9-9.9-25.9-9.9-35.8 0L370.9 611.3c7.5-51.4 63.7-153.6 171.2-261.1 64-64 132-115.9 191.5-146.1 54.9-27.9 89.6-30.1 99.8-20 24.9 24.9-28.7 153.8-166.1 291.3-51.9 51.9-106.4 95.8-157.7 127.1-11.9 7.3-15.7 22.9-8.4 34.8 7.3 11.9 22.9 15.7 34.8 8.4 54.7-33.4 112.4-79.9 167.1-134.6 67.7-67.7 122.9-140.3 155.5-204.4 47.1-92.7 31.8-137.3 10.7-158.5-21.1-21.1-65.8-36.4-158.5 10.7-64.1 32.6-136.7 87.8-204.4 155.5-119 119-211.6 266.9-180.3 341.8L142 840.2c-9.9 9.9-9.9 25.9 0 35.8 4.9 4.9 11.4 7.4 17.9 7.4s13-2.5 17.9-7.4l351.5-351.5c9.9-9.9 9.9-25.9 0-35.8z"p-id="7186"fill="#8a8a8a"></path></svg><em class="joe_journal-posttime">'+arr[i].date+'</em></p><div class="blog1018_comment"><div class="substance">'+arr[i].content+'</div><div class="agent"><span class="owner">'+arr[i].author+'</span><div style="float:right;"><span class="owner1"onClick="weiyu_slzan('+arr[i].id+')"><i class="fa fa-thumbs-o-up"></i><span id="weiyuz_'+arr[i].id+'">'+arr[i].slzan+'</span></span></div></div></div></li>';
				}
				$('#weiyu_lieiao').html(content);
				$('#weiyu_gengduo').html('<div class="joe_load" onclick="weiyu_gengduo('+result.page+')">查看更多</div>');
			}
        }
    })
}
function weiyu_faiao() {
    var url = quanjuurl + 'inc/huiyuan.php?weiyu=faiao';
	var content = $("#weiyu_lieiao").html();
    $.ajax({
        url: url,
        type: "post",
        data: {content: $("#weiyu_comment").val()},
        dataType: "TEXT",
        success: function(result) {
			if(result == 1){
				xtip.msg('内容不可为空');
			}else{
				xtip.msg('发表成功');
				$('#weiyu_lieiao').html('<li class="joe_journal__item animated wow"data-wow-delay="0.2s"data-cid="9"data-clikes="6"style="visibility: visible; animation-delay: 0.2s;"><p class="joe_journal_date"><svg t="1643062512088"class="icon"viewBox="0 0 1024 1024"version="1.1"p-id="7185"width="20"height="20"><path d="M841 822c-0.7 0.6-69 55.2-207.2-3.8-163.5-69.7-288.8-1.7-294 1.2-12.2 6.8-16.6 22.2-9.8 34.4 6.8 12.2 22.2 16.6 34.4 9.8 1.1-0.6 108.6-58.9 249.5 1.2 54.7 23.3 101 31.2 138.8 31.2 77 0 118.1-32.9 120.6-35 10.8-8.9 12.3-24.9 3.3-35.6-8.9-10.8-24.8-12.3-35.6-3.4zM529.3 488.7c-9.9-9.9-25.9-9.9-35.8 0L370.9 611.3c7.5-51.4 63.7-153.6 171.2-261.1 64-64 132-115.9 191.5-146.1 54.9-27.9 89.6-30.1 99.8-20 24.9 24.9-28.7 153.8-166.1 291.3-51.9 51.9-106.4 95.8-157.7 127.1-11.9 7.3-15.7 22.9-8.4 34.8 7.3 11.9 22.9 15.7 34.8 8.4 54.7-33.4 112.4-79.9 167.1-134.6 67.7-67.7 122.9-140.3 155.5-204.4 47.1-92.7 31.8-137.3 10.7-158.5-21.1-21.1-65.8-36.4-158.5 10.7-64.1 32.6-136.7 87.8-204.4 155.5-119 119-211.6 266.9-180.3 341.8L142 840.2c-9.9 9.9-9.9 25.9 0 35.8 4.9 4.9 11.4 7.4 17.9 7.4s13-2.5 17.9-7.4l351.5-351.5c9.9-9.9 9.9-25.9 0-35.8z"p-id="7186"fill="#8a8a8a"></path></svg><em class="joe_journal-posttime">刚刚</em></p><div class="blog1018_comment"><div class="substance">'+$("#weiyu_comment").val()+'</div><div class="agent"><span class="owner">'+result+'</div></div></div></li>'+content);
				$('#weiyu_comment').val('');
			}
        }
    });
}
function saveUserInfo(id) {
    xtip.confirm('确定购买该资源吗？', function() {
        var url = quanjuurl + 'inc/huiyuan.php?pay=goumai';
        $.ajax({
            url: url,
            type: "post",
            data: {
                gid: id
            },
            dataType: "TEXT",
            success: function(data) {
                xtip.msg(data);
                setTimeout(function() {
                    location.reload();
                }, 2000)
            }
        });
    });
}
function saveUserInfos(id) {
    xtip.confirm('确定购买该资源吗？', function() {
        var url = quanjuurl + 'inc/huiyuan.php?pay=point';
        $.ajax({
            url: url,
            type: "post",
            data: {
                gid: id
            },
            dataType: "TEXT",
            success: function(data) {
                xtip.msg(data);
                // setTimeout(function() {
                    // location.reload();
                // }, 2000)
            }
        });
    });
}
function shangpin_goumai(id) {
    xtip.confirm('是否确定购买？', function() {
        $.ajax({
            url: quanjuurl + 'inc/huiyuan.php?pay=shangpin',
            type: "post",
            data: {gid:id,arr:$("#shangopin_arr").val()},
            dataType: "TEXT",
            success: function(result) {
				if(result == 1){
					blog_denglu();//未登录
				}else if(result == '2'){
					Sz_souhuo();//未设置收获地址
				}else if(result == '3'){
					Sz_youxiang();//未设置邮箱
				}else if(result == '4'){
					xtip.msg('您的余额不足');
					setTimeout(function() {
						window.open(window.location.protocol+"/?joe&home");
					}, 2000)
				}else{
					xtip.msg(result);
				}
            }
        });
    });
}
function Sz_youxiang() {
    xtip.closeAll();
    xtip.open({
        type: 'html',
        content: '<div class="layui-form-pane" style="padding:15px 15px;"><input type="text" id="shouhuo_emall" style="width:100%;padding: 10px 10px;border: 1px solid #ccc;border-radius:5px;margin-bottom:10px;" placeholder="您的邮箱地址"><button type="button" style="width:100%;padding: 10px 10px;border: 1px solid #ccc;border-radius:5px;margin-bottom:10px;" onclick="youxiang_shezhi()">确认设置</button></div>',
        width: '320px',
        height: '160px',
		title: '邮箱设置',
        lock: true,
		over: false,
		shadeClose: false,
    });
}
function youxiang_shezhi() {
    xtip.closeAll();
    var url = quanjuurl+'inc/huiyuan.php?dingdan=emall';
    $.ajax({
        url: url,
        type: "post",
        data: {emall:$("#shouhuo_emall").val()},
        dataType: "TEXT",
        success: function(result) {
			if(result==1){
				xtip.msg('设置成功');
				setTimeout(function(){
					location.reload();
				},2000)
			}else{
				xtip.msg(result);
			}
        }
    });
}
function Sz_souhuo() {
    xtip.closeAll();
    xtip.open({
        type: 'html',
        content: '<div class="layui-form-pane" style="padding:15px 15px;"><input type="text" id="shouhuo_dizhi" style="width:100%;padding: 10px 10px;border: 1px solid #ccc;border-radius:5px;margin-bottom:10px;" placeholder="您的收货地址"><input type="text" id="shouhuo_shoujihao" style="width:100%;padding: 10px 10px;border: 1px solid #ccc;border-radius:5px;margin-bottom:10px;" placeholder="您的手机号"><button type="button" style="width:100%;padding: 10px 10px;border: 1px solid #ccc;border-radius:5px;margin-bottom:10px;" onclick="shouhuo_shezhi()">确认设置</button></div>',
        width: '320px',
        height: '200px',
		title: '设置您的收货信息',
        lock: true,
		over: false,
		shadeClose: false,
    });
}
function shouhuo_shezhi() {
    xtip.closeAll();
    var url = quanjuurl+'inc/huiyuan.php?dingdan=shouhuo';
    $.ajax({
        url: url,
        type: "post",
        data: {dizhi:$("#shouhuo_dizhi").val(),shoujihao:$("#shouhuo_shoujihao").val()},
        dataType: "TEXT",
        success: function(result) {
            xtip.msg(result);
			setTimeout(function(){
				location.reload();
			},1000)
        }
    });
}
function blog_denglu() {
    xtip.open({
        type: 'html',
        content: '<div class="ajaxdlk"><div class="form"><h2 class="headline">登录帐号</h2><div class="input-field"><label class="input-box"for="email"><i class="fa fa-user-o"></i><input type="text"name="user_yonghuming"id="user_yonghuming"class="rgreytrhrthj"placeholder="输入账号"autocomplete="off"></label><label class="input-box"for="username"><i class="fa fa-eye-slash"></i><input type="password"name="user_mima"id="user_mima"placeholder="输入密码"autocomplete="off"></label></div><button class="button"type="button"onClick="dengluzhanghao()">登陆账号</button></div></br><div class="login1"><a href="#"onclick="zhaoHuiMiMa()">找回密码</a><a style="float:right"href="#"onclick="qiehuan_zhuce()">注册账号</a></div></div>',
        width: '320px',
        height: '330px',
        min: true,
        lock: true,
        shade: true,
        shade: true,
        over: false,
        closeBtn: false,
    });
}
function dengluzhanghao() {
    var url = quanjuurl + 'inc/huiyuan.php?user=denglu1';
    $.ajax({
        url: url,
        type: "post",
        data: {user: $("#user_yonghuming").val(),pw: $("#user_mima").val()},
        dataType: "TEXT",
        success: function(result) {
			if(result == 1){
				setTimeout(function() {
					location.reload();
				}, 1000)
			}else{
				xtip.msg(result);
			}
        }
    });
}
function blog_zhuce() {
	xtip.open({
		type: 'html',
		content: '<div class="ajaxdlk"><div class="form"><h2 class="headline">注册账号</h2><div class="input-field"><label class="input-box"for="email"><i class="fa fa-envelope-o"></i><input type="text"name="zhuce_yonghuming"id="zhuce_yonghuming"placeholder="输入账号"autocomplete="off"></label><label class="input-box"for="username"><i class="fa fa-eye-slash"></i><input type="password"name="zhuce_mima"id="zhuce_mima"placeholder="输入密码"autocomplete="off"></label><label class="input-box"for="password"><i class="fa fa-eye-slash"></i><input type="password"name="zhuce_cfmima"id="zhuce_cfmima"placeholder="再次输入密码"autocomplete="off"></label></div><button class="button"type="button"onClick="zhucezhanghao()">提交注册</button></br><div class="login"></br><p>已经是会员了？<a href="#"onclick="qiehuan_denglu()">登录</a></p></div></div></div>',
		width: '320px',
		height: '350px',
		min: true,
		shade: true,
		over: false,
		closeBtn: false,
	});
}
function zhucezhanghao() {
    var url = quanjuurl + 'inc/huiyuan.php?user=zhuce';
    $.ajax({
        url: url,
        type: "post",
        data: {
            username: $("#zhuce_yonghuming").val(),
            password: $("#zhuce_mima").val(),
            password1: $("#zhuce_cfmima").val()
        },
        dataType: "TEXT",
        success: function(result) {
			if(result=='注册成功'){
				xtip.msg(result);
				qiehuan_denglu();
			}else{
				xtip.msg(result);
			}
            xtip.msg(result);
        }
    });
}
function zhaoHuiMiMa() {
    xtip.closeAll();
    xtip.open({
        type: 'html',
        content: '<div class="ajaxdlk"><div class="form"><h2 class="headline">忘记密码?</h2><div class="input-field"><label class="input-box"for="email"><i class="fa fa-envelope-o"></i><input type="text"name="exampleInputEmail"id="exampleInputEmail"class="rgreytrhrthj"placeholder="您的邮箱"autocomplete="off"></label></div><button class="button"type="button"onClick="passwordzh()">找回密码</button></div></br><a href="#"onclick="qiehuan_denglu()">返回登陆</a><a style="float:right"href="#"onclick="qiehuan_zhuce()">注册账号</a></div>',
        width: '320px',
        height: '255px',
        min: true,
        lock: true,
        shadeClose: true,
        shade: true,
		over: false,
        closeBtn: false,
    });
}
function passwordzh() {
    var url = quanjuurl + 'inc/huiyuan.php?user=password';
    $.ajax({
        url: url,
        type: "post",
        data: {mail: $("#exampleInputEmail").val()},
        dataType: "TEXT",
        success: function(result) {
			if(result=='发送成功'){
				xtip.msg('验证码发送成功，请到您的邮箱查收');
				ChongZhiMiMa()
			}else{
				xtip.msg(result);
			}
        }
    });
}
function ChongZhiMiMa() {
    xtip.closeAll();
    xtip.open({
        type: 'html',
        content: '<div class="ajaxdlk"><div class="form"><h2 class="headline">重置密码</h2><div class="input-field"><label class="input-box"for="email"><i class="fa fa-envelope-o"></i><input type="text"name="mail_code"id="mail_code"class="rgreytrhrthj"placeholder="邮箱验证码"autocomplete="off"></label><label class="input-box"for="email"><i class="fa fa-eye-slash"></i><input type="text"name="mail_passwd"id="mail_passwd"class="rgreytrhrthj"placeholder="新的密码"autocomplete="off"></label><label class="input-box"for="email"><i class="fa fa-eye-slash"></i><input type="text"name="mail_password"id="mail_password"class="rgreytrhrthj"placeholder="确认新密码"autocomplete="off"></label></div><button class="button"type="button"onClick="passwordCz()">重置密码</button></div></br><a href="#"onclick="qiehuan_denglu()">返回登陆</a><a style="float:right"href="#"onclick="qiehuan_zhuce()">注册账号</a></div>',
        width: '320px',
        height: '385px',
        min: true,
        lock: true,
        shadeClose: true,
        shade: true,
		over: false,
        closeBtn: false,
    });
}
function passwordCz() {
    var url = quanjuurl + 'inc/huiyuan.php?user=czpassword';
    $.ajax({
        url: url,
        type: "post",
        data: {mail_code: $("#mail_code").val(),passwd: $("#mail_passwd").val(),password: $("#mail_password").val()},
        dataType: "TEXT",
        success: function(result) {
			if(result=='重置成功'){
				xtip.msg('密码重置成功');
				qiehuan_denglu();
			}else{
				xtip.msg(result);
			}
        }
    });
}
function user_logout() {
    var url = quanjuurl + 'inc/huiyuan.php?user=logout';
    $.ajax({
        url: url,
        type: "get",
        dataType: "TEXT",
        success: function(result) {
			xtip.msg(result);
			setTimeout(function() {
				location.reload();
			}, 1000)
        }
    });
}
function qiehuan_denglu() {
    xtip.closeAll();
    blog_denglu()
}
function qiehuan_zhuce() {
    xtip.closeAll();
    blog_zhuce()
}
function weiyu_slzan(id) {
    var url = quanjuurl + 'inc/huiyuan.php?weiyu=dianzan';
    $.ajax({
        url: url,
        type: "post",
        data: {id: id},
        dataType: "TEXT",
        success: function(result) {
			if(result == 1){
				xtip.msg('感谢您的点赞！');
				$("#weiyuz_"+id).text(parseInt($("#weiyuz_"+id).text())+1);
			}else{
				xtip.msg('您已经赞过啦！');
			}
        }
    });
}
function qinyin_gg() {
	$.ajax({
		url: quanjuurl+'inc/huiyuan.php?qinyin=tanchuang',
		type: "get",
		dataType: "json",
		success: function (result) {
			if(result.title){
				xtip.open({
					type: 'html',
					width: '350px',
					content: '<div style="padding:10px 10px;">'+result.content+'</div>',
					title: result.title,
					lock: true,
					shadeClose: false,
				});
			}
		}
	});
}
$(function() {
    $(".add-plus-input .plus").click(function() {
        var $num = $(this).prev(".num");
        var number = $num.attr("value");
        $num.attr("value", parseInt(number) + 1);
    });
    $(".add-plus-input .add").click(function() {
        var $num = $(this).next(".num");
        var number = $num.attr("value");
		if(number >= 2){
			$num.attr("value", parseInt(number) - 1);
		}else{
			xtip.msg('数量不可少于1');
		}
    });
})
function Sketchpad(t) {
    for (var e in this.constructor.prototype) this[e] = this[e].bind(this);
    t.hasOwnProperty("element") ? ("string" == typeof t.element ? this.element = $(t.element) : this.element = t.element, this._width = t.width || this.element.attr("data-width") || 0, this._height = t.height || this.element.attr("data-height") || 0, this.color = t.color || this.element.attr("data-color") || "#000000", this.penSize = t.penSize || this.element.attr("data-penSize") || 5, this.readOnly = t.readOnly || this.element.attr("data-readOnly") || !1, this.readOnly || this.element.css({
        cursor: "crosshair"
    }), this.strokes = t.strokes || [], this._currentStroke = {
        color: null,
        size: null,
        lines: []
    }, this.undoHistory = t.undoHistory || [], this.animateIds = [], this._sketching = !1, this.reset()) : console.error("SKETCHPAD ERROR: No element selected")
}
Sketchpad.prototype._cursorPosition = function(t) {
    return {
        x: t.pageX - $(this.canvas).offset().left,
        y: t.pageY - $(this.canvas).offset().top
    }
}, Sketchpad.prototype._draw = function(t, e, s, i) {
    this._stroke(t, e, s, i, "source-over")
}, Sketchpad.prototype._erase = function(t, e, s, i) {
    this._stroke(t, e, s, i, "destination-out")
}, Sketchpad.prototype._stroke = function(t, e, s, i, o) {
    this.context.save(), this.context.lineJoin = "round", this.context.lineCap = "round", this.context.strokeStyle = s, this.context.lineWidth = i, this.context.globalCompositeOperation = o, this.context.beginPath(), this.context.moveTo(t.x, t.y), this.context.lineTo(e.x, e.y), this.context.closePath(), this.context.stroke(), this.context.restore()
}, Sketchpad.prototype._mouseDown = function(t) {
    this._lastPosition = this._cursorPosition(t), this._currentStroke.color = this.color, this._currentStroke.size = this.penSize, this._currentStroke.lines = [], this._sketching = !0, this.canvas.addEventListener("mousemove", this._mouseMove)
}, Sketchpad.prototype._mouseUp = function(t) {
    this._sketching && (this.strokes.push($.extend(!0, {}, this._currentStroke)), this._sketching = !1), this.canvas.removeEventListener("mousemove", this._mouseMove)
}, Sketchpad.prototype._mouseMove = function(t) {
    var e = this._cursorPosition(t);
    this._draw(this._lastPosition, e, this.color, this.penSize), this._currentStroke.lines.push({
        start: $.extend(!0, {}, this._lastPosition),
        end: $.extend(!0, {}, e)
    }), this._lastPosition = e
}, Sketchpad.prototype._touchStart = function(t) {
    t.preventDefault(), this._sketching || (this._lastPosition = this._cursorPosition(t.changedTouches[0]), this._currentStroke.color = this.color, this._currentStroke.size = this.penSize, this._currentStroke.lines = [], this._sketching = !0, this.canvas.addEventListener("touchmove", this._touchMove, !1))
}, Sketchpad.prototype._touchEnd = function(t) {
    t.preventDefault(), this._sketching && (this.strokes.push($.extend(!0, {}, this._currentStroke)), this._sketching = !1), this.canvas.removeEventListener("touchmove", this._touchMove)
}, Sketchpad.prototype._touchCancel = function(t) {
    t.preventDefault(), this._sketching && (this.strokes.push($.extend(!0, {}, this._currentStroke)), this._sketching = !1), this.canvas.removeEventListener("touchmove", this._touchMove)
}, Sketchpad.prototype._touchLeave = function(t) {
    t.preventDefault(), this._sketching && (this.strokes.push($.extend(!0, {}, this._currentStroke)), this._sketching = !1), this.canvas.removeEventListener("touchmove", this._touchMove)
}, Sketchpad.prototype._touchMove = function(t) {
    t.preventDefault();
    var e = this._cursorPosition(t.changedTouches[0]);
    this._draw(this._lastPosition, e, this.color, this.penSize), this._currentStroke.lines.push({
        start: $.extend(!0, {}, this._lastPosition),
        end: $.extend(!0, {}, e)
    }), this._lastPosition = e
}, Sketchpad.prototype.reset = function() {
    this.canvas = this.element[0], this.canvas.width = this._width, this.canvas.height = this._height, this.context = this.canvas.getContext("2d"), this.redraw(this.strokes), this.readOnly || (this.canvas.addEventListener("mousedown", this._mouseDown), this.canvas.addEventListener("mouseout", this._mouseUp), this.canvas.addEventListener("mouseup", this._mouseUp), this.canvas.addEventListener("touchstart", this._touchStart), this.canvas.addEventListener("touchend", this._touchEnd), this.canvas.addEventListener("touchcancel", this._touchCancel), this.canvas.addEventListener("touchleave", this._touchLeave))
}, Sketchpad.prototype.drawStroke = function(t) {
    for (var e = 0; e < t.lines.length; e++) {
        var s = t.lines[e];
        this._draw(s.start, s.end, t.color, t.size)
    }
}, Sketchpad.prototype.redraw = function(t) {
    for (var e = 0; e < t.length; e++) this.drawStroke(t[e])
}, Sketchpad.prototype.toObject = function() {
    return {
        width: this.canvas.width,
        height: this.canvas.height,
        strokes: this.strokes,
        undoHistory: this.undoHistory
    }
}, Sketchpad.prototype.toJSON = function() {
    return JSON.stringify(this.toObject())
}, Sketchpad.prototype.animate = function(t, e, s) {
    this.clear();
    for (var i = t, o = null, h = 0; h < this.strokes.length; h++)
        for (var n = this.strokes[h], r = 0; r < n.lines.length; r++) {
            var a = n.lines[r];
            o = this._draw.bind(this, a.start, a.end, n.color, n.size), this.animateIds.push(setTimeout(o, i)), i += t
        }
    e && (s = s || 0, o = this.animate.bind(this, t, e, s), this.animateIds.push(setTimeout(o, i + s)))
}, Sketchpad.prototype.cancelAnimation = function() {
    for (var t = 0; t < this.animateIds.length; t++) clearTimeout(this.animateIds[t])
}, Sketchpad.prototype.clear = function() {
    this.context.clearRect(0, 0, this.canvas.width, this.canvas.height)
}, Sketchpad.prototype.undo = function() {
    this.clear();
    var t = this.strokes.pop();
    t && (this.undoHistory.push(t), this.redraw(this.strokes))
}, Sketchpad.prototype.redo = function() {
    var t = this.undoHistory.pop();
    t && (this.strokes.push(t), this.drawStroke(t))
};