This commit is contained in:
haoouba 2021-03-06 19:57:59 +08:00
parent 4cadbec9e3
commit 93d791caaa
3 changed files with 132 additions and 103 deletions

View File

@ -98,10 +98,39 @@ document.addEventListener('DOMContentLoaded', () => {
$(item).draggabilly({ containment: true });
$(item).on('dragStart', e => {
_index++;
$(item).css({
zIndex: _index,
});
$(item).css({ zIndex: _index });
});
});
}
/* 格式化分页的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'));
}
});
}
});
/* 写在load事件里为了解决图片未加载完成滚动距离获取会不准确的问题 */
window.addEventListener('load', function () {
/* 判断地址栏是否有锚点链接,有则跳转到对应位置 */
{
const scroll = new URLSearchParams(location.search).get('scroll');
if (scroll) {
const height = $('.joe_header').height();
let elementEL = null;
if ($('#' + scroll).length > 0) {
elementEL = $('#' + scroll);
} else {
elementEL = $('.' + scroll);
}
if (elementEL && elementEL.length > 0) {
const top = elementEL.offset().top - height - 15;
window.scrollTo({ top, behavior: 'smooth' });
}
}
}
});

View File

@ -1 +1 @@
document.addEventListener("DOMContentLoaded",()=>{const e=e=>window.btoa(unescape(encodeURIComponent(e))),o=e=>decodeURIComponent(escape(window.atob(e))),t=$(".joe_detail").attr("data-cid");$.ajax({url:Joe.BASE_API,type:"POST",data:{routeType:"baidu_record",site:window.location.href},success(e){if(e.data&&"已收录"===e.data)$("#Joe_Baidu_Record").css("color","#67C23A"),$("#Joe_Baidu_Record").html("已收录");else if(Joe.BAIDU_PUSH){$("#Joe_Baidu_Record").html('<span style="color: #E6A23C">未收录,推送中...</span>');const e=setTimeout(function(){$.ajax({url:Joe.BASE_API,type:"POST",data:{routeType:"baidu_push",domain:encodeURI(window.location.hostname),url:encodeURI(window.location.href)},success(e){e.error?$("#Joe_Baidu_Record").html('<span style="color: #F56C6C">推送失败,请检查!</span>'):$("#Joe_Baidu_Record").html('<span style="color: #67C23A">推送成功!</span>')}}),clearTimeout(e)},1e3)}else{const e=`https://ziyuan.baidu.com/linksubmit/url?sitename=${encodeURI(window.location.href)}`;$("#Joe_Baidu_Record").html(`<a target="_blank" href="${e}" rel="noopener noreferrer nofollow" style="color: #F56C6C">未收录,提交收录</a>`)}}});{let a=localStorage.getItem(e("views"))?JSON.parse(o(localStorage.getItem(e("views")))):[];const i=a.includes(t);i||$.ajax({url:Joe.BASE_API,type:"POST",data:{routeType:"handle_views",cid:t},success(o){if(1!==o.code)return;$("#Joe_Article_Views").html(`${o.data.views} 阅读`),a.push(t);const i=e("views"),n=e(JSON.stringify(a));localStorage.setItem(i,n)}})}{let e=100;const o=["#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"],t=(e,o)=>Math.floor(Math.random()*(o-e+1))+e,a=$(".joe_detail__leaving-list").width(),i=$(".joe_detail__leaving-list").height(),n=["20px 300px","20px 400px","20px 500px","30px 300px","30px 400px","30px 500px","40px 300px","40px 400px","40px 500px"],d=["300px 20px","400px 20px","500px 20px","300px 30px","400px 30px","500px 30px","300px 40px","400px 40px","500px 40px"];$(".joe_detail__leaving-list .item").each((l,c)=>{const s=t(1,99),p=o[t(0,o.length-1)],r=Math.ceil($(c).width()),x=Math.ceil($(c).height()),u=t(0,i-x),h=t(0,a-r);$(c).css({display:"block",zIndex:s,background:p,top:u,left:h,borderTopLeftRadius:d[t(0,d.length-1)],borderTopRightRadius:n[t(0,n.length-1)],borderBottomLeftRadius:n[t(0,n.length-1)],borderBottomRightRadius:n[t(0,n.length-1)]}),$(c).draggabilly({containment:!0}),$(c).on("dragStart",o=>{e++,$(c).css({zIndex:e})})})}});
document.addEventListener("DOMContentLoaded",()=>{const e=e=>window.btoa(unescape(encodeURIComponent(e))),o=e=>decodeURIComponent(escape(window.atob(e))),t=$(".joe_detail").attr("data-cid");$.ajax({url:Joe.BASE_API,type:"POST",data:{routeType:"baidu_record",site:window.location.href},success(e){if(e.data&&"已收录"===e.data)$("#Joe_Baidu_Record").css("color","#67C23A"),$("#Joe_Baidu_Record").html("已收录");else if(Joe.BAIDU_PUSH){$("#Joe_Baidu_Record").html('<span style="color: #E6A23C">未收录,推送中...</span>');const e=setTimeout(function(){$.ajax({url:Joe.BASE_API,type:"POST",data:{routeType:"baidu_push",domain:encodeURI(window.location.hostname),url:encodeURI(window.location.href)},success(e){e.error?$("#Joe_Baidu_Record").html('<span style="color: #F56C6C">推送失败,请检查!</span>'):$("#Joe_Baidu_Record").html('<span style="color: #67C23A">推送成功!</span>')}}),clearTimeout(e)},1e3)}else{const e=`https://ziyuan.baidu.com/linksubmit/url?sitename=${encodeURI(window.location.href)}`;$("#Joe_Baidu_Record").html(`<a target="_blank" href="${e}" rel="noopener noreferrer nofollow" style="color: #F56C6C">未收录,提交收录</a>`)}}});{let a=localStorage.getItem(e("views"))?JSON.parse(o(localStorage.getItem(e("views")))):[];const n=a.includes(t);n||$.ajax({url:Joe.BASE_API,type:"POST",data:{routeType:"handle_views",cid:t},success(o){if(1!==o.code)return;$("#Joe_Article_Views").html(`${o.data.views} 阅读`),a.push(t);const n=e("views"),i=e(JSON.stringify(a));localStorage.setItem(n,i)}})}{let e=100;const o=["#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"],t=(e,o)=>Math.floor(Math.random()*(o-e+1))+e,a=$(".joe_detail__leaving-list").width(),n=$(".joe_detail__leaving-list").height(),i=["20px 300px","20px 400px","20px 500px","30px 300px","30px 400px","30px 500px","40px 300px","40px 400px","40px 500px"],l=["300px 20px","400px 20px","500px 20px","300px 30px","400px 30px","500px 30px","300px 40px","400px 40px","500px 40px"];$(".joe_detail__leaving-list .item").each((c,s)=>{const d=t(1,99),r=o[t(0,o.length-1)],p=Math.ceil($(s).width()),h=Math.ceil($(s).height()),x=t(0,n-h),u=t(0,a-p);$(s).css({display:"block",zIndex:d,background:r,top:x,left:u,borderTopLeftRadius:l[t(0,l.length-1)],borderTopRightRadius:i[t(0,i.length-1)],borderBottomLeftRadius:i[t(0,i.length-1)],borderBottomRightRadius:i[t(0,i.length-1)]}),$(s).draggabilly({containment:!0}),$(s).on("dragStart",o=>{e++,$(s).css({zIndex:e})})})}$(".joe_comment .joe_pagination a").each((e,o)=>{const t=$(o).attr("href");t&&t.includes("#")&&$(o).attr("href",t.replace("#comments","?scroll=joe_comment"))})}),window.addEventListener("load",function(){{const e=new URLSearchParams(location.search).get("scroll");if(e){const o=$(".joe_header").height();let t=null;if(t=$("#"+e).length>0?$("#"+e):$("."+e),t&&t.length>0){const e=t.offset().top-o-15;window.scrollTo({top:e,behavior:"smooth"})}}}});

View File

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