sakura/js/sakura-app.js

1979 lines
79 KiB
JavaScript
Raw Normal View History

2018-05-26 18:59:29 +08:00
/*
2019-10-24 22:26:11 +08:00
* Sakura theme application bundle
2018-05-26 18:59:29 +08:00
* @author Mashiro
* @url https://2heng.xin
2019-08-03 19:51:27 +08:00
* @date 2019.8.3
2018-05-26 18:59:29 +08:00
*/
2018-06-06 11:32:00 +08:00
mashiro_global.variables = new function () {
2020-03-06 00:08:36 +08:00
this.has_hls = false;
2019-08-19 17:47:43 +08:00
this.skinSecter = true;
2018-06-06 11:32:00 +08:00
}
mashiro_global.ini = new function () {
2019-10-17 19:45:07 +08:00
this.normalize = function () { // initial functions when page first load (首次加载页面时的初始化函数)
2018-06-06 11:32:00 +08:00
lazyload();
2018-12-28 13:41:17 +08:00
social_share();
2019-08-25 11:57:53 +08:00
post_list_show_animation();
2019-01-24 17:01:27 +08:00
copy_code_block();
coverVideoIni();
2019-08-19 17:47:43 +08:00
checkskinSecter();
2019-10-07 18:29:50 +08:00
scrollBar();
load_bangumi();
2018-06-06 11:32:00 +08:00
}
2019-10-17 19:45:07 +08:00
this.pjax = function () { // pjax reload functions (pjax 重载函数)
2018-06-06 11:32:00 +08:00
pjaxInit();
2018-12-28 13:41:17 +08:00
social_share();
2019-08-25 11:57:53 +08:00
post_list_show_animation();
2019-01-24 17:01:27 +08:00
copy_code_block();
coverVideoIni();
2019-08-19 17:47:43 +08:00
checkskinSecter();
load_bangumi();
2018-06-06 11:32:00 +08:00
}
}
function setCookie(name, value, days) {
var expires = "";
if (days) {
var date = new Date();
date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
expires = "; expires=" + date.toUTCString();
}
document.cookie = name + mashiro_option.cookie_version_control + "=" + (value || "") + expires + "; path=/";
}
function getCookie(name) {
var nameEQ = name + mashiro_option.cookie_version_control + "=";
var ca = document.cookie.split(';');
for (var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ' ') c = c.substring(1, c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
}
return null;
}
function removeCookie(name) {
document.cookie = name + mashiro_option.cookie_version_control + '=; Max-Age=-99999999;';
}
function imgError(ele, type) {
switch (type) {
case 1:
ele.src = 'https://view.moezx.cc/images/2017/12/30/Transparent_Akkarin.th.jpg';
break;
case 2:
ele.src = 'https://gravatar.shino.cc/avatar/?s=80&d=mm&r=g';
break;
default:
ele.src = 'https://view.moezx.cc/images/2018/05/13/image-404.png';
}
2019-11-14 02:39:22 +08:00
}
2019-01-24 17:01:27 +08:00
2019-08-25 11:57:53 +08:00
function post_list_show_animation() {
if ($("article").hasClass("post-list-thumb")) {
2019-09-05 17:09:44 +08:00
var options = {
2019-08-25 11:57:53 +08:00
root: null,
threshold: [0.66]
}
var io = new IntersectionObserver(callback, options);
2019-09-05 17:09:44 +08:00
var articles = document.querySelectorAll('.post-list-thumb');
2019-11-14 02:39:22 +08:00
2019-08-25 11:57:53 +08:00
function callback(entries) {
entries.forEach((article) => {
2020-04-11 23:08:16 +08:00
if (!window.IntersectionObserver) {
article.target.style.willChange = 'auto';
2020-04-11 23:08:16 +08:00
if( article.target.classList.contains("post-list-show") === false){
2019-09-05 17:09:44 +08:00
article.target.classList.add("post-list-show");
2020-04-11 23:08:16 +08:00
}
} else {
if (article.target.classList.contains("post-list-show")) {
article.target.style.willChange = 'auto';
2019-09-05 17:09:44 +08:00
io.unobserve(article.target)
2020-04-11 23:08:16 +08:00
} else {
if (article.isIntersecting) {
article.target.classList.add("post-list-show");
article.target.style.willChange = 'auto';
io.unobserve(article.target)
}
2019-09-05 17:09:44 +08:00
}
2018-06-06 11:32:00 +08:00
}
2019-08-25 11:57:53 +08:00
})
}
articles.forEach((article) => {
io.observe(article)
})
2018-06-06 11:32:00 +08:00
}
}
mashiro_global.font_control = new function () {
this.change_font = function () {
if ($("body").hasClass("serif")) {
$("body").removeClass("serif");
$(".control-btn-serif").removeClass("selected");
$(".control-btn-sans-serif").addClass("selected");
setCookie("font_family", "sans-serif", 30);
} else {
$("body").addClass("serif");
$(".control-btn-serif").addClass("selected");
$(".control-btn-sans-serif").removeClass("selected");
setCookie("font_family", "serif", 30);
if (document.body.clientWidth <= 860) {
addComment.createButterbar("将从网络加载字体,流量请注意");
}
}
}
this.ini = function () {
if (document.body.clientWidth > 860) {
if (!getCookie("font_family") || getCookie("font_family") == "serif")
$("body").addClass("serif");
}
if (getCookie("font_family") == "sans-serif") {
$("body").removeClass("sans-serif");
$(".control-btn-serif").removeClass("selected");
$(".control-btn-sans-serif").addClass("selected");
}
}
}
mashiro_global.font_control.ini();
function code_highlight_style() {
function gen_top_bar(i) {
var attributes = {
'autocomplete': 'off',
'autocorrect': 'off',
'autocapitalize': 'off',
'spellcheck': 'false',
'contenteditable': 'false',
'design': 'by Mashiro'
}
var ele_name = $('pre:eq(' + i + ')')[0].children[0].className;
var lang = ele_name.substr(0, ele_name.indexOf(" ")).replace('language-', '');
2020-08-02 22:20:56 +08:00
if (lang.toLowerCase() == "hljs") var lang = $('pre:eq(' + i + ') code').attr("class").replace('hljs', '')?$('pre:eq(' + i + ') code').attr("class").replace('hljs', ''):"text";
2018-06-06 11:32:00 +08:00
$('pre:eq(' + i + ')').addClass('highlight-wrap');
for (var t in attributes) {
$('pre:eq(' + i + ')').attr(t, attributes[t]);
}
$('pre:eq(' + i + ') code').attr('data-rel', lang.toUpperCase());
}
$('pre code').each(function (i, block) {
hljs.highlightBlock(block);
});
for (var i = 0; i < $('pre').length; i++) {
gen_top_bar(i);
}
hljs.initLineNumbersOnLoad();
$('pre').on('click', function (e) {
if (e.target !== this) return;
$(this).toggleClass('code-block-fullscreen');
$('html').toggleClass('code-block-fullscreen-html-scroll');
});
}
try {
code_highlight_style();
} catch (e) {}
2019-11-14 02:39:22 +08:00
if (Poi.reply_link_version == 'new') {
$('body').on('click', '.comment-reply-link', function () {
addComment.moveForm("comment-" + $(this).attr('data-commentid'), $(this).attr('data-commentid'), "respond", $(this).attr('data-postid'));
return false;
});
}
2018-06-06 11:32:00 +08:00
function attach_image() {
2019-09-05 17:09:44 +08:00
var cached = $('.insert-image-tips');
2018-06-06 11:32:00 +08:00
$('#upload-img-file').change(function () {
if (this.files.length > 10) {
addComment.createButterbar("每次上传上限为10张.<br>10 files max per request.");
return 0;
}
for (i = 0; i < this.files.length; i++) {
if (this.files[i].size >= 5242880) {
alert('图片上传大小限制为5 MB.\n5 MB max per file.\n\n「' + this.files[i].name + '」\n\n这张图太大啦~\nThis image is too large~');
}
}
for (var i = 0; i < this.files.length; i++) {
var f = this.files[i];
var formData = new FormData();
2019-11-14 02:39:22 +08:00
formData.append('cmt_img_file', f);
2018-06-06 11:32:00 +08:00
$.ajax({
2019-11-15 09:23:07 +08:00
url: Poi.api + 'sakura/v1/image/upload?_wpnonce=' + Poi.nonce,
2018-06-06 11:32:00 +08:00
type: 'POST',
processData: false,
contentType: false,
data: formData,
beforeSend: function (xhr) {
2019-09-05 17:09:44 +08:00
cached.html('<i class="fa fa-spinner rotating" aria-hidden="true"></i>');
2018-06-06 11:32:00 +08:00
addComment.createButterbar("上传中...<br>Uploading...");
},
success: function (res) {
2019-09-05 17:09:44 +08:00
cached.html('<i class="fa fa-check" aria-hidden="true"></i>');
2018-06-06 11:32:00 +08:00
setTimeout(function () {
2019-09-05 17:09:44 +08:00
cached.html('<i class="fa fa-picture-o" aria-hidden="true"></i>');
2018-06-06 11:32:00 +08:00
}, 1000);
2019-11-14 19:15:53 +08:00
if (res.status == 200) {
var get_the_url = res.proxy;
$('#upload-img-show').append('<img class="lazyload upload-image-preview" src="https://cdn.jsdelivr.net/gh/moezx/cdn@3.0.2/img/svg/loader/trans.ajax-spinner-preloader.svg" data-src="' + get_the_url + '" onclick="window.open(\'' + get_the_url + '\')" onerror="imgError(this)" />');
lazyload();
addComment.createButterbar("图片上传成功~<br>Uploaded successfully~");
grin(get_the_url, type = 'Img');
} else {
addComment.createButterbar("上传失败!<br>Uploaded failed!<br> 文件名/Filename: "+f.name+"<br>code: "+res.status+"<br>"+res.message, 3000);
}
2018-06-06 11:32:00 +08:00
},
2019-11-14 02:39:22 +08:00
error: function (jqXHR, textStatus, errorThrown) {
2019-09-05 17:09:44 +08:00
cached.html('<i class="fa fa-times" aria-hidden="true" style="color:red"></i>');
2018-06-06 11:32:00 +08:00
alert("上传失败,请重试.\nUpload failed, please try again.");
setTimeout(function () {
2019-09-05 17:09:44 +08:00
cached.html('<i class="fa fa-picture-o" aria-hidden="true"></i>');
2018-06-06 11:32:00 +08:00
}, 1000);
2019-11-14 02:39:22 +08:00
// console.info(jqXHR.responseText);
// console.info(jqXHR.status);
// console.info(jqXHR.readyState);
// console.info(jqXHR.statusText);
// console.info(textStatus);
// console.info(errorThrown);
2018-06-06 11:32:00 +08:00
}
})
}
});
}
function clean_upload_images() {
$('#upload-img-show').html('');
}
function add_upload_tips() {
$('<div class="insert-image-tips popup"><i class="fa fa-picture-o" aria-hidden="true"></i><span class="insert-img-popuptext" id="uploadTipPopup">上传图片</span></div><input id="upload-img-file" type="file" accept="image/*" multiple="multiple" class="insert-image-button">').insertAfter($(".form-submit #submit"));
attach_image();
$("#upload-img-file").hover(function () {
$(".insert-image-tips").addClass("insert-image-tips-hover");
$("#uploadTipPopup").addClass("show");
}, function () {
$(".insert-image-tips").removeClass("insert-image-tips-hover");
$("#uploadTipPopup").removeClass("show");
});
}
function click_to_view_image() {
$(".comment_inline_img").click(function () {
2019-09-05 17:09:44 +08:00
var temp_url = this.src;
2018-06-06 11:32:00 +08:00
window.open(temp_url);
});
}
click_to_view_image();
function original_emoji_click() {
$(".emoji-item").click(function () {
grin($(this).text(), type = "custom", before = "`", after = "` ");
});
}
original_emoji_click();
function showPopup(ele) {
var popup = ele.querySelector("#thePopup");
popup.classList.toggle("show");
}
function cmt_showPopup(ele) {
var popup = $(ele).find("#thePopup");
popup.addClass("show");
$(ele).find("input").blur(function () {
popup.removeClass("show");
});
}
function scrollBar() {
if (document.body.clientWidth > 860) {
$(window).scroll(function () {
2019-09-05 17:09:44 +08:00
var s = $(window).scrollTop(),
a = $(document).height(),
b = $(window).height(),
result = parseInt(s / (a - b) * 100),
cached = $("#bar");
cached.css("width", result + "%");
2018-06-06 11:32:00 +08:00
if (false) {
if (result >= 0 && result <= 19)
2019-09-05 17:09:44 +08:00
cached.css("background", "#cccccc");
2018-06-06 11:32:00 +08:00
if (result >= 20 && result <= 39)
2019-09-05 17:09:44 +08:00
cached.css("background", "#50bcb6");
2018-06-06 11:32:00 +08:00
if (result >= 40 && result <= 59)
2019-09-05 17:09:44 +08:00
cached.css("background", "#85c440");
2018-06-06 11:32:00 +08:00
if (result >= 60 && result <= 79)
2019-09-05 17:09:44 +08:00
cached.css("background", "#f2b63c");
2018-06-06 11:32:00 +08:00
if (result >= 80 && result <= 99)
2019-09-05 17:09:44 +08:00
cached.css("background", "#FF0000");
2018-06-06 11:32:00 +08:00
if (result == 100)
2019-09-05 17:09:44 +08:00
cached.css("background", "#5aaadb");
2018-06-06 11:32:00 +08:00
} else {
2019-09-05 17:09:44 +08:00
cached.css("background", "orange");
2018-06-06 11:32:00 +08:00
}
$(".toc-container").css("height", $(".site-content").outerHeight());
$(".skin-menu").removeClass('show');
});
}
}
2019-08-19 17:47:43 +08:00
function checkskinSecter() {
if (mashiro_global.variables.skinSecter === false) {
$(".pattern-center").removeClass('pattern-center').addClass('pattern-center-sakura');
$(".headertop-bar").removeClass('headertop-bar').addClass('headertop-bar-sakura');
} else {
$(".pattern-center-sakura").removeClass('pattern-center-sakura').addClass('pattern-center');
$(".headertop-bar-sakura").removeClass('headertop-bar-sakura').addClass('headertop-bar');
}
}
2019-11-14 02:39:22 +08:00
2018-06-06 11:32:00 +08:00
function checkBgImgCookie() {
var bgurl = getCookie("bgImgSetting");
2019-10-07 18:29:50 +08:00
if (!bgurl) {
2019-09-05 17:09:44 +08:00
$("#white-bg").click();
2019-10-07 18:29:50 +08:00
} else {
$("#" + bgurl).click();
2019-08-19 17:47:43 +08:00
}
2018-06-06 11:32:00 +08:00
}
function checkDarkModeCookie() {
2020-04-09 16:11:54 +08:00
var dark = getCookie("dark"),
2020-04-11 23:08:16 +08:00
today = new Date(),
hour = today.getHours();
if (mashiro_option.darkmode && ((!dark && (hour > 21 || hour < 7) ) || (dark == '1' && (hour >= 22 || hour <= 6)))) {
2020-04-09 16:11:54 +08:00
setTimeout(function () {
$("#dark-bg").click();
}, 100);
2020-04-11 23:08:16 +08:00
$("#moblieDarkLight").html('<i class="fa fa-sun-o" aria-hidden="true"></i>');
} else {
2020-04-11 23:08:16 +08:00
if (document.body.clientWidth > 860) {
setTimeout(function () {
checkBgImgCookie();
2020-04-09 16:11:54 +08:00
}, 100);
} else {
$("html").css("background", "unset");
$("body").removeClass("dark");
$("#moblieDarkLight").html('<i class="fa fa-moon-o" aria-hidden="true"></i>');
setCookie("dark", "0", 0.33);
}
}
}
if (!getCookie("darkcache") && (new Date().getHours() > 21 || new Date().getHours() < 7)) {
removeCookie("dark");
setCookie("darkcache", "cached", 0.4);
}
setTimeout(function() {
checkDarkModeCookie();
}, 100);
function mobile_dark_light() {
if ($("body").hasClass("dark")) {
$("html").css("background", "unset");
$("body").removeClass("dark");
$("#moblieDarkLight").html('<i class="fa fa-moon-o" aria-hidden="true"></i>');
setCookie("dark", "0", 0.33);
} else {
$("html").css("background", "#31363b");
$("#moblieDarkLight").html('<i class="fa fa-sun-o" aria-hidden="true"></i>');
$("body").addClass("dark");
setCookie("dark", "1", 0.33);
}
2018-06-06 11:32:00 +08:00
}
function no_right_click() {
$('.post-thumb img').bind('contextmenu', function (e) {
return false;
});
}
no_right_click();
2019-11-14 02:39:22 +08:00
$(document).ready(function () {
function checkskin_bg(a) {
2019-08-19 17:47:43 +08:00
return a == "none" ? "" : a
2018-06-06 11:32:00 +08:00
}
2019-08-19 17:47:43 +08:00
function changeBG() {
2019-11-14 02:39:22 +08:00
var cached = $(".menu-list");
cached.find("li").each(function () {
2019-08-19 17:47:43 +08:00
var tagid = this.id;
2019-11-14 02:39:22 +08:00
cached.on("click", "#" + tagid, function () {
if (tagid == "white-bg" || tagid == "dark-bg") {
2019-08-19 17:47:43 +08:00
mashiro_global.variables.skinSecter = true;
2019-08-19 18:42:36 +08:00
checkskinSecter();
2019-08-19 17:47:43 +08:00
} else {
mashiro_global.variables.skinSecter = false;
2019-08-19 18:42:36 +08:00
checkskinSecter();
2019-08-19 17:47:43 +08:00
}
if (tagid == "dark-bg") {
addComment.I("content").classList.add('notransition');
addComment.I("content").style.backgroundColor = "#fff";
addComment.I("content").offsetHeight;
addComment.I("content").classList.remove('notransition');
$("html").css("background", "#31363b");
$("body").addClass("dark");
setCookie("dark", "1", 0.33);
} else{
$("html").css("background", "unset");
$("body").removeClass("dark");
setCookie("dark", "0", 0.33);
setCookie("bgImgSetting", tagid, 30);
setTimeout(function () {
addComment.I("content").style.backgroundColor = "rgba(255, 255, 255, 0.8)";
}, 1000);
}
2019-08-19 17:47:43 +08:00
switch (tagid) {
case "white-bg":
$("body").css("background-image", "url(" + checkskin_bg(mashiro_option.skin_bg0) + ")");
break;
case "sakura-bg":
$("body").css("background-image", "url(" + checkskin_bg(mashiro_option.skin_bg1) + ")");
break;
case "gribs-bg":
$("body").css("background-image", "url(" + checkskin_bg(mashiro_option.skin_bg2) + ")");
break;
case "pixiv-bg":
$("body").css("background-image", "url(" + checkskin_bg(mashiro_option.skin_bg3) + ")");
break;
case "KAdots-bg":
$("body").css("background-image", "url(" + checkskin_bg(mashiro_option.skin_bg4) + ")");
break;
case "totem-bg":
$("body").css("background-image", "url(" + checkskin_bg(mashiro_option.skin_bg5) + ")");
break;
case "bing-bg":
$("body").css("background-image", "url(" + checkskin_bg(mashiro_option.skin_bg6) + ")");
break;
// case "dark-bg":
// $("body").css("background-image", "url(" + checkskin_bg(mashiro_option.skin_bg7) + ")");
// break;
2019-08-19 17:47:43 +08:00
}
closeSkinMenu();
});
2018-06-06 11:32:00 +08:00
});
}
2019-08-19 17:47:43 +08:00
changeBG();
2018-06-06 11:32:00 +08:00
function closeSkinMenu() {
$(".skin-menu").removeClass('show');
2019-11-14 02:39:22 +08:00
setTimeout(function () {
2018-06-06 11:32:00 +08:00
$(".changeSkin-gear").css("visibility", "visible");
}, 300);
}
2019-11-14 02:39:22 +08:00
$(".changeSkin-gear").click(function () {
2018-06-06 11:32:00 +08:00
$(".skin-menu").toggleClass('show');
})
2019-11-14 02:39:22 +08:00
$(".skin-menu #close-skinMenu").click(function () {
2018-06-06 11:32:00 +08:00
closeSkinMenu();
});
add_upload_tips();
});
var bgn = 1;
function nextBG() {
$(".centerbg").css("background-image", "url(" + mashiro_option.cover_api + "?" + bgn + ")");
bgn = bgn + 1;
}
function preBG() {
bgn = bgn - 1;
2018-08-03 11:17:19 +08:00
$(".centerbg").css("background-image", "url(" + mashiro_option.cover_api + "?" + bgn + ")");
2018-06-06 11:32:00 +08:00
}
$(document).ready(function () {
$("#bg-next").click(function () {
nextBG();
});
$("#bg-pre").click(function () {
preBG();
});
});
function topFunction() {
2020-04-11 23:08:16 +08:00
$('body,html').animate({
scrollTop: 0
})
2018-06-06 11:32:00 +08:00
}
function timeSeriesReload(flag) {
2019-09-05 17:09:44 +08:00
var cached = $('#archives');
2018-06-06 11:32:00 +08:00
if (flag == true) {
2019-09-05 17:09:44 +08:00
cached.find('span.al_mon').click(function () {
2018-06-06 11:32:00 +08:00
$(this).next().slideToggle(400);
return false;
});
lazyload();
} else {
(function () {
$('#al_expand_collapse,#archives span.al_mon').css({
cursor: "s-resize"
});
2019-09-05 17:09:44 +08:00
cached.find('span.al_mon').each(function () {
2018-06-06 11:32:00 +08:00
var num = $(this).next().children('li').length;
$(this).children('#post-num').text(num);
});
2019-09-05 17:09:44 +08:00
var $al_post_list = cached.find('ul.al_post_list'),
$al_post_list_f = cached.find('ul.al_post_list:first');
2018-06-06 11:32:00 +08:00
$al_post_list.hide(1, function () {
$al_post_list_f.show();
});
2019-09-05 17:09:44 +08:00
cached.find('span.al_mon').click(function () {
2018-06-06 11:32:00 +08:00
$(this).next().slideToggle(400);
return false;
});
if (document.body.clientWidth > 860) {
2019-09-05 17:09:44 +08:00
cached.find('li.al_li').mouseover(function () {
2018-06-06 11:32:00 +08:00
$(this).children('.al_post_list').show(400);
return false;
});
if (false) {
2019-09-05 17:09:44 +08:00
cached.find('li.al_li').mouseout(function () {
2018-06-06 11:32:00 +08:00
$(this).children('.al_post_list').hide(400);
return false;
});
}
}
var al_expand_collapse_click = 0;
$('#al_expand_collapse').click(function () {
if (al_expand_collapse_click == 0) {
$al_post_list.each(function(index){
var $this = $(this),
s = setTimeout(function() {
$this.show(400);
}, 50 * index);
});
2018-06-06 11:32:00 +08:00
al_expand_collapse_click++;
} else if (al_expand_collapse_click == 1) {
$al_post_list.each(function(index){
var $this = $(this),
h = setTimeout(function() {
$this.hide(400);
}, 50 * index);
});
2018-06-06 11:32:00 +08:00
al_expand_collapse_click--;
}
});
})();
}
}
timeSeriesReload();
2019-01-24 17:01:27 +08:00
/*视频feature*/
function coverVideo() {
2019-08-19 18:42:36 +08:00
var video = addComment.I("coverVideo");
var btn = addComment.I("coverVideo-btn");
2019-01-24 17:01:27 +08:00
if (video.paused) {
video.play();
try {
btn.innerHTML = '<i class="fa fa-pause" aria-hidden="true"></i>';
} catch (e) {};
//console.info('play:coverVideo()');
} else {
video.pause();
try {
btn.innerHTML = '<i class="fa fa-play" aria-hidden="true"></i>';
} catch (e) {};
//console.info('pause:coverVideo()');
}
}
function killCoverVideo() {
2019-08-19 18:42:36 +08:00
var video = addComment.I("coverVideo");
var btn = addComment.I("coverVideo-btn");
2019-01-24 17:01:27 +08:00
if (video.paused) {
//console.info('none:killCoverVideo()');
} else {
video.pause();
try {
btn.innerHTML = '<i class="fa fa-play" aria-hidden="true"></i>';
} catch (e) {};
//console.info('pause:killCoverVideo()');
}
}
2020-03-06 00:08:36 +08:00
function loadHls(){
var video = addComment.I('coverVideo');
var video_src = $('#coverVideo').attr('data-src');
if (Hls.isSupported()) {
var hls = new Hls();
hls.loadSource(video_src);
hls.attachMedia(video);
hls.on(Hls.Events.MANIFEST_PARSED, function () {
video.play();
});
} else if (video.canPlayType('application/vnd.apple.mpegurl')) {
video.src = video_src;
video.addEventListener('loadedmetadata', function () {
video.play();
});
}
}
2019-01-24 17:01:27 +08:00
function coverVideoIni() {
if ($('video').hasClass('hls')) {
2020-03-06 00:08:36 +08:00
if (mashiro_global.variables.has_hls){
loadHls();
}else{
$.getScript("https://cdn.jsdelivr.net/gh/mashirozx/Sakura@3.3.3/cdn/js/src/16.hls.js", function(){
loadHls();
mashiro_global.variables.has_hls = true;
});
}
2019-01-24 17:01:27 +08:00
//console.info('ini:coverVideoIni()');
}
}
function copy_code_block() {
$('pre code').each(function (i, block) {
2019-11-14 02:39:22 +08:00
$(block).attr({
id: 'hljs-' + i
});
2019-01-24 17:01:27 +08:00
$(this).after('<a class="copy-code" href="javascript:" data-clipboard-target="#hljs-' + i + '" title="拷贝代码"><i class="fa fa-clipboard" aria-hidden="true"></i></a>');
});
var clipboard = new ClipboardJS('.copy-code');
}
2018-06-06 11:32:00 +08:00
function tableOfContentScroll(flag) {
if (document.body.clientWidth <= 1200) {
return;
} else if ($("div").hasClass("have-toc") == false && $("div").hasClass("has-toc") == false) {
$(".toc-container").remove();
} else {
if (flag) {
2019-09-26 18:26:37 +08:00
var id = 1,
2019-10-28 17:43:19 +08:00
heading_fix = mashiro_option.entry_content_theme == "sakura" ? $("article").hasClass("type-post") ? $("div").hasClass("pattern-attachment-img") ? -75 : 200 : 375 : window.innerHeight / 2;
2019-11-14 02:39:22 +08:00
$(".entry-content , .links").children("h1,h2,h3,h4,h5").each(function () {
2018-06-06 11:32:00 +08:00
var hyphenated = "toc-head-" + id;
2019-09-05 17:09:44 +08:00
this.id = hyphenated;
2018-06-06 11:32:00 +08:00
id++;
});
tocbot.init({
tocSelector: '.toc',
contentSelector: ['.entry-content', '.links'],
headingSelector: 'h1, h2, h3, h4, h5',
2019-11-14 02:39:22 +08:00
headingsOffset: heading_fix - window.innerHeight / 2,
2018-06-06 11:32:00 +08:00
});
}
}
}
tableOfContentScroll(flag = true);
var pjaxInit = function () {
add_upload_tips();
no_right_click();
click_to_view_image();
original_emoji_click();
mashiro_global.font_control.ini();
$("p").remove(".head-copyright");
try {
code_highlight_style();
} catch (e) {};
try {
2019-01-24 17:01:27 +08:00
getqqinfo();
2018-06-06 11:32:00 +08:00
} catch (e) {};
lazyload();
$("#to-load-aplayer").click(function () {
try {
reloadHermit();
} catch (e) {};
$("div").remove(".load-aplayer");
});
if ($("div").hasClass("aplayer")) {
2018-12-14 00:02:32 +08:00
try {
reloadHermit();
} catch (e) {};
2018-06-06 11:32:00 +08:00
}
$('.iconflat').css('width', '50px').css('height', '50px');
$('.openNav').css('height', '50px');
$("#bg-next").click(function () {
nextBG();
});
$("#bg-pre").click(function () {
preBG();
});
smileBoxToggle();
timeSeriesReload();
add_copyright();
tableOfContentScroll(flag = true);
}
$(document).on("click", ".sm", function () {
var msg = "您真的要设为私密吗?";
if (confirm(msg) == true) {
$(this).commentPrivate();
} else {
2019-12-06 14:16:14 +08:00
alert("已取消");
2018-06-06 11:32:00 +08:00
}
});
$.fn.commentPrivate = function () {
if ($(this).hasClass('private_now')) {
alert('您之前已设过私密评论');
return false;
} else {
$(this).addClass('private_now');
var idp = $(this).data('idp'),
actionp = $(this).data('actionp'),
rateHolderp = $(this).children('.has_set_private');
var ajax_data = {
action: "siren_private",
p_id: idp,
p_action: actionp
};
$.post("/wp-admin/admin-ajax.php", ajax_data, function (data) {
$(rateHolderp).html(data);
});
return false;
}
};
POWERMODE.colorful = true;
POWERMODE.shake = false;
document.body.addEventListener('input', POWERMODE);
function motionSwitch(ele) {
var motionEles = [".bili", ".menhera", ".tieba"];
for (var i in motionEles) {
$(motionEles[i] + '-bar').removeClass("on-hover");
$(motionEles[i] + '-container').css("display", "none");
}
$(ele + '-bar').addClass("on-hover");
$(ele + '-container').css("display", "block");
}
$('.comt-addsmilies').click(function () {
$('.comt-smilies').toggle();
})
$('.comt-smilies a').click(function () {
$(this).parent().hide();
})
function smileBoxToggle() {
$(document).ready(function () {
$("#emotion-toggle").click(function () {
$(".emotion-toggle-off").toggle(0);
$(".emotion-toggle-on").toggle(0);
$(".emotion-box").toggle(160);
});
});
}
smileBoxToggle();
function grin(tag, type, before, after) {
var myField;
if (type == "custom") {
tag = before + tag + after;
} else if (type == "Img") {
tag = '[img]' + tag + '[/img]';
} else if (type == "Math") {
tag = ' {{' + tag + '}} ';
} else {
tag = ' :' + tag + ': ';
}
2019-08-19 18:42:36 +08:00
if (addComment.I('comment') && addComment.I('comment').type == 'textarea') {
myField = addComment.I('comment');
2018-06-06 11:32:00 +08:00
} else {
return false;
}
if (document.selection) {
myField.focus();
sel = document.selection.createRange();
sel.text = tag;
myField.focus();
} else if (myField.selectionStart || myField.selectionStart == '0') {
var startPos = myField.selectionStart;
var endPos = myField.selectionEnd;
var cursorPos = endPos;
myField.value = myField.value.substring(0, startPos) + tag + myField.value.substring(endPos, myField.value.length);
cursorPos += tag.length;
myField.focus();
myField.selectionStart = cursorPos;
myField.selectionEnd = cursorPos;
} else {
myField.value += tag;
myField.focus();
}
}
function add_copyright() {
document.body.addEventListener("copy", function (e) {
2019-01-24 17:01:27 +08:00
if (window.getSelection().toString().length > 30 && mashiro_option.clipboardCopyright) {
2018-06-06 11:32:00 +08:00
setClipboardText(e);
}
2019-01-24 17:01:27 +08:00
addComment.createButterbar("复制成功!<br>Copied to clipboard successfully!", 1000);
2018-06-06 11:32:00 +08:00
});
function setClipboardText(event) {
event.preventDefault();
2019-01-24 17:01:27 +08:00
var htmlData = "# 商业转载请联系作者获得授权,非商业转载请注明出处。<br>" + "# For commercial use, please contact the author for authorization. For non-commercial use, please indicate the source.<br>" + "# 协议(License):署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0)<br>" + "# 作者(Author)" + mashiro_option.author_name + "<br>" + "# 链接(URL)" + window.location.href + "<br>" + "# 来源(Source)" + mashiro_option.site_name + "<br><br>" + window.getSelection().toString().replace(/\r\n/g, "<br>");;
var textData = "# 商业转载请联系作者获得授权,非商业转载请注明出处。\n" + "# For commercial use, please contact the author for authorization. For non-commercial use, please indicate the source.\n" + "# 协议(License):署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0)\n" + "# 作者(Author)" + mashiro_option.author_name + "\n" + "# 链接(URL)" + window.location.href + "\n" + "# 来源(Source)" + mashiro_option.site_name + "\n\n" + window.getSelection().toString().replace(/\r\n/g, "\n");
2018-06-06 11:32:00 +08:00
if (event.clipboardData) {
event.clipboardData.setData("text/html", htmlData);
event.clipboardData.setData("text/plain", textData);
} else if (window.clipboardData) {
return window.clipboardData.setData("text", textData);
}
}
}
add_copyright();
$(function () {
2019-01-24 17:01:27 +08:00
getqqinfo();
2018-06-06 11:32:00 +08:00
});
2019-11-14 02:39:22 +08:00
if (mashiro_option.float_player_on) {
2018-11-04 19:20:10 +08:00
function aplayerF() {
'use strict';
var aplayers = [],
loadMeting = function () {
function a(a, b) {
var c = {
container: a,
audio: b,
mini: null,
fixed: null,
autoplay: !1,
mutex: !0,
lrcType: 3,
2019-12-29 13:19:03 +08:00
listFolded: 1,
2018-11-04 19:20:10 +08:00
preload: 'auto',
theme: '#2980b9',
loop: 'all',
order: 'list',
volume: null,
listMaxHeight: null,
customAudioType: null,
storageName: 'metingjs'
};
if (b.length) {
b[0].lrc || (c.lrcType = 0);
var d = {};
for (var e in c) {
var f = e.toLowerCase();
(a.dataset.hasOwnProperty(f) || a.dataset.hasOwnProperty(e) || null !== c[e]) && (d[e] = a.dataset[f] || a.dataset[e] || c[e], ('true' === d[e] || 'false' === d[e]) && (d[e] = 'true' == d[e]))
}
aplayers.push(new APlayer(d))
}
for (var f = 0; f < aplayers.length; f++) try {
aplayers[f].lrc.hide();
} catch (a) {
console.log(a)
}
var lrcTag = 1;
2019-11-14 02:39:22 +08:00
$(".aplayer.aplayer-fixed").click(function () {
2018-11-04 19:20:10 +08:00
if (lrcTag == 1) {
for (var f = 0; f < aplayers.length; f++) try {
aplayers[f].lrc.show();
} catch (a) {
console.log(a)
}
}
lrcTag = 2;
});
var apSwitchTag = 0;
$(".aplayer.aplayer-fixed .aplayer-body").addClass("ap-hover");
2019-11-14 02:39:22 +08:00
$(".aplayer-miniswitcher").click(function () {
2018-11-04 19:20:10 +08:00
if (apSwitchTag == 0) {
2019-11-14 02:39:22 +08:00
$(".aplayer.aplayer-fixed .aplayer-body").removeClass("ap-hover");
2019-11-16 22:08:20 +08:00
$("#secondary").addClass("active");
2018-11-04 19:20:10 +08:00
apSwitchTag = 1;
} else {
2019-11-14 02:39:22 +08:00
$(".aplayer.aplayer-fixed .aplayer-body").addClass("ap-hover");
2019-11-16 22:08:20 +08:00
$("#secondary").removeClass("active");
2019-11-14 02:39:22 +08:00
apSwitchTag = 0;
2018-11-04 19:20:10 +08:00
}
});
}
var b = mashiro_option.meting_api_url + '?server=:server&type=:type&id=:id&_wpnonce=' + Poi.nonce;
2018-11-04 19:20:10 +08:00
'undefined' != typeof meting_api && (b = meting_api);
for (var f = 0; f < aplayers.length; f++) try {
aplayers[f].destroy()
} catch (a) {
console.log(a)
}
aplayers = [];
for (var c = document.querySelectorAll('.aplayer'), d = function () {
var d = c[e],
f = d.dataset.id;
if (f) {
var g = d.dataset.api || b;
g = g.replace(':server', d.dataset.server), g = g.replace(':type', d.dataset.type), g = g.replace(':id', d.dataset.id);
2018-11-04 19:20:10 +08:00
var h = new XMLHttpRequest;
h.onreadystatechange = function () {
if (4 === h.readyState && (200 <= h.status && 300 > h.status || 304 === h.status)) {
var b = JSON.parse(h.responseText);
a(d, b)
}
}, h.open('get', g, !0), h.send(null)
} else if (d.dataset.url) {
var i = [{
name: d.dataset.name || d.dataset.title || 'Audio name',
artist: d.dataset.artist || d.dataset.author || 'Audio artist',
url: d.dataset.url,
cover: d.dataset.cover || d.dataset.pic,
lrc: d.dataset.lrc,
type: d.dataset.type || 'auto'
}];
a(d, i)
}
}, e = 0; e < c.length; e++) d()
};
document.addEventListener('DOMContentLoaded', loadMeting, !1);
}
if (document.body.clientWidth > 860) {
2019-11-14 02:39:22 +08:00
aplayerF();
2018-11-04 19:20:10 +08:00
}
}
2019-01-24 17:01:27 +08:00
function getqqinfo() {
2019-11-14 02:39:22 +08:00
var is_get_by_qq = false,
cached = $('input');
2018-06-06 11:32:00 +08:00
if (!getCookie('user_qq') && !getCookie('user_qq_email') && !getCookie('user_author')) {
2019-09-05 17:09:44 +08:00
cached.filter('#qq,#author,#email,#url').val('');
2018-06-06 11:32:00 +08:00
}
if (getCookie('user_avatar') && getCookie('user_qq') && getCookie('user_qq_email')) {
$('div.comment-user-avatar img').attr('src', getCookie('user_avatar'));
2019-09-05 17:09:44 +08:00
cached.filter('#author').val(getCookie('user_author'));
cached.filter('#email').val(getCookie('user_qq') + '@qq.com');
cached.filter('#qq').val(getCookie('user_qq'));
2018-06-06 11:32:00 +08:00
if (mashiro_option.qzone_autocomplete) {
2019-09-05 17:09:44 +08:00
cached.filter('#url').val('https://user.qzone.qq.com/' + getCookie('user_qq'));
2018-06-06 11:32:00 +08:00
}
2019-09-05 17:09:44 +08:00
if (cached.filter('#qq').val()) {
2018-06-06 11:32:00 +08:00
$('.qq-check').css('display', 'block');
$('.gravatar-check').css('display', 'none');
}
}
2019-09-05 17:09:44 +08:00
var emailAddressFlag = cached.filter('#email').val();
cached.filter('#author').on('blur', function () {
var qq = cached.filter('#author').val(),
$reg = /^[1-9]\d{4,9}$/;
if ($reg.test(qq)) {
$.ajax({
type: 'get',
url: mashiro_option.qq_api_url + '?qq=' + qq + '&_wpnonce=' + Poi.nonce,
dataType: 'json',
success: function (data) {
cached.filter('#author').val(data.name);
cached.filter('#email').val($.trim(qq) + '@qq.com');
if (mashiro_option.qzone_autocomplete) {
cached.filter('#url').val('https://user.qzone.qq.com/' + $.trim(qq));
}
$('div.comment-user-avatar img').attr('src', 'https://q2.qlogo.cn/headimg_dl?dst_uin=' + qq + '&spec=100');
is_get_by_qq = true;
cached.filter('#qq').val($.trim(qq));
if (cached.filter('#qq').val()) {
$('.qq-check').css('display', 'block');
$('.gravatar-check').css('display', 'none');
}
setCookie('user_author', data.name, 30);
setCookie('user_qq', qq, 30);
setCookie('is_user_qq', 'yes', 30);
setCookie('user_qq_email', qq + '@qq.com', 30);
setCookie('user_email', qq + '@qq.com', 30);
emailAddressFlag = cached.filter('#email').val();
/***/
$('div.comment-user-avatar img').attr('src', data.avatar);
setCookie('user_avatar', data.avatar, 30);
},
error: function () {
cached.filter('#qq').val('');
2018-06-06 11:32:00 +08:00
$('.qq-check').css('display', 'none');
$('.gravatar-check').css('display', 'block');
2019-09-05 17:09:44 +08:00
$('div.comment-user-avatar img').attr('src', get_gravatar(cached.filter('#email').val(), 80));
setCookie('user_qq', '', 30);
setCookie('user_email', cached.filter('#email').val(), 30);
2019-09-05 17:09:44 +08:00
setCookie('user_avatar', get_gravatar(cached.filter('#email').val(), 80), 30);
/***/
cached.filter('#qq,#email,#url').val('');
if (!cached.filter('#qq').val()) {
$('.qq-check').css('display', 'none');
$('.gravatar-check').css('display', 'block');
setCookie('user_qq', '', 30);
$('div.comment-user-avatar img').attr('src', get_gravatar(cached.filter('#email').val(), 80));
setCookie('user_avatar', get_gravatar(cached.filter('#email').val(), 80), 30);
}
2018-06-06 11:32:00 +08:00
}
});
}
2018-06-06 11:32:00 +08:00
});
if (getCookie('user_avatar') && getCookie('user_email') && getCookie('is_user_qq') == 'no' && !getCookie('user_qq_email')) {
$('div.comment-user-avatar img').attr('src', getCookie('user_avatar'));
2019-09-05 17:09:44 +08:00
cached.filter('#email').val(getCookie('user_email'));
cached.filter('#qq').val('');
if (!cached.filter('#qq').val()) {
2018-06-06 11:32:00 +08:00
$('.qq-check').css('display', 'none');
$('.gravatar-check').css('display', 'block');
}
}
2019-09-05 17:09:44 +08:00
cached.filter('#email').on('blur', function () {
var emailAddress = cached.filter('#email').val();
2018-06-06 11:32:00 +08:00
if (is_get_by_qq == false || emailAddressFlag != emailAddress) {
$('div.comment-user-avatar img').attr('src', get_gravatar(emailAddress, 80));
setCookie('user_avatar', get_gravatar(emailAddress, 80), 30);
setCookie('user_email', emailAddress, 30);
setCookie('user_qq_email', '', 30);
setCookie('is_user_qq', 'no', 30);
2019-09-05 17:09:44 +08:00
cached.filter('#qq').val('');
if (!cached.filter('#qq').val()) {
2018-06-06 11:32:00 +08:00
$('.qq-check').css('display', 'none');
$('.gravatar-check').css('display', 'block');
}
}
});
if (getCookie('user_url')) {
2019-09-05 17:09:44 +08:00
cached.filter('#url').val(getCookie('user_url'));
2018-06-06 11:32:00 +08:00
}
2019-09-05 17:09:44 +08:00
cached.filter('#url').on('blur', function () {
var URL_Address = cached.filter('#url').val();
cached.filter('#url').val(URL_Address);
2018-06-06 11:32:00 +08:00
setCookie('user_url', URL_Address, 30);
});
if (getCookie('user_author')) {
2019-09-05 17:09:44 +08:00
cached.filter('#author').val(getCookie('user_author'));
2018-06-06 11:32:00 +08:00
}
2019-09-05 17:09:44 +08:00
cached.filter('#author').on('blur', function () {
var user_name = cached.filter('#author').val();
cached.filter('#author').val(user_name);
2018-06-06 11:32:00 +08:00
setCookie('user_author', user_name, 30);
});
}
function mail_me() {
var mail = "mailto:" + mashiro_option.email_name + "@" + mashiro_option.email_domain;
window.open(mail);
}
2019-01-25 11:27:53 +08:00
2019-11-15 23:17:20 +08:00
function activate_widget(){
if (document.body.clientWidth > 860) {
2019-11-16 22:08:20 +08:00
$('.show-hide').on('click', function() {
2019-11-15 23:17:20 +08:00
$("#secondary").toggleClass("active")
});
}else{
$("#secondary").remove();
}
}
2020-01-07 13:03:16 +08:00
setTimeout(function () {
activate_widget();
}, 100);
2019-11-15 23:17:20 +08:00
function load_bangumi() {
if ($("section").hasClass("bangumi")) {
$('body').on('click', '#bangumi-pagination a', function () {
$("#bangumi-pagination a").addClass("loading").text("");
var xhr = new XMLHttpRequest();
xhr.open('POST', this.href + "&_wpnonce=" + Poi.nonce, true);
xhr.onreadystatechange = function() {
if (xhr.readyState == 4 ) {
if(xhr.status == 200){
var html = JSON.parse(xhr.responseText);
$("#bangumi-pagination").remove();
$(".row").append(html);
}else{
$("#bangumi-pagination a").removeClass("loading").html('<i class="fa fa-exclamation-triangle" aria-hidden="true"></i> ERROR ');
}
}
};
xhr.send();
return false;
});
}
}
2018-06-06 11:32:00 +08:00
mashiro_global.ini.normalize();
loadCSS(mashiro_option.jsdelivr_css_src);
2019-01-25 11:27:53 +08:00
loadCSS(mashiro_option.entry_content_theme_src);
2018-06-06 11:32:00 +08:00
loadCSS("https://at.alicdn.com/t/font_679578_qyt5qzzavdo39pb9.css");
2018-11-04 19:20:10 +08:00
loadCSS("https://cdn.jsdelivr.net/npm/aplayer@1.10.1/dist/APlayer.min.css");
2018-12-28 13:41:17 +08:00
loadCSS("https://fonts.googleapis.com/css?family=Noto+SerifMerriweather|Merriweather+Sans|Source+Code+Pro|Ubuntu:400,700|Noto+Serif+SC");
2018-06-06 11:32:00 +08:00
(function webpackUniversalModuleDefinition(b, a) {
if (typeof exports === "object" && typeof module === "object") {
module.exports = a()
} else {
if (typeof define === "function" && define.amd) {
define([], a)
} else {
if (typeof exports === "object") {
exports.POWERMODE = a()
} else {
b.POWERMODE = a()
}
}
}
})(this, function () {
return (function (c) {
var b = {};
function a(e) {
if (b[e]) {
return b[e].exports
}
var d = b[e] = {
exports: {},
id: e,
loaded: false
};
c[e].call(d.exports, d, d.exports, a);
d.loaded = true;
return d.exports
}
a.m = c;
a.c = b;
a.p = "";
return a(0)
})([function (j, e, a) {
var b = document.createElement("canvas");
b.width = window.innerWidth;
b.height = window.innerHeight;
b.style.cssText = "position:fixed;top:0;left:0;pointer-events:none;z-index:999999";
window.addEventListener("resize", function () {
b.width = window.innerWidth;
b.height = window.innerHeight
});
document.body.appendChild(b);
var c = b.getContext("2d");
var l = [];
var k = 0;
m.shake = true;
function h(o, n) {
return Math.random() * (n - o) + o
}
function g(n) {
if (m.colorful) {
var o = h(0, 360);
return "hsla(" + h(o - 10, o + 10) + ", 100%, " + h(50, 80) + "%, " + 1 + ")"
} else {
return window.getComputedStyle(n).color
}
}
function f() {
var o = document.activeElement;
var n;
if (o.tagName === "TEXTAREA" || (o.tagName === "INPUT" && o.getAttribute("type") === "text")) {
var p = a(1)(o, o.selectionStart);
n = o.getBoundingClientRect();
return {
x: p.left + n.left,
y: p.top + n.top,
color: g(o)
}
}
var r = window.getSelection();
if (r.rangeCount) {
var q = r.getRangeAt(0);
var s = q.startContainer;
if (s.nodeType === document.TEXT_NODE) {
s = s.parentNode
}
n = q.getBoundingClientRect();
return {
x: n.left,
y: n.top,
color: g(s)
}
}
return {
x: 0,
y: 0,
color: "transparent"
}
}
function d(o, p, n) {
return {
x: o,
y: p,
alpha: 1,
color: n,
velocity: {
x: -1 + Math.random() * 2,
y: -3.5 + Math.random() * 2
}
}
}
function m() {
var n = f();
var p = 5 + Math.round(Math.random() * 10);
while (p--) {
l[k] = d(n.x, n.y, n.color);
k = (k + 1) % 500
}
if (m.shake) {
var o = 1 + 2 * Math.random();
var q = o * (Math.random() > 0.5 ? -1 : 1);
var r = o * (Math.random() > 0.5 ? -1 : 1);
document.body.style.marginLeft = q + "px";
document.body.style.marginTop = r + "px";
setTimeout(function () {
document.body.style.marginLeft = "";
document.body.style.marginTop = ""
}, 75)
}
}
m.colorful = false;
function i() {
requestAnimationFrame(i);
c.clearRect(0, 0, b.width, b.height);
for (var n = 0; n < l.length; ++n) {
var o = l[n];
if (o.alpha <= 0.1) {
continue
}
o.velocity.y += 0.075;
o.x += o.velocity.x;
o.y += o.velocity.y;
o.alpha *= 0.96;
c.globalAlpha = o.alpha;
c.fillStyle = o.color;
c.fillRect(Math.round(o.x - 1.5), Math.round(o.y - 1.5), 3, 3)
}
}
requestAnimationFrame(i);
j.exports = m
}, function (b, a) {
(function () {
var e = ["direction", "boxSizing", "width", "height", "overflowX", "overflowY", "borderTopWidth", "borderRightWidth", "borderBottomWidth", "borderLeftWidth", "borderStyle", "paddingTop", "paddingRight", "paddingBottom", "paddingLeft", "fontStyle", "fontVariant", "fontWeight", "fontStretch", "fontSize", "fontSizeAdjust", "lineHeight", "fontFamily", "textAlign", "textTransform", "textIndent", "textDecoration", "letterSpacing", "wordSpacing", "tabSize", "MozTabSize"];
var d = window.mozInnerScreenX != null;
function c(k, m, l) {
var h = l && l.debug || false;
if (h) {
var j = document.querySelector("#input-textarea-caret-position-mirror-div");
if (j) {
j.parentNode.removeChild(j)
}
}
var i = document.createElement("div");
i.id = "input-textarea-caret-position-mirror-div";
document.body.appendChild(i);
var o = i.style;
var f = window.getComputedStyle ? getComputedStyle(k) : k.currentStyle;
o.whiteSpace = "pre-wrap";
if (k.nodeName !== "INPUT") {
o.wordWrap = "break-word"
}
o.position = "absolute";
if (!h) {
o.visibility = "hidden"
}
e.forEach(function (p) {
o[p] = f[p]
});
if (d) {
if (k.scrollHeight > parseInt(f.height)) {
o.overflowY = "scroll"
}
} else {
o.overflow = "hidden"
}
i.textContent = k.value.substring(0, m);
if (k.nodeName === "INPUT") {
i.textContent = i.textContent.replace(/\s/g, "\u00a0")
}
var n = document.createElement("span");
n.textContent = k.value.substring(m) || ".";
i.appendChild(n);
var g = {
top: n.offsetTop + parseInt(f.borderTopWidth),
left: n.offsetLeft + parseInt(f.borderLeftWidth)
};
if (h) {
n.style.backgroundColor = "#aaa"
} else {
document.body.removeChild(i)
}
return g
}
if (typeof b != "undefined" && typeof b.exports != "undefined") {
b.exports = c
} else {
window.getCaretCoordinates = c
}
}())
}])
});
var home = location.href,
s = $('#bgvideo')[0],
Siren = {
MN: function () {
$('.iconflat').on('click', function () {
$('body').toggleClass('navOpen');
$('#main-container,#mo-nav,.openNav').toggleClass('open');
});
},
MNH: function () {
if ($('body').hasClass('navOpen')) {
$('body').toggleClass('navOpen');
$('#main-container,#mo-nav,.openNav').toggleClass('open');
}
},
splay: function () {
$('#video-btn').addClass('video-pause').removeClass('video-play').show();
$('.video-stu').css({
"bottom": "-100px"
});
$('.focusinfo').css({
"top": "-999px"
});
2018-12-14 00:21:35 +08:00
try {
for (var i = 0; i < ap.length; i++) {
try {
ap[i].destroy()
} catch (e) {}
}
} catch (e) {}
2018-06-06 11:32:00 +08:00
try {
hermitInit()
} catch (e) {}
s.play();
},
spause: function () {
$('#video-btn').addClass('video-play').removeClass('video-pause');
$('.focusinfo').css({
"top": "49.3%"
});
s.pause();
},
liveplay: function () {
if (s.oncanplay != undefined && $('.haslive').length > 0) {
if ($('.videolive').length > 0) {
Siren.splay();
}
}
},
livepause: function () {
if (s.oncanplay != undefined && $('.haslive').length > 0) {
Siren.spause();
$('.video-stu').css({
"bottom": "0px"
}).html('已暂停 ...');
}
},
addsource: function () {
$('.video-stu').html('正在载入视频 ...').css({
"bottom": "0px"
});
var t = Poi.movies.name.split(","),
_t = t[Math.floor(Math.random() * t.length)];
$('#bgvideo').attr('src', Poi.movies.url + '/' + _t + '.mp4');
$('#bgvideo').attr('video-name', _t);
},
LV: function () {
var _btn = $('#video-btn');
_btn.on('click', function () {
if ($(this).hasClass('loadvideo')) {
$(this).addClass('video-pause').removeClass('loadvideo').hide();
Siren.addsource();
s.oncanplay = function () {
Siren.splay();
$('#video-add').show();
2019-10-07 18:29:50 +08:00
_btn.addClass('videolive').addClass('haslive');
2018-06-06 11:32:00 +08:00
}
} else {
if ($(this).hasClass('video-pause')) {
Siren.spause();
_btn.removeClass('videolive');
$('.video-stu').css({
"bottom": "0px"
}).html('已暂停 ...');
} else {
Siren.splay();
_btn.addClass('videolive');
}
}
s.onended = function () {
$('#bgvideo').attr('src', '');
$('#video-add').hide();
2019-10-07 18:29:50 +08:00
_btn.addClass('loadvideo').removeClass('video-pause').removeClass('videolive').removeClass('haslive');
2018-06-06 11:32:00 +08:00
$('.focusinfo').css({
"top": "49.3%"
});
}
});
$('#video-add').on('click', function () {
Siren.addsource();
});
},
AH: function () {
if (Poi.windowheight == 'auto' && mashiro_option.windowheight == 'auto') {
2018-06-06 11:32:00 +08:00
if ($('h1.main-title').length > 0) {
2019-11-14 02:39:22 +08:00
var _height = $(window).height() + "px";
2018-06-06 11:32:00 +08:00
$('#centerbg').css({
'height': '100vh'
2018-06-06 11:32:00 +08:00
});
$('#bgvideo').css({
'min-height': '100vh'
2018-06-06 11:32:00 +08:00
});
}
} else {
$('.headertop').addClass('headertop-bar');
}
},
PE: function () {
if ($('.headertop').length > 0) {
if ($('h1.main-title').length > 0) {
$('.blank').css({
"padding-top": "0px"
});
$('.headertop').css({
"height": "auto"
}).show();
if (Poi.movies.live == 'open') Siren.liveplay();
} else {
$('.blank').css({
"padding-top": "75px"
});
$('.headertop').css({
"height": "0px"
}).hide();
Siren.livepause();
}
}
},
CE: function () {
$('.comments-hidden').show();
$('.comments-main').hide();
$('.comments-hidden').click(function () {
$('.comments-main').slideDown(500);
$('.comments-hidden').hide();
});
$('.archives').hide();
$('.archives:first').show();
$('#archives-temp h3').click(function () {
$(this).next().slideToggle('fast');
return false;
});
2019-01-24 17:01:27 +08:00
if (mashiro_option.baguetteBoxON) {
baguetteBox.run('.entry-content', {
captions: function (element) {
return element.getElementsByTagName('img')[0].alt;
},
ignoreClass: 'fancybox',
});
}
2018-06-06 11:32:00 +08:00
$('.js-toggle-search').on('click', function () {
$('.js-toggle-search').toggleClass('is-active');
$('.js-search').toggleClass('is-visible');
2019-11-14 02:39:22 +08:00
$('html').css('overflow-y', 'hidden');
2019-08-18 01:50:21 +08:00
if (mashiro_option.live_search) {
2019-11-14 02:39:22 +08:00
var QueryStorage = [];
search_a(Poi.api + "sakura/v1/cache_search/json?_wpnonce=" + Poi.nonce);
2019-08-18 01:50:21 +08:00
2019-11-14 02:39:22 +08:00
var otxt = addComment.I("search-input"),
list = addComment.I("PostlistBox"),
Record = list.innerHTML,
searchFlag = null;
otxt.oninput = function () {
if (searchFlag = null) {
clearTimeout(searchFlag);
}
searchFlag = setTimeout(function () {
query(QueryStorage, otxt.value, Record);
div_href();
}, 250);
};
function search_a(val) {
if (sessionStorage.getItem('search') != null) {
QueryStorage = JSON.parse(sessionStorage.getItem('search'));
query(QueryStorage, $("#search-input").val(), Record);
div_href();
} else {
var _xhr = new XMLHttpRequest();
_xhr.open("GET", val, true)
_xhr.send();
_xhr.onreadystatechange = function () {
if (_xhr.readyState == 4 && _xhr.status == 200) {
json = _xhr.responseText;
if (json != "") {
sessionStorage.setItem('search', json);
QueryStorage = JSON.parse(json);
query(QueryStorage, otxt.value, Record);
div_href();
}
2019-08-18 01:50:21 +08:00
}
}
}
}
2019-11-14 02:39:22 +08:00
if (!Object.values) Object.values = function (obj) {
if (obj !== Object(obj))
throw new TypeError('Object.values called on a non-object');
var val = [],
key;
for (key in obj) {
if (Object.prototype.hasOwnProperty.call(obj, key)) {
val.push(obj[key]);
}
2019-08-18 01:50:21 +08:00
}
2019-11-14 02:39:22 +08:00
return val;
2019-08-18 01:50:21 +08:00
}
2019-11-14 02:39:22 +08:00
function Cx(arr, q) {
q = q.replace(q, "^(?=.*?" + q + ").+$").replace(/\s/g, ")(?=.*?");
i = arr.filter(
v => Object.values(v).some(
v => new RegExp(q + '').test(v)
)
);
return i;
}
function div_href() {
$(".ins-selectable").each(function () {
$(this).click(function () {
$("#Ty").attr('href', $(this).attr('href'));
$("#Ty").click();
$(".search_close").click();
});
2019-08-18 01:50:21 +08:00
});
}
2019-11-14 02:39:22 +08:00
function search_result(keyword, link, fa, title, iconfont, comments, text) {
if (keyword) {
var s = keyword.trim().split(" "),
a = title.indexOf(s[s.length - 1]),
b = text.indexOf(s[s.length - 1]);
title = a < 60 ? title.slice(0, 80) : title.slice(a - 30, a + 30);
title = title.replace(s[s.length - 1], '<mark class="search-keyword"> ' + s[s.length - 1].toUpperCase() + ' </mark>');
text = b < 60 ? text.slice(0, 80) : text.slice(b - 30, b + 30);
text = text.replace(s[s.length - 1], '<mark class="search-keyword"> ' + s[s.length - 1].toUpperCase() + ' </mark>');
}
return '<div class="ins-selectable ins-search-item" href="' + link + '"><header><i class="fa fa-' + fa + '" aria-hidden="true"></i>' + title + '<i class="iconfont icon-' + iconfont + '"> ' + comments + '</i>' + '</header><p class="ins-search-preview">' + text + '</p></div>';
}
function query(B, A, z) {
var x, v, s, y = "",
w = "",
u = "",
r = "",
p = "",
F = "",
H = "",
G = '<section class="ins-section"><header class="ins-section-header">',
D = "</section>",
E = "</header>",
C = Cx(B, A.trim());
for (x = 0; x < Object.keys(C).length; x++) {
H = C[x];
switch (v = H.type) {
case "post":
w = w + search_result(A, H.link, "file", H.title, "mark", H.comments, H.text);
break;
case "tag":
p = p + search_result("", H.link, "tag", H.title, "none", "", "");
break;
case "category":
r = r + search_result("", H.link, "folder", H.title, "none", "", "");
break;
case "page":
u = u + search_result(A, H.link, "file", H.title, "mark", H.comments, H.text);
break;
case "comment":
F = F + search_result(A, H.link, "comment", H.title, "none", "", H.text);
break
}
}
w && (y = y + G + "文章" + E + w + D), u && (y = y + G + "页面" + E + u + D), r && (y = y + G + "分类" + E + r + D), p && (y = y + G + "标签" + E + p + D), F && (y = y + G + "评论" + E + F + D), s = addComment.I("PostlistBox"), s.innerHTML = y
}
2019-08-18 01:50:21 +08:00
}
2018-06-06 11:32:00 +08:00
});
$('.search_close').on('click', function () {
if ($('.js-search').hasClass('is-visible')) {
$('.js-toggle-search').toggleClass('is-active');
$('.js-search').toggleClass('is-visible');
2019-11-14 02:39:22 +08:00
$('html').css('overflow-y', 'unset');
2018-06-06 11:32:00 +08:00
}
});
$('#show-nav').on('click', function () {
if ($('#show-nav').hasClass('showNav')) {
$('#show-nav').removeClass('showNav').addClass('hideNav');
$('.site-top .lower nav').addClass('navbar');
} else {
$('#show-nav').removeClass('hideNav').addClass('showNav');
$('.site-top .lower nav').removeClass('navbar');
}
});
$("#loading").click(function () {
$("#loading").fadeOut(500);
});
},
NH: function () {
if(document.body.clientWidth > 860){
var h1 = 0;
$(window).scroll(function () {
var s = $(document).scrollTop(),
cached = $('.site-header');
if (s == h1) {
cached.removeClass('yya');
}
if (s > h1) {
cached.addClass('yya');
}
2018-06-06 11:32:00 +08:00
});
}
2018-06-06 11:32:00 +08:00
},
XLS: function () {
$body = (window.opera) ? (document.compatMode == "CSS1Compat" ? $('html') : $('body')) : $('html,body');
2019-08-04 13:43:28 +08:00
var load_post_timer;
2019-08-05 12:09:04 +08:00
var intersectionObserver = new IntersectionObserver(function (entries) {
2019-11-14 02:39:22 +08:00
if (entries[0].intersectionRatio <= 0) return;
var page_next = $('#pagination a').attr("href");
var load_key = addComment.I("add_post_time");
if (page_next != undefined && load_key) {
var load_time = addComment.I("add_post_time").title;
if (load_time != "233") {
console.log("%c 自动加载时倒计时 %c", "background:#9a9da2; color:#ffffff; border-radius:4px;", "", "", load_time);
load_post_timer = setTimeout(function () {
load_post();
}, load_time * 1000);
}
}
2019-08-04 13:43:28 +08:00
});
2019-08-05 12:09:04 +08:00
intersectionObserver.observe(
document.querySelector('.footer-device')
);
2018-06-06 11:32:00 +08:00
$('body').on('click', '#pagination a', function () {
2019-08-04 13:43:28 +08:00
clearTimeout(load_post_timer);
load_post();
return false;
});
2019-11-14 02:39:22 +08:00
function load_post() {
2019-08-04 13:43:28 +08:00
$('#pagination a').addClass("loading").text("");
2018-06-06 11:32:00 +08:00
$.ajax({
type: "POST",
2019-08-04 13:43:28 +08:00
url: $('#pagination a').attr("href") + "#main",
2018-06-06 11:32:00 +08:00
success: function (data) {
result = $(data).find("#main .post");
nextHref = $(data).find("#pagination a").attr("href");
$("#main").append(result.fadeIn(500));
$("#pagination a").removeClass("loading").text("Previous");
2019-08-04 13:43:28 +08:00
$('#add_post span').removeClass("loading").text("");
2018-06-06 11:32:00 +08:00
lazyload();
2019-08-25 11:57:53 +08:00
post_list_show_animation();
2018-06-06 11:32:00 +08:00
if (nextHref != undefined) {
$("#pagination a").attr("href", nextHref);
2019-11-14 02:39:22 +08:00
//加载完成上滑
2019-08-04 13:43:28 +08:00
var tempScrollTop = $(window).scrollTop();
$(window).scrollTop(tempScrollTop);
2019-11-14 02:39:22 +08:00
$body.animate({
scrollTop: tempScrollTop + 100
2019-11-14 02:39:22 +08:00
}, 666)
2018-06-06 11:32:00 +08:00
} else {
$("#pagination").html("<span>很高兴你翻到这里,但是真的没有了...</span>");
}
}
});
return false;
2019-11-14 02:39:22 +08:00
}
2018-06-06 11:32:00 +08:00
},
XCS: function () {
var __cancel = jQuery('#cancel-comment-reply-link'),
__cancel_text = __cancel.text(),
__list = 'commentwrap';
jQuery(document).on("submit", "#commentform", function () {
jQuery.ajax({
url: Poi.ajaxurl,
data: jQuery(this).serialize() + "&action=ajax_comment",
type: jQuery(this).attr('method'),
beforeSend: addComment.createButterbar("提交中(Commiting)...."),
error: function (request) {
var t = addComment;
t.createButterbar(request.responseText);
},
success: function (data) {
jQuery('textarea').each(function () {
this.value = ''
});
var t = addComment,
cancel = t.I('cancel-comment-reply-link'),
temp = t.I('wp-temp-form-div'),
respond = t.I(t.respondId),
post = t.I('comment_post_ID').value,
parent = t.I('comment_parent').value;
if (parent != '0') {
jQuery('#respond').before('<ol class="children">' + data + '</ol>');
} else if (!jQuery('.' + __list).length) {
if (Poi.formpostion == 'bottom') {
jQuery('#respond').before('<ol class="' + __list + '">' + data + '</ol>');
} else {
jQuery('#respond').after('<ol class="' + __list + '">' + data + '</ol>');
}
} else {
if (Poi.order == 'asc') {
jQuery('.' + __list).append(data);
} else {
jQuery('.' + __list).prepend(data);
}
}
t.createButterbar("提交成功(Succeed)");
lazyload();
code_highlight_style();
click_to_view_image();
clean_upload_images();
cancel.style.display = 'none';
cancel.onclick = null;
t.I('comment_parent').value = '0';
if (temp && respond) {
temp.parentNode.insertBefore(respond, temp);
temp.parentNode.removeChild(temp)
}
}
});
return false;
});
addComment = {
moveForm: function (commId, parentId, respondId) {
var t = this,
div, comm = t.I(commId),
respond = t.I(respondId),
cancel = t.I('cancel-comment-reply-link'),
parent = t.I('comment_parent'),
post = t.I('comment_post_ID');
__cancel.text(__cancel_text);
t.respondId = respondId;
if (!t.I('wp-temp-form-div')) {
div = document.createElement('div');
div.id = 'wp-temp-form-div';
div.style.display = 'none';
respond.parentNode.insertBefore(div, respond)
}!comm ? (temp = t.I('wp-temp-form-div'), t.I('comment_parent').value = '0', temp.parentNode.insertBefore(respond, temp), temp.parentNode.removeChild(temp)) : comm.parentNode.insertBefore(respond, comm.nextSibling);
jQuery("body").animate({
scrollTop: jQuery('#respond').offset().top - 180
}, 400);
parent.value = parentId;
cancel.style.display = '';
cancel.onclick = function () {
var t = addComment,
temp = t.I('wp-temp-form-div'),
respond = t.I(t.respondId);
t.I('comment_parent').value = '0';
if (temp && respond) {
temp.parentNode.insertBefore(respond, temp);
temp.parentNode.removeChild(temp);
}
this.style.display = 'none';
this.onclick = null;
return false;
};
try {
t.I('comment').focus();
} catch (e) {}
return false;
},
I: function (e) {
return document.getElementById(e);
},
clearButterbar: function (e) {
if (jQuery(".butterBar").length > 0) {
jQuery(".butterBar").remove();
}
},
createButterbar: function (message, showtime) {
var t = this;
t.clearButterbar();
jQuery("body").append('<div class="butterBar butterBar--center"><p class="butterBar-message">' + message + '</p></div>');
if (showtime > 0) {
setTimeout("jQuery('.butterBar').remove()", showtime);
} else {
setTimeout("jQuery('.butterBar').remove()", 6000);
}
}
};
},
XCP: function () {
$body = (window.opera) ? (document.compatMode == "CSS1Compat" ? $('html') : $('body')) : $('html,body');
$('body').on('click', '#comments-navi a', function (e) {
e.preventDefault();
2020-03-21 17:38:05 +08:00
var path = $(this)[0].pathname;
2018-06-06 11:32:00 +08:00
$.ajax({
type: "GET",
url: $(this).attr('href'),
beforeSend: function () {
$('#comments-navi').remove();
$('ul.commentwrap').remove();
$('#loading-comments').slideDown();
$body.animate({
scrollTop: $('#comments-list-title').offset().top - 65
}, 800);
},
dataType: "html",
success: function (out) {
result = $(out).find('ul.commentwrap');
nextlink = $(out).find('#comments-navi');
$('#loading-comments').slideUp('fast');
$('#loading-comments').after(result.fadeIn(500));
$('ul.commentwrap').after(nextlink);
lazyload();
2020-03-19 16:03:06 +08:00
if (window.gtag) {
gtag('config', Poi.google_analytics_id, {
'page_path': path
});
}
2018-06-06 11:32:00 +08:00
code_highlight_style();
click_to_view_image();
}
});
});
},
IA: function () {
POWERMODE.colorful = true;
POWERMODE.shake = false;
document.body.addEventListener('input', POWERMODE)
},
GT: function () {
var cwidth = document.body.clientWidth,
cheight = window.innerHeight,
pc_to_top = document.querySelector(".cd-top"),
mb_to_top = document.querySelector("#moblieGoTop"),
mb_dark_light = document.querySelector("#moblieDarkLight"),
changeskin = document.querySelector(".changeSkin-gear");
$(window).scroll(function() {
if (cwidth <= 860) {
if ($(this).scrollTop() > 20) {
mb_to_top.style.transform = "scale(1)";
mb_dark_light.style.transform = "scale(1)";
2018-06-06 11:32:00 +08:00
} else {
mb_to_top.style.transform = "scale(0)";
mb_dark_light.style.transform = "scale(0)";
2018-06-06 11:32:00 +08:00
}
} else {
if ($(this).scrollTop() > 100) {
pc_to_top.classList.add("cd-is-visible");
changeskin.style.bottom = "0";
if (cheight > 950) {
pc_to_top.style.top = "0";
} else {
pc_to_top.style.top = cheight - 950 + "px";
}
} else {
changeskin.style.bottom = "-999px";
pc_to_top.style.top = "-999px";
pc_to_top.classList.remove("cd-fade-out", "cd-is-visible");
}
if ($(this).scrollTop() > 1200) {
pc_to_top.classList.add("cd-fade-out");
}
2018-06-06 11:32:00 +08:00
}
});
2019-01-24 17:01:27 +08:00
//smooth scroll to top
pc_to_top.onclick = function() {
topFunction();
}
mb_to_top.onclick = function() {
topFunction();
}
mb_dark_light.onclick = function() {
mobile_dark_light();
}
2018-06-06 11:32:00 +08:00
}
}
$(function () {
Siren.AH();
Siren.PE();
Siren.NH();
Siren.GT();
Siren.XLS();
Siren.XCS();
Siren.XCP();
Siren.CE();
Siren.MN();
Siren.IA();
Siren.LV();
if (Poi.pjax) {
$(document).pjax('a[target!=_top]', '#page', {
fragment: '#page',
timeout: 8000,
2019-11-14 02:39:22 +08:00
}).on('pjax:beforeSend', () => { //离开页面停止播放
$('.normal-cover-video').each(function () {
2019-01-24 17:01:27 +08:00
this.pause();
this.src = '';
this.load = '';
});
2018-06-06 11:32:00 +08:00
}).on('pjax:send', function () {
$("#bar").css("width", "0%");
if (mashiro_option.NProgressON) NProgress.start();
Siren.MNH();
}).on('pjax:complete', function () {
Siren.AH();
Siren.PE();
Siren.CE();
if (mashiro_option.NProgressON) NProgress.done();
mashiro_global.ini.pjax();
$("#loading").fadeOut(500);
if (Poi.codelamp == 'open') {
self.Prism.highlightAll(event)
};
if ($('.ds-thread').length > 0) {
if (typeof DUOSHUO !== 'undefined') {
DUOSHUO.EmbedThread('.ds-thread');
} else {
$.getScript("//static.duoshuo.com/embed.js");
}
}
2020-03-19 16:03:06 +08:00
}).on('pjax:end', function() {
if (window.gtag){
gtag('config', Poi.google_analytics_id, {
'page_path': window.location.pathname
});
}
2018-06-06 11:32:00 +08:00
}).on('submit', '.search-form,.s-search', function (event) {
event.preventDefault();
$.pjax.submit(event, '#page', {
fragment: '#page',
timeout: 8000,
});
if ($('.js-search.is-visible').length > 0) {
$('.js-toggle-search').toggleClass('is-active');
$('.js-search').toggleClass('is-visible');
2019-11-14 02:39:22 +08:00
$('html').css('overflow-y', 'unset');
2018-06-06 11:32:00 +08:00
}
});
window.addEventListener('popstate', function (e) {
Siren.AH();
Siren.PE();
Siren.CE();
timeSeriesReload(true);
2019-10-07 18:29:50 +08:00
post_list_show_animation();
2018-06-06 11:32:00 +08:00
}, false);
}
$.fn.postLike = function () {
if ($(this).hasClass('done')) {
return false;
} else {
$(this).addClass('done');
var id = $(this).data("id"),
action = $(this).data('action'),
rateHolder = $(this).children('.count');
var ajax_data = {
action: "specs_zan",
um_id: id,
um_action: action
};
$.post(Poi.ajaxurl, ajax_data, function (data) {
$(rateHolder).html(data);
});
return false;
}
};
$(document).on("click", ".specsZan", function () {
$(this).postLike();
});
console.log("%c Mashiro %c", "background:#24272A; color:#ffffff", "", "https://2heng.xin/");
console.log("%c Github %c", "background:#24272A; color:#ffffff", "", "https://github.com/mashirozx");
});
var isWebkit = navigator.userAgent.toLowerCase().indexOf('webkit') > -1,
isOpera = navigator.userAgent.toLowerCase().indexOf('opera') > -1,
isIe = navigator.userAgent.toLowerCase().indexOf('msie') > -1;
if ((isWebkit || isOpera || isIe) && document.getElementById && window.addEventListener) {
window.addEventListener('hashchange', function () {
var id = location.hash.substring(1),
element;
if (!(/^[A-z0-9_-]+$/.test(id))) {
return;
}
2019-08-19 18:42:36 +08:00
element = addComment.I(id);
2018-06-06 11:32:00 +08:00
if (element) {
if (!(/^(?:a|select|input|button|textarea)$/i.test(element.tagName))) {
element.tabIndex = -1;
}
element.focus();
}
}, false);
2019-11-15 09:23:07 +08:00
}