diff --git a/dist/js/bundle.js b/dist/js/bundle.js index b15a642..1cbdef1 100644 --- a/dist/js/bundle.js +++ b/dist/js/bundle.js @@ -1,70 +1,5 @@ -(() => { - // - window.addComment = function(v) { - var I, C, h, E = v.document, b = { commentReplyClass: "comment-reply-link", commentReplyTitleId: "reply-title", cancelReplyId: "cancel-comment-reply-link", commentFormId: "commentform", temporaryFormId: "wp-temp-form-div", parentIdFieldId: "comment_parent", postIdFieldId: "comment_post_ID" }, e = v.MutationObserver || v.WebKitMutationObserver || v.MozMutationObserver, r = "querySelector" in E && "addEventListener" in v, n = !!E.documentElement.dataset; - function t() { - d(), e && new e(o).observe(E.body, { childList: true, subtree: true }); - } - function d(e2) { - if (r && (I = g(b.cancelReplyId), C = g(b.commentFormId), I)) { - let t3 = function(e3) { - if ((e3.metaKey || e3.ctrlKey) && 13 === e3.keyCode) - return C.removeEventListener("keydown", t3), e3.preventDefault(), C.submit.click(), false; - }; - var t2 = t3; - I.addEventListener("touchstart", l), I.addEventListener("click", l); - C && C.addEventListener("keydown", t3); - for (var n2, d2 = function(e3) { - var t4 = b.commentReplyClass; - e3 && e3.childNodes || (e3 = E); - e3 = E.getElementsByClassName ? e3.getElementsByClassName(t4) : e3.querySelectorAll("." + t4); - return e3; - }(e2), o2 = 0, i = d2.length; o2 < i; o2++) - (n2 = d2[o2]).addEventListener("touchstart", a), n2.addEventListener("click", a); - } - } - function l(e2) { - var t2, n2, d2 = g(b.temporaryFormId); - d2 && h && (g(b.parentIdFieldId).value = "0", t2 = d2.textContent, d2.parentNode.replaceChild(h, d2), this.style.display = "none", n2 = (d2 = (d2 = g(b.commentReplyTitleId)) && d2.firstChild) && d2.nextSibling, d2 && d2.nodeType === Node.TEXT_NODE && t2 && (n2 && "A" === n2.nodeName && n2.id !== b.cancelReplyId && (n2.style.display = ""), d2.textContent = t2), e2.preventDefault()); - } - function a(e2) { - var t2 = g(b.commentReplyTitleId), t2 = t2 && t2.firstChild.textContent, n2 = this, d2 = m(n2, "belowelement"), o2 = m(n2, "commentid"), i = m(n2, "respondelement"), r2 = m(n2, "postid"), n2 = m(n2, "replyto") || t2; - d2 && o2 && i && r2 && false === v.addComment.moveForm(d2, o2, i, r2, n2) && e2.preventDefault(); - } - function o(e2) { - for (var t2 = e2.length; t2--; ) - if (e2[t2].addedNodes.length) - return void d(); - } - function m(e2, t2) { - return n ? e2.dataset[t2] : e2.getAttribute("data-" + t2); - } - function g(e2) { - return E.getElementById(e2); - } - return r && "loading" !== E.readyState ? t() : r && v.addEventListener("DOMContentLoaded", t, false), { init: d, moveForm: function(e2, t2, n2, d2, o2) { - var i, r2, l2, a2, m2, c, s, e2 = g(e2), n2 = (h = g(n2), g(b.parentIdFieldId)), y = g(b.postIdFieldId), p = g(b.commentReplyTitleId), u = (p = p && p.firstChild) && p.nextSibling; - if (e2 && h && n2) { - void 0 === o2 && (o2 = p && p.textContent), a2 = h, m2 = b.temporaryFormId, c = g(m2), s = (s = g(b.commentReplyTitleId)) ? s.firstChild.textContent : "", c || ((c = E.createElement("div")).id = m2, c.style.display = "none", c.textContent = s, a2.parentNode.insertBefore(c, a2)), d2 && y && (y.value = d2), n2.value = t2, I.style.display = "", e2.parentNode.insertBefore(h, e2.nextSibling), p && p.nodeType === Node.TEXT_NODE && (u && "A" === u.nodeName && u.id !== b.cancelReplyId && (u.style.display = "none"), p.textContent = o2), I.onclick = function() { - return false; - }; - try { - for (var f = 0; f < C.elements.length; f++) - if (i = C.elements[f], r2 = false, "getComputedStyle" in v ? l2 = v.getComputedStyle(i) : E.documentElement.currentStyle && (l2 = i.currentStyle), (i.offsetWidth <= 0 && i.offsetHeight <= 0 || "hidden" === l2.visibility) && (r2 = true), "hidden" !== i.type && !i.disabled && !r2) { - i.focus(); - break; - } - } catch (e3) { - } - return false; - } - } }; - }(window); - })(); - /*! This file is auto-generated */ ; (() => { - // ns-hugo:E:\OneDrive\桌面\suxiaoxiao\bigfa\bigfa.github.io\themes\farallon\assets\ts\utils.ts var farallonHelper = class { getCookie(t) { if (0 < document.cookie.length) { @@ -77,169 +12,12 @@ } return ""; } - setCookie(t, e, n) { - var o = /* @__PURE__ */ new Date(); - o.setTime(o.getTime() + 24 * n * 60 * 60 * 1e3); - var i = "expires=" + o.toUTCString(); - document.cookie = t + "=" + e + ";" + i + ";path=/"; - } - showNotice(message, type = "success") { - const html = `
${message}
`; - document.querySelector("body").insertAdjacentHTML("beforeend", html); - document.querySelector(".notice--wrapper").classList.add("is-active"); - setTimeout(() => { - document.querySelector(".notice--wrapper").remove(); - }, 3e3); - } }; - - // ns-hugo:E:\OneDrive\桌面\suxiaoxiao\bigfa\bigfa.github.io\themes\farallon\assets\ts\date.ts - var farallonDate = class { - selector; - timeFormat = { - second: "second ago", - seconds: "seconds ago", - minute: "minute ago", - minutes: "minutes ago", - hour: "hour ago", - hours: "hours ago", - day: "day ago", - days: "days ago", - week: "week ago", - weeks: "weeks ago", - month: "month ago", - months: "months ago", - year: "year ago", - years: "years ago" - }; - doms = []; - constructor(config) { - this.selector = config.selector; - if (config.timeFormat) { - this.timeFormat = config.timeFormat; - } - this.init(); - setTimeout(() => { - this.refresh(); - }, 1e3 * 5); - } - init() { - this.doms = Array.from(document.querySelectorAll(this.selector)); - this.doms.forEach((dom) => { - dom.innerText = this.humanize_time_ago( - dom.attributes["datetime"].value - ); - }); - } - humanize_time_ago(datetime) { - const time = new Date(datetime); - const between = Date.now() / 1e3 - Number(time.getTime() / 1e3); - if (between < 3600) { - return `${Math.ceil(between / 60)} ${Math.ceil(between / 60) == 1 ? this.timeFormat.second : this.timeFormat.seconds}`; - } else if (between < 86400) { - return `${Math.ceil(between / 3600)} ${Math.ceil(between / 3660) == 1 ? this.timeFormat.hour : this.timeFormat.hours}`; - } else if (between < 86400 * 30) { - return `${Math.ceil(between / 86400)} ${Math.ceil(between / 86400) == 1 ? this.timeFormat.day : this.timeFormat.days}`; - } else if (between < 86400 * 30 * 12) { - return `${Math.ceil(between / (86400 * 30))} ${Math.ceil(between / (86400 * 30)) == 1 ? this.timeFormat.month : this.timeFormat.months}`; - } else { - return time.getFullYear() + "-" + (time.getMonth() + 1) + "-" + time.getDate(); - } - } - refresh() { - this.doms.forEach((dom) => { - dom.innerText = this.humanize_time_ago( - dom.attributes["datetime"].value - ); - }); - } - }; - var date_default = farallonDate; - - // ns-hugo:E:\OneDrive\桌面\suxiaoxiao\bigfa\bigfa.github.io\themes\farallon\assets\ts\action.ts - var farallonActions = class extends farallonHelper { - singleSelector = ".post--single"; - likeButtonSelctor = ".like-btn"; - articleSelector = ".post--item"; - viewSelector = ".article--views"; - actionDomain; - text = ""; - likeButton = null; - post_id; - is_single = false; - constructor(config) { - super(); - this.singleSelector = config.singleSelector ?? this.singleSelector; - this.likeButtonSelctor = config.likeButtonSelctor ?? this.likeButtonSelctor; - this.articleSelector = config.articleSelector ?? this.articleSelector; - this.viewSelector = config.viewSelector ?? this.viewSelector; - this.actionDomain = config.actionDomain; - this.text = config.text ?? this.text; - this.is_single = document.querySelector(this.singleSelector) ? true : false; - if (this.is_single) { - const postSingle = document.querySelector( - this.singleSelector - ); - this.post_id = postSingle.dataset.id ?? ""; - this.initArticleLike(); - } - } - initArticleLike() { - this.likeButton = document.querySelector(this.likeButtonSelctor); - if (this.likeButton) { - fetch(this.actionDomain + "post/" + this.post_id + "/like").then( - (res) => { - res.json().then((data) => { - this.likeButton.querySelector( - ".count" - ).innerText = data.likes; - }); - } - ); - this.likeButton.addEventListener("click", () => { - this.handleLike(); - }); - if (this.getCookie("like_" + this.post_id)) { - this.likeButton.classList.add("is-active"); - } - } - } - handleLike() { - if (this.getCookie("like_" + this.post_id)) { - return this.showNotice("You have already liked this post"); - } - if (this.likeButton) { - const url = this.actionDomain + "post/" + this.post_id + "/like"; - fetch(url, { - method: "post" - }).then((response) => { - return response.json(); - }).then((data) => { - this.showNotice("Thanks for your like"); - const countElement = this.likeButton?.querySelector( - ".count" - ); - if (countElement) { - countElement.innerText = data.likes; - } - this.setCookie("like_" + this.post_id, "1", 1); - }); - this.likeButton?.classList.add("is-active"); - } - } - }; - var action_default = farallonActions; - - // var farallonBase = class extends farallonHelper { is_single = false; post_id = 0; is_archive = false; VERSION = "0.4.1"; - like_btn; - selctor = ".like-btn"; - // @ts-ignore - actionDomain = window.actionDomain; constructor() { super(); this.initCopyright(); @@ -338,18 +116,5 @@ }); } }; - new action_default({ - singleSelector: ".post--single", - articleSelector: ".post--item", - likeButtonSelctor: ".like-btn", - // @ts-ignore - actionDomain: window.actionDomain - }); new farallonBase(); - new date_default({ - selector: ".humane--time", - //@ts-ignore - timeFormat: window.timeFormat - }); - })(); - \ No newline at end of file + })(); \ No newline at end of file