Process JS files with gulp
This commit is contained in:
parent
0e9104a58f
commit
da9f7b8218
37 changed files with 380 additions and 326 deletions
4
.gitignore
vendored
4
.gitignore
vendored
|
@ -5,3 +5,7 @@
|
||||||
# jekyll cache
|
# jekyll cache
|
||||||
_site
|
_site
|
||||||
vendor
|
vendor
|
||||||
|
|
||||||
|
# npm dependencies
|
||||||
|
node_modules
|
||||||
|
package-lock.json
|
||||||
|
|
|
@ -194,6 +194,10 @@ exclude:
|
||||||
- docs
|
- docs
|
||||||
- README.md
|
- README.md
|
||||||
- LICENSE
|
- LICENSE
|
||||||
|
- gulpfile.js
|
||||||
|
- node_modules
|
||||||
|
- package.json
|
||||||
|
- package-lock.json
|
||||||
|
|
||||||
jekyll-archives:
|
jekyll-archives:
|
||||||
enabled: [categories, tags]
|
enabled: [categories, tags]
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<!--
|
<!--
|
||||||
The Disqus lazy loading.
|
The Disqus lazy loading.
|
||||||
Powered by: https://osvaldas.info/lazy-loading-disqus-comments
|
Powered by: <https://github.com/osvaldasvalutis/disqusLoader.js>
|
||||||
v2.0
|
v2.0
|
||||||
https://github.com/cotes2020/jekyll-theme-chirpy
|
https://github.com/cotes2020/jekyll-theme-chirpy
|
||||||
© 2019 Cotes Chung
|
© 2019 Cotes Chung
|
||||||
|
@ -8,17 +8,18 @@
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<div id="disqus" class="pt-2 pb-2">
|
<div id="disqus" class="pt-2 pb-2">
|
||||||
<p class="font-italic text-center text-muted small">
|
<p class="text-center text-muted pb-5">
|
||||||
Comments powered by <a href="https://disqus.com/">Disqus</a>.
|
Loading comments from <a href="https://disqus.com/">Disqus</a> ...
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="{{ '/assets/js/lib/jquery.disqusloader.min.js' | relative_url }}"></script>
|
<script src="{{ '/assets/js/lib/jquery.disqusloader.min.js' | relative_url }}"></script>
|
||||||
<script>
|
<script>
|
||||||
var options = {
|
const options = {
|
||||||
scriptUrl: '//{{ site.disqus.shortname }}.disqus.com/embed.js',
|
scriptUrl: '//{{ site.disqus.shortname }}.disqus.com/embed.js',
|
||||||
|
|
||||||
disqusConfig: function() {
|
disqusConfig: function() {
|
||||||
|
this.page.title = '{{ page.title }}';
|
||||||
this.page.url = '{{ page.url | absolute_url }}';
|
this.page.url = '{{ page.url | absolute_url }}';
|
||||||
this.page.identifier = '{{ page.url }}';
|
this.page.identifier = '{{ page.url }}';
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,22 @@
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||||
<meta name="theme" content="{{ site.data.meta.name }} v{{ site.data.meta.version }}">
|
<meta name="theme" content="{{ site.data.meta.name }} v{{ site.data.meta.version }}">
|
||||||
|
|
||||||
|
{% if page.layout == 'home' or page.layout == 'post' %}
|
||||||
|
<meta name="pv-cache-enabled" content="{{ site.google_analytics.pv.enabled }}">
|
||||||
|
|
||||||
|
{% if site.google_analytics.pv.enabled %}
|
||||||
|
{% if site.google_analytics.pv.proxy_endpoint != ''
|
||||||
|
and site.google_analytics.pv.proxy_endpoint %}
|
||||||
|
<meta name="pv-proxy-endpoint" content="{{ site.google_analytics.pv.proxy_endpoint }}">
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if site.google_analytics.pv.cache %}
|
||||||
|
<meta name="pv-cache-data" content="{{ '/assets/js/data/pageviews.json' | relative_url }}">
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% seo title=false %}
|
{% seo title=false %}
|
||||||
|
|
||||||
<title>
|
<title>
|
||||||
|
|
|
@ -6,15 +6,24 @@
|
||||||
MIT Licensed
|
MIT Licensed
|
||||||
-->
|
-->
|
||||||
|
|
||||||
{% if page.layout == 'home' or page.layout == 'post' or page.layout == 'categories' %}
|
{% if page.layout == 'home' or page.layout == 'post' %}
|
||||||
{% assign js = page.layout %}
|
{% if site.google_analytics.pv.enabled %}
|
||||||
{% else %}
|
<!-- pv-report needs countup.js -->
|
||||||
{% assign js = "page" %}
|
<script async src="https://cdn.jsdelivr.net/npm/countup.js@1.9.3/dist/countUp.min.js"></script>
|
||||||
|
<script async src="{{ '/assets/js/dist/pvreport.min.js' | relative_url }}"></script>
|
||||||
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% assign js_src = js | prepend: '/assets/js/' | append: '.min.js' | relative_url %}
|
{% if page.layout == 'home'
|
||||||
|
or page.layout == 'post'
|
||||||
|
or page.layout == 'categories' %}
|
||||||
|
{% assign type = page.layout %}
|
||||||
|
{% else %}
|
||||||
|
{% assign type = "page" %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
<script async src="{{ js_src }}"></script>
|
{% assign js = type | prepend: '/assets/js/dist/' | append: '.min.js' %}
|
||||||
|
<script defer src="{{ js | relative_url }}"></script>
|
||||||
|
|
||||||
{% if page.math %}
|
{% if page.math %}
|
||||||
<!-- MathJax -->
|
<!-- MathJax -->
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
<!--
|
<!--
|
||||||
mermaid-js loader
|
mermaid-js loader
|
||||||
-->
|
-->
|
||||||
<script src="https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js"></script>
|
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/mermaid@8/dist/mermaid.min.js"></script>
|
||||||
<script>
|
<script>
|
||||||
$(function() {
|
$(function() {
|
||||||
let initTheme = "default";
|
let initTheme = "default";
|
||||||
|
|
|
@ -48,6 +48,8 @@
|
||||||
</div> <!-- .access -->
|
</div> <!-- .access -->
|
||||||
|
|
||||||
{% if include.toc %}
|
{% if include.toc %}
|
||||||
|
<!-- BS-toc.js will be loaded at medium priority -->
|
||||||
|
<script src="https://cdn.jsdelivr.net/gh/afeld/bootstrap-toc@1.0.1/dist/bootstrap-toc.min.js"></script>
|
||||||
<div id="toc-wrapper" class="pl-0 pr-4 mb-5">
|
<div id="toc-wrapper" class="pl-0 pr-4 mb-5">
|
||||||
<span class="pl-3 pt-2 mb-2">
|
<span class="pl-3 pt-2 mb-2">
|
||||||
{{- site.data.label.panel.toc -}}
|
{{- site.data.label.panel.toc -}}
|
||||||
|
|
|
@ -1,23 +0,0 @@
|
||||||
/*!
|
|
||||||
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 _commons/checkbox.js %}
|
|
||||||
|
|
||||||
{% include_relative _utils/tooltip-loader.js %}
|
|
|
@ -10,8 +10,8 @@ function copyLink(url) {
|
||||||
if (!url || 0 === url.length) {
|
if (!url || 0 === url.length) {
|
||||||
url = window.location.href;
|
url = window.location.href;
|
||||||
}
|
}
|
||||||
|
|
||||||
var $temp = $("<input>");
|
const $temp = $("<input>");
|
||||||
$("body").append($temp);
|
$("body").append($temp);
|
||||||
$temp.val(url).select();
|
$temp.val(url).select();
|
||||||
document.execCommand("copy");
|
document.execCommand("copy");
|
||||||
|
|
|
@ -8,24 +8,24 @@
|
||||||
|
|
||||||
$(function() {
|
$(function() {
|
||||||
|
|
||||||
var btnSbTrigger = $("#sidebar-trigger");
|
const btnSbTrigger = $("#sidebar-trigger");
|
||||||
var btnSearchTrigger = $("#search-trigger");
|
const btnSearchTrigger = $("#search-trigger");
|
||||||
var btnCancel = $("#search-cancel");
|
const btnCancel = $("#search-cancel");
|
||||||
var btnClear = $("#search-cleaner");
|
const btnClear = $("#search-cleaner");
|
||||||
|
|
||||||
var main = $("#main");
|
const main = $("#main");
|
||||||
var topbarTitle = $("#topbar-title");
|
const topbarTitle = $("#topbar-title");
|
||||||
var searchWrapper = $("#search-wrapper");
|
const searchWrapper = $("#search-wrapper");
|
||||||
var resultWrapper = $("#search-result-wrapper");
|
const resultWrapper = $("#search-result-wrapper");
|
||||||
var results = $("#search-results");
|
const results = $("#search-results");
|
||||||
var input = $("#search-input");
|
const input = $("#search-input");
|
||||||
var hints = $("#search-hints");
|
const hints = $("#search-hints");
|
||||||
|
|
||||||
|
|
||||||
/*--- Actions in small screens (Sidebar unloaded) ---*/
|
/*--- Actions in small screens (Sidebar unloaded) ---*/
|
||||||
|
|
||||||
var scrollBlocker = (function() {
|
const scrollBlocker = (function () {
|
||||||
var offset = 0;
|
let offset = 0;
|
||||||
return {
|
return {
|
||||||
block() {
|
block() {
|
||||||
offset = $(window).scrollTop();
|
offset = $(window).scrollTop();
|
||||||
|
@ -39,7 +39,7 @@ $(function() {
|
||||||
};
|
};
|
||||||
}());
|
}());
|
||||||
|
|
||||||
var mobileSearchBar = (function() {
|
const mobileSearchBar = (function () {
|
||||||
return {
|
return {
|
||||||
on() {
|
on() {
|
||||||
btnSbTrigger.addClass("unloaded");
|
btnSbTrigger.addClass("unloaded");
|
||||||
|
@ -58,21 +58,21 @@ $(function() {
|
||||||
};
|
};
|
||||||
}());
|
}());
|
||||||
|
|
||||||
var resultSwitch = (function() {
|
const resultSwitch = (function () {
|
||||||
var visable = false;
|
let visible = false;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
on() {
|
on() {
|
||||||
if (!visable) {
|
if (!visible) {
|
||||||
resultWrapper.removeClass("unloaded");
|
resultWrapper.removeClass("unloaded");
|
||||||
main.addClass("hidden");
|
main.addClass("hidden");
|
||||||
|
|
||||||
visable = true;
|
visible = true;
|
||||||
scrollBlocker.block();
|
scrollBlocker.block();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
off() {
|
off() {
|
||||||
if (visable) {
|
if (visible) {
|
||||||
results.empty();
|
results.empty();
|
||||||
if (hints.hasClass("unloaded")) {
|
if (hints.hasClass("unloaded")) {
|
||||||
hints.removeClass("unloaded");
|
hints.removeClass("unloaded");
|
||||||
|
@ -82,13 +82,13 @@ $(function() {
|
||||||
main.removeClass("hidden");
|
main.removeClass("hidden");
|
||||||
|
|
||||||
input.val("");
|
input.val("");
|
||||||
visable = false;
|
visible = false;
|
||||||
|
|
||||||
scrollBlocker.release();
|
scrollBlocker.release();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
isVisable() {
|
isVisible() {
|
||||||
return visable;
|
return visible;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -8,10 +8,10 @@
|
||||||
|
|
||||||
$(function() {
|
$(function() {
|
||||||
|
|
||||||
var sidebarUtil = (function() {
|
const sidebarUtil = (function () {
|
||||||
const ATTR_DISPLAY = "sidebar-display";
|
const ATTR_DISPLAY = "sidebar-display";
|
||||||
var isExpanded = false;
|
let isExpanded = false;
|
||||||
var body = $("body");
|
const body = $("body");
|
||||||
|
|
||||||
return {
|
return {
|
||||||
toggle() {
|
toggle() {
|
||||||
|
|
|
@ -8,10 +8,16 @@
|
||||||
|
|
||||||
$(function() {
|
$(function() {
|
||||||
|
|
||||||
var didScroll;
|
const topbarWrapper = $("#topbar-wrapper");
|
||||||
var lastScrollTop = 0;
|
const toc = $("#toc-wrapper");
|
||||||
var delta = 5;
|
const access = $(".access");
|
||||||
var topbarHeight = $("#topbar-wrapper").outerHeight();
|
const searchInput = $("#search-input");
|
||||||
|
|
||||||
|
let didScroll;
|
||||||
|
let lastScrollTop = 0;
|
||||||
|
|
||||||
|
const delta = 5;
|
||||||
|
const topbarHeight = topbarWrapper.outerHeight();
|
||||||
|
|
||||||
function hasScrolled() {
|
function hasScrolled() {
|
||||||
var st = $(this).scrollTop();
|
var st = $(this).scrollTop();
|
||||||
|
@ -23,30 +29,28 @@ $(function() {
|
||||||
|
|
||||||
if (st > lastScrollTop && st > topbarHeight) {
|
if (st > lastScrollTop && st > topbarHeight) {
|
||||||
/* Scroll Down */
|
/* Scroll Down */
|
||||||
$("#topbar-wrapper").removeClass("topbar-down").addClass("topbar-up");
|
topbarWrapper.removeClass("topbar-down").addClass("topbar-up");
|
||||||
|
|
||||||
if ($("#toc-wrapper").length > 0) {
|
if (toc.length > 0) {
|
||||||
$("#toc-wrapper").removeClass("topbar-down");
|
toc.removeClass("topbar-down");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($(".access").length > 0) {
|
if (access.length > 0) {
|
||||||
$(".access").removeClass("topbar-down");
|
access.removeClass("topbar-down");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($("#search-input").is(":focus")) {
|
if (searchInput.is(":focus")) {
|
||||||
$("#search-input").blur(); /* remove focus */
|
searchInput.blur(); /* remove focus */
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else if (st + $(window).height() < $(document).height()) {
|
||||||
/* Scroll Up */
|
/* Scroll Up */
|
||||||
if (st + $(window).height() < $(document).height()) {
|
topbarWrapper.removeClass("topbar-up").addClass("topbar-down");
|
||||||
$("#topbar-wrapper").removeClass("topbar-up").addClass("topbar-down");
|
if (toc.length > 0) {
|
||||||
if ($("#toc-wrapper").length > 0) {
|
toc.addClass("topbar-down");
|
||||||
$("#toc-wrapper").addClass("topbar-down");
|
}
|
||||||
}
|
if (access.length > 0) {
|
||||||
if ($(".access").length > 0) {
|
access.addClass("topbar-down");
|
||||||
$(".access").addClass("topbar-down");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,4 +70,4 @@ $(function() {
|
||||||
}
|
}
|
||||||
}, 250);
|
}, 250);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Topbar title auto change while scrolling in mobile screens.
|
* Top bar title auto change while scrolling in mobile screens.
|
||||||
* v2.0
|
* v2.0
|
||||||
* https://github.com/cotes2020/jekyll-theme-chirpy
|
* https://github.com/cotes2020/jekyll-theme-chirpy
|
||||||
* © 2018-2019 Cotes Chung
|
* © 2018-2019 Cotes Chung
|
||||||
|
@ -8,9 +8,13 @@
|
||||||
|
|
||||||
$(function() {
|
$(function() {
|
||||||
|
|
||||||
var DEFAULT = $("#topbar-title").text().trim();
|
const topbarTitle = $("#topbar-title");
|
||||||
var title = ($("div.post>h1").length > 0) ?
|
const postTitle = $("div.post>h1");
|
||||||
$("div.post>h1").text().trim() : $("h1").text().trim();
|
|
||||||
|
const DEFAULT = topbarTitle.text().trim();
|
||||||
|
|
||||||
|
let title = (postTitle.length > 0) ?
|
||||||
|
postTitle.text().trim() : $("h1").text().trim();
|
||||||
|
|
||||||
if ($("#page-category").length || $("#page-tag").length) {
|
if ($("#page-category").length || $("#page-tag").length) {
|
||||||
/* The title in Category or Tag page will be "<title> <count_of_posts>" */
|
/* The title in Category or Tag page will be "<title> <count_of_posts>" */
|
||||||
|
@ -22,26 +26,26 @@ $(function() {
|
||||||
/* Replace topbar title while scroll screens. */
|
/* Replace topbar title while scroll screens. */
|
||||||
$(window).scroll(function () {
|
$(window).scroll(function () {
|
||||||
if ($("#post-list").length /* in Home page */
|
if ($("#post-list").length /* in Home page */
|
||||||
|| $("div.post>h1").is(":hidden") /* is tab pages */
|
|| postTitle.is(":hidden") /* is tab pages */
|
||||||
|| $("#topbar-title").is(":hidden") /* not mobile screens */
|
|| topbarTitle.is(":hidden") /* not mobile screens */
|
||||||
|| $("#sidebar.sidebar-expand").length) { /* when the sidebar trigger is clicked */
|
|| $("#sidebar.sidebar-expand").length) { /* when the sidebar trigger is clicked */
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($(this).scrollTop() >= 95) {
|
if ($(this).scrollTop() >= 95) {
|
||||||
if ($("#topbar-title").text() !== title) {
|
if (topbarTitle.text() !== title) {
|
||||||
$("#topbar-title").text(title);
|
topbarTitle.text(title);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ($("#topbar-title").text() !== DEFAULT) {
|
if (topbarTitle.text() !== DEFAULT) {
|
||||||
$("#topbar-title").text(DEFAULT);
|
topbarTitle.text(DEFAULT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/* Click title remove hover effect. */
|
/* Click title remove hover effect. */
|
||||||
$("#topbar-title").click(function() {
|
topbarTitle.click(function() {
|
||||||
$("body,html").animate({scrollTop: 0}, 800);
|
$("body,html").animate({scrollTop: 0}, 800);
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,22 +0,0 @@
|
||||||
/*!
|
|
||||||
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 _pv-config.js %}
|
|
||||||
|
|
||||||
{% include_relative _utils/pageviews.js %}
|
|
||||||
|
|
||||||
{% include_relative lib/_countUp.min.js %}
|
|
||||||
|
|
||||||
{% endif %}
|
|
|
@ -1,16 +0,0 @@
|
||||||
/*!
|
|
||||||
PV configuration and Javascript conversion.
|
|
||||||
*/
|
|
||||||
|
|
||||||
const proxyEndpoint = "{{ site.google_analytics.pv.proxy_endpoint }}";
|
|
||||||
|
|
||||||
|
|
||||||
{% if site.google_analytics.pv.cache and site.google_analytics.pv.enabled %}
|
|
||||||
{% assign enabled = true %}
|
|
||||||
{% else %}
|
|
||||||
{% assign enabled = false %}
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
const pvCacheEnabled = {{ enabled }};
|
|
||||||
|
|
||||||
const pvCacheData = "{{ '/assets/js/data/pageviews.json' | relative_url }}";
|
|
|
@ -7,27 +7,28 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$(function() {
|
$(function() {
|
||||||
var childPrefix = "l_";
|
const childPrefix = "l_";
|
||||||
var parentPrefix = "h_";
|
const parentPrefix = "h_";
|
||||||
|
const collapse = $(".collapse");
|
||||||
|
|
||||||
/* close up top-category */
|
/* close up top-category */
|
||||||
$(".collapse").on("hide.bs.collapse", function() { /* Bootstrap collapse events. */
|
collapse.on("hide.bs.collapse", function () { /* Bootstrap collapse events. */
|
||||||
var parentId = parentPrefix + $(this).attr("id").substring(childPrefix.length);
|
const parentId = parentPrefix + $(this).attr("id").substring(childPrefix.length);
|
||||||
if (parentId) {
|
if (parentId) {
|
||||||
$("#" + parentId + " .far.fa-folder-open").attr("class", "far fa-folder fa-fw");
|
$(`#${parentId} .far.fa-folder-open`).attr("class", "far fa-folder fa-fw");
|
||||||
$("#" + parentId + " i.fas").addClass("rotate");
|
$(`#${parentId} i.fas`).addClass("rotate");
|
||||||
$("#" + parentId).removeClass("hide-border-bottom");
|
$(`#${parentId}`).removeClass("hide-border-bottom");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
/* expand the top category */
|
/* expand the top category */
|
||||||
$(".collapse").on("show.bs.collapse", function() {
|
collapse.on("show.bs.collapse", function() {
|
||||||
var parentId = parentPrefix + $(this).attr("id").substring(childPrefix.length);
|
const parentId = parentPrefix + $(this).attr("id").substring(childPrefix.length);
|
||||||
if (parentId) {
|
if (parentId) {
|
||||||
$("#" + parentId + " .far.fa-folder").attr("class", "far fa-folder-open fa-fw");
|
$(`#${parentId} .far.fa-folder`).attr("class", "far fa-folder-open fa-fw");
|
||||||
$("#" + parentId + " i.fas").removeClass("rotate");
|
$(`#${parentId} i.fas`).removeClass("rotate");
|
||||||
$("#" + parentId).addClass("hide-border-bottom");
|
$(`#${parentId}`).addClass("hide-border-bottom");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -8,9 +8,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$(function() {
|
$(function() {
|
||||||
|
const MARK = "img-hyperlink";
|
||||||
var MARK="img-hyperlink";
|
|
||||||
|
|
||||||
$("a:has(img)").addClass(MARK);
|
$("a:has(img)").addClass(MARK);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -7,11 +7,11 @@ $(function() {
|
||||||
const regex = new RegExp(`^${prefix}([a-z])+$`);
|
const regex = new RegExp(`^${prefix}([a-z])+$`);
|
||||||
|
|
||||||
$(`div[class^=${prefix}`).each(function() {
|
$(`div[class^=${prefix}`).each(function() {
|
||||||
let clzsses = $(this).attr("class").split(" ");
|
let classes = $(this).attr("class").split(" ");
|
||||||
|
|
||||||
clzsses.forEach((clzss) => {
|
classes.forEach((_class) => {
|
||||||
if (regex.test(clzss)) {
|
if (regex.test(_class)) {
|
||||||
let lang = clzss.substring(prefix.length);
|
let lang = _class.substring(prefix.length);
|
||||||
$(this).attr("lang", `${lang}`);
|
$(this).attr("lang", `${lang}`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* Count pageviews form GA or local cache file.
|
* Count page views form GA or local cache file.
|
||||||
*
|
*
|
||||||
* Dependences:
|
* Dependencies:
|
||||||
* - jQuery
|
* - jQuery
|
||||||
* - countUp.js <https://github.com/inorganik/countUp.js>
|
* - countUp.js <https://github.com/inorganik/countUp.js>
|
||||||
*
|
*
|
||||||
|
@ -11,8 +11,8 @@
|
||||||
* MIT License
|
* MIT License
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var getInitStatus = (function () {
|
const getInitStatus = (function () {
|
||||||
var hasInit = false;
|
let hasInit = false;
|
||||||
return () => {
|
return () => {
|
||||||
let ret = hasInit;
|
let ret = hasInit;
|
||||||
if (!hasInit) {
|
if (!hasInit) {
|
||||||
|
@ -22,13 +22,26 @@ var getInitStatus = (function () {
|
||||||
};
|
};
|
||||||
}());
|
}());
|
||||||
|
|
||||||
|
const PvOpts = (function () {
|
||||||
|
return {
|
||||||
|
isEnabled() {
|
||||||
|
return "true" === $("meta[name=pv-cache-enabled]").attr("content");
|
||||||
|
},
|
||||||
|
getProxyEndpoint() {
|
||||||
|
return $("meta[name=pv-proxy-endpoint]").attr("content");
|
||||||
|
},
|
||||||
|
getLocalData() {
|
||||||
|
return $("meta[name=pv-cache-data]").attr("content");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}());
|
||||||
|
|
||||||
var PvCache = (function () {
|
const PvCache = (function () {
|
||||||
const KEY_PV = "pv";
|
const KEY_PV = "pv";
|
||||||
const KEY_CREATION = "pv_created_date";
|
const KEY_CREATION = "pv_created_date";
|
||||||
const KEY_PV_SRC = "pv_source";
|
const KEY_PV_SRC = "pv_source";
|
||||||
|
|
||||||
var Source = {
|
const Source = {
|
||||||
ORIGIN: "origin",
|
ORIGIN: "origin",
|
||||||
PROXY: "proxy"
|
PROXY: "proxy"
|
||||||
};
|
};
|
||||||
|
@ -43,17 +56,18 @@ var PvCache = (function () {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
getData() {
|
getData() {
|
||||||
return JSON.parse(localStorage.getItem(KEY_PV) );
|
// get data from browser cache
|
||||||
|
return JSON.parse(localStorage.getItem(KEY_PV));
|
||||||
},
|
},
|
||||||
saveOriginCache(pv) {
|
saveOriginCache(pv) {
|
||||||
set(KEY_PV, pv);
|
set(KEY_PV, pv);
|
||||||
set(KEY_PV_SRC, Source.ORIGIN );
|
set(KEY_PV_SRC, Source.ORIGIN);
|
||||||
set(KEY_CREATION, new Date().toJSON() );
|
set(KEY_CREATION, new Date().toJSON());
|
||||||
},
|
},
|
||||||
saveProxyCache(pv) {
|
saveProxyCache(pv) {
|
||||||
set(KEY_PV, pv);
|
set(KEY_PV, pv);
|
||||||
set(KEY_PV_SRC, Source.PROXY );
|
set(KEY_PV_SRC, Source.PROXY);
|
||||||
set(KEY_CREATION, new Date().toJSON() );
|
set(KEY_CREATION, new Date().toJSON());
|
||||||
},
|
},
|
||||||
isFromOrigin() {
|
isFromOrigin() {
|
||||||
return get(KEY_PV_SRC) === Source.ORIGIN;
|
return get(KEY_PV_SRC) === Source.ORIGIN;
|
||||||
|
@ -62,23 +76,23 @@ var PvCache = (function () {
|
||||||
return get(KEY_PV_SRC) === Source.PROXY;
|
return get(KEY_PV_SRC) === Source.PROXY;
|
||||||
},
|
},
|
||||||
isExpired() {
|
isExpired() {
|
||||||
if (PvCache.isFromOrigin() ) {
|
if (PvCache.isFromOrigin()) {
|
||||||
let date = new Date(get(KEY_CREATION));
|
let date = new Date(get(KEY_CREATION));
|
||||||
date.setDate(date.getDate() + 1); /* update origin records every day */
|
date.setDate(date.getDate() + 1); /* update origin records every day */
|
||||||
return Date.now() >= date.getTime();
|
return Date.now() >= date.getTime();
|
||||||
|
|
||||||
} else if (PvCache.isFromProxy() ) {
|
} else if (PvCache.isFromProxy()) {
|
||||||
let date = new Date(get(KEY_CREATION) );
|
let date = new Date(get(KEY_CREATION));
|
||||||
date.setHours(date.getHours() + 1); /* update proxy records per hour */
|
date.setHours(date.getHours() + 1); /* update proxy records per hour */
|
||||||
return Date.now() >= date.getTime();
|
return Date.now() >= date.getTime();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
getAllPagevies() {
|
getAllPageviews() {
|
||||||
return PvCache.getData().totalsForAllResults["ga:pageviews"];
|
return PvCache.getData().totalsForAllResults["ga:pageviews"];
|
||||||
},
|
},
|
||||||
newerThan(pv) {
|
newerThan(pv) {
|
||||||
return PvCache.getAllPagevies() > pv.totalsForAllResults["ga:pageviews"];
|
return PvCache.getAllPageviews() > pv.totalsForAllResults["ga:pageviews"];
|
||||||
},
|
},
|
||||||
inspectKeys() {
|
inspectKeys() {
|
||||||
if (localStorage.getItem(KEY_PV) === null
|
if (localStorage.getItem(KEY_PV) === null
|
||||||
|
@ -91,9 +105,10 @@ var PvCache = (function () {
|
||||||
|
|
||||||
}()); /* PvCache */
|
}()); /* PvCache */
|
||||||
|
|
||||||
|
|
||||||
function countUp(min, max, destId) {
|
function countUp(min, max, destId) {
|
||||||
if (min < max) {
|
if (min < max) {
|
||||||
var numAnim = new CountUp(destId, min, max);
|
let numAnim = new CountUp(destId, min, max);
|
||||||
if (!numAnim.error) {
|
if (!numAnim.error) {
|
||||||
numAnim.start();
|
numAnim.start();
|
||||||
} else {
|
} else {
|
||||||
|
@ -104,11 +119,11 @@ function countUp(min, max, destId) {
|
||||||
|
|
||||||
|
|
||||||
function countPV(path, rows) {
|
function countPV(path, rows) {
|
||||||
var count = 0;
|
let count = 0;
|
||||||
|
|
||||||
if (typeof rows !== "undefined" ) {
|
if (typeof rows !== "undefined" ) {
|
||||||
for (var i = 0; i < rows.length; ++i) {
|
for (let i = 0; i < rows.length; ++i) {
|
||||||
var gaPath = rows[parseInt(i, 10)][0];
|
const gaPath = rows[parseInt(i, 10)][0];
|
||||||
if (gaPath === path) { /* path format see: site.permalink */
|
if (gaPath === path) { /* path format see: site.permalink */
|
||||||
count += parseInt(rows[parseInt(i, 10)][1], 10);
|
count += parseInt(rows[parseInt(i, 10)][1], 10);
|
||||||
break;
|
break;
|
||||||
|
@ -121,13 +136,13 @@ function countPV(path, rows) {
|
||||||
|
|
||||||
|
|
||||||
function tacklePV(rows, path, elem, hasInit) {
|
function tacklePV(rows, path, elem, hasInit) {
|
||||||
var count = countPV(path, rows);
|
let count = countPV(path, rows);
|
||||||
count = (count === 0 ? 1 : count);
|
count = (count === 0 ? 1 : count);
|
||||||
|
|
||||||
if (!hasInit) {
|
if (!hasInit) {
|
||||||
elem.text(new Intl.NumberFormat().format(count));
|
elem.text(new Intl.NumberFormat().format(count));
|
||||||
} else {
|
} else {
|
||||||
var initCount = parseInt(elem.text().replace(/,/g, ""), 10);
|
const initCount = parseInt(elem.text().replace(/,/g, ""), 10);
|
||||||
if (count > initCount) {
|
if (count > initCount) {
|
||||||
countUp(initCount, count, elem.attr("id"));
|
countUp(initCount, count, elem.attr("id"));
|
||||||
}
|
}
|
||||||
|
@ -140,17 +155,17 @@ function displayPageviews(data) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var hasInit = getInitStatus();
|
let hasInit = getInitStatus();
|
||||||
var rows = data.rows; /* could be undefined */
|
const rows = data.rows; /* could be undefined */
|
||||||
|
|
||||||
if ($("#post-list").length > 0) { /* the Home page */
|
if ($("#post-list").length > 0) { /* the Home page */
|
||||||
$(".post-preview").each(function() {
|
$(".post-preview").each(function() {
|
||||||
var path = $(this).find("a").attr("href");
|
const path = $(this).find("a").attr("href");
|
||||||
tacklePV(rows, path, $(this).find(".pageviews"), hasInit);
|
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;
|
const path = window.location.pathname;
|
||||||
tacklePV(rows, path, $("#pv"), hasInit);
|
tacklePV(rows, path, $("#pv"), hasInit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -159,7 +174,7 @@ function displayPageviews(data) {
|
||||||
function fetchProxyPageviews() {
|
function fetchProxyPageviews() {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "GET",
|
type: "GET",
|
||||||
url: proxyEndpoint, /* see: /assets/js/_pv-config.js */
|
url: PvOpts.getProxyEndpoint(),
|
||||||
dataType: "jsonp",
|
dataType: "jsonp",
|
||||||
jsonpCallback: "displayPageviews",
|
jsonpCallback: "displayPageviews",
|
||||||
success: (data, textStatus, jqXHR) => {
|
success: (data, textStatus, jqXHR) => {
|
||||||
|
@ -173,9 +188,8 @@ function fetchProxyPageviews() {
|
||||||
|
|
||||||
|
|
||||||
function fetchPageviews(fetchOrigin = true, filterOrigin = false) {
|
function fetchPageviews(fetchOrigin = true, filterOrigin = false) {
|
||||||
/* pvCacheEnabled, pvCacheData › see: /assets/js/_pv-config.js */
|
if (PvOpts.isEnabled() && fetchOrigin) {
|
||||||
if (pvCacheEnabled && fetchOrigin) {
|
fetch(PvOpts.getLocalData())
|
||||||
fetch(pvCacheData)
|
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
if (filterOrigin) {
|
if (filterOrigin) {
|
||||||
|
@ -196,9 +210,7 @@ function fetchPageviews(fetchOrigin = true, filterOrigin = false) {
|
||||||
|
|
||||||
|
|
||||||
$(function() {
|
$(function() {
|
||||||
|
|
||||||
if ($(".pageviews").length > 0) {
|
if ($(".pageviews").length > 0) {
|
||||||
|
|
||||||
PvCache.inspectKeys();
|
PvCache.inspectKeys();
|
||||||
let cache = PvCache.getData();
|
let cache = PvCache.getData();
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
/*
|
/*
|
||||||
Safari doesn't support CSS `scroll-behavior: smooth`,
|
Safari doesn't support CSS `scroll-behavior: smooth`,
|
||||||
so here is a compatible sollution for all browser to smooth scrolling
|
so here is a compatible solution for all browser to smooth scrolling
|
||||||
|
|
||||||
See: <https://css-tricks.com/snippets/jquery/smooth-scrolling/>
|
See: <https://css-tricks.com/snippets/jquery/smooth-scrolling/>
|
||||||
|
|
||||||
|
@ -13,66 +13,67 @@ $(function() {
|
||||||
.not("[href='#0']")
|
.not("[href='#0']")
|
||||||
.click(function(event) {
|
.click(function(event) {
|
||||||
|
|
||||||
if (location.pathname.replace(/^\//, "") === this.pathname.replace(/^\//, "")
|
if (this.pathname.replace(/^\//, "") === location.pathname.replace(/^\//, "")) {
|
||||||
&& location.hostname === this.hostname) {
|
if (location.hostname === this.hostname) {
|
||||||
|
|
||||||
const REM = 16; /* 16px */
|
const REM = 16; /* 16px */
|
||||||
|
|
||||||
const hash = decodeURI(this.hash);
|
const hash = decodeURI(this.hash);
|
||||||
let isFnRef = RegExp(/^#fnref:/).test(hash);
|
let isFnRef = RegExp(/^#fnref:/).test(hash);
|
||||||
let isFn = RegExp(/^#fn:/).test(hash);
|
let isFn = RegExp(/^#fn:/).test(hash);
|
||||||
let selector = hash.includes(":") ? hash.replace(/\:/, "\\:") : hash;
|
let selector = hash.includes(":") ? hash.replace(/\:/, "\\:") : hash;
|
||||||
const target = $(selector);
|
let target = $(selector);
|
||||||
|
|
||||||
if (target.length) {
|
if (target.length) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
|
||||||
if (history.pushState) { /* add hash to URL */
|
if (history.pushState) { /* add hash to URL */
|
||||||
history.pushState(null, null, hash);
|
history.pushState(null, null, hash);
|
||||||
|
}
|
||||||
|
|
||||||
|
let curOffset = $(this).offset().top;
|
||||||
|
let destOffset = target.offset().top;
|
||||||
|
const scrollUp = (destOffset < curOffset);
|
||||||
|
const topbarHeight = $("#topbar-wrapper").outerHeight();
|
||||||
|
|
||||||
|
if (scrollUp && isFnRef) {
|
||||||
|
/* Avoid the top-bar covering `fnref` when scrolling up
|
||||||
|
because `fnref` has no `%anchor`(see: module.scss) style. */
|
||||||
|
destOffset -= (topbarHeight + REM / 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
$("html,body").animate({
|
||||||
|
scrollTop: destOffset
|
||||||
|
}, 800, () => {
|
||||||
|
|
||||||
|
const $target = $(target);
|
||||||
|
$target.focus();
|
||||||
|
|
||||||
|
const SCROLL_MARK = "scroll-focus";
|
||||||
|
|
||||||
|
/* clean up old scroll mark */
|
||||||
|
if ($(`[${SCROLL_MARK}=true]`).length) {
|
||||||
|
$(`[${SCROLL_MARK}=true]`).attr(SCROLL_MARK, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Clean :target links */
|
||||||
|
if ($(":target").length) { /* element that visited by the URL with hash */
|
||||||
|
$(":target").attr(SCROLL_MARK, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* set scroll mark to footnotes */
|
||||||
|
if (isFn || isFnRef) {
|
||||||
|
$target.attr(SCROLL_MARK, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($target.is(":focus")) { /* Checking if the target was focused */
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
$target.attr("tabindex", "-1"); /* Adding tabindex for elements not focusable */
|
||||||
|
$target.focus(); /* Set focus again */
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
let curOffset = $(this).offset().top;
|
|
||||||
let destOffset = target.offset().top;
|
|
||||||
const scrollUp = (destOffset < curOffset);
|
|
||||||
const topbarHeight = $("#topbar-wrapper").outerHeight();
|
|
||||||
|
|
||||||
if (scrollUp && isFnRef) {
|
|
||||||
/* Avoid the top-bar covering `fnref` when scrolling up
|
|
||||||
because `fnref` has no `%anchor`(see: module.scss) style. */
|
|
||||||
destOffset -= (topbarHeight + REM / 2);
|
|
||||||
}
|
|
||||||
|
|
||||||
$("html,body").animate({
|
|
||||||
scrollTop: destOffset
|
|
||||||
}, 800, () => {
|
|
||||||
|
|
||||||
var $target = $(target);
|
|
||||||
$target.focus();
|
|
||||||
|
|
||||||
const SCROLL_MARK = "scroll-focus";
|
|
||||||
|
|
||||||
/* clean up old scroll mark */
|
|
||||||
if ($(`[${ SCROLL_MARK }=true]`).length) {
|
|
||||||
$(`[${ SCROLL_MARK }=true]`).attr(SCROLL_MARK, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Clean :target links */
|
|
||||||
if ($(":target").length) { /* element that visited by the URL with hash */
|
|
||||||
$(":target").attr(SCROLL_MARK, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* set scroll mark to footnotes */
|
|
||||||
if (isFn || isFnRef) {
|
|
||||||
$target.attr(SCROLL_MARK, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($target.is(":focus")) { /* Checking if the target was focused */
|
|
||||||
return false;
|
|
||||||
} else {
|
|
||||||
$target.attr("tabindex", "-1"); /* Adding tabindex for elements not focusable */
|
|
||||||
$target.focus(); /* Set focus again */
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Caculate the Timeago
|
* Calculate the Timeago
|
||||||
* v2.0
|
* v2.0
|
||||||
* https://github.com/cotes2020/jekyll-theme-chirpy
|
* https://github.com/cotes2020/jekyll-theme-chirpy
|
||||||
* © 2019 Cotes Chung
|
* © 2019 Cotes Chung
|
||||||
|
@ -8,9 +8,11 @@
|
||||||
|
|
||||||
$(function() {
|
$(function() {
|
||||||
|
|
||||||
var toRefresh = $(".timeago").length;
|
const timeagoElem = $(".timeago");
|
||||||
|
|
||||||
var intervalId = void 0;
|
let toRefresh = timeagoElem.length;
|
||||||
|
|
||||||
|
let intervalId = void 0;
|
||||||
|
|
||||||
function timeago(iso, isLastmod) {
|
function timeago(iso, isLastmod) {
|
||||||
let now = new Date();
|
let now = new Date();
|
||||||
|
@ -57,10 +59,10 @@ $(function() {
|
||||||
function updateTimeago() {
|
function updateTimeago() {
|
||||||
$(".timeago").each(function() {
|
$(".timeago").each(function() {
|
||||||
if ($(this).children("i").length > 0) {
|
if ($(this).children("i").length > 0) {
|
||||||
var basic = $(this).text();
|
$(this).text();
|
||||||
var isLastmod = $(this).hasClass("lastmod");
|
let isLastmod = $(this).hasClass("lastmod");
|
||||||
var node = $(this).children("i");
|
let node = $(this).children("i");
|
||||||
var date = node.text(); /* ISO Date: "YYYY-MM-DDTHH:MM:SSZ" */
|
let date = node.text(); /* ISO Date: "YYYY-MM-DDTHH:MM:SSZ" */
|
||||||
$(this).text(timeago(date, isLastmod));
|
$(this).text(timeago(date, isLastmod));
|
||||||
$(this).append(node);
|
$(this).append(node);
|
||||||
}
|
}
|
||||||
|
|
13
assets/js/categories.min.js
vendored
13
assets/js/categories.min.js
vendored
|
@ -1,13 +0,0 @@
|
||||||
---
|
|
||||||
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 %}
|
|
|
@ -11,22 +11,13 @@ layout: compress
|
||||||
const include = [
|
const include = [
|
||||||
|
|
||||||
/*--- CSS ---*/
|
/*--- CSS ---*/
|
||||||
|
'{{ "/assets/css/style.css" | relative_url }}',
|
||||||
'{{ "/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 ---*/
|
/*--- Javascripts ---*/
|
||||||
|
'{{ "/assets/js/dist/home.min.js" | relative_url }}',
|
||||||
'{{ "/assets/js/home.min.js" | relative_url }}',
|
'{{ "/assets/js/dist/page.min.js" | relative_url }}',
|
||||||
'{{ "/assets/js/page.min.js" | relative_url }}',
|
'{{ "/assets/js/dist/post.min.js" | relative_url }}',
|
||||||
'{{ "/assets/js/post.min.js" | relative_url }}',
|
'{{ "/assets/js/dist/categories.min.js" | relative_url }}',
|
||||||
'{{ "/assets/js/categories.min.js" | relative_url }}',
|
|
||||||
|
|
||||||
/*--- HTML ---*/
|
/*--- HTML ---*/
|
||||||
|
|
||||||
|
|
1
assets/js/dist/categories.min.js
vendored
Normal file
1
assets/js/dist/categories.min.js
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
function copyLink(e){e&&0!==e.length||(e=window.location.href);const o=$("<input>");$("body").append(o),o.val(e).select(),document.execCommand("copy"),o.remove(),alert("Link copied successfully!")}$(function(){$(window).scroll(()=>{$(this).scrollTop()>50&&"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(){$("input[type=checkbox]").addClass("unloaded"),$("input[type=checkbox][checked]").before('<i class="fas fa-check-circle checked"></i>'),$("input[type=checkbox]:not([checked])").before('<i class="far fa-circle"></i>')}),$(function(){const e=$("#sidebar-trigger"),o=$("#search-trigger"),s=$("#search-cancel"),t=$("#search-cleaner"),a=$("#main"),l=$("#topbar-title"),n=$("#search-wrapper"),d=$("#search-result-wrapper"),r=$("#search-results"),c=$("#search-input"),i=$("#search-hints"),f=function(){let e=0;return{block(){e=$(window).scrollTop()},release(){$("html,body").scrollTop(e)},getOffset:()=>e}}(),u={on(){e.addClass("unloaded"),l.addClass("unloaded"),o.addClass("unloaded"),n.addClass("d-flex"),s.addClass("loaded")},off(){s.removeClass("loaded"),n.removeClass("d-flex"),e.removeClass("unloaded"),l.removeClass("unloaded"),o.removeClass("unloaded")}},p=function(){let e=!1;return{on(){e||(d.removeClass("unloaded"),a.addClass("hidden"),e=!0,f.block())},off(){e&&(r.empty(),i.hasClass("unloaded")&&i.removeClass("unloaded"),d.addClass("unloaded"),t.removeClass("visible"),a.removeClass("hidden"),c.val(""),e=!1,f.release())},isVisible:()=>e}}();function h(){return s.hasClass("loaded")}o.click(function(){u.on(),p.on(),c.focus()}),s.click(function(){u.off(),p.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()?i.removeClass("unloaded"):p.off():""!==c.val()&&(p.on(),t.hasClass("visible")||t.addClass("visible"),h()&&i.addClass("unloaded"))}),t.on("click",function(){c.val(""),h()?(i.removeClass("unloaded"),r.empty()):p.off(),c.focus(),t.removeClass("visible")})}),$(function(){const e=function(){let e=!1;const o=$("body");return{toggle(){!1===e?o.attr("sidebar-display",""):o.removeAttr("sidebar-display"),e=!e}}}();$("#sidebar-trigger").click(e.toggle),$("#mask").click(e.toggle)}),$(function(){$('[data-toggle="tooltip"]').tooltip()}),$(function(){const e=$("#topbar-wrapper"),o=$("#toc-wrapper"),s=$(".access"),t=$("#search-input");let a,l=0;const n=5,d=e.outerHeight();$(window).scroll(function(e){$("#topbar-title").is(":hidden")&&(a=!0)}),setInterval(function(){a&&(!function(){var a=$(this).scrollTop();Math.abs(l-a)<=n||(a>l&&a>d?(e.removeClass("topbar-down").addClass("topbar-up"),o.length>0&&o.removeClass("topbar-down"),s.length>0&&s.removeClass("topbar-down"),t.is(":focus")&&t.blur()):a+$(window).height()<$(document).height()&&(e.removeClass("topbar-up").addClass("topbar-down"),o.length>0&&o.addClass("topbar-down"),s.length>0&&s.addClass("topbar-down")),l=a)}(),a=!1)},250)}),$(function(){const e=$("#topbar-title"),o=$("div.post>h1"),s=e.text().trim();let t=o.length>0?o.text().trim():$("h1").text().trim();($("#page-category").length||$("#page-tag").length)&&/\s/.test(t)&&(t=t.replace(/[0-9]/g,"").trim()),$(window).scroll(function(){if($("#post-list").length||o.is(":hidden")||e.is(":hidden")||$("#sidebar.sidebar-expand").length)return!1;$(this).scrollTop()>=95?e.text()!==t&&e.text(t):e.text()!==s&&e.text(s)}),e.click(function(){$("body,html").animate({scrollTop:0},800)})}),$(function(){const e=$(".collapse");e.on("hide.bs.collapse",function(){const e="h_"+$(this).attr("id").substring("l_".length);e&&($(`#${e} .far.fa-folder-open`).attr("class","far fa-folder fa-fw"),$(`#${e} i.fas`).addClass("rotate"),$(`#${e}`).removeClass("hide-border-bottom"))}),e.on("show.bs.collapse",function(){const e="h_"+$(this).attr("id").substring("l_".length);e&&($(`#${e} .far.fa-folder`).attr("class","far fa-folder-open fa-fw"),$(`#${e} i.fas`).removeClass("rotate"),$(`#${e}`).addClass("hide-border-bottom"))})});
|
1
assets/js/dist/home.min.js
vendored
Normal file
1
assets/js/dist/home.min.js
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
function copyLink(e){e&&0!==e.length||(e=window.location.href);const t=$("<input>");$("body").append(t),t.val(e).select(),document.execCommand("copy"),t.remove(),alert("Link copied successfully!")}$(function(){$(window).scroll(()=>{$(this).scrollTop()>50&&"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(){$("input[type=checkbox]").addClass("unloaded"),$("input[type=checkbox][checked]").before('<i class="fas fa-check-circle checked"></i>'),$("input[type=checkbox]:not([checked])").before('<i class="far fa-circle"></i>')}),$(function(){const e=$("#sidebar-trigger"),t=$("#search-trigger"),o=$("#search-cancel"),a=$("#search-cleaner"),s=$("#main"),n=$("#topbar-title"),l=$("#search-wrapper"),i=$("#search-result-wrapper"),r=$("#search-results"),c=$("#search-input"),d=$("#search-hints"),u=function(){let e=0;return{block(){e=$(window).scrollTop()},release(){$("html,body").scrollTop(e)},getOffset:()=>e}}(),h={on(){e.addClass("unloaded"),n.addClass("unloaded"),t.addClass("unloaded"),l.addClass("d-flex"),o.addClass("loaded")},off(){o.removeClass("loaded"),l.removeClass("d-flex"),e.removeClass("unloaded"),n.removeClass("unloaded"),t.removeClass("unloaded")}},f=function(){let e=!1;return{on(){e||(i.removeClass("unloaded"),s.addClass("hidden"),e=!0,u.block())},off(){e&&(r.empty(),d.hasClass("unloaded")&&d.removeClass("unloaded"),i.addClass("unloaded"),a.removeClass("visible"),s.removeClass("hidden"),c.val(""),e=!1,u.release())},isVisible:()=>e}}();function p(){return o.hasClass("loaded")}t.click(function(){h.on(),f.on(),c.focus()}),o.click(function(){h.off(),f.off()}),c.focus(function(){l.addClass("input-focus")}),c.focusout(function(){l.removeClass("input-focus")}),c.on("keyup",function(e){8===e.keyCode&&""===c.val()?p()?d.removeClass("unloaded"):f.off():""!==c.val()&&(f.on(),a.hasClass("visible")||a.addClass("visible"),p()&&d.addClass("unloaded"))}),a.on("click",function(){c.val(""),p()?(d.removeClass("unloaded"),r.empty()):f.off(),c.focus(),a.removeClass("visible")})}),$(function(){const e=function(){let e=!1;const t=$("body");return{toggle(){!1===e?t.attr("sidebar-display",""):t.removeAttr("sidebar-display"),e=!e}}}();$("#sidebar-trigger").click(e.toggle),$("#mask").click(e.toggle)}),$(function(){$('[data-toggle="tooltip"]').tooltip()}),$(function(){const e=$("#topbar-wrapper"),t=$("#toc-wrapper"),o=$(".access"),a=$("#search-input");let s,n=0;const l=5,i=e.outerHeight();$(window).scroll(function(e){$("#topbar-title").is(":hidden")&&(s=!0)}),setInterval(function(){s&&(!function(){var s=$(this).scrollTop();Math.abs(n-s)<=l||(s>n&&s>i?(e.removeClass("topbar-down").addClass("topbar-up"),t.length>0&&t.removeClass("topbar-down"),o.length>0&&o.removeClass("topbar-down"),a.is(":focus")&&a.blur()):s+$(window).height()<$(document).height()&&(e.removeClass("topbar-up").addClass("topbar-down"),t.length>0&&t.addClass("topbar-down"),o.length>0&&o.addClass("topbar-down")),n=s)}(),s=!1)},250)}),$(function(){const e=$("#topbar-title"),t=$("div.post>h1"),o=e.text().trim();let a=t.length>0?t.text().trim():$("h1").text().trim();($("#page-category").length||$("#page-tag").length)&&/\s/.test(a)&&(a=a.replace(/[0-9]/g,"").trim()),$(window).scroll(function(){if($("#post-list").length||t.is(":hidden")||e.is(":hidden")||$("#sidebar.sidebar-expand").length)return!1;$(this).scrollTop()>=95?e.text()!==a&&e.text(a):e.text()!==o&&e.text(o)}),e.click(function(){$("body,html").animate({scrollTop:0},800)})}),$(function(){let e=$(".timeago").length,t=void 0;function o(){return $(".timeago").each(function(){if($(this).children("i").length>0){$(this).text();let t=$(this).hasClass("lastmod"),o=$(this).children("i"),a=o.text();$(this).text(function(t,o){let a=new Date,s=new Date(t);if(s.getFullYear()!==a.getFullYear())return e-=1,s.toLocaleString("en-US",{year:"numeric",month:"short",day:"numeric"});if(s.getMonth()!==a.getMonth())return e-=1,s.toLocaleString("en-US",{month:"short",day:"numeric"});let n=Math.floor((a-s)/1e3),l=Math.floor(n/86400);if(l>=1)return e-=1,l+" day"+(l>1?"s":"")+" ago";let i=Math.floor(n/3600);if(i>=1)return i+" hour"+(i>1?"s":"")+" ago";let r=Math.floor(n/60);return r>=1?r+" minute"+(r>1?"s":"")+" ago":(o?"just":"Just")+" now"}(a,t)),$(this).append(o)}}),0===e&&void 0!==t&&clearInterval(t),e}0!==e&&o()>0&&(t=setInterval(o,6e4))});
|
1
assets/js/dist/page.min.js
vendored
Normal file
1
assets/js/dist/page.min.js
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
function copyLink(e){e&&0!==e.length||(e=window.location.href);const t=$("<input>");$("body").append(t),t.val(e).select(),document.execCommand("copy"),t.remove(),alert("Link copied successfully!")}$(function(){$(window).scroll(()=>{$(this).scrollTop()>50&&"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(){$("input[type=checkbox]").addClass("unloaded"),$("input[type=checkbox][checked]").before('<i class="fas fa-check-circle checked"></i>'),$("input[type=checkbox]:not([checked])").before('<i class="far fa-circle"></i>')}),$(function(){const e=$("#sidebar-trigger"),t=$("#search-trigger"),o=$("#search-cancel"),s=$("#search-cleaner"),a=$("#main"),l=$("#topbar-title"),n=$("#search-wrapper"),c=$("#search-result-wrapper"),r=$("#search-results"),i=$("#search-input"),d=$("#search-hints"),u=function(){let e=0;return{block(){e=$(window).scrollTop()},release(){$("html,body").scrollTop(e)},getOffset:()=>e}}(),f={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")}},p=function(){let e=!1;return{on(){e||(c.removeClass("unloaded"),a.addClass("hidden"),e=!0,u.block())},off(){e&&(r.empty(),d.hasClass("unloaded")&&d.removeClass("unloaded"),c.addClass("unloaded"),s.removeClass("visible"),a.removeClass("hidden"),i.val(""),e=!1,u.release())},isVisible:()=>e}}();function h(){return o.hasClass("loaded")}t.click(function(){f.on(),p.on(),i.focus()}),o.click(function(){f.off(),p.off()}),i.focus(function(){n.addClass("input-focus")}),i.focusout(function(){n.removeClass("input-focus")}),i.on("keyup",function(e){8===e.keyCode&&""===i.val()?h()?d.removeClass("unloaded"):p.off():""!==i.val()&&(p.on(),s.hasClass("visible")||s.addClass("visible"),h()&&d.addClass("unloaded"))}),s.on("click",function(){i.val(""),h()?(d.removeClass("unloaded"),r.empty()):p.off(),i.focus(),s.removeClass("visible")})}),$(function(){const e=function(){let e=!1;const t=$("body");return{toggle(){!1===e?t.attr("sidebar-display",""):t.removeAttr("sidebar-display"),e=!e}}}();$("#sidebar-trigger").click(e.toggle),$("#mask").click(e.toggle)}),$(function(){$('[data-toggle="tooltip"]').tooltip()}),$(function(){const e=$("#topbar-wrapper"),t=$("#toc-wrapper"),o=$(".access"),s=$("#search-input");let a,l=0;const n=5,c=e.outerHeight();$(window).scroll(function(e){$("#topbar-title").is(":hidden")&&(a=!0)}),setInterval(function(){a&&(!function(){var a=$(this).scrollTop();Math.abs(l-a)<=n||(a>l&&a>c?(e.removeClass("topbar-down").addClass("topbar-up"),t.length>0&&t.removeClass("topbar-down"),o.length>0&&o.removeClass("topbar-down"),s.is(":focus")&&s.blur()):a+$(window).height()<$(document).height()&&(e.removeClass("topbar-up").addClass("topbar-down"),t.length>0&&t.addClass("topbar-down"),o.length>0&&o.addClass("topbar-down")),l=a)}(),a=!1)},250)}),$(function(){const e=$("#topbar-title"),t=$("div.post>h1"),o=e.text().trim();let s=t.length>0?t.text().trim():$("h1").text().trim();($("#page-category").length||$("#page-tag").length)&&/\s/.test(s)&&(s=s.replace(/[0-9]/g,"").trim()),$(window).scroll(function(){if($("#post-list").length||t.is(":hidden")||e.is(":hidden")||$("#sidebar.sidebar-expand").length)return!1;$(this).scrollTop()>=95?e.text()!==s&&e.text(s):e.text()!==o&&e.text(o)}),e.click(function(){$("body,html").animate({scrollTop:0},800)})}),$(function(){$("a[href*='#']").not("[href='#']").not("[href='#0']").click(function(e){if(this.pathname.replace(/^\//,"")===location.pathname.replace(/^\//,"")&&location.hostname===this.hostname){const t=16,o=decodeURI(this.hash);let s=RegExp(/^#fnref:/).test(o),a=RegExp(/^#fn:/).test(o),l=o.includes(":")?o.replace(/\:/,"\\:"):o,n=$(l);if(n.length){e.preventDefault(),history.pushState&&history.pushState(null,null,o);let l=$(this).offset().top,c=n.offset().top;const r=c<l,i=$("#topbar-wrapper").outerHeight();r&&s&&(c-=i+t/2),$("html,body").animate({scrollTop:c},800,()=>{const e=$(n);e.focus();if($("[scroll-focus=true]").length&&$("[scroll-focus=true]").attr("scroll-focus",!1),$(":target").length&&$(":target").attr("scroll-focus",!1),(a||s)&&e.attr("scroll-focus",!0),e.is(":focus"))return!1;e.attr("tabindex","-1"),e.focus()})}}})});
|
1
assets/js/dist/post.min.js
vendored
Normal file
1
assets/js/dist/post.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
assets/js/dist/pvreport.min.js
vendored
Normal file
1
assets/js/dist/pvreport.min.js
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
const getInitStatus=function(){let e=!1;return()=>{let t=e;return e||(e=!0),t}}(),PvOpts={isEnabled:()=>"true"===$("meta[name=pv-cache-enabled]").attr("content"),getProxyEndpoint:()=>$("meta[name=pv-proxy-endpoint]").attr("content"),getLocalData:()=>$("meta[name=pv-cache-data]").attr("content")},PvCache=function(){const e="origin",t="proxy";function a(e){return localStorage.getItem(e)}function n(e,t){localStorage.setItem(e,t)}return{getData:()=>JSON.parse(localStorage.getItem("pv")),saveOriginCache(t){n("pv",t),n("pv_source",e),n("pv_created_date",(new Date).toJSON())},saveProxyCache(e){n("pv",e),n("pv_source",t),n("pv_created_date",(new Date).toJSON())},isFromOrigin:()=>a("pv_source")===e,isFromProxy:()=>a("pv_source")===t,isExpired(){if(PvCache.isFromOrigin()){let e=new Date(a("pv_created_date"));return e.setDate(e.getDate()+1),Date.now()>=e.getTime()}if(PvCache.isFromProxy()){let e=new Date(a("pv_created_date"));return e.setHours(e.getHours()+1),Date.now()>=e.getTime()}return!1},getAllPageviews:()=>PvCache.getData().totalsForAllResults["ga:pageviews"],newerThan:e=>PvCache.getAllPageviews()>e.totalsForAllResults["ga:pageviews"],inspectKeys(){null!==localStorage.getItem("pv")&&null!==localStorage.getItem("pv_source")&&null!==localStorage.getItem("pv_created_date")||localStorage.clear()}}}();function countUp(e,t,a){if(e<t){let n=new CountUp(a,e,t);n.error?console.error(n.error):n.start()}}function countPV(e,t){let a=0;if(void 0!==t)for(let n=0;n<t.length;++n){if(t[parseInt(n,10)][0]===e){a+=parseInt(t[parseInt(n,10)][1],10);break}}return a}function tacklePV(e,t,a,n){let r=countPV(t,e);if(r=0===r?1:r,n){const e=parseInt(a.text().replace(/,/g,""),10);r>e&&countUp(e,r,a.attr("id"))}else a.text((new Intl.NumberFormat).format(r))}function displayPageviews(e){if(void 0===e)return;let t=getInitStatus();const a=e.rows;if($("#post-list").length>0)$(".post-preview").each(function(){const e=$(this).find("a").attr("href");tacklePV(a,e,$(this).find(".pageviews"),t)});else if($(".post").length>0){const e=window.location.pathname;tacklePV(a,e,$("#pv"),t)}}function fetchProxyPageviews(){$.ajax({type:"GET",url:PvOpts.getProxyEndpoint(),dataType:"jsonp",jsonpCallback:"displayPageviews",success:(e,t,a)=>{PvCache.saveProxyCache(JSON.stringify(e))},error:(e,t,a)=>{console.log("Failed to load pageviews from proxy server: "+a)}})}function fetchPageviews(e=!0,t=!1){PvOpts.isEnabled()&&e?fetch(PvOpts.getLocalData()).then(e=>e.json()).then(e=>{t&&PvCache.newerThan(e)||(displayPageviews(e),PvCache.saveOriginCache(JSON.stringify(e)))}).then(()=>fetchProxyPageviews()):fetchProxyPageviews()}$(function(){if($(".pageviews").length>0){PvCache.inspectKeys();let e=PvCache.getData();e?(displayPageviews(e),PvCache.isExpired()?fetchPageviews(!0,PvCache.isFromProxy()):PvCache.isFromOrigin()&&fetchPageviews(!1)):fetchPageviews()}});
|
11
assets/js/home.min.js
vendored
11
assets/js/home.min.js
vendored
|
@ -1,11 +0,0 @@
|
||||||
---
|
|
||||||
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
5
assets/js/lib/_bootstrap-toc.min.js
vendored
|
@ -1,5 +0,0 @@
|
||||||
/*!
|
|
||||||
* 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
2
assets/js/lib/_countUp.min.js
vendored
|
@ -1,2 +0,0 @@
|
||||||
/*! 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)}};
|
|
13
assets/js/page.min.js
vendored
13
assets/js/page.min.js
vendored
|
@ -1,13 +0,0 @@
|
||||||
---
|
|
||||||
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 %}
|
|
||||||
|
|
||||||
{% include_relative _utils/smooth-scroll.js %}
|
|
20
assets/js/post.min.js
vendored
20
assets/js/post.min.js
vendored
|
@ -1,20 +0,0 @@
|
||||||
---
|
|
||||||
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 %}
|
|
||||||
|
|
||||||
{% include_relative lib/_bootstrap-toc.min.js %}
|
|
||||||
|
|
||||||
{% include_relative _utils/img-hyperlink.js %}
|
|
||||||
|
|
||||||
{% include_relative _utils/lang-badge.js %}
|
|
||||||
|
|
||||||
{% comment %} `smooth-scroll.js` must be called after ToC is ready {% endcomment %}
|
|
||||||
{% include_relative _utils/smooth-scroll.js %}
|
|
10
gulpfile.js/index.js
Normal file
10
gulpfile.js/index.js
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
const js = require('./tasks/js');
|
||||||
|
|
||||||
|
exports.default = js.build;
|
||||||
|
|
||||||
|
/* keep-alive develop mode, without uglify */
|
||||||
|
exports.dev = js.liveRebuild;
|
86
gulpfile.js/tasks/js.js
Normal file
86
gulpfile.js/tasks/js.js
Normal file
|
@ -0,0 +1,86 @@
|
||||||
|
#!/usr/bin/env node
|
||||||
|
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
const { src, dest, watch, series, parallel} = require('gulp');
|
||||||
|
|
||||||
|
const concat = require('gulp-concat');
|
||||||
|
const rename = require("gulp-rename");
|
||||||
|
const uglify = require('gulp-uglify');
|
||||||
|
|
||||||
|
const JS_ROOT = './assets/js';
|
||||||
|
const jsDest = `${ JS_ROOT }/dist/`;
|
||||||
|
|
||||||
|
function concatJs(files, output) {
|
||||||
|
return src(files)
|
||||||
|
.pipe(concat(output))
|
||||||
|
.pipe(rename({ extname: '.min.js' }))
|
||||||
|
.pipe(dest(jsDest));
|
||||||
|
}
|
||||||
|
|
||||||
|
function minifyJs() {
|
||||||
|
return src(`${ jsDest }/*.js`)
|
||||||
|
.pipe(uglify())
|
||||||
|
.pipe(dest(jsDest));
|
||||||
|
}
|
||||||
|
|
||||||
|
const homeJs = () => {
|
||||||
|
return concatJs([
|
||||||
|
`${JS_ROOT}/_commons/*.js`,
|
||||||
|
`${JS_ROOT}/_utils/timeago.js`
|
||||||
|
],
|
||||||
|
'home'
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const postJs = () => {
|
||||||
|
return concatJs([
|
||||||
|
`${JS_ROOT}/_commons/*.js`,
|
||||||
|
`${JS_ROOT}/_utils/timeago.js`,
|
||||||
|
`${JS_ROOT}/_utils/img-hyperlink.js`,
|
||||||
|
`${JS_ROOT}/_utils/lang-badge.js`,
|
||||||
|
// 'smooth-scroll.js' must be called after ToC is ready
|
||||||
|
`${JS_ROOT}/_utils/smooth-scroll.js`
|
||||||
|
], 'post'
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const categoriesJs = () => {
|
||||||
|
return concatJs([
|
||||||
|
`${JS_ROOT}/_commons/*.js`,
|
||||||
|
`${JS_ROOT}/_utils/category-collapse.js`
|
||||||
|
], 'categories'
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const pageJs = () => {
|
||||||
|
return concatJs([
|
||||||
|
`${JS_ROOT}/_commons/*.js`,
|
||||||
|
`${JS_ROOT}/_utils/smooth-scroll.js`
|
||||||
|
], 'page'
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
// GA pageviews report
|
||||||
|
const pvreportJs = () => {
|
||||||
|
return concatJs([
|
||||||
|
`${JS_ROOT}/_utils/pageviews.js`
|
||||||
|
], 'pvreport'
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
const buildJs = parallel(homeJs, postJs, categoriesJs, pageJs, pvreportJs);
|
||||||
|
|
||||||
|
exports.build = series(buildJs, minifyJs);
|
||||||
|
|
||||||
|
exports.liveRebuild = () => {
|
||||||
|
buildJs();
|
||||||
|
|
||||||
|
watch([
|
||||||
|
`${ JS_ROOT }/_commons/*.js`,
|
||||||
|
`${ JS_ROOT }/_utils/*.js`
|
||||||
|
],
|
||||||
|
buildJs
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
29
package.json
Normal file
29
package.json
Normal file
|
@ -0,0 +1,29 @@
|
||||||
|
{
|
||||||
|
"name": "jekyll-theme-chirpy",
|
||||||
|
"version": "3.0.0",
|
||||||
|
"description": "A minimal, sidebar, responsive web design Jekyll theme that focuses on text presentation.",
|
||||||
|
"main": "index.js",
|
||||||
|
"directories": {
|
||||||
|
"doc": "docs"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git+https://github.com/cotes2020/jekyll-theme-chirpy.git"
|
||||||
|
},
|
||||||
|
"author": "Cotes Chung",
|
||||||
|
"license": "MIT",
|
||||||
|
"bugs": {
|
||||||
|
"url": "https://github.com/cotes2020/jekyll-theme-chirpy/issues"
|
||||||
|
},
|
||||||
|
"homepage": "https://github.com/cotes2020/jekyll-theme-chirpy#readme",
|
||||||
|
"dependencies": {
|
||||||
|
"uglify-js": "git+https://github.com/mishoo/UglifyJS2.git#harmony",
|
||||||
|
"gulp": "^4.0.2",
|
||||||
|
"gulp-concat": "^2.6.1",
|
||||||
|
"gulp-rename": "^2.0.0",
|
||||||
|
"gulp-uglify": "^3.0.2"
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue