1
0
mirror of https://github.com/cotes2020/jekyll-theme-chirpy.git synced 2025-12-18 05:41:31 +00:00

Combine local JS.

’yui-compressor’ is no longer used.
This commit is contained in:
Cotes Chung
2020-05-30 00:48:10 +08:00
parent cfb67a1cb9
commit 1a2767ca24
44 changed files with 213 additions and 195 deletions

21
assets/js/_commons.js Normal file
View File

@@ -0,0 +1,21 @@
/*!
Aggregation of common JS.
Chirpy@2.3
https://github.com/cotes2020/jekyll-theme-chirpy
© 2020 Cotes Chung
MIT License
*/
{% include_relative _commons/back-to-top.js %}
{% include_relative _commons/search-display.js %}
{% include_relative _commons/sidebar.js %}
{% include_relative _commons/topbar-switch.js %}
{% include_relative _commons/topbar-title.js %}
{% include_relative _commons/copy-link.js %}
{% include_relative _utils/tooltip-loader.js %}

View File

@@ -5,6 +5,7 @@
* © 2018-2019 Cotes Chung
* MIT License
*/
$(function() {
var didScroll;
@@ -13,7 +14,7 @@ $(function() {
var topbarHeight = $('#topbar-wrapper').outerHeight();
$(window).scroll(function(event) {
if ($("#topbar-title").is(":hidden")) { // Not in small screens
if ($("#topbar-title").is(":hidden")) { /* Not in small screens */
didScroll = true;
}
});
@@ -28,12 +29,12 @@ $(function() {
function hasScrolled() {
var st = $(this).scrollTop();
// Make sure they scroll more than delta
/* Make sure they scroll more than delta */
if (Math.abs(lastScrollTop - st) <= delta)
return;
if (st > lastScrollTop && st > topbarHeight) {
// Scroll Down
/* Scroll Down */
$('#topbar-wrapper').removeClass('topbar-down').addClass('topbar-up');
if ( $('#toc-wrapper').length > 0) {
@@ -45,11 +46,11 @@ $(function() {
}
if ($('#search-input').is(':focus')) {
$('#search-input').blur(); // remove focus
$('#search-input').blur(); /* remove focus */
}
} else {
// Scroll Up
/* Scroll Up */
if (st + $(window).height() < $(document).height()) {
$('#topbar-wrapper').removeClass('topbar-up').addClass('topbar-down');
if ( $('#toc-wrapper').length > 0) {

View File

@@ -5,7 +5,8 @@
* © 2018-2019 Cotes Chung
* MIT License
*/
$(function(){
$(function() {
var DEFAULT = $("#topbar-title").text().trim();
var title = ($("div.post>h1").length > 0) ?
@@ -18,12 +19,12 @@ $(function(){
}
}
// Replace topbar title while scroll screens.
/* Replace topbar title while scroll screens. */
$(window).scroll(function () {
if ($("#post-list").length // in Home page
|| $("div.post>h1").is(":hidden") // is tab pages
|| $("#topbar-title").is(":hidden") // not mobile screens
|| $("#sidebar.sidebar-expand").length) { // when the sidebar trigger is clicked
if ($("#post-list").length /* in Home page */
|| $("div.post>h1").is(":hidden") /* is tab pages */
|| $("#topbar-title").is(":hidden") /* not mobile screens */
|| $("#sidebar.sidebar-expand").length) { /* when the sidebar trigger is clicked */
return false;
}
@@ -36,9 +37,9 @@ $(function(){
$("#topbar-title").text(DEFAULT);
}
}
})
});
// Click title remove hover effect.
/* Click title remove hover effect. */
$('#topbar-title').click(function() {
$('body,html').animate({scrollTop: 0}, 800);
});

22
assets/js/_home-post.js Normal file
View File

@@ -0,0 +1,22 @@
/*!
JS group for layout Home or Post
Chirpy v2.3
https://github.com/cotes2020/jekyll-theme-chirpy
© 2020 Cotes Chung
MIT License
*/
{% include_relative _commons.js %}
{% include_relative _utils/timeago.js %}
{% if site.google_analytics.pv.enabled %}
{% include_relative data/pv-data.js %}
{% include_relative _utils/pageviews.js %}
{% include_relative lib/_countUp.min.js %}
{% endif %}

View File

@@ -10,8 +10,8 @@ $(function() {
var child_prefix = "l_";
var parent_prefix = "h_";
// close up top-category
$(".collapse").on("hide.bs.collapse", function() { // Bootstrap collapse events.
/* close up top-category */
$(".collapse").on("hide.bs.collapse", function() { /* Bootstrap collapse events. */
var parent_id = parent_prefix + $(this).attr('id').substring(child_prefix.length);
if (parent_id) {
$("#" + parent_id + " .far.fa-folder-open").attr("class", "far fa-folder fa-fw");
@@ -20,7 +20,7 @@ $(function() {
}
});
// expand the top category
/* expand the top category */
$(".collapse").on("show.bs.collapse", function() {
var parent_id = parent_prefix + $(this).attr('id').substring(child_prefix.length);
if (parent_id) {

View File

@@ -35,7 +35,7 @@ function countPV(path, rows) {
if (gaPath == path ||
gaPath == _v2_url ||
gaPath.concat('/') == _v2_url ||
gaPath.slice(gaPath.lastIndexOf('/') + 1) === fileName) { // old permalink record
gaPath.slice(gaPath.lastIndexOf('/') + 1) === fileName) { /* old permalink record */
count += parseInt(rows[i][1]);
}
}
@@ -67,13 +67,13 @@ function displayPageviews(data) {
var hasInit = getInitStatus();
var rows = data.rows;
if ($("#post-list").length > 0) { // the Home page
if ($("#post-list").length > 0) { /* the Home page */
$(".post-preview").each(function() {
var path = $(this).children("h1").children("a").attr("href");
tacklePV(rows, path, $(this).find('.pageviews'), hasInit);
});
} else if ($(".post").length > 0) { // the post
} else if ($(".post").length > 0) { /* the post */
var path = window.location.pathname;
tacklePV(rows, path, $('#pv'), hasInit);
}
@@ -133,12 +133,12 @@ var PvCache = (function() {
isExpired: function() {
if (PvCache.isOriginCache() ) {
let date = new Date(get(KEY_CREATION));
date.setDate(date.getDate() + 1); // fetch origin-data every day
date.setDate(date.getDate() + 1); /* fetch origin-data every day */
return Date.now() >= date.getTime();
} else if (PvCache.isProxyCache() ) {
let date = new Date(get(KEY_CREATION) );
date.setHours(date.getHours() + 1); // proxy-data is updated every hour
date.setHours(date.getHours() + 1); /* proxy-data is updated every hour */
return Date.now() >= date.getTime();
}
return false;
@@ -151,7 +151,7 @@ var PvCache = (function() {
}
};
})(); // PvCache
})(); /* PvCache */
function fetchOriginPageviews(pvData) {
@@ -164,7 +164,7 @@ function fetchOriginPageviews(pvData) {
function fetchProxyPageviews() {
let proxy = JSON.parse(proxyData); // see file '/assets/data/pv-data.json'
let proxy = JSON.parse(proxyData); /* see file '/assets/data/pv-data.json' */
$.ajax({
type: 'GET',
url: proxy.url,
@@ -205,7 +205,7 @@ $(function() {
fetchProxyPageviews();
}
} else { // still valid
} else { /* still valid */
displayPageviews(cache);
if (PvCache.isOriginCache() ) {

View File

@@ -7,4 +7,4 @@
*/
$(function () {
$('[data-toggle="tooltip"]').tooltip();
})
});

13
assets/js/categories.min.js vendored Normal file
View File

@@ -0,0 +1,13 @@
---
layout: compress
# JS for layout tab Categories.
# Chirpy v2.3
# https://github.com/cotes2020/jekyll-theme-chirpy
# © 2020 Cotes Chung
# MIT License
---
{% include_relative _commons.js %}
{% include_relative _utils/category-collapse.js %}

View File

@@ -0,0 +1,112 @@
---
layout: compress
# The list to be cached by PWA
# Chirpy v2.2
# https://github.com/cotes2020/jekyll-theme-chirpy
# © 2020 Cotes Chung
# MIT Licensed
---
const include = [
/*--- CSS ---*/
'{{ "/assets/css/home.css" | relative_url }}',
'{{ "/assets/css/categories.css" | relative_url }}',
'{{ "/assets/css/tags.css" | relative_url }}',
'{{ "/assets/css/archives.css" | relative_url }}',
'{{ "/assets/css/page.css" | relative_url }}',
'{{ "/assets/css/post.css" | relative_url }}',
'{{ "/assets/css/category-tag.css" | relative_url }}',
'{{ "/assets/css/lib/bootstrap-toc.min.css" | relative_url }}',
/*--- Javascripts ---*/
'{{ "/assets/js/home.min.js" | relative_url }}',
'{{ "/assets/js/page.min.js" | relative_url }}',
'{{ "/assets/js/post.min.js" | relative_url }}',
'{{ "/assets/js/post-toc.min.js" | relative_url }}',
/*--- HTML ---*/
/* Tabs */
{% for tab in site.data.tabs %}
{% capture item %}
{%- unless tab.name == 'Home' -%}
/tabs/{{ tab.name | downcase }}
{%- endunless -%}
{{- "/" -}}
{% endcapture %}
'{{ item | relative_url }}',
{% endfor %}
/* The posts of first Home page and recent update list */
{% assign post_list = "" | split: "" %}
{% assign sum = 0 %}
{% for post in site.posts %}
{% assign post_list = post_list | push: post.url %}
{% assign sum = sum | plus: 1 %}
{% if sum >= site.paginate %}
{% break %}
{% endif %}
{% endfor %}
{% include update_list.html %}
{% for item in update_list %}
{% assign url = item | split: "::" | last | prepend: "/posts/" | append: "/" %}
{% assign post_list = post_list | push: url %}
{% endfor %}
{% assign post_list = post_list | uniq %}
{% for url in post_list %}
'{{ url }}',
{% endfor %}
/* Trending tags */
{% include trending-tags.html %}
{% for tag in trending_tags %}
{% capture tag_url %}/tags/{{ tag | downcase | url_encode }}/{% endcapture %}
'{{ tag_url | relative_url }}',
{% endfor %}
/*--- Icons ---*/
{%- capture icon_url -%}
{{ "/assets/img/favicons" | relative_url }}
{%- endcapture -%}
'{{ icon_url }}/favicon.ico',
'{{ icon_url }}/apple-icon.png',
'{{ icon_url }}/apple-icon-precomposed.png',
'{{ icon_url }}/apple-icon-57x57.png',
'{{ icon_url }}/apple-icon-60x60.png',
'{{ icon_url }}/apple-icon-72x72.png',
'{{ icon_url }}/apple-icon-76x76.png',
'{{ icon_url }}/apple-icon-114x114.png',
'{{ icon_url }}/apple-icon-120x120.png',
'{{ icon_url }}/apple-icon-144x144.png',
'{{ icon_url }}/apple-icon-152x152.png',
'{{ icon_url }}/apple-icon-180x180.png',
'{{ icon_url }}/android-icon-192x192.png',
'{{ icon_url }}/favicon-32x32.png',
'{{ icon_url }}/favicon-96x96.png',
'{{ icon_url }}/favicon-16x16.png',
'{{ icon_url }}/ms-icon-144x144.png',
'{{ icon_url }}/manifest.json',
'{{ icon_url }}/browserconfig.xml',
/*--- Others ---*/
'{{ "/assets/js/data/search.json" | relative_url }}',
'{{ "/404.html" | relative_url }}',
'{{ "/app.js" | relative_url }}',
'{{ "/sw.js" | relative_url }}'
];
const exclude = [
'/assets/js/data/pv-data.js',
'/img.shields.io/'
];

View File

@@ -0,0 +1,9 @@
const proxyData = '{"url": "{{ site.google_analytics.pv.proxy_endpoint }}"}';
{%- capture pv_data -%}
{%- if site.google_analytics.pv.cache and site.google_analytics.pv.enabled -%}
{% include_relative data/_pageviews.json %}
{%- endif -%}
{%- endcapture -%}
const pageviews = '{{ pv_data }}';

View File

@@ -0,0 +1,18 @@
---
layout: compress
---
[
{% for post in site.posts %}
{
"title": "{{ post.title | escape }}",
"url": "{{ site.baseurl }}{{ post.url }}",
"categories": "{{ post.categories | join: ', '}}",
"tags": "{{ post.tags | join: ', ' }}",
"date": "{{ post.date }}",
{% assign content = post.content %}
{% include no-linenos.html %}
"snippet": "{{ content | strip_html | strip_newlines | remove_chars | escape | truncate: 300 | replace: '\', '\\\\' }}"
}{% unless forloop.last %},{% endunless %}
{% endfor %}
]

View File

@@ -1 +0,0 @@
$(window).scroll(function(){if($(this).scrollTop()>50&&$("#sidebar-trigger").css("display")=="none"){$("#back-to-top").fadeIn()}else{$("#back-to-top").fadeOut()}});$(function(){$("#back-to-top").click(function(){$("body,html").animate({scrollTop:0},800);return false})});

View File

@@ -1 +0,0 @@
function copyLink(a){if(!a||0===a.length){a=window.location.href}var b=$("<input>");$("body").append(b);b.val(a).select();document.execCommand("copy");b.remove();alert("Link copied successfully!")};

View File

@@ -1 +0,0 @@
$(function(){var j=$("#sidebar-trigger");var o=$("#search-trigger");var h=$("#search-cancel");var b=$("#search-cleaner");var e=$("#main");var c=$("#topbar-title");var k=$("#search-wrapper");var i=$("#search-result-wrapper");var g=$("#search-results");var l=$("#search-input");var a=$("#search-hints");var d=(function(){var p=0;return{block:function(){p=$(window).scrollTop()},release:function(){$("html,body").scrollTop(p)},getOffset:function(){return p}}})();var m=(function(){return{on:function(){j.addClass("unloaded");c.addClass("unloaded");o.addClass("unloaded");k.addClass("d-flex");h.addClass("loaded")},off:function(){h.removeClass("loaded");k.removeClass("d-flex");j.removeClass("unloaded");c.removeClass("unloaded");o.removeClass("unloaded")}}})();var n=(function(){var p=false;return{on:function(){if(!p){i.removeClass("unloaded");e.addClass("hidden");p=true;d.block()}},off:function(){if(p){g.empty();if(a.hasClass("unloaded")){a.removeClass("unloaded")}i.addClass("unloaded");b.removeClass("visable");e.removeClass("hidden");l.val("");p=false;d.release()}},isVisable:function(){return p}}})();function f(){return h.hasClass("loaded")}o.click(function(){m.on();n.on();l.focus()});h.click(function(){m.off();n.off()});l.focus(function(){k.addClass("input-focus")});l.focusout(function(){k.removeClass("input-focus")});l.on("keyup",function(p){if(p.keyCode==8&&l.val()==""){if(!f()){n.off()}else{a.removeClass("unloaded")}}else{if(l.val()!=""){n.on();if(!b.hasClass("visible")){b.addClass("visable")}if(f()){a.addClass("unloaded")}}}});b.on("click",function(){l.val("");if(f()){a.removeClass("unloaded");g.empty()}else{n.off()}l.focus();b.removeClass("visable")})});

View File

@@ -1 +0,0 @@
$(function(){var a=(function(){const c="sidebar-display";var d=false;var b=$("body");return{toggle:function(){if(d==false){b.attr(c,"")}else{b.removeAttr(c)}d=!d}}})();$("#sidebar-trigger").click(a.toggle);$("#mask").click(a.toggle)});

View File

@@ -1 +0,0 @@
$(function(){var d;var c=0;var e=5;var b=$("#topbar-wrapper").outerHeight();$(window).scroll(function(f){if($("#topbar-title").is(":hidden")){d=true}});setInterval(function(){if(d){a();d=false}},250);function a(){var f=$(this).scrollTop();if(Math.abs(c-f)<=e){return}if(f>c&&f>b){$("#topbar-wrapper").removeClass("topbar-down").addClass("topbar-up");if($("#toc-wrapper").length>0){$("#toc-wrapper").removeClass("topbar-down")}if($(".access").length>0){$(".access").removeClass("topbar-down")}if($("#search-input").is(":focus")){$("#search-input").blur()}}else{if(f+$(window).height()<$(document).height()){$("#topbar-wrapper").removeClass("topbar-up").addClass("topbar-down");if($("#toc-wrapper").length>0){$("#toc-wrapper").addClass("topbar-down")}if($(".access").length>0){$(".access").addClass("topbar-down")}}}c=f}});

View File

@@ -1 +0,0 @@
$(function(){var a=$("#topbar-title").text().trim();var b=($("div.post>h1").length>0)?$("div.post>h1").text().trim():$("h1").text().trim();if($("#page-category").length||$("#page-tag").length){if(/\s/.test(b)){b=b.replace(/[0-9]/g,"").trim()}}$(window).scroll(function(){if($("#post-list").length||$("div.post>h1").is(":hidden")||$("#topbar-title").is(":hidden")||$("#sidebar.sidebar-expand").length){return false}if($(this).scrollTop()>=95){if($("#topbar-title").text()!=b){$("#topbar-title").text(b)}}else{if($("#topbar-title").text()!=a){$("#topbar-title").text(a)}}});$("#topbar-title").click(function(){$("body,html").animate({scrollTop:0},800)})});

View File

@@ -1 +0,0 @@
$(function(){var b="l_";var a="h_";$(".collapse").on("hide.bs.collapse",function(){var c=a+$(this).attr("id").substring(b.length);if(c){$("#"+c+" .far.fa-folder-open").attr("class","far fa-folder fa-fw");$("#"+c+" i.fas").addClass("rotate");$("#"+c).removeClass("hide-border-bottom")}});$(".collapse").on("show.bs.collapse",function(){var c=a+$(this).attr("id").substring(b.length);if(c){$("#"+c+" .far.fa-folder").attr("class","far fa-folder-open fa-fw");$("#"+c+" i.fas").removeClass("rotate");$("#"+c).addClass("hide-border-bottom")}})});

View File

@@ -1,12 +0,0 @@
---
# Aggregation of common JS.
# © 2018-2019 Cotes Chung
# MIT License
---
{% include_relative _commons/back-to-top.min.js %}
{% include_relative _commons/search-display.min.js %}
{% include_relative _commons/sidebar.min.js %}
{% include_relative _commons/topbar-switch.min.js %}
{% include_relative _commons/topbar-title.min.js %}
{% include_relative _commons/copy-link.min.js %}

View File

@@ -1 +0,0 @@
function countUp(b,a,d){if(b<a){var c=new CountUp(d,b,a);if(!c.error){c.start()}else{console.error(c.error)}}}function countPV(f,e){var g=f.replace(/\/posts\//g,"").replace(/\//g,".html");var d=0;var c=f.replace(/posts\//g,"");for(var b=0;b<e.length;++b){var a=e[b][0];if(a==f||a==c||a.concat("/")==c||a.slice(a.lastIndexOf("/")+1)===g){d+=parseInt(e[b][1])}}return d}function tacklePV(e,f,d,b){var c=countPV(f,e);c=(c==0?1:c);if(!b){d.text(new Intl.NumberFormat().format(c))}else{var a=parseInt(d.text().replace(/,/g,""));if(c>a){countUp(a,c,d.attr("id"))}}}function displayPageviews(c){if(c===undefined){return}var a=getInitStatus();var b=c.rows;if($("#post-list").length>0){$(".post-preview").each(function(){var e=$(this).children("h1").children("a").attr("href");tacklePV(b,e,$(this).find(".pageviews"),a)})}else{if($(".post").length>0){var d=window.location.pathname;tacklePV(b,d,$("#pv"),a)}}}var getInitStatus=(function(){var a=false;return function(){let ret=a;if(!a){a=true}return ret}})();var PvCache=(function(){const e="pv";const b="pv-created-date";const d="pv-type";var c={ORIGIN:"origin",PROXY:"proxy"};function a(g){return localStorage.getItem(g)}function f(g,h){localStorage.setItem(g,h)}return{getData:function(){return JSON.parse(localStorage.getItem(e))},saveOriginCache:function(g){f(e,g);f(d,c.ORIGIN);f(b,new Date().toJSON())},saveProxyCache:function(g){f(e,g);f(d,c.PROXY);f(b,new Date().toJSON())},isOriginCache:function(){return a(d)==c.ORIGIN},isProxyCache:function(){return a(d)==c.PROXY},isExpired:function(){if(PvCache.isOriginCache()){let date=new Date(a(b));date.setDate(date.getDate()+1);return Date.now()>=date.getTime()}else{if(PvCache.isProxyCache()){let date=new Date(a(b));date.setHours(date.getHours()+1);return Date.now()>=date.getTime()}}return false},getAllPagevies:function(){return PvCache.getData().totalsForAllResults["ga:pageviews"]},newerThan:function(g){return PvCache.getAllPagevies()>g.totalsForAllResults["ga:pageviews"]}}})();function fetchOriginPageviews(a){if(a===undefined){return}displayPageviews(a);PvCache.saveOriginCache(JSON.stringify(a))}function fetchProxyPageviews(){let proxy=JSON.parse(proxyData);$.ajax({type:"GET",url:proxy.url,dataType:"jsonp",jsonpCallback:"displayPageviews",success:function(b,c,a){PvCache.saveProxyCache(JSON.stringify(b))},error:function(a,c,b){console.log("Failed to load pageviews from proxy server: "+b)}})}$(function(){if($(".pageviews").length>0){let cache=PvCache.getData();if(cache){if(PvCache.isExpired()){if(PvCache.isProxyCache()){let originPvData=pageviews?JSON.parse(pageviews):undefined;if(originPvData){if(PvCache.newerThan(originPvData)){displayPageviews(cache)}else{fetchOriginPageviews(originPvData)}}fetchProxyPageviews()}else{if(PvCache.isOriginCache()){fetchOriginPageviews(originPvData);fetchProxyPageviews()}}}else{displayPageviews(cache);if(PvCache.isOriginCache()){fetchProxyPageviews()}}}else{let originPvData=pageviews?JSON.parse(pageviews):undefined;fetchOriginPageviews(originPvData);fetchProxyPageviews()}}});

View File

@@ -1 +0,0 @@
$(function(){function d(h,g){var f=new Date();var o=new Date(h);var n=Math.floor((f-o)/1000);var l=Math.floor(n/31536000);if(l>=1){return l+" year"+(l>1?"s":"")+" ago"}var k=Math.floor(n/2592000);if(k>=1){return k+" month"+(k>1?"s":"")+" ago"}var e=Math.floor(n/604800);if(e>=1){return e+" week"+(e>1?"s":"")+" ago"}var m=Math.floor(n/86400);if(m>=1){return m+" day"+(m>1?"s":"")+" ago"}var j=Math.floor(n/3600);if(j>=1){return j+" hour"+(j>1?"s":"")+" ago"}var i=Math.floor(n/60);if(i>=1){return i+" minute"+(i>1?"s":"")+" ago"}return(g?"just":"Just")+" now"}function c(){$(".timeago").each(function(){if($(this).children("i").length>0){var g=$(this).hasClass("lastmod");var f=$(this).children("i");var e=f.text();$(this).text(d(e,g));$(this).append(f)}});if(a==0&&b!=undefined){clearInterval(b)}return a}var a=$(".timeago").length;if(a==0){return}if(c()>0){a=$(".timeago").length;var b=setInterval(c,60000)}});

View File

@@ -1 +0,0 @@
$(function(){if($("#post-wrapper .post-content h1").length==0&&$("#post-wrapper .post-content h2").length==0){$("#toc-wrapper").addClass("unloaded")}});

View File

@@ -1 +0,0 @@
$(function(){$('[data-toggle="tooltip"]').tooltip()});

11
assets/js/home.min.js vendored Normal file
View File

@@ -0,0 +1,11 @@
---
layout: compress
# JS for layout home.
# Chirpy v2.3
# https://github.com/cotes2020/jekyll-theme-chirpy
# © 2020 Cotes Chung
# MIT License
---
{% include_relative _home-post.js %}

5
assets/js/lib/_bootstrap-toc.min.js vendored Normal file
View File

@@ -0,0 +1,5 @@
/*!
* Bootstrap Table of Contents v1.0.1 (http://afeld.github.io/bootstrap-toc/)
* Copyright 2015 Aidan Feldman
* Licensed under MIT (https://github.com/afeld/bootstrap-toc/blob/gh-pages/LICENSE.md) */
!function(a){"use strict";window.Toc={helpers:{findOrFilter:function(e,t){var n=e.find(t);return e.filter(t).add(n).filter(":not([data-toc-skip])")},generateUniqueIdBase:function(e){return a(e).text().trim().replace(/\'/gi,"").replace(/[& +$,:;=?@"#{}|^~[`%!'<>\]\.\/\(\)\*\\\n\t\b\v]/g,"-").replace(/-{2,}/g,"-").substring(0,64).replace(/^-+|-+$/gm,"").toLowerCase()||e.tagName.toLowerCase()},generateUniqueId:function(e){for(var t=this.generateUniqueIdBase(e),n=0;;n++){var r=t;if(0<n&&(r+="-"+n),!document.getElementById(r))return r}},generateAnchor:function(e){if(e.id)return e.id;var t=this.generateUniqueId(e);return e.id=t},createNavList:function(){return a('<ul class="nav navbar-nav"></ul>')},createChildNavList:function(e){var t=this.createNavList();return e.append(t),t},generateNavEl:function(e,t){var n=a('<a class="nav-link"></a>');n.attr("href","#"+e),n.text(t);var r=a("<li></li>");return r.append(n),r},generateNavItem:function(e){var t=this.generateAnchor(e),n=a(e),r=n.data("toc-text")||n.text();return this.generateNavEl(t,r)},getTopLevel:function(e){for(var t=1;t<=6;t++){if(1<this.findOrFilter(e,"h"+t).length)return t}return 1},getHeadings:function(e,t){var n="h"+t,r="h"+(t+1);return this.findOrFilter(e,n+","+r)},getNavLevel:function(e){return parseInt(e.tagName.charAt(1),10)},populateNav:function(r,a,e){var i,s=r,c=this;e.each(function(e,t){var n=c.generateNavItem(t);c.getNavLevel(t)===a?s=r:i&&s===r&&(s=c.createChildNavList(i)),s.append(n),i=n})},parseOps:function(e){var t;return(t=e.jquery?{$nav:e}:e).$scope=t.$scope||a(document.body),t}},init:function(e){(e=this.helpers.parseOps(e)).$nav.attr("data-toggle","toc");var t=this.helpers.createChildNavList(e.$nav),n=this.helpers.getTopLevel(e.$scope),r=this.helpers.getHeadings(e.$scope,n);this.helpers.populateNav(t,n,r)}},a(function(){a('nav[data-toggle="toc"]').each(function(e,t){var n=a(t);Toc.init(n)})})}(jQuery);

2
assets/js/lib/_countUp.min.js vendored Normal file
View File

@@ -0,0 +1,2 @@
/*! https://github.com/inorganik/countUp.js */
var CountUp=function(h,b,i,e,g,n){var m=this;m.version=function(){return"1.9.3"};m.options={useEasing:true,useGrouping:true,separator:",",decimal:".",easingFn:c,formattingFn:d,prefix:"",suffix:"",numerals:[]};if(n&&typeof n==="object"){for(var k in m.options){if(n.hasOwnProperty(k)&&n[k]!==null){m.options[k]=n[k]}}}if(m.options.separator===""){m.options.useGrouping=false}else{m.options.separator=""+m.options.separator}var a=0;var l=["webkit","moz","ms","o"];for(var j=0;j<l.length&&!window.requestAnimationFrame;++j){window.requestAnimationFrame=window[l[j]+"RequestAnimationFrame"];window.cancelAnimationFrame=window[l[j]+"CancelAnimationFrame"]||window[l[j]+"CancelRequestAnimationFrame"]}if(!window.requestAnimationFrame){window.requestAnimationFrame=function(s,p){var o=new Date().getTime();var q=Math.max(0,16-(o-a));var r=window.setTimeout(function(){s(o+q)},q);a=o+q;return r}}if(!window.cancelAnimationFrame){window.cancelAnimationFrame=function(o){clearTimeout(o)}}function d(t){var v=(t<0),p,s,r,q,u,o;t=Math.abs(t).toFixed(m.decimals);t+="";p=t.split(".");s=p[0];r=p.length>1?m.options.decimal+p[1]:"";if(m.options.useGrouping){q="";for(u=0,o=s.length;u<o;++u){if(u!==0&&((u%3)===0)){q=m.options.separator+q}q=s[o-u-1]+q}s=q}if(m.options.numerals.length){s=s.replace(/[0-9]/g,function(x){return m.options.numerals[+x]});r=r.replace(/[0-9]/g,function(x){return m.options.numerals[+x]})}return(v?"-":"")+m.options.prefix+s+r+m.options.suffix}function c(p,o,r,q){return r*(-Math.pow(2,-10*p/q)+1)*1024/1023+o}function f(o){return(typeof o==="number"&&!isNaN(o))}m.initialize=function(){if(m.initialized){return true}m.error="";m.d=(typeof h==="string")?document.getElementById(h):h;if(!m.d){m.error="[CountUp] target is null or undefined";return false}m.startVal=Number(b);m.endVal=Number(i);if(f(m.startVal)&&f(m.endVal)){m.decimals=Math.max(0,e||0);m.dec=Math.pow(10,m.decimals);m.duration=Number(g)*1000||2000;m.countDown=(m.startVal>m.endVal);m.frameVal=m.startVal;m.initialized=true;return true}else{m.error="[CountUp] startVal ("+b+") or endVal ("+i+") is not a number";return false}};m.printValue=function(p){var o=m.options.formattingFn(p);if(m.d.tagName==="INPUT"){this.d.value=o}else{if(m.d.tagName==="text"||m.d.tagName==="tspan"){this.d.textContent=o}else{this.d.innerHTML=o}}};m.count=function(p){if(!m.startTime){m.startTime=p}m.timestamp=p;var o=p-m.startTime;m.remaining=m.duration-o;if(m.options.useEasing){if(m.countDown){m.frameVal=m.startVal-m.options.easingFn(o,0,m.startVal-m.endVal,m.duration)}else{m.frameVal=m.options.easingFn(o,m.startVal,m.endVal-m.startVal,m.duration)}}else{if(m.countDown){m.frameVal=m.startVal-((m.startVal-m.endVal)*(o/m.duration))}else{m.frameVal=m.startVal+(m.endVal-m.startVal)*(o/m.duration)}}if(m.countDown){m.frameVal=(m.frameVal<m.endVal)?m.endVal:m.frameVal}else{m.frameVal=(m.frameVal>m.endVal)?m.endVal:m.frameVal}m.frameVal=Math.round(m.frameVal*m.dec)/m.dec;m.printValue(m.frameVal);if(o<m.duration){m.rAF=requestAnimationFrame(m.count)}else{if(m.callback){m.callback()}}};m.start=function(o){if(!m.initialize()){return}m.callback=o;m.rAF=requestAnimationFrame(m.count)};m.pauseResume=function(){if(!m.paused){m.paused=true;cancelAnimationFrame(m.rAF)}else{m.paused=false;delete m.startTime;m.duration=m.remaining;m.startVal=m.frameVal;requestAnimationFrame(m.count)}};m.reset=function(){m.paused=false;delete m.startTime;m.initialized=false;if(m.initialize()){cancelAnimationFrame(m.rAF);m.printValue(m.startVal)}};m.update=function(o){if(!m.initialize()){return}o=Number(o);if(!f(o)){m.error="[CountUp] update() - new endVal is not a number: "+o;return}m.error="";if(o===m.frameVal){return}cancelAnimationFrame(m.rAF);m.paused=false;delete m.startTime;m.startVal=m.frameVal;m.endVal=o;m.countDown=(m.startVal>m.endVal);m.rAF=requestAnimationFrame(m.count)};if(m.initialize()){m.printValue(m.startVal)}};

View File

@@ -0,0 +1,8 @@
/*!
disqusLoader.js v1.0
A JavaScript plugin for lazy-loading Disqus comments widget.
-
By Osvaldas Valutis, www.osvaldas.info
Available for use under the MIT License
*/
(function(e,g,h,d){var a=e(g),k=function(o,n){var q,p;return function(){var t=this,s=arguments,r=+new Date;q&&r<q+o?(clearTimeout(p),p=setTimeout(function(){q=r,n.apply(t,s)},o)):(q=r,n.apply(t,s))}},m=false,j=false,i=false,c=false,f="unloaded",b=e(),l=function(){if(!b.length||b.data("disqusLoaderStatus")=="loaded"){return true}var n=a.scrollTop();if(b.offset().top-n>a.height()*j||n-b.offset().top-b.outerHeight()-(a.height()*j)>0){return true}e("#disqus_thread").removeAttr("id");b.attr("id","disqus_thread").data("disqusLoaderStatus","loaded");if(f=="loaded"){DISQUS.reset({reload:true,config:i})}else{g.disqus_config=i;if(f=="unloaded"){f="loading";e.ajax({url:c,async:true,cache:true,dataType:"script",success:function(){f="loaded"}})}}};a.on("scroll resize",k(m,l));e.disqusLoader=function(o,n){n=e.extend({},{laziness:1,throttle:250,scriptUrl:false,disqusConfig:false},n);j=n.laziness+1;m=n.throttle;i=n.disqusConfig;c=c===false?n.scriptUrl:c;b=(typeof o=="string"?e(o):o).eq(0);b.data("disqusLoaderStatus","unloaded");l()}})(jQuery,window,document);

11
assets/js/page.min.js vendored Normal file
View File

@@ -0,0 +1,11 @@
---
layout: compress
# JS for layout page by default.
# Chirpy v2.3
# https://github.com/cotes2020/jekyll-theme-chirpy
# © 2020 Cotes Chung
# MIT License
---
{% include_relative _commons.js %}

16
assets/js/post-toc.min.js vendored Normal file
View File

@@ -0,0 +1,16 @@
---
layout: compress
# JS for layout post (with ToC).
# Chirpy v2.3
# https://github.com/cotes2020/jekyll-theme-chirpy
# © 2020 Cotes Chung
# MIT License
---
{% include_relative _home-post.js %}
{% include_relative lib/_bootstrap-toc.min.js %}
{% include_relative _utils/toc.js %}

11
assets/js/post.min.js vendored Normal file
View File

@@ -0,0 +1,11 @@
---
layout: compress
# JS for layout post.
# Chirpy v2.3
# https://github.com/cotes2020/jekyll-theme-chirpy
# © 2020 Cotes Chung
# MIT License
---
{% include_relative _home-post.js %}