From a5d38e7fbca6fc0815f7c532321d5e3d4bae6c9f Mon Sep 17 00:00:00 2001 From: Cotes Chung <11371340+cotes2020@users.noreply.github.com> Date: Wed, 26 Jan 2022 22:06:44 +0800 Subject: [PATCH] Improve local datetime display - Protect author's location privacy - Reduce locale configuration parameters --- _config.yml | 3 + _data/locales/en.yml | 13 ---- _data/locales/id-ID.yml | 13 ---- _data/locales/ko-KR.yml | 13 ---- _data/locales/my-MM.yml | 13 ---- _data/locales/ru-RU.yml | 13 ---- _data/locales/uk-UA.yml | 13 ---- _data/locales/zh-CN.yml | 13 ---- _includes/head.html | 11 ++- _includes/js-selector.html | 25 ++++++- _includes/no-zero-date.html | 13 ---- _includes/timeago.html | 23 ++---- _javascript/commons/locale-helper.js | 19 +++++ _javascript/utils/locale-datetime.js | 20 ++++++ _javascript/utils/timeago.js | 100 +++++++++++++++------------ _layouts/archives.html | 10 +-- _layouts/category.html | 6 +- _layouts/home.html | 2 +- _layouts/tag.html | 6 +- assets/js/dist/categories.min.js | 2 +- assets/js/dist/commons.min.js | 2 +- assets/js/dist/home.min.js | 2 +- assets/js/dist/misc.min.js | 6 ++ assets/js/dist/page.min.js | 2 +- assets/js/dist/post.min.js | 2 +- gulpfile.js/tasks/js.js | 16 +++-- 26 files changed, 165 insertions(+), 196 deletions(-) delete mode 100644 _includes/no-zero-date.html create mode 100644 _javascript/commons/locale-helper.js create mode 100644 _javascript/utils/locale-datetime.js create mode 100644 assets/js/dist/misc.min.js diff --git a/_config.yml b/_config.yml index 4feeee0..1a1e998 100644 --- a/_config.yml +++ b/_config.yml @@ -12,6 +12,9 @@ baseurl: '' # otherwise, the layout language will use the default value of 'en'. lang: en +# Additional parameters for datetime localization, optional. › https://github.com/iamkun/dayjs/tree/dev/src/locale +prefer_datetime_locale: + # Change to your timezone › http://www.timezoneconverter.com/cgi-bin/findzone/findzone timezone: Asia/Shanghai diff --git a/_data/locales/en.yml b/_data/locales/en.yml index 4781340..1221776 100644 --- a/_data/locales/en.yml +++ b/_data/locales/en.yml @@ -27,14 +27,6 @@ panel: trending_tags: Trending Tags toc: Contents -# The liquid date format › http://strftime.net/ -date_format: - tooltip: '%a, %b %e, %Y, %l:%M %p %z' - post: - long: '%b %e, %Y' - short: '%b %e' - archive_month: '%b' - copyright: # Shown at the bottom of the post license: @@ -62,11 +54,6 @@ post: written_by: By posted: Posted updated: Updated - timeago: - day: days ago - hour: hours ago - minute: minutes ago - just_now: just now words: words pageview_measure: views read_time: diff --git a/_data/locales/id-ID.yml b/_data/locales/id-ID.yml index 4693c5e..37ad8ea 100644 --- a/_data/locales/id-ID.yml +++ b/_data/locales/id-ID.yml @@ -27,14 +27,6 @@ panel: trending_tags: Tagar Terpopuler toc: Konten -# The liquid date format › http://strftime.net/ -date_format: - tooltip: "%a, %e %b, %Y, %l:%M %p" - post: - long: "%e %b, %Y" - short: "%e %b" - archive_month: "%b" - copyright: # Shown at the bottom of the post license: @@ -62,11 +54,6 @@ post: written_by: Oleh posted: Diterbitkan updated: Diperbarui - timeago: - day: hari yang lalu - hour: jam yang lalu - minute: menit yang lalu - just_now: baru saja words: kata pageview_measure: dilihat read_time: diff --git a/_data/locales/ko-KR.yml b/_data/locales/ko-KR.yml index 34d48aa..4bfd318 100644 --- a/_data/locales/ko-KR.yml +++ b/_data/locales/ko-KR.yml @@ -27,14 +27,6 @@ panel: trending_tags: 인기 태그 toc: 바로가기 -# The liquid date format › http://strftime.net/ -date_format: - tooltip: '%F, %R %z' - post: - long: '%Y년 %m월 %d일' - short: '%m월 %d일' - archive_month: '%b월' - copyright: # Shown at the bottom of the post license: @@ -62,11 +54,6 @@ post: written_by: By posted: 게시 updated: 업데이트 - timeago: - day: 일 전 - hour: 시간 전 - minute: 분 전 - just_now: 방금 words: 단어 pageview_measure: 조회 read_time: diff --git a/_data/locales/my-MM.yml b/_data/locales/my-MM.yml index e7affff..6ad9e28 100644 --- a/_data/locales/my-MM.yml +++ b/_data/locales/my-MM.yml @@ -27,14 +27,6 @@ panel: trending_tags: ခေတ်စားနေသည့်တက်ဂ်များ toc: အကြောင်းအရာများ -# The liquid date format › http://strftime.net/ -date_format: - tooltip: '%a, %b %e, %Y, %l:%M %p %z' - post: - long: '%b %e, %Y' - short: '%b %e' - archive_month: '%b' - copyright: # Shown at the bottom of the post license: @@ -62,11 +54,6 @@ post: written_by: ကရေးသားခဲ့သည်။ posted: တင်ထားခဲ့သည်။ updated: မွမ်းမံထားခဲ့သည်။ - timeago: - day: လွန်ခဲ့သော ရက်များတွင်း - hour: လွန်ခဲ့သော နာရီပိုင်းတွင်း - minute: လွန်ခဲ့သော မိနစ်အနည်းငယ်က - just_now: အခုလေးတင် words: စကားလုံးများ pageview_measure: အမြင်များ read_time: diff --git a/_data/locales/ru-RU.yml b/_data/locales/ru-RU.yml index 663a044..1a538fe 100644 --- a/_data/locales/ru-RU.yml +++ b/_data/locales/ru-RU.yml @@ -27,14 +27,6 @@ panel: trending_tags: Популярные теги toc: Содержание -# The liquid date format › http://strftime.net/ -date_format: - tooltip: '%a, %b %e, %Y, %l:%M %p %z' - post: - long: '%b %e, %Y' - short: '%b %e' - archive_month: '%b' - copyright: # Shown at the bottom of the post license: @@ -62,11 +54,6 @@ post: written_by: Автор posted: Время публикации updated: Обновлено - timeago: - day: дней назад - hour: часов назад - minute: минут назад - just_now: только что words: слов pageview_measure: просмотров read_time: diff --git a/_data/locales/uk-UA.yml b/_data/locales/uk-UA.yml index 95de4ac..c06faaf 100644 --- a/_data/locales/uk-UA.yml +++ b/_data/locales/uk-UA.yml @@ -27,14 +27,6 @@ panel: trending_tags: Популярні теги toc: Зміст -# The liquid date format › http://strftime.net/ -date_format: - tooltip: '%a, %b %e, %Y, %l:%M %p %z' - post: - long: '%b %e, %Y' - short: '%b %e' - archive_month: '%b' - copyright: # Shown at the bottom of the post license: @@ -62,11 +54,6 @@ post: written_by: Автор posted: Час публікації updated: Оновлено - timeago: - day: днів тому - hour: годин тому - minute: хвилин тому - just_now: щойно words: слів pageview_measure: переглядів read_time: diff --git a/_data/locales/zh-CN.yml b/_data/locales/zh-CN.yml index 83f2376..880a47e 100644 --- a/_data/locales/zh-CN.yml +++ b/_data/locales/zh-CN.yml @@ -27,14 +27,6 @@ panel: trending_tags: 热门标签 toc: 文章内容 -# The liquid date format › http://strftime.net/ -date_format: - tooltip: '%F, %R %z' - post: - long: '%F' - short: '%m-%d' - archive_month: '%m月' - copyright: # Shown at the bottom of the post license: @@ -61,11 +53,6 @@ post: written_by: 作者 posted: 发表于 updated: 更新于 - timeago: - day: 天前 - hour: 小时前 - minute: 分钟前 - just_now: 刚刚 words: 字 pageview_measure: 次浏览 read_time: diff --git a/_includes/head.html b/_includes/head.html index eac902b..404e3de 100644 --- a/_includes/head.html +++ b/_includes/head.html @@ -6,13 +6,12 @@ - {% if page.layout == 'home' or page.layout == 'post' %} + + {% if site.prefer_datetime_locale %} + + {% endif %} - - - - - + {% if page.layout == 'home' or page.layout == 'post' %} {% if site.google_analytics.pv.proxy_endpoint %} diff --git a/_includes/js-selector.html b/_includes/js-selector.html index 2e73f60..0b32169 100644 --- a/_includes/js-selector.html +++ b/_includes/js-selector.html @@ -18,10 +18,29 @@ {% endif %} {% if page.layout == 'home' - or page.layout == 'categories' - or page.layout == 'post' - or page.layout == 'page' %} + or page.layout == 'post' + or page.layout == 'archives' + or page.layout == 'category' + or page.layout == 'tag' %} + + {% if site.prefer_datetime_locale %} + {% assign locale = site.prefer_datetime_locale | downcase %} + {% else %} + {% assign locale = site.lang | split: '-' | first %} + {% endif %} + + +{% endif %} + +{% if page.layout == 'home' + or page.layout == 'categories' + or page.layout == 'post' + or page.layout == 'page' %} {% assign type = page.layout %} +{% elsif page.layout == 'archives' + or page.layout == 'category' + or page.layout == 'tag' %} + {% assign type = "misc" %} {% else %} {% assign type = "commons" %} {% endif %} diff --git a/_includes/no-zero-date.html b/_includes/no-zero-date.html deleted file mode 100644 index 5c98b73..0000000 --- a/_includes/no-zero-date.html +++ /dev/null @@ -1,13 +0,0 @@ -{% comment %} - Remove the zero padding from a month/day string -{% endcomment %} - -{% assign ret = include.date_str %} -{% assign _first_chat = ret | slice: 0 %} - -{% if _first_chat == '0' %} - {% assign _last_idx = ret.size | minus: 1 %} - {% assign ret = ret | slice: 1, _last_idx %} -{% endif %} - -{{ ret | replace: ' 0', ' ' }} diff --git a/_includes/timeago.html b/_includes/timeago.html index 3b68fd4..899d41b 100644 --- a/_includes/timeago.html +++ b/_includes/timeago.html @@ -3,24 +3,13 @@ See: ${JS_ROOT}/utils/timeago.js --> -{% assign tooltip_df = site.data.locales[lang].date_format.tooltip %} -{% assign post_long_df = site.data.locales[lang].date_format.post.long %} -{% assign post_short_df = site.data.locales[lang].date_format.post.short %} - - - {%- assign this_year = site.time | date: "%Y" -%} - {%- assign post_year = include.date | date: "%Y" -%} - - {%- if post_year == this_year -%} - {{ include.date | date: post_short_df }} - {%- else -%} - {{ include.date | date: post_long_df }} - {%- endif -%} + {{ include.date | date: '%Y-%m-%d' }} diff --git a/_javascript/commons/locale-helper.js b/_javascript/commons/locale-helper.js new file mode 100644 index 0000000..196ca6c --- /dev/null +++ b/_javascript/commons/locale-helper.js @@ -0,0 +1,19 @@ +/** + * A tool for locale datetime + */ + +const LocaleHelper = (function () { + const $preferLocale = $('meta[name="prefer-datetime-locale"]'); + const locale = $preferLocale.length > 0 ? + $preferLocale.attr('content').toLowerCase() : $('html').attr('lang').substr(0, 2); + const attrTimestamp = 'data-ts'; + const attrDateFormat = 'data-df'; + + return { + locale: () => locale, + attrTimestamp: () => attrTimestamp, + attrDateFormat: () => attrDateFormat, + getTimestamp: ($elem) => Number($elem.attr(attrTimestamp)), // unix timestamp + getDateFormat: ($elem) => $elem.attr(attrDateFormat) + }; +}()); diff --git a/_javascript/utils/locale-datetime.js b/_javascript/utils/locale-datetime.js new file mode 100644 index 0000000..a7766f0 --- /dev/null +++ b/_javascript/utils/locale-datetime.js @@ -0,0 +1,20 @@ +/** + * Update month/day to locale datetime + * + * Requirement: + */ + +$(function() { + dayjs.locale(LocaleHelper.locale()); + dayjs.extend(window.dayjs_plugin_localizedFormat); + + $(`[${LocaleHelper.attrTimestamp()}]`).each(function () { + const date = dayjs.unix(LocaleHelper.getTimestamp($(this))); + const df = LocaleHelper.getDateFormat($(this)); + const text = date.format(df); + + $(this).text(text); + $(this).removeAttr(LocaleHelper.attrTimestamp()); + $(this).removeAttr(LocaleHelper.attrDateFormat()); + }); +}); diff --git a/_javascript/utils/timeago.js b/_javascript/utils/timeago.js index 371231a..d7746d6 100644 --- a/_javascript/utils/timeago.js +++ b/_javascript/utils/timeago.js @@ -1,77 +1,87 @@ -/* +/** * Calculate the Timeago + * + * Requirement: */ $(function() { - const timeagoElem = $(".timeago"); - let tasks = timeagoElem.length; + const attrTimestamp = LocaleHelper.attrTimestamp(); + const attrCapitalize = 'data-capitalize'; + const $timeago = $(".timeago"); + + let timeagoTasks = $timeago.length; let intervalId = void 0; - const dPrompt = $("meta[name=day-prompt]").attr("content"); - const hrPrompt = $("meta[name=hour-prompt]").attr("content"); - const minPrompt = $("meta[name=minute-prompt]").attr("content"); - const justnowPrompt = $("meta[name=justnow-prompt]").attr("content"); + dayjs.locale(LocaleHelper.locale()); + dayjs.extend(window.dayjs_plugin_relativeTime); + dayjs.extend(window.dayjs_plugin_localizedFormat); - function timeago(date, initDate) { - let now = new Date(); - let past = new Date(date); + function relativetime($elem) { + const now = dayjs(); + const past = dayjs.unix(LocaleHelper.getTimestamp($elem)); - if (past.getFullYear() !== now.getFullYear() - || past.getMonth() !== now.getMonth()) { - return initDate; + let diffMonth = now.diff(past, 'month', true); + if (diffMonth > 10) { // year ago range: 11 months to 17months + $elem.removeAttr(attrTimestamp); + return past.format('ll'); // see: https://day.js.org/docs/en/display/format#list-of-localized-formats } - let seconds = Math.floor((now - past) / 1000); - - let day = Math.floor(seconds / 86400); - if (day >= 1) { - return ` ${day} ${dPrompt}`; + let diffMinute = now.diff(past, 'minute', true); + if (diffMinute > 44) { // an hour ago range: 45 to 89 minutes + $elem.removeAttr(attrTimestamp); } - let hour = Math.floor(seconds / 3600); - if (hour >= 1) { - return ` ${hour} ${hrPrompt}`; - } - - let minute = Math.floor(seconds / 60); - if (minute >= 1) { - return ` ${minute} ${minPrompt}`; - } - - return justnowPrompt; + return past.fromNow(); } function updateTimeago() { - $(".timeago").each(function() { - if ($(this)[0].hasAttribute("date") === false) { - tasks -= 1; + $timeago.each(function() { + if (typeof $(this).attr(attrTimestamp) === 'undefined') { + timeagoTasks -= 1; return; } - let date = $(this).attr("date"); - let initDate = $(this).text(); - let relativeDate = timeago(date, initDate); - - if (relativeDate === initDate) { - $(this).removeAttr("date"); - } else { - $(this).text(relativeDate); + let relativeTime = relativetime($(this)); + const capitalize = $(this).attr(attrCapitalize); + if (typeof capitalize !== 'undefined' && capitalize === 'true') { + relativeTime = relativeTime.replace(/^\w/, (c) => c.toUpperCase()); } + if ($(this).text() !== relativeTime) { + $(this).text(relativeTime); + } }); - if (tasks === 0 && typeof intervalId !== "undefined") { + if (timeagoTasks === 0 && typeof intervalId !== "undefined") { clearInterval(intervalId); /* stop interval */ } - return tasks; + + return timeagoTasks; } - if (tasks === 0) { + function setupTooltips() { + $timeago.each(function() { + const tooltip = $(this).attr('data-toggle'); + if (typeof tooltip === 'undefined' || tooltip !== 'tooltip') { + return; + } + + const df = $(this).attr('data-tooltip-df'); + const ts = LocaleHelper.getTimestamp($(this)); + const dateStr = dayjs.unix(ts).format(df); + $(this).attr('data-original-title', dateStr); + $(this).removeAttr('data-tooltip-df'); + }); + } + + if (timeagoTasks === 0) { return; } - if (updateTimeago() > 0) { /* run immediately */ - intervalId = setInterval(updateTimeago, 60000); /* run every minute */ + setupTooltips(); + + if (updateTimeago()) { /* run immediately */ + intervalId = setInterval(updateTimeago, 60 * 1000); /* run every minute */ } }); diff --git a/_layouts/archives.html b/_layouts/archives.html index dfb2d32..ff5404b 100644 --- a/_layouts/archives.html +++ b/_layouts/archives.html @@ -18,11 +18,11 @@ layout: page {% endif %}
  • - {% capture this_day %}{{ post.date | date: "%d" }}{% endcapture %} - {% capture _mth_df %}{{ site.data.locales[lang].date_format.post.archive_month }}{% endcapture %} - {% capture this_month %}{{ post.date | date: _mth_df }}{% endcapture %} - {{ this_day }} - {% include no-zero-date.html date_str=this_month %} + {% assign ts = post.date | date: '%s' %} + {{ post.date | date: "%d" }} + + {{ post.date | date: '%m' }} + {{ post.title }}
  • diff --git a/_layouts/category.html b/_layouts/category.html index a366081..cd688d8 100644 --- a/_layouts/category.html +++ b/_layouts/category.html @@ -13,13 +13,13 @@ layout: page diff --git a/_layouts/home.html b/_layouts/home.html index 9d31784..b43689c 100644 --- a/_layouts/home.html +++ b/_layouts/home.html @@ -62,7 +62,7 @@ layout: page
    - {% include timeago.html date=post.date tooltip=true %} + {% include timeago.html date=post.date tooltip=true capitalize=true %} diff --git a/_layouts/tag.html b/_layouts/tag.html index 30371ef..c2ba286 100644 --- a/_layouts/tag.html +++ b/_layouts/tag.html @@ -12,13 +12,13 @@ layout: page {{ page.posts | size }}
      - {% assign post_df = site.data.locales[lang].date_format.post.long %} - {% for post in page.posts %}
    • {{ post.title }} - {{ post.date | date: post_df }} + + {{ post.date | date: '%Y-%m-%d' }} +
    • {% endfor %}
    diff --git a/assets/js/dist/categories.min.js b/assets/js/dist/categories.min.js index ea5bb0d..d200a7c 100644 --- a/assets/js/dist/categories.min.js +++ b/assets/js/dist/categories.min.js @@ -3,4 +3,4 @@ * © 2019 Cotes Chung * MIT Licensed */ -$(function(){$(window).scroll(()=>{50<$(this).scrollTop()&&"none"===$("#sidebar-trigger").css("display")?$("#back-to-top").fadeIn():$("#back-to-top").fadeOut()}),$("#back-to-top").click(()=>($("body,html").animate({scrollTop:0},800),!1))}),$(function(){$(".mode-toggle").click(o=>{const e=$(o.target);let t=e.prop("tagName")==="button".toUpperCase()?e:e.parent();t.blur(),flipMode()})});const ScrollHelper=function(){const o=$("body"),e="data-topbar-visible",t=$("#topbar-wrapper").outerHeight();let l=0,a=!1,r=!1;return{hideTopbar:()=>o.attr(e,!1),showTopbar:()=>o.attr(e,!0),addScrollUpTask:()=>{l+=1,a=a||!0},popScrollUpTask:()=>--l,hasScrollUpTask:()=>0!0===a,unlockTopbar:()=>a=!1,getTopbarHeight:()=>t,orientationLocked:()=>!0===r,lockOrientation:()=>r=!0,unLockOrientation:()=>r=!1}}();$(function(){const o=$("#sidebar-trigger"),e=$("#search-trigger"),t=$("#search-cancel"),l=$("#search-cleaner"),a=$("#main"),r=$("#topbar-title"),s=$("#search-wrapper"),n=$("#search-result-wrapper"),i=$("#search-results"),c=$("#search-input"),d=$("#search-hints"),p=function(){let o=0;return{block(){o=window.scrollY,$("html,body").scrollTop(0)},release(){$("html,body").scrollTop(o)},getOffset(){return o}}}(),f={on(){o.addClass("unloaded"),r.addClass("unloaded"),e.addClass("unloaded"),s.addClass("d-flex"),t.addClass("loaded")},off(){t.removeClass("loaded"),s.removeClass("d-flex"),o.removeClass("unloaded"),r.removeClass("unloaded"),e.removeClass("unloaded")}},u=function(){let o=!1;return{on(){o||(p.block(),n.removeClass("unloaded"),a.addClass("unloaded"),o=!0)},off(){o&&(i.empty(),d.hasClass("unloaded")&&d.removeClass("unloaded"),n.addClass("unloaded"),l.removeClass("visible"),a.removeClass("unloaded"),p.release(),c.val(""),o=!1)},isVisible(){return o}}}();function h(){return t.hasClass("loaded")}e.click(function(){f.on(),u.on(),c.focus()}),t.click(function(){f.off(),u.off()}),c.focus(function(){s.addClass("input-focus")}),c.focusout(function(){s.removeClass("input-focus")}),c.on("keyup",function(o){8===o.keyCode&&""===c.val()?h()?d.removeClass("unloaded"):u.off():""!==c.val()&&(u.on(),l.hasClass("visible")||l.addClass("visible"),h()&&d.addClass("unloaded"))}),l.on("click",function(){c.val(""),h()?(d.removeClass("unloaded"),i.empty()):u.off(),c.focus(),l.removeClass("visible")})}),$(function(){var o=function(){const o="sidebar-display";let e=!1;const t=$("body");return{toggle(){!1===e?t.attr(o,""):t.removeAttr(o),e=!e}}}();$("#sidebar-trigger").click(o.toggle),$("#mask").click(o.toggle)}),$(function(){$('[data-toggle="tooltip"]').tooltip()}),$(function(){const e=$("#search-input"),t=ScrollHelper.getTopbarHeight();let o,l=0;function a(){0!==$(window).scrollTop()&&(ScrollHelper.lockOrientation(),ScrollHelper.hideTopbar())}screen.orientation?screen.orientation.onchange=()=>{var o=screen.orientation.type;"landscape-primary"!==o&&"landscape-secondary"!==o||a()}:$(window).on("orientationchange",()=>{$(window).width()<$(window).height()&&a()}),$(window).scroll(()=>{o=o||!0}),setInterval(()=>{o&&(function(){var o=$(this).scrollTop();if(!(Math.abs(l-o)<=t)){if(o>l)ScrollHelper.hideTopbar(),e.is(":focus")&&e.blur();else if(o+$(window).height()<$(document).height()){if(ScrollHelper.hasScrollUpTask())return;ScrollHelper.topbarLocked()?ScrollHelper.unlockTopbar():ScrollHelper.orientationLocked()?ScrollHelper.unLockOrientation():ScrollHelper.showTopbar()}l=o}}(),o=!1)},250)}),$(function(){var e="div.post>h1:first-of-type";const t=$(e),s=$("#topbar-title");if(0!==t.length&&!t.hasClass("dynamic-title")&&!s.is(":hidden")){const n=s.text().trim();let l=t.text().trim(),a=!1,r=0;($("#page-category").length||$("#page-tag").length)&&/\s/.test(l)&&(l=l.replace(/[0-9]/g,"").trim()),t.offset().top<$(window).scrollTop()&&s.text(l);let o=new IntersectionObserver(o=>{var e,t;a?(e=$(window).scrollTop(),t=r{50<$(this).scrollTop()&&"none"===$("#sidebar-trigger").css("display")?$("#back-to-top").fadeIn():$("#back-to-top").fadeOut()}),$("#back-to-top").click(()=>($("body,html").animate({scrollTop:0},800),!1))});const LocaleHelper=function(){const e=$('meta[name="prefer-datetime-locale"]'),o=0o,attrTimestamp:()=>t,attrDateFormat:()=>a,getTimestamp:e=>Number(e.attr(t)),getDateFormat:e=>e.attr(a)}}();$(function(){$(".mode-toggle").click(e=>{const o=$(e.target);let t=o.prop("tagName")==="button".toUpperCase()?o:o.parent();t.blur(),flipMode()})});const ScrollHelper=function(){const e=$("body"),o="data-topbar-visible",t=$("#topbar-wrapper").outerHeight();let a=0,l=!1,r=!1;return{hideTopbar:()=>e.attr(o,!1),showTopbar:()=>e.attr(o,!0),addScrollUpTask:()=>{a+=1,l=l||!0},popScrollUpTask:()=>--a,hasScrollUpTask:()=>0!0===l,unlockTopbar:()=>l=!1,getTopbarHeight:()=>t,orientationLocked:()=>!0===r,lockOrientation:()=>r=!0,unLockOrientation:()=>r=!1}}();$(function(){const e=$("#sidebar-trigger"),o=$("#search-trigger"),t=$("#search-cancel"),a=$("#search-cleaner"),l=$("#main"),r=$("#topbar-title"),s=$("#search-wrapper"),n=$("#search-result-wrapper"),i=$("#search-results"),c=$("#search-input"),d=$("#search-hints"),p=function(){let e=0;return{block(){e=window.scrollY,$("html,body").scrollTop(0)},release(){$("html,body").scrollTop(e)},getOffset(){return e}}}(),f={on(){e.addClass("unloaded"),r.addClass("unloaded"),o.addClass("unloaded"),s.addClass("d-flex"),t.addClass("loaded")},off(){t.removeClass("loaded"),s.removeClass("d-flex"),e.removeClass("unloaded"),r.removeClass("unloaded"),o.removeClass("unloaded")}},u=function(){let e=!1;return{on(){e||(p.block(),n.removeClass("unloaded"),l.addClass("unloaded"),e=!0)},off(){e&&(i.empty(),d.hasClass("unloaded")&&d.removeClass("unloaded"),n.addClass("unloaded"),a.removeClass("visible"),l.removeClass("unloaded"),p.release(),c.val(""),e=!1)},isVisible(){return e}}}();function h(){return t.hasClass("loaded")}o.click(function(){f.on(),u.on(),c.focus()}),t.click(function(){f.off(),u.off()}),c.focus(function(){s.addClass("input-focus")}),c.focusout(function(){s.removeClass("input-focus")}),c.on("keyup",function(e){8===e.keyCode&&""===c.val()?h()?d.removeClass("unloaded"):u.off():""!==c.val()&&(u.on(),a.hasClass("visible")||a.addClass("visible"),h()&&d.addClass("unloaded"))}),a.on("click",function(){c.val(""),h()?(d.removeClass("unloaded"),i.empty()):u.off(),c.focus(),a.removeClass("visible")})}),$(function(){var e=function(){const e="sidebar-display";let o=!1;const t=$("body");return{toggle(){!1===o?t.attr(e,""):t.removeAttr(e),o=!o}}}();$("#sidebar-trigger").click(e.toggle),$("#mask").click(e.toggle)}),$(function(){$('[data-toggle="tooltip"]').tooltip()}),$(function(){const o=$("#search-input"),t=ScrollHelper.getTopbarHeight();let e,a=0;function l(){0!==$(window).scrollTop()&&(ScrollHelper.lockOrientation(),ScrollHelper.hideTopbar())}screen.orientation?screen.orientation.onchange=()=>{var e=screen.orientation.type;"landscape-primary"!==e&&"landscape-secondary"!==e||l()}:$(window).on("orientationchange",()=>{$(window).width()<$(window).height()&&l()}),$(window).scroll(()=>{e=e||!0}),setInterval(()=>{e&&(function(){var e=$(this).scrollTop();if(!(Math.abs(a-e)<=t)){if(e>a)ScrollHelper.hideTopbar(),o.is(":focus")&&o.blur();else if(e+$(window).height()<$(document).height()){if(ScrollHelper.hasScrollUpTask())return;ScrollHelper.topbarLocked()?ScrollHelper.unlockTopbar():ScrollHelper.orientationLocked()?ScrollHelper.unLockOrientation():ScrollHelper.showTopbar()}a=e}}(),e=!1)},250)}),$(function(){var o="div.post>h1:first-of-type";const t=$(o),s=$("#topbar-title");if(0!==t.length&&!t.hasClass("dynamic-title")&&!s.is(":hidden")){const n=s.text().trim();let a=t.text().trim(),l=!1,r=0;($("#page-category").length||$("#page-tag").length)&&/\s/.test(a)&&(a=a.replace(/[0-9]/g,"").trim()),t.offset().top<$(window).scrollTop()&&s.text(a);let e=new IntersectionObserver(e=>{var o,t;l?(o=$(window).scrollTop(),t=r{50<$(this).scrollTop()&&"none"===$("#sidebar-trigger").css("display")?$("#back-to-top").fadeIn():$("#back-to-top").fadeOut()}),$("#back-to-top").click(()=>($("body,html").animate({scrollTop:0},800),!1))}),$(function(){$(".mode-toggle").click(e=>{const o=$(e.target);let t=o.prop("tagName")==="button".toUpperCase()?o:o.parent();t.blur(),flipMode()})});const ScrollHelper=function(){const e=$("body"),o="data-topbar-visible",t=$("#topbar-wrapper").outerHeight();let l=0,a=!1,r=!1;return{hideTopbar:()=>e.attr(o,!1),showTopbar:()=>e.attr(o,!0),addScrollUpTask:()=>{l+=1,a=a||!0},popScrollUpTask:()=>--l,hasScrollUpTask:()=>0!0===a,unlockTopbar:()=>a=!1,getTopbarHeight:()=>t,orientationLocked:()=>!0===r,lockOrientation:()=>r=!0,unLockOrientation:()=>r=!1}}();$(function(){const e=$("#sidebar-trigger"),o=$("#search-trigger"),t=$("#search-cancel"),l=$("#search-cleaner"),a=$("#main"),r=$("#topbar-title"),n=$("#search-wrapper"),s=$("#search-result-wrapper"),i=$("#search-results"),c=$("#search-input"),d=$("#search-hints"),p=function(){let e=0;return{block(){e=window.scrollY,$("html,body").scrollTop(0)},release(){$("html,body").scrollTop(e)},getOffset(){return e}}}(),u={on(){e.addClass("unloaded"),r.addClass("unloaded"),o.addClass("unloaded"),n.addClass("d-flex"),t.addClass("loaded")},off(){t.removeClass("loaded"),n.removeClass("d-flex"),e.removeClass("unloaded"),r.removeClass("unloaded"),o.removeClass("unloaded")}},f=function(){let e=!1;return{on(){e||(p.block(),s.removeClass("unloaded"),a.addClass("unloaded"),e=!0)},off(){e&&(i.empty(),d.hasClass("unloaded")&&d.removeClass("unloaded"),s.addClass("unloaded"),l.removeClass("visible"),a.removeClass("unloaded"),p.release(),c.val(""),e=!1)},isVisible(){return e}}}();function h(){return t.hasClass("loaded")}o.click(function(){u.on(),f.on(),c.focus()}),t.click(function(){u.off(),f.off()}),c.focus(function(){n.addClass("input-focus")}),c.focusout(function(){n.removeClass("input-focus")}),c.on("keyup",function(e){8===e.keyCode&&""===c.val()?h()?d.removeClass("unloaded"):f.off():""!==c.val()&&(f.on(),l.hasClass("visible")||l.addClass("visible"),h()&&d.addClass("unloaded"))}),l.on("click",function(){c.val(""),h()?(d.removeClass("unloaded"),i.empty()):f.off(),c.focus(),l.removeClass("visible")})}),$(function(){var e=function(){const e="sidebar-display";let o=!1;const t=$("body");return{toggle(){!1===o?t.attr(e,""):t.removeAttr(e),o=!o}}}();$("#sidebar-trigger").click(e.toggle),$("#mask").click(e.toggle)}),$(function(){$('[data-toggle="tooltip"]').tooltip()}),$(function(){const o=$("#search-input"),t=ScrollHelper.getTopbarHeight();let e,l=0;function a(){0!==$(window).scrollTop()&&(ScrollHelper.lockOrientation(),ScrollHelper.hideTopbar())}screen.orientation?screen.orientation.onchange=()=>{var e=screen.orientation.type;"landscape-primary"!==e&&"landscape-secondary"!==e||a()}:$(window).on("orientationchange",()=>{$(window).width()<$(window).height()&&a()}),$(window).scroll(()=>{e=e||!0}),setInterval(()=>{e&&(function(){var e=$(this).scrollTop();if(!(Math.abs(l-e)<=t)){if(e>l)ScrollHelper.hideTopbar(),o.is(":focus")&&o.blur();else if(e+$(window).height()<$(document).height()){if(ScrollHelper.hasScrollUpTask())return;ScrollHelper.topbarLocked()?ScrollHelper.unlockTopbar():ScrollHelper.orientationLocked()?ScrollHelper.unLockOrientation():ScrollHelper.showTopbar()}l=e}}(),e=!1)},250)}),$(function(){var o="div.post>h1:first-of-type";const t=$(o),n=$("#topbar-title");if(0!==t.length&&!t.hasClass("dynamic-title")&&!n.is(":hidden")){const s=n.text().trim();let l=t.text().trim(),a=!1,r=0;($("#page-category").length||$("#page-tag").length)&&/\s/.test(l)&&(l=l.replace(/[0-9]/g,"").trim()),t.offset().top<$(window).scrollTop()&&n.text(l);let e=new IntersectionObserver(e=>{var o,t;a?(o=$(window).scrollTop(),t=r{50<$(this).scrollTop()&&"none"===$("#sidebar-trigger").css("display")?$("#back-to-top").fadeIn():$("#back-to-top").fadeOut()}),$("#back-to-top").click(()=>($("body,html").animate({scrollTop:0},800),!1))});const LocaleHelper=function(){const e=$('meta[name="prefer-datetime-locale"]'),o=0o,attrTimestamp:()=>t,attrDateFormat:()=>a,getTimestamp:e=>Number(e.attr(t)),getDateFormat:e=>e.attr(a)}}();$(function(){$(".mode-toggle").click(e=>{const o=$(e.target);let t=o.prop("tagName")==="button".toUpperCase()?o:o.parent();t.blur(),flipMode()})});const ScrollHelper=function(){const e=$("body"),o="data-topbar-visible",t=$("#topbar-wrapper").outerHeight();let a=0,l=!1,r=!1;return{hideTopbar:()=>e.attr(o,!1),showTopbar:()=>e.attr(o,!0),addScrollUpTask:()=>{a+=1,l=l||!0},popScrollUpTask:()=>--a,hasScrollUpTask:()=>0!0===l,unlockTopbar:()=>l=!1,getTopbarHeight:()=>t,orientationLocked:()=>!0===r,lockOrientation:()=>r=!0,unLockOrientation:()=>r=!1}}();$(function(){const e=$("#sidebar-trigger"),o=$("#search-trigger"),t=$("#search-cancel"),a=$("#search-cleaner"),l=$("#main"),r=$("#topbar-title"),n=$("#search-wrapper"),s=$("#search-result-wrapper"),i=$("#search-results"),c=$("#search-input"),d=$("#search-hints"),p=function(){let e=0;return{block(){e=window.scrollY,$("html,body").scrollTop(0)},release(){$("html,body").scrollTop(e)},getOffset(){return e}}}(),u={on(){e.addClass("unloaded"),r.addClass("unloaded"),o.addClass("unloaded"),n.addClass("d-flex"),t.addClass("loaded")},off(){t.removeClass("loaded"),n.removeClass("d-flex"),e.removeClass("unloaded"),r.removeClass("unloaded"),o.removeClass("unloaded")}},f=function(){let e=!1;return{on(){e||(p.block(),s.removeClass("unloaded"),l.addClass("unloaded"),e=!0)},off(){e&&(i.empty(),d.hasClass("unloaded")&&d.removeClass("unloaded"),s.addClass("unloaded"),a.removeClass("visible"),l.removeClass("unloaded"),p.release(),c.val(""),e=!1)},isVisible(){return e}}}();function h(){return t.hasClass("loaded")}o.click(function(){u.on(),f.on(),c.focus()}),t.click(function(){u.off(),f.off()}),c.focus(function(){n.addClass("input-focus")}),c.focusout(function(){n.removeClass("input-focus")}),c.on("keyup",function(e){8===e.keyCode&&""===c.val()?h()?d.removeClass("unloaded"):f.off():""!==c.val()&&(f.on(),a.hasClass("visible")||a.addClass("visible"),h()&&d.addClass("unloaded"))}),a.on("click",function(){c.val(""),h()?(d.removeClass("unloaded"),i.empty()):f.off(),c.focus(),a.removeClass("visible")})}),$(function(){var e=function(){const e="sidebar-display";let o=!1;const t=$("body");return{toggle(){!1===o?t.attr(e,""):t.removeAttr(e),o=!o}}}();$("#sidebar-trigger").click(e.toggle),$("#mask").click(e.toggle)}),$(function(){$('[data-toggle="tooltip"]').tooltip()}),$(function(){const o=$("#search-input"),t=ScrollHelper.getTopbarHeight();let e,a=0;function l(){0!==$(window).scrollTop()&&(ScrollHelper.lockOrientation(),ScrollHelper.hideTopbar())}screen.orientation?screen.orientation.onchange=()=>{var e=screen.orientation.type;"landscape-primary"!==e&&"landscape-secondary"!==e||l()}:$(window).on("orientationchange",()=>{$(window).width()<$(window).height()&&l()}),$(window).scroll(()=>{e=e||!0}),setInterval(()=>{e&&(function(){var e=$(this).scrollTop();if(!(Math.abs(a-e)<=t)){if(e>a)ScrollHelper.hideTopbar(),o.is(":focus")&&o.blur();else if(e+$(window).height()<$(document).height()){if(ScrollHelper.hasScrollUpTask())return;ScrollHelper.topbarLocked()?ScrollHelper.unlockTopbar():ScrollHelper.orientationLocked()?ScrollHelper.unLockOrientation():ScrollHelper.showTopbar()}a=e}}(),e=!1)},250)}),$(function(){var o="div.post>h1:first-of-type";const t=$(o),n=$("#topbar-title");if(0!==t.length&&!t.hasClass("dynamic-title")&&!n.is(":hidden")){const s=n.text().trim();let a=t.text().trim(),l=!1,r=0;($("#page-category").length||$("#page-tag").length)&&/\s/.test(a)&&(a=a.replace(/[0-9]/g,"").trim()),t.offset().top<$(window).scrollTop()&&n.text(a);let e=new IntersectionObserver(e=>{var o,t;l?(o=$(window).scrollTop(),t=r{50<$(this).scrollTop()&&"none"===$("#sidebar-trigger").css("display")?$("#back-to-top").fadeIn():$("#back-to-top").fadeOut()}),$("#back-to-top").click(()=>($("body,html").animate({scrollTop:0},800),!1))}),$(function(){$(".mode-toggle").click(e=>{const t=$(e.target);let o=t.prop("tagName")==="button".toUpperCase()?t:t.parent();o.blur(),flipMode()})});const ScrollHelper=function(){const e=$("body"),t="data-topbar-visible",o=$("#topbar-wrapper").outerHeight();let a=0,l=!1,r=!1;return{hideTopbar:()=>e.attr(t,!1),showTopbar:()=>e.attr(t,!0),addScrollUpTask:()=>{a+=1,l=l||!0},popScrollUpTask:()=>--a,hasScrollUpTask:()=>0!0===l,unlockTopbar:()=>l=!1,getTopbarHeight:()=>o,orientationLocked:()=>!0===r,lockOrientation:()=>r=!0,unLockOrientation:()=>r=!1}}();$(function(){const e=$("#sidebar-trigger"),t=$("#search-trigger"),o=$("#search-cancel"),a=$("#search-cleaner"),l=$("#main"),r=$("#topbar-title"),n=$("#search-wrapper"),s=$("#search-result-wrapper"),i=$("#search-results"),c=$("#search-input"),d=$("#search-hints"),p=function(){let e=0;return{block(){e=window.scrollY,$("html,body").scrollTop(0)},release(){$("html,body").scrollTop(e)},getOffset(){return e}}}(),u={on(){e.addClass("unloaded"),r.addClass("unloaded"),t.addClass("unloaded"),n.addClass("d-flex"),o.addClass("loaded")},off(){o.removeClass("loaded"),n.removeClass("d-flex"),e.removeClass("unloaded"),r.removeClass("unloaded"),t.removeClass("unloaded")}},f=function(){let e=!1;return{on(){e||(p.block(),s.removeClass("unloaded"),l.addClass("unloaded"),e=!0)},off(){e&&(i.empty(),d.hasClass("unloaded")&&d.removeClass("unloaded"),s.addClass("unloaded"),a.removeClass("visible"),l.removeClass("unloaded"),p.release(),c.val(""),e=!1)},isVisible(){return e}}}();function h(){return o.hasClass("loaded")}t.click(function(){u.on(),f.on(),c.focus()}),o.click(function(){u.off(),f.off()}),c.focus(function(){n.addClass("input-focus")}),c.focusout(function(){n.removeClass("input-focus")}),c.on("keyup",function(e){8===e.keyCode&&""===c.val()?h()?d.removeClass("unloaded"):f.off():""!==c.val()&&(f.on(),a.hasClass("visible")||a.addClass("visible"),h()&&d.addClass("unloaded"))}),a.on("click",function(){c.val(""),h()?(d.removeClass("unloaded"),i.empty()):f.off(),c.focus(),a.removeClass("visible")})}),$(function(){var e=function(){const e="sidebar-display";let t=!1;const o=$("body");return{toggle(){!1===t?o.attr(e,""):o.removeAttr(e),t=!t}}}();$("#sidebar-trigger").click(e.toggle),$("#mask").click(e.toggle)}),$(function(){$('[data-toggle="tooltip"]').tooltip()}),$(function(){const t=$("#search-input"),o=ScrollHelper.getTopbarHeight();let e,a=0;function l(){0!==$(window).scrollTop()&&(ScrollHelper.lockOrientation(),ScrollHelper.hideTopbar())}screen.orientation?screen.orientation.onchange=()=>{var e=screen.orientation.type;"landscape-primary"!==e&&"landscape-secondary"!==e||l()}:$(window).on("orientationchange",()=>{$(window).width()<$(window).height()&&l()}),$(window).scroll(()=>{e=e||!0}),setInterval(()=>{e&&(function(){var e=$(this).scrollTop();if(!(Math.abs(a-e)<=o)){if(e>a)ScrollHelper.hideTopbar(),t.is(":focus")&&t.blur();else if(e+$(window).height()<$(document).height()){if(ScrollHelper.hasScrollUpTask())return;ScrollHelper.topbarLocked()?ScrollHelper.unlockTopbar():ScrollHelper.orientationLocked()?ScrollHelper.unLockOrientation():ScrollHelper.showTopbar()}a=e}}(),e=!1)},250)}),$(function(){var t="div.post>h1:first-of-type";const o=$(t),n=$("#topbar-title");if(0!==o.length&&!o.hasClass("dynamic-title")&&!n.is(":hidden")){const s=n.text().trim();let a=o.text().trim(),l=!1,r=0;($("#page-category").length||$("#page-tag").length)&&/\s/.test(a)&&(a=a.replace(/[0-9]/g,"").trim()),o.offset().top<$(window).scrollTop()&&n.text(a);let e=new IntersectionObserver(e=>{var t,o;l?(t=$(window).scrollTop(),o=r{50<$(this).scrollTop()&&"none"===$("#sidebar-trigger").css("display")?$("#back-to-top").fadeIn():$("#back-to-top").fadeOut()}),$("#back-to-top").click(()=>($("body,html").animate({scrollTop:0},800),!1))});const LocaleHelper=function(){const e=$('meta[name="prefer-datetime-locale"]'),t=0t,attrTimestamp:()=>o,attrDateFormat:()=>a,getTimestamp:e=>Number(e.attr(o)),getDateFormat:e=>e.attr(a)}}();$(function(){$(".mode-toggle").click(e=>{const t=$(e.target);let o=t.prop("tagName")==="button".toUpperCase()?t:t.parent();o.blur(),flipMode()})});const ScrollHelper=function(){const e=$("body"),t="data-topbar-visible",o=$("#topbar-wrapper").outerHeight();let a=0,l=!1,r=!1;return{hideTopbar:()=>e.attr(t,!1),showTopbar:()=>e.attr(t,!0),addScrollUpTask:()=>{a+=1,l=l||!0},popScrollUpTask:()=>--a,hasScrollUpTask:()=>0!0===l,unlockTopbar:()=>l=!1,getTopbarHeight:()=>o,orientationLocked:()=>!0===r,lockOrientation:()=>r=!0,unLockOrientation:()=>r=!1}}();$(function(){const e=$("#sidebar-trigger"),t=$("#search-trigger"),o=$("#search-cancel"),a=$("#search-cleaner"),l=$("#main"),r=$("#topbar-title"),n=$("#search-wrapper"),s=$("#search-result-wrapper"),i=$("#search-results"),c=$("#search-input"),d=$("#search-hints"),p=function(){let e=0;return{block(){e=window.scrollY,$("html,body").scrollTop(0)},release(){$("html,body").scrollTop(e)},getOffset(){return e}}}(),u={on(){e.addClass("unloaded"),r.addClass("unloaded"),t.addClass("unloaded"),n.addClass("d-flex"),o.addClass("loaded")},off(){o.removeClass("loaded"),n.removeClass("d-flex"),e.removeClass("unloaded"),r.removeClass("unloaded"),t.removeClass("unloaded")}},f=function(){let e=!1;return{on(){e||(p.block(),s.removeClass("unloaded"),l.addClass("unloaded"),e=!0)},off(){e&&(i.empty(),d.hasClass("unloaded")&&d.removeClass("unloaded"),s.addClass("unloaded"),a.removeClass("visible"),l.removeClass("unloaded"),p.release(),c.val(""),e=!1)},isVisible(){return e}}}();function h(){return o.hasClass("loaded")}t.click(function(){u.on(),f.on(),c.focus()}),o.click(function(){u.off(),f.off()}),c.focus(function(){n.addClass("input-focus")}),c.focusout(function(){n.removeClass("input-focus")}),c.on("keyup",function(e){8===e.keyCode&&""===c.val()?h()?d.removeClass("unloaded"):f.off():""!==c.val()&&(f.on(),a.hasClass("visible")||a.addClass("visible"),h()&&d.addClass("unloaded"))}),a.on("click",function(){c.val(""),h()?(d.removeClass("unloaded"),i.empty()):f.off(),c.focus(),a.removeClass("visible")})}),$(function(){var e=function(){const e="sidebar-display";let t=!1;const o=$("body");return{toggle(){!1===t?o.attr(e,""):o.removeAttr(e),t=!t}}}();$("#sidebar-trigger").click(e.toggle),$("#mask").click(e.toggle)}),$(function(){$('[data-toggle="tooltip"]').tooltip()}),$(function(){const t=$("#search-input"),o=ScrollHelper.getTopbarHeight();let e,a=0;function l(){0!==$(window).scrollTop()&&(ScrollHelper.lockOrientation(),ScrollHelper.hideTopbar())}screen.orientation?screen.orientation.onchange=()=>{var e=screen.orientation.type;"landscape-primary"!==e&&"landscape-secondary"!==e||l()}:$(window).on("orientationchange",()=>{$(window).width()<$(window).height()&&l()}),$(window).scroll(()=>{e=e||!0}),setInterval(()=>{e&&(function(){var e=$(this).scrollTop();if(!(Math.abs(a-e)<=o)){if(e>a)ScrollHelper.hideTopbar(),t.is(":focus")&&t.blur();else if(e+$(window).height()<$(document).height()){if(ScrollHelper.hasScrollUpTask())return;ScrollHelper.topbarLocked()?ScrollHelper.unlockTopbar():ScrollHelper.orientationLocked()?ScrollHelper.unLockOrientation():ScrollHelper.showTopbar()}a=e}}(),e=!1)},250)}),$(function(){var t="div.post>h1:first-of-type";const o=$(t),n=$("#topbar-title");if(0!==o.length&&!o.hasClass("dynamic-title")&&!n.is(":hidden")){const s=n.text().trim();let a=o.text().trim(),l=!1,r=0;($("#page-category").length||$("#page-tag").length)&&/\s/.test(a)&&(a=a.replace(/[0-9]/g,"").trim()),o.offset().top<$(window).scrollTop()&&n.text(a);let e=new IntersectionObserver(e=>{var t,o;l?(t=$(window).scrollTop(),o=re.toUpperCase())),$(this).text()!==e&&$(this).text(e)}else--o}),0===o&&void 0!==t&&clearInterval(t),o}dayjs.locale(LocaleHelper.locale()),dayjs.extend(window.dayjs_plugin_relativeTime),dayjs.extend(window.dayjs_plugin_localizedFormat),0!==o&&(e.each(function(){var e,t=$(this).attr("data-toggle");void 0!==t&&"tooltip"===t&&(e=$(this).attr("data-tooltip-df"),t=LocaleHelper.getTimestamp($(this)),e=dayjs.unix(t).format(e),$(this).attr("data-original-title",e),$(this).removeAttr("data-tooltip-df"))}),l()&&(t=setInterval(l,6e4)))}); \ No newline at end of file diff --git a/assets/js/dist/misc.min.js b/assets/js/dist/misc.min.js new file mode 100644 index 0000000..b9c8e0b --- /dev/null +++ b/assets/js/dist/misc.min.js @@ -0,0 +1,6 @@ +/*! + * Chirpy v5.0.2 (https://github.com/cotes2020/jekyll-theme-chirpy/) + * © 2019 Cotes Chung + * MIT Licensed + */ +$(function(){$(window).scroll(()=>{50<$(this).scrollTop()&&"none"===$("#sidebar-trigger").css("display")?$("#back-to-top").fadeIn():$("#back-to-top").fadeOut()}),$("#back-to-top").click(()=>($("body,html").animate({scrollTop:0},800),!1))});const LocaleHelper=function(){const e=$('meta[name="prefer-datetime-locale"]'),t=0t,attrTimestamp:()=>o,attrDateFormat:()=>a,getTimestamp:e=>Number(e.attr(o)),getDateFormat:e=>e.attr(a)}}();$(function(){$(".mode-toggle").click(e=>{const t=$(e.target);let o=t.prop("tagName")==="button".toUpperCase()?t:t.parent();o.blur(),flipMode()})});const ScrollHelper=function(){const e=$("body"),t="data-topbar-visible",o=$("#topbar-wrapper").outerHeight();let a=0,l=!1,r=!1;return{hideTopbar:()=>e.attr(t,!1),showTopbar:()=>e.attr(t,!0),addScrollUpTask:()=>{a+=1,l=l||!0},popScrollUpTask:()=>--a,hasScrollUpTask:()=>0!0===l,unlockTopbar:()=>l=!1,getTopbarHeight:()=>o,orientationLocked:()=>!0===r,lockOrientation:()=>r=!0,unLockOrientation:()=>r=!1}}();$(function(){const e=$("#sidebar-trigger"),t=$("#search-trigger"),o=$("#search-cancel"),a=$("#search-cleaner"),l=$("#main"),r=$("#topbar-title"),n=$("#search-wrapper"),s=$("#search-result-wrapper"),i=$("#search-results"),c=$("#search-input"),d=$("#search-hints"),p=function(){let e=0;return{block(){e=window.scrollY,$("html,body").scrollTop(0)},release(){$("html,body").scrollTop(e)},getOffset(){return e}}}(),u={on(){e.addClass("unloaded"),r.addClass("unloaded"),t.addClass("unloaded"),n.addClass("d-flex"),o.addClass("loaded")},off(){o.removeClass("loaded"),n.removeClass("d-flex"),e.removeClass("unloaded"),r.removeClass("unloaded"),t.removeClass("unloaded")}},f=function(){let e=!1;return{on(){e||(p.block(),s.removeClass("unloaded"),l.addClass("unloaded"),e=!0)},off(){e&&(i.empty(),d.hasClass("unloaded")&&d.removeClass("unloaded"),s.addClass("unloaded"),a.removeClass("visible"),l.removeClass("unloaded"),p.release(),c.val(""),e=!1)},isVisible(){return e}}}();function m(){return o.hasClass("loaded")}t.click(function(){u.on(),f.on(),c.focus()}),o.click(function(){u.off(),f.off()}),c.focus(function(){n.addClass("input-focus")}),c.focusout(function(){n.removeClass("input-focus")}),c.on("keyup",function(e){8===e.keyCode&&""===c.val()?m()?d.removeClass("unloaded"):f.off():""!==c.val()&&(f.on(),a.hasClass("visible")||a.addClass("visible"),m()&&d.addClass("unloaded"))}),a.on("click",function(){c.val(""),m()?(d.removeClass("unloaded"),i.empty()):f.off(),c.focus(),a.removeClass("visible")})}),$(function(){var e=function(){const e="sidebar-display";let t=!1;const o=$("body");return{toggle(){!1===t?o.attr(e,""):o.removeAttr(e),t=!t}}}();$("#sidebar-trigger").click(e.toggle),$("#mask").click(e.toggle)}),$(function(){$('[data-toggle="tooltip"]').tooltip()}),$(function(){const t=$("#search-input"),o=ScrollHelper.getTopbarHeight();let e,a=0;function l(){0!==$(window).scrollTop()&&(ScrollHelper.lockOrientation(),ScrollHelper.hideTopbar())}screen.orientation?screen.orientation.onchange=()=>{var e=screen.orientation.type;"landscape-primary"!==e&&"landscape-secondary"!==e||l()}:$(window).on("orientationchange",()=>{$(window).width()<$(window).height()&&l()}),$(window).scroll(()=>{e=e||!0}),setInterval(()=>{e&&(function(){var e=$(this).scrollTop();if(!(Math.abs(a-e)<=o)){if(e>a)ScrollHelper.hideTopbar(),t.is(":focus")&&t.blur();else if(e+$(window).height()<$(document).height()){if(ScrollHelper.hasScrollUpTask())return;ScrollHelper.topbarLocked()?ScrollHelper.unlockTopbar():ScrollHelper.orientationLocked()?ScrollHelper.unLockOrientation():ScrollHelper.showTopbar()}a=e}}(),e=!1)},250)}),$(function(){var t="div.post>h1:first-of-type";const o=$(t),n=$("#topbar-title");if(0!==o.length&&!o.hasClass("dynamic-title")&&!n.is(":hidden")){const s=n.text().trim();let a=o.text().trim(),l=!1,r=0;($("#page-category").length||$("#page-tag").length)&&/\s/.test(a)&&(a=a.replace(/[0-9]/g,"").trim()),o.offset().top<$(window).scrollTop()&&n.text(a);let e=new IntersectionObserver(e=>{var t,o;l?(t=$(window).scrollTop(),o=r{50<$(this).scrollTop()&&"none"===$("#sidebar-trigger").css("display")?$("#back-to-top").fadeIn():$("#back-to-top").fadeOut()}),$("#back-to-top").click(()=>($("body,html").animate({scrollTop:0},800),!1))}),$(function(){$(".mode-toggle").click(e=>{const t=$(e.target);let o=t.prop("tagName")==="button".toUpperCase()?t:t.parent();o.blur(),flipMode()})});const ScrollHelper=function(){const e=$("body"),t="data-topbar-visible",o=$("#topbar-wrapper").outerHeight();let l=0,a=!1,r=!1;return{hideTopbar:()=>e.attr(t,!1),showTopbar:()=>e.attr(t,!0),addScrollUpTask:()=>{l+=1,a=a||!0},popScrollUpTask:()=>--l,hasScrollUpTask:()=>0!0===a,unlockTopbar:()=>a=!1,getTopbarHeight:()=>o,orientationLocked:()=>!0===r,lockOrientation:()=>r=!0,unLockOrientation:()=>r=!1}}();$(function(){const e=$("#sidebar-trigger"),t=$("#search-trigger"),o=$("#search-cancel"),l=$("#search-cleaner"),a=$("#main"),r=$("#topbar-title"),n=$("#search-wrapper"),i=$("#search-result-wrapper"),s=$("#search-results"),c=$("#search-input"),d=$("#search-hints"),p=function(){let e=0;return{block(){e=window.scrollY,$("html,body").scrollTop(0)},release(){$("html,body").scrollTop(e)},getOffset(){return e}}}(),u={on(){e.addClass("unloaded"),r.addClass("unloaded"),t.addClass("unloaded"),n.addClass("d-flex"),o.addClass("loaded")},off(){o.removeClass("loaded"),n.removeClass("d-flex"),e.removeClass("unloaded"),r.removeClass("unloaded"),t.removeClass("unloaded")}},f=function(){let e=!1;return{on(){e||(p.block(),i.removeClass("unloaded"),a.addClass("unloaded"),e=!0)},off(){e&&(s.empty(),d.hasClass("unloaded")&&d.removeClass("unloaded"),i.addClass("unloaded"),l.removeClass("visible"),a.removeClass("unloaded"),p.release(),c.val(""),e=!1)},isVisible(){return e}}}();function h(){return o.hasClass("loaded")}t.click(function(){u.on(),f.on(),c.focus()}),o.click(function(){u.off(),f.off()}),c.focus(function(){n.addClass("input-focus")}),c.focusout(function(){n.removeClass("input-focus")}),c.on("keyup",function(e){8===e.keyCode&&""===c.val()?h()?d.removeClass("unloaded"):f.off():""!==c.val()&&(f.on(),l.hasClass("visible")||l.addClass("visible"),h()&&d.addClass("unloaded"))}),l.on("click",function(){c.val(""),h()?(d.removeClass("unloaded"),s.empty()):f.off(),c.focus(),l.removeClass("visible")})}),$(function(){var e=function(){const e="sidebar-display";let t=!1;const o=$("body");return{toggle(){!1===t?o.attr(e,""):o.removeAttr(e),t=!t}}}();$("#sidebar-trigger").click(e.toggle),$("#mask").click(e.toggle)}),$(function(){$('[data-toggle="tooltip"]').tooltip()}),$(function(){const t=$("#search-input"),o=ScrollHelper.getTopbarHeight();let e,l=0;function a(){0!==$(window).scrollTop()&&(ScrollHelper.lockOrientation(),ScrollHelper.hideTopbar())}screen.orientation?screen.orientation.onchange=()=>{var e=screen.orientation.type;"landscape-primary"!==e&&"landscape-secondary"!==e||a()}:$(window).on("orientationchange",()=>{$(window).width()<$(window).height()&&a()}),$(window).scroll(()=>{e=e||!0}),setInterval(()=>{e&&(function(){var e=$(this).scrollTop();if(!(Math.abs(l-e)<=o)){if(e>l)ScrollHelper.hideTopbar(),t.is(":focus")&&t.blur();else if(e+$(window).height()<$(document).height()){if(ScrollHelper.hasScrollUpTask())return;ScrollHelper.topbarLocked()?ScrollHelper.unlockTopbar():ScrollHelper.orientationLocked()?ScrollHelper.unLockOrientation():ScrollHelper.showTopbar()}l=e}}(),e=!1)},250)}),$(function(){var t="div.post>h1:first-of-type";const o=$(t),n=$("#topbar-title");if(0!==o.length&&!o.hasClass("dynamic-title")&&!n.is(":hidden")){const i=n.text().trim();let l=o.text().trim(),a=!1,r=0;($("#page-category").length||$("#page-tag").length)&&/\s/.test(l)&&(l=l.replace(/[0-9]/g,"").trim()),o.offset().top<$(window).scrollTop()&&n.text(l);let e=new IntersectionObserver(e=>{var t,o;a?(t=$(window).scrollTop(),o=r'),$("input[type=checkbox]:not([checked])").before('')}),$(function(){var e="#main > div.row:first-child > div:first-child";if(!($(e+" img").length<=0)){var t=document.querySelectorAll(e+" img[data-src]");const o=lozad(t);o.observe(),$(e+` p > img[data-src],${e} img[data-src].preview-img`).each(function(){let e=$(this).next();var t="EM"===e.prop("tagName")?e.text():"",o=$(this).attr("data-src");$(this).wrap(``)}),$(".popup").magnificPopup({type:"image",closeOnContentClick:!0,showCloseBtn:!1,zoom:{enabled:!0,duration:300,easing:"ease-in-out"}}),$(e+" a").has("img").addClass("img-link")}}),$(function(){var e=".code-header>button";const t="timeout",a="data-title-succeed",r="data-original-title";function n(e){if($(e)[0].hasAttribute(t)){e=$(e).attr(t);if(Number(e)>Date.now())return 1}}function i(e){$(e).attr(t,Date.now()+2e3)}function s(e){$(e).removeAttr(t)}const o=new ClipboardJS(e,{target(e){let t=e.parentNode.nextElementSibling;return t.querySelector("code .rouge-code")}});$(e).tooltip({trigger:"hover",placement:"left"});const l=function(e){let t=$(e).children();return t.attr("class")}(e);o.on("success",e=>{e.clearSelection();const t=e.trigger;var o;n(t)||(function(e){let t=$(e),o=t.children();o.attr("class","fas fa-check")}(t),o=t,e=$(o).attr(a),$(o).attr(r,e).tooltip("show"),i(t),setTimeout(()=>{var e;e=t,$(e).tooltip("hide").removeAttr(r),function(e){let t=$(e),o=t.children();o.attr("class",l)}(t),s(t)},2e3))}),$("#copy-link").click(e=>{let t=$(e.target);if(!n(t)){e=window.location.href;const o=$("");$("body").append(o),o.val(e).select(),document.execCommand("copy"),o.remove();const l=t.attr(r);e=t.attr(a);t.attr(r,e).tooltip("show"),i(t),setTimeout(()=>{t.attr(r,l),s(t)},2e3)}})}),$(function(){const e=$("#topbar-title"),s="scroll-focus";$("a[href*='#']").not("[href='#']").not("[href='#0']").click(function(a){if(this.pathname.replace(/^\//,"")===location.pathname.replace(/^\//,"")&&location.hostname===this.hostname){const i=decodeURI(this.hash);let t=RegExp(/^#fnref:/).test(i),o=!t&&RegExp(/^#fn:/).test(i);var r=i.includes(":")?i.replace(/\:/g,"\\:"):i;let l=$(r);var n=e.is(":visible"),r=$(window).width()<$(window).height();if(void 0!==l){a.preventDefault(),history.pushState&&history.pushState(null,null,i);a=$(window).scrollTop();let e=l.offset().top-=8;e(l.focus(),$(`[${s}=true]`).length&&$(`[${s}=true]`).attr(s,!1),$(":target").length&&$(":target").attr(s,!1),(o||t)&&l.attr(s,!0),l.is(":focus")?!1:(l.attr("tabindex","-1"),l.focus(),void(ScrollHelper.hasScrollUpTask()&&ScrollHelper.popScrollUpTask()))))}}})}); \ No newline at end of file +$(function(){$(window).scroll(()=>{50<$(this).scrollTop()&&"none"===$("#sidebar-trigger").css("display")?$("#back-to-top").fadeIn():$("#back-to-top").fadeOut()}),$("#back-to-top").click(()=>($("body,html").animate({scrollTop:0},800),!1))});const LocaleHelper=function(){const e=$('meta[name="prefer-datetime-locale"]'),t=0t,attrTimestamp:()=>o,attrDateFormat:()=>a,getTimestamp:e=>Number(e.attr(o)),getDateFormat:e=>e.attr(a)}}();$(function(){$(".mode-toggle").click(e=>{const t=$(e.target);let o=t.prop("tagName")==="button".toUpperCase()?t:t.parent();o.blur(),flipMode()})});const ScrollHelper=function(){const e=$("body"),t="data-topbar-visible",o=$("#topbar-wrapper").outerHeight();let a=0,r=!1,l=!1;return{hideTopbar:()=>e.attr(t,!1),showTopbar:()=>e.attr(t,!0),addScrollUpTask:()=>{a+=1,r=r||!0},popScrollUpTask:()=>--a,hasScrollUpTask:()=>0!0===r,unlockTopbar:()=>r=!1,getTopbarHeight:()=>o,orientationLocked:()=>!0===l,lockOrientation:()=>l=!0,unLockOrientation:()=>l=!1}}();$(function(){const e=$("#sidebar-trigger"),t=$("#search-trigger"),o=$("#search-cancel"),a=$("#search-cleaner"),r=$("#main"),l=$("#topbar-title"),n=$("#search-wrapper"),i=$("#search-result-wrapper"),s=$("#search-results"),c=$("#search-input"),d=$("#search-hints"),p=function(){let e=0;return{block(){e=window.scrollY,$("html,body").scrollTop(0)},release(){$("html,body").scrollTop(e)},getOffset(){return e}}}(),u={on(){e.addClass("unloaded"),l.addClass("unloaded"),t.addClass("unloaded"),n.addClass("d-flex"),o.addClass("loaded")},off(){o.removeClass("loaded"),n.removeClass("d-flex"),e.removeClass("unloaded"),l.removeClass("unloaded"),t.removeClass("unloaded")}},f=function(){let e=!1;return{on(){e||(p.block(),i.removeClass("unloaded"),r.addClass("unloaded"),e=!0)},off(){e&&(s.empty(),d.hasClass("unloaded")&&d.removeClass("unloaded"),i.addClass("unloaded"),a.removeClass("visible"),r.removeClass("unloaded"),p.release(),c.val(""),e=!1)},isVisible(){return e}}}();function h(){return o.hasClass("loaded")}t.click(function(){u.on(),f.on(),c.focus()}),o.click(function(){u.off(),f.off()}),c.focus(function(){n.addClass("input-focus")}),c.focusout(function(){n.removeClass("input-focus")}),c.on("keyup",function(e){8===e.keyCode&&""===c.val()?h()?d.removeClass("unloaded"):f.off():""!==c.val()&&(f.on(),a.hasClass("visible")||a.addClass("visible"),h()&&d.addClass("unloaded"))}),a.on("click",function(){c.val(""),h()?(d.removeClass("unloaded"),s.empty()):f.off(),c.focus(),a.removeClass("visible")})}),$(function(){var e=function(){const e="sidebar-display";let t=!1;const o=$("body");return{toggle(){!1===t?o.attr(e,""):o.removeAttr(e),t=!t}}}();$("#sidebar-trigger").click(e.toggle),$("#mask").click(e.toggle)}),$(function(){$('[data-toggle="tooltip"]').tooltip()}),$(function(){const t=$("#search-input"),o=ScrollHelper.getTopbarHeight();let e,a=0;function r(){0!==$(window).scrollTop()&&(ScrollHelper.lockOrientation(),ScrollHelper.hideTopbar())}screen.orientation?screen.orientation.onchange=()=>{var e=screen.orientation.type;"landscape-primary"!==e&&"landscape-secondary"!==e||r()}:$(window).on("orientationchange",()=>{$(window).width()<$(window).height()&&r()}),$(window).scroll(()=>{e=e||!0}),setInterval(()=>{e&&(function(){var e=$(this).scrollTop();if(!(Math.abs(a-e)<=o)){if(e>a)ScrollHelper.hideTopbar(),t.is(":focus")&&t.blur();else if(e+$(window).height()<$(document).height()){if(ScrollHelper.hasScrollUpTask())return;ScrollHelper.topbarLocked()?ScrollHelper.unlockTopbar():ScrollHelper.orientationLocked()?ScrollHelper.unLockOrientation():ScrollHelper.showTopbar()}a=e}}(),e=!1)},250)}),$(function(){var t="div.post>h1:first-of-type";const o=$(t),n=$("#topbar-title");if(0!==o.length&&!o.hasClass("dynamic-title")&&!n.is(":hidden")){const i=n.text().trim();let a=o.text().trim(),r=!1,l=0;($("#page-category").length||$("#page-tag").length)&&/\s/.test(a)&&(a=a.replace(/[0-9]/g,"").trim()),o.offset().top<$(window).scrollTop()&&n.text(a);let e=new IntersectionObserver(e=>{var t,o;r?(t=$(window).scrollTop(),o=l'),$("input[type=checkbox]:not([checked])").before('')}),$(function(){var e="#main > div.row:first-child > div:first-child";if(!($(e+" img").length<=0)){var t=document.querySelectorAll(e+" img[data-src]");const o=lozad(t);o.observe(),$(e+` p > img[data-src],${e} img[data-src].preview-img`).each(function(){let e=$(this).next();var t="EM"===e.prop("tagName")?e.text():"",o=$(this).attr("data-src");$(this).wrap(``)}),$(".popup").magnificPopup({type:"image",closeOnContentClick:!0,showCloseBtn:!1,zoom:{enabled:!0,duration:300,easing:"ease-in-out"}}),$(e+" a").has("img").addClass("img-link")}}),$(function(){var e=".code-header>button";const t="timeout",r="data-title-succeed",l="data-original-title";function n(e){if($(e)[0].hasAttribute(t)){e=$(e).attr(t);if(Number(e)>Date.now())return 1}}function i(e){$(e).attr(t,Date.now()+2e3)}function s(e){$(e).removeAttr(t)}const o=new ClipboardJS(e,{target(e){let t=e.parentNode.nextElementSibling;return t.querySelector("code .rouge-code")}});$(e).tooltip({trigger:"hover",placement:"left"});const a=function(e){let t=$(e).children();return t.attr("class")}(e);o.on("success",e=>{e.clearSelection();const t=e.trigger;var o;n(t)||(function(e){let t=$(e),o=t.children();o.attr("class","fas fa-check")}(t),o=t,e=$(o).attr(r),$(o).attr(l,e).tooltip("show"),i(t),setTimeout(()=>{var e;e=t,$(e).tooltip("hide").removeAttr(l),function(e){let t=$(e),o=t.children();o.attr("class",a)}(t),s(t)},2e3))}),$("#copy-link").click(e=>{let t=$(e.target);if(!n(t)){e=window.location.href;const o=$("");$("body").append(o),o.val(e).select(),document.execCommand("copy"),o.remove();const a=t.attr(l);e=t.attr(r);t.attr(l,e).tooltip("show"),i(t),setTimeout(()=>{t.attr(l,a),s(t)},2e3)}})}),$(function(){const e=$("#topbar-title"),s="scroll-focus";$("a[href*='#']").not("[href='#']").not("[href='#0']").click(function(r){if(this.pathname.replace(/^\//,"")===location.pathname.replace(/^\//,"")&&location.hostname===this.hostname){const i=decodeURI(this.hash);let t=RegExp(/^#fnref:/).test(i),o=!t&&RegExp(/^#fn:/).test(i);var l=i.includes(":")?i.replace(/\:/g,"\\:"):i;let a=$(l);var n=e.is(":visible"),l=$(window).width()<$(window).height();if(void 0!==a){r.preventDefault(),history.pushState&&history.pushState(null,null,i);r=$(window).scrollTop();let e=a.offset().top-=8;e(a.focus(),$(`[${s}=true]`).length&&$(`[${s}=true]`).attr(s,!1),$(":target").length&&$(":target").attr(s,!1),(o||t)&&a.attr(s,!0),a.is(":focus")?!1:(a.attr("tabindex","-1"),a.focus(),void(ScrollHelper.hasScrollUpTask()&&ScrollHelper.popScrollUpTask()))))}}})}); \ No newline at end of file diff --git a/assets/js/dist/post.min.js b/assets/js/dist/post.min.js index 517122c..5cc6075 100644 --- a/assets/js/dist/post.min.js +++ b/assets/js/dist/post.min.js @@ -3,4 +3,4 @@ * © 2019 Cotes Chung * MIT Licensed */ -$(function(){$(window).scroll(()=>{50<$(this).scrollTop()&&"none"===$("#sidebar-trigger").css("display")?$("#back-to-top").fadeIn():$("#back-to-top").fadeOut()}),$("#back-to-top").click(()=>($("body,html").animate({scrollTop:0},800),!1))}),$(function(){$(".mode-toggle").click(t=>{const e=$(t.target);let o=e.prop("tagName")==="button".toUpperCase()?e:e.parent();o.blur(),flipMode()})});const ScrollHelper=function(){const t=$("body"),e="data-topbar-visible",o=$("#topbar-wrapper").outerHeight();let a=0,r=!1,l=!1;return{hideTopbar:()=>t.attr(e,!1),showTopbar:()=>t.attr(e,!0),addScrollUpTask:()=>{a+=1,r=r||!0},popScrollUpTask:()=>--a,hasScrollUpTask:()=>0!0===r,unlockTopbar:()=>r=!1,getTopbarHeight:()=>o,orientationLocked:()=>!0===l,lockOrientation:()=>l=!0,unLockOrientation:()=>l=!1}}();$(function(){const t=$("#sidebar-trigger"),e=$("#search-trigger"),o=$("#search-cancel"),a=$("#search-cleaner"),r=$("#main"),l=$("#topbar-title"),n=$("#search-wrapper"),i=$("#search-result-wrapper"),c=$("#search-results"),s=$("#search-input"),d=$("#search-hints"),p=function(){let t=0;return{block(){t=window.scrollY,$("html,body").scrollTop(0)},release(){$("html,body").scrollTop(t)},getOffset(){return t}}}(),u={on(){t.addClass("unloaded"),l.addClass("unloaded"),e.addClass("unloaded"),n.addClass("d-flex"),o.addClass("loaded")},off(){o.removeClass("loaded"),n.removeClass("d-flex"),t.removeClass("unloaded"),l.removeClass("unloaded"),e.removeClass("unloaded")}},h=function(){let t=!1;return{on(){t||(p.block(),i.removeClass("unloaded"),r.addClass("unloaded"),t=!0)},off(){t&&(c.empty(),d.hasClass("unloaded")&&d.removeClass("unloaded"),i.addClass("unloaded"),a.removeClass("visible"),r.removeClass("unloaded"),p.release(),s.val(""),t=!1)},isVisible(){return t}}}();function f(){return o.hasClass("loaded")}e.click(function(){u.on(),h.on(),s.focus()}),o.click(function(){u.off(),h.off()}),s.focus(function(){n.addClass("input-focus")}),s.focusout(function(){n.removeClass("input-focus")}),s.on("keyup",function(t){8===t.keyCode&&""===s.val()?f()?d.removeClass("unloaded"):h.off():""!==s.val()&&(h.on(),a.hasClass("visible")||a.addClass("visible"),f()&&d.addClass("unloaded"))}),a.on("click",function(){s.val(""),f()?(d.removeClass("unloaded"),c.empty()):h.off(),s.focus(),a.removeClass("visible")})}),$(function(){var t=function(){const t="sidebar-display";let e=!1;const o=$("body");return{toggle(){!1===e?o.attr(t,""):o.removeAttr(t),e=!e}}}();$("#sidebar-trigger").click(t.toggle),$("#mask").click(t.toggle)}),$(function(){$('[data-toggle="tooltip"]').tooltip()}),$(function(){const e=$("#search-input"),o=ScrollHelper.getTopbarHeight();let t,a=0;function r(){0!==$(window).scrollTop()&&(ScrollHelper.lockOrientation(),ScrollHelper.hideTopbar())}screen.orientation?screen.orientation.onchange=()=>{var t=screen.orientation.type;"landscape-primary"!==t&&"landscape-secondary"!==t||r()}:$(window).on("orientationchange",()=>{$(window).width()<$(window).height()&&r()}),$(window).scroll(()=>{t=t||!0}),setInterval(()=>{t&&(function(){var t=$(this).scrollTop();if(!(Math.abs(a-t)<=o)){if(t>a)ScrollHelper.hideTopbar(),e.is(":focus")&&e.blur();else if(t+$(window).height()<$(document).height()){if(ScrollHelper.hasScrollUpTask())return;ScrollHelper.topbarLocked()?ScrollHelper.unlockTopbar():ScrollHelper.orientationLocked()?ScrollHelper.unLockOrientation():ScrollHelper.showTopbar()}a=t}}(),t=!1)},250)}),$(function(){var e="div.post>h1:first-of-type";const o=$(e),n=$("#topbar-title");if(0!==o.length&&!o.hasClass("dynamic-title")&&!n.is(":hidden")){const i=n.text().trim();let a=o.text().trim(),r=!1,l=0;($("#page-category").length||$("#page-tag").length)&&/\s/.test(a)&&(a=a.replace(/[0-9]/g,"").trim()),o.offset().top<$(window).scrollTop()&&n.text(a);let t=new IntersectionObserver(t=>{var e,o;r?(e=$(window).scrollTop(),o=l img[data-src],${t} img[data-src].preview-img`).each(function(){let t=$(this).next();var e="EM"===t.prop("tagName")?t.text():"",o=$(this).attr("data-src");$(this).wrap(``)}),$(".popup").magnificPopup({type:"image",closeOnContentClick:!0,showCloseBtn:!1,zoom:{enabled:!0,duration:300,easing:"ease-in-out"}}),$(t+" a").has("img").addClass("img-link")}}),$(function(){let o=$(".timeago").length,t=void 0;const r=$("meta[name=day-prompt]").attr("content"),l=$("meta[name=hour-prompt]").attr("content"),n=$("meta[name=minute-prompt]").attr("content"),i=$("meta[name=justnow-prompt]").attr("content");function e(){return $(".timeago").each(function(){var t,e;!1!==$(this)[0].hasAttribute("date")?(e=function(t,e){let o=new Date,a=new Date(t);return a.getFullYear()!==o.getFullYear()||a.getMonth()!==o.getMonth()?e:(t=Math.floor((o-a)/1e3),1<=(e=Math.floor(t/86400))?` ${e} `+r:1<=(e=Math.floor(t/3600))?` ${e} `+l:1<=(t=Math.floor(t/60))?` ${t} `+n:i)}($(this).attr("date"),t=$(this).text()))===t?$(this).removeAttr("date"):$(this).text(e):--o}),0===o&&void 0!==t&&clearInterval(t),o}0!==o&&0'),$("input[type=checkbox]:not([checked])").before('')}),$(function(){var t=".code-header>button";const e="timeout",r="data-title-succeed",l="data-original-title";function n(t){if($(t)[0].hasAttribute(e)){t=$(t).attr(e);if(Number(t)>Date.now())return 1}}function i(t){$(t).attr(e,Date.now()+2e3)}function c(t){$(t).removeAttr(e)}const o=new ClipboardJS(t,{target(t){let e=t.parentNode.nextElementSibling;return e.querySelector("code .rouge-code")}});$(t).tooltip({trigger:"hover",placement:"left"});const a=function(t){let e=$(t).children();return e.attr("class")}(t);o.on("success",t=>{t.clearSelection();const e=t.trigger;var o;n(e)||(function(t){let e=$(t),o=e.children();o.attr("class","fas fa-check")}(e),o=e,t=$(o).attr(r),$(o).attr(l,t).tooltip("show"),i(e),setTimeout(()=>{var t;t=e,$(t).tooltip("hide").removeAttr(l),function(t){let e=$(t),o=e.children();o.attr("class",a)}(e),c(e)},2e3))}),$("#copy-link").click(t=>{let e=$(t.target);if(!n(e)){t=window.location.href;const o=$("");$("body").append(o),o.val(t).select(),document.execCommand("copy"),o.remove();const a=e.attr(l);t=e.attr(r);e.attr(l,t).tooltip("show"),i(e),setTimeout(()=>{e.attr(l,a),c(e)},2e3)}})}),$(function(){const t=$("#topbar-title"),c="scroll-focus";$("a[href*='#']").not("[href='#']").not("[href='#0']").click(function(r){if(this.pathname.replace(/^\//,"")===location.pathname.replace(/^\//,"")&&location.hostname===this.hostname){const i=decodeURI(this.hash);let e=RegExp(/^#fnref:/).test(i),o=!e&&RegExp(/^#fn:/).test(i);var l=i.includes(":")?i.replace(/\:/g,"\\:"):i;let a=$(l);var n=t.is(":visible"),l=$(window).width()<$(window).height();if(void 0!==a){r.preventDefault(),history.pushState&&history.pushState(null,null,i);r=$(window).scrollTop();let t=a.offset().top-=8;t(a.focus(),$(`[${c}=true]`).length&&$(`[${c}=true]`).attr(c,!1),$(":target").length&&$(":target").attr(c,!1),(o||e)&&a.attr(c,!0),a.is(":focus")?!1:(a.attr("tabindex","-1"),a.focus(),void(ScrollHelper.hasScrollUpTask()&&ScrollHelper.popScrollUpTask()))))}}})}); \ No newline at end of file +$(function(){$(window).scroll(()=>{50<$(this).scrollTop()&&"none"===$("#sidebar-trigger").css("display")?$("#back-to-top").fadeIn():$("#back-to-top").fadeOut()}),$("#back-to-top").click(()=>($("body,html").animate({scrollTop:0},800),!1))});const LocaleHelper=function(){const t=$('meta[name="prefer-datetime-locale"]'),e=0e,attrTimestamp:()=>o,attrDateFormat:()=>a,getTimestamp:t=>Number(t.attr(o)),getDateFormat:t=>t.attr(a)}}();$(function(){$(".mode-toggle").click(t=>{const e=$(t.target);let o=e.prop("tagName")==="button".toUpperCase()?e:e.parent();o.blur(),flipMode()})});const ScrollHelper=function(){const t=$("body"),e="data-topbar-visible",o=$("#topbar-wrapper").outerHeight();let a=0,r=!1,l=!1;return{hideTopbar:()=>t.attr(e,!1),showTopbar:()=>t.attr(e,!0),addScrollUpTask:()=>{a+=1,r=r||!0},popScrollUpTask:()=>--a,hasScrollUpTask:()=>0!0===r,unlockTopbar:()=>r=!1,getTopbarHeight:()=>o,orientationLocked:()=>!0===l,lockOrientation:()=>l=!0,unLockOrientation:()=>l=!1}}();$(function(){const t=$("#sidebar-trigger"),e=$("#search-trigger"),o=$("#search-cancel"),a=$("#search-cleaner"),r=$("#main"),l=$("#topbar-title"),n=$("#search-wrapper"),i=$("#search-result-wrapper"),s=$("#search-results"),c=$("#search-input"),d=$("#search-hints"),p=function(){let t=0;return{block(){t=window.scrollY,$("html,body").scrollTop(0)},release(){$("html,body").scrollTop(t)},getOffset(){return t}}}(),u={on(){t.addClass("unloaded"),l.addClass("unloaded"),e.addClass("unloaded"),n.addClass("d-flex"),o.addClass("loaded")},off(){o.removeClass("loaded"),n.removeClass("d-flex"),t.removeClass("unloaded"),l.removeClass("unloaded"),e.removeClass("unloaded")}},f=function(){let t=!1;return{on(){t||(p.block(),i.removeClass("unloaded"),r.addClass("unloaded"),t=!0)},off(){t&&(s.empty(),d.hasClass("unloaded")&&d.removeClass("unloaded"),i.addClass("unloaded"),a.removeClass("visible"),r.removeClass("unloaded"),p.release(),c.val(""),t=!1)},isVisible(){return t}}}();function h(){return o.hasClass("loaded")}e.click(function(){u.on(),f.on(),c.focus()}),o.click(function(){u.off(),f.off()}),c.focus(function(){n.addClass("input-focus")}),c.focusout(function(){n.removeClass("input-focus")}),c.on("keyup",function(t){8===t.keyCode&&""===c.val()?h()?d.removeClass("unloaded"):f.off():""!==c.val()&&(f.on(),a.hasClass("visible")||a.addClass("visible"),h()&&d.addClass("unloaded"))}),a.on("click",function(){c.val(""),h()?(d.removeClass("unloaded"),s.empty()):f.off(),c.focus(),a.removeClass("visible")})}),$(function(){var t=function(){const t="sidebar-display";let e=!1;const o=$("body");return{toggle(){!1===e?o.attr(t,""):o.removeAttr(t),e=!e}}}();$("#sidebar-trigger").click(t.toggle),$("#mask").click(t.toggle)}),$(function(){$('[data-toggle="tooltip"]').tooltip()}),$(function(){const e=$("#search-input"),o=ScrollHelper.getTopbarHeight();let t,a=0;function r(){0!==$(window).scrollTop()&&(ScrollHelper.lockOrientation(),ScrollHelper.hideTopbar())}screen.orientation?screen.orientation.onchange=()=>{var t=screen.orientation.type;"landscape-primary"!==t&&"landscape-secondary"!==t||r()}:$(window).on("orientationchange",()=>{$(window).width()<$(window).height()&&r()}),$(window).scroll(()=>{t=t||!0}),setInterval(()=>{t&&(function(){var t=$(this).scrollTop();if(!(Math.abs(a-t)<=o)){if(t>a)ScrollHelper.hideTopbar(),e.is(":focus")&&e.blur();else if(t+$(window).height()<$(document).height()){if(ScrollHelper.hasScrollUpTask())return;ScrollHelper.topbarLocked()?ScrollHelper.unlockTopbar():ScrollHelper.orientationLocked()?ScrollHelper.unLockOrientation():ScrollHelper.showTopbar()}a=t}}(),t=!1)},250)}),$(function(){var e="div.post>h1:first-of-type";const o=$(e),n=$("#topbar-title");if(0!==o.length&&!o.hasClass("dynamic-title")&&!n.is(":hidden")){const i=n.text().trim();let a=o.text().trim(),r=!1,l=0;($("#page-category").length||$("#page-tag").length)&&/\s/.test(a)&&(a=a.replace(/[0-9]/g,"").trim()),o.offset().top<$(window).scrollTop()&&n.text(a);let t=new IntersectionObserver(t=>{var e,o;r?(e=$(window).scrollTop(),o=l img[data-src],${t} img[data-src].preview-img`).each(function(){let t=$(this).next();var e="EM"===t.prop("tagName")?t.text():"",o=$(this).attr("data-src");$(this).wrap(``)}),$(".popup").magnificPopup({type:"image",closeOnContentClick:!0,showCloseBtn:!1,zoom:{enabled:!0,duration:300,easing:"ease-in-out"}}),$(t+" a").has("img").addClass("img-link")}}),$(function(){const a=LocaleHelper.attrTimestamp(),t=$(".timeago");let o=t.length,e=void 0;function r(){return t.each(function(){if(void 0!==$(this).attr(a)){let t=function(t){const e=dayjs(),o=dayjs.unix(LocaleHelper.getTimestamp(t));return 10t.toUpperCase())),$(this).text()!==t&&$(this).text(t)}else--o}),0===o&&void 0!==e&&clearInterval(e),o}dayjs.locale(LocaleHelper.locale()),dayjs.extend(window.dayjs_plugin_relativeTime),dayjs.extend(window.dayjs_plugin_localizedFormat),0!==o&&(t.each(function(){var t,e=$(this).attr("data-toggle");void 0!==e&&"tooltip"===e&&(t=$(this).attr("data-tooltip-df"),e=LocaleHelper.getTimestamp($(this)),t=dayjs.unix(e).format(t),$(this).attr("data-original-title",t),$(this).removeAttr("data-tooltip-df"))}),r()&&(e=setInterval(r,6e4)))}),$(function(){$("input[type=checkbox]").addClass("unloaded"),$("input[type=checkbox][checked]").before(''),$("input[type=checkbox]:not([checked])").before('')}),$(function(){var t=".code-header>button";const e="timeout",r="data-title-succeed",l="data-original-title";function n(t){if($(t)[0].hasAttribute(e)){t=$(t).attr(e);if(Number(t)>Date.now())return 1}}function i(t){$(t).attr(e,Date.now()+2e3)}function s(t){$(t).removeAttr(e)}const o=new ClipboardJS(t,{target(t){let e=t.parentNode.nextElementSibling;return e.querySelector("code .rouge-code")}});$(t).tooltip({trigger:"hover",placement:"left"});const a=function(t){let e=$(t).children();return e.attr("class")}(t);o.on("success",t=>{t.clearSelection();const e=t.trigger;var o;n(e)||(function(t){let e=$(t),o=e.children();o.attr("class","fas fa-check")}(e),o=e,t=$(o).attr(r),$(o).attr(l,t).tooltip("show"),i(e),setTimeout(()=>{var t;t=e,$(t).tooltip("hide").removeAttr(l),function(t){let e=$(t),o=e.children();o.attr("class",a)}(e),s(e)},2e3))}),$("#copy-link").click(t=>{let e=$(t.target);if(!n(e)){t=window.location.href;const o=$("");$("body").append(o),o.val(t).select(),document.execCommand("copy"),o.remove();const a=e.attr(l);t=e.attr(r);e.attr(l,t).tooltip("show"),i(e),setTimeout(()=>{e.attr(l,a),s(e)},2e3)}})}),$(function(){const t=$("#topbar-title"),s="scroll-focus";$("a[href*='#']").not("[href='#']").not("[href='#0']").click(function(r){if(this.pathname.replace(/^\//,"")===location.pathname.replace(/^\//,"")&&location.hostname===this.hostname){const i=decodeURI(this.hash);let e=RegExp(/^#fnref:/).test(i),o=!e&&RegExp(/^#fn:/).test(i);var l=i.includes(":")?i.replace(/\:/g,"\\:"):i;let a=$(l);var n=t.is(":visible"),l=$(window).width()<$(window).height();if(void 0!==a){r.preventDefault(),history.pushState&&history.pushState(null,null,i);r=$(window).scrollTop();let t=a.offset().top-=8;t(a.focus(),$(`[${s}=true]`).length&&$(`[${s}=true]`).attr(s,!1),$(":target").length&&$(":target").attr(s,!1),(o||e)&&a.attr(s,!0),a.is(":focus")?!1:(a.attr("tabindex","-1"),a.focus(),void(ScrollHelper.hasScrollUpTask()&&ScrollHelper.popScrollUpTask()))))}}})}); \ No newline at end of file diff --git a/gulpfile.js/tasks/js.js b/gulpfile.js/tasks/js.js index dc6a14f..4c41df2 100644 --- a/gulpfile.js/tasks/js.js +++ b/gulpfile.js/tasks/js.js @@ -11,7 +11,7 @@ const insert = require('gulp-insert'); const fs = require('fs'); const JS_SRC = '_javascript'; -const JS_DEST = `assets/js/dist/`; +const JS_DEST = `assets/js/dist`; function concatJs(files, output) { return src(files) @@ -72,12 +72,21 @@ const pageJs = () => { ); }; +const miscJs = () => { + return concatJs([ + `${JS_SRC}/commons/*.js`, + `${JS_SRC}/utils/locale-datetime.js` + ], 'misc' + ); +}; + // GA pageviews report const pvreportJs = () => { return concatJs(`${JS_SRC}/utils/pageviews.js`, 'pvreport'); }; -const buildJs = parallel(commonsJs, homeJs, postJs, categoriesJs, pageJs, pvreportJs); +const buildJs = parallel( + commonsJs, homeJs, postJs, categoriesJs, pageJs, miscJs, pvreportJs); exports.build = series(buildJs, minifyJs); @@ -86,8 +95,7 @@ exports.liveRebuild = () => { watch([ `${ JS_SRC }/commons/*.js`, - `${ JS_SRC }/utils/*.js`, - `${ JS_SRC }/lib/*.js` + `${ JS_SRC }/utils/*.js` ], buildJs );