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
|
||||
_site
|
||||
vendor
|
||||
|
||||
# npm dependencies
|
||||
node_modules
|
||||
package-lock.json
|
||||
|
|
|
@ -194,6 +194,10 @@ exclude:
|
|||
- docs
|
||||
- README.md
|
||||
- LICENSE
|
||||
- gulpfile.js
|
||||
- node_modules
|
||||
- package.json
|
||||
- package-lock.json
|
||||
|
||||
jekyll-archives:
|
||||
enabled: [categories, tags]
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<!--
|
||||
The Disqus lazy loading.
|
||||
Powered by: https://osvaldas.info/lazy-loading-disqus-comments
|
||||
Powered by: <https://github.com/osvaldasvalutis/disqusLoader.js>
|
||||
v2.0
|
||||
https://github.com/cotes2020/jekyll-theme-chirpy
|
||||
© 2019 Cotes Chung
|
||||
|
@ -8,17 +8,18 @@
|
|||
-->
|
||||
|
||||
<div id="disqus" class="pt-2 pb-2">
|
||||
<p class="font-italic text-center text-muted small">
|
||||
Comments powered by <a href="https://disqus.com/">Disqus</a>.
|
||||
<p class="text-center text-muted pb-5">
|
||||
Loading comments from <a href="https://disqus.com/">Disqus</a> ...
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<script src="{{ '/assets/js/lib/jquery.disqusloader.min.js' | relative_url }}"></script>
|
||||
<script>
|
||||
var options = {
|
||||
const options = {
|
||||
scriptUrl: '//{{ site.disqus.shortname }}.disqus.com/embed.js',
|
||||
|
||||
disqusConfig: function() {
|
||||
this.page.title = '{{ page.title }}';
|
||||
this.page.url = '{{ page.url | absolute_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="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 %}
|
||||
|
||||
<title>
|
||||
|
|
|
@ -6,15 +6,24 @@
|
|||
MIT Licensed
|
||||
-->
|
||||
|
||||
{% if page.layout == 'home' or page.layout == 'post' or page.layout == 'categories' %}
|
||||
{% assign js = page.layout %}
|
||||
{% else %}
|
||||
{% assign js = "page" %}
|
||||
{% if page.layout == 'home' or page.layout == 'post' %}
|
||||
{% if site.google_analytics.pv.enabled %}
|
||||
<!-- pv-report needs countup.js -->
|
||||
<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 %}
|
||||
|
||||
{% 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 %}
|
||||
<!-- MathJax -->
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
<!--
|
||||
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>
|
||||
$(function() {
|
||||
let initTheme = "default";
|
||||
|
|
|
@ -48,6 +48,8 @@
|
|||
</div> <!-- .access -->
|
||||
|
||||
{% 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">
|
||||
<span class="pl-3 pt-2 mb-2">
|
||||
{{- 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 %}
|
|
@ -11,7 +11,7 @@ function copyLink(url) {
|
|||
url = window.location.href;
|
||||
}
|
||||
|
||||
var $temp = $("<input>");
|
||||
const $temp = $("<input>");
|
||||
$("body").append($temp);
|
||||
$temp.val(url).select();
|
||||
document.execCommand("copy");
|
||||
|
|
|
@ -8,24 +8,24 @@
|
|||
|
||||
$(function() {
|
||||
|
||||
var btnSbTrigger = $("#sidebar-trigger");
|
||||
var btnSearchTrigger = $("#search-trigger");
|
||||
var btnCancel = $("#search-cancel");
|
||||
var btnClear = $("#search-cleaner");
|
||||
const btnSbTrigger = $("#sidebar-trigger");
|
||||
const btnSearchTrigger = $("#search-trigger");
|
||||
const btnCancel = $("#search-cancel");
|
||||
const btnClear = $("#search-cleaner");
|
||||
|
||||
var main = $("#main");
|
||||
var topbarTitle = $("#topbar-title");
|
||||
var searchWrapper = $("#search-wrapper");
|
||||
var resultWrapper = $("#search-result-wrapper");
|
||||
var results = $("#search-results");
|
||||
var input = $("#search-input");
|
||||
var hints = $("#search-hints");
|
||||
const main = $("#main");
|
||||
const topbarTitle = $("#topbar-title");
|
||||
const searchWrapper = $("#search-wrapper");
|
||||
const resultWrapper = $("#search-result-wrapper");
|
||||
const results = $("#search-results");
|
||||
const input = $("#search-input");
|
||||
const hints = $("#search-hints");
|
||||
|
||||
|
||||
/*--- Actions in small screens (Sidebar unloaded) ---*/
|
||||
|
||||
var scrollBlocker = (function() {
|
||||
var offset = 0;
|
||||
const scrollBlocker = (function () {
|
||||
let offset = 0;
|
||||
return {
|
||||
block() {
|
||||
offset = $(window).scrollTop();
|
||||
|
@ -39,7 +39,7 @@ $(function() {
|
|||
};
|
||||
}());
|
||||
|
||||
var mobileSearchBar = (function() {
|
||||
const mobileSearchBar = (function () {
|
||||
return {
|
||||
on() {
|
||||
btnSbTrigger.addClass("unloaded");
|
||||
|
@ -58,21 +58,21 @@ $(function() {
|
|||
};
|
||||
}());
|
||||
|
||||
var resultSwitch = (function() {
|
||||
var visable = false;
|
||||
const resultSwitch = (function () {
|
||||
let visible = false;
|
||||
|
||||
return {
|
||||
on() {
|
||||
if (!visable) {
|
||||
if (!visible) {
|
||||
resultWrapper.removeClass("unloaded");
|
||||
main.addClass("hidden");
|
||||
|
||||
visable = true;
|
||||
visible = true;
|
||||
scrollBlocker.block();
|
||||
}
|
||||
},
|
||||
off() {
|
||||
if (visable) {
|
||||
if (visible) {
|
||||
results.empty();
|
||||
if (hints.hasClass("unloaded")) {
|
||||
hints.removeClass("unloaded");
|
||||
|
@ -82,13 +82,13 @@ $(function() {
|
|||
main.removeClass("hidden");
|
||||
|
||||
input.val("");
|
||||
visable = false;
|
||||
visible = false;
|
||||
|
||||
scrollBlocker.release();
|
||||
}
|
||||
},
|
||||
isVisable() {
|
||||
return visable;
|
||||
isVisible() {
|
||||
return visible;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -8,10 +8,10 @@
|
|||
|
||||
$(function() {
|
||||
|
||||
var sidebarUtil = (function() {
|
||||
const sidebarUtil = (function () {
|
||||
const ATTR_DISPLAY = "sidebar-display";
|
||||
var isExpanded = false;
|
||||
var body = $("body");
|
||||
let isExpanded = false;
|
||||
const body = $("body");
|
||||
|
||||
return {
|
||||
toggle() {
|
||||
|
|
|
@ -8,10 +8,16 @@
|
|||
|
||||
$(function() {
|
||||
|
||||
var didScroll;
|
||||
var lastScrollTop = 0;
|
||||
var delta = 5;
|
||||
var topbarHeight = $("#topbar-wrapper").outerHeight();
|
||||
const topbarWrapper = $("#topbar-wrapper");
|
||||
const toc = $("#toc-wrapper");
|
||||
const access = $(".access");
|
||||
const searchInput = $("#search-input");
|
||||
|
||||
let didScroll;
|
||||
let lastScrollTop = 0;
|
||||
|
||||
const delta = 5;
|
||||
const topbarHeight = topbarWrapper.outerHeight();
|
||||
|
||||
function hasScrolled() {
|
||||
var st = $(this).scrollTop();
|
||||
|
@ -23,30 +29,28 @@ $(function() {
|
|||
|
||||
if (st > lastScrollTop && st > topbarHeight) {
|
||||
/* Scroll Down */
|
||||
$("#topbar-wrapper").removeClass("topbar-down").addClass("topbar-up");
|
||||
topbarWrapper.removeClass("topbar-down").addClass("topbar-up");
|
||||
|
||||
if ($("#toc-wrapper").length > 0) {
|
||||
$("#toc-wrapper").removeClass("topbar-down");
|
||||
if (toc.length > 0) {
|
||||
toc.removeClass("topbar-down");
|
||||
}
|
||||
|
||||
if ($(".access").length > 0) {
|
||||
$(".access").removeClass("topbar-down");
|
||||
if (access.length > 0) {
|
||||
access.removeClass("topbar-down");
|
||||
}
|
||||
|
||||
if ($("#search-input").is(":focus")) {
|
||||
$("#search-input").blur(); /* remove focus */
|
||||
if (searchInput.is(":focus")) {
|
||||
searchInput.blur(); /* remove focus */
|
||||
}
|
||||
|
||||
} else {
|
||||
} else if (st + $(window).height() < $(document).height()) {
|
||||
/* Scroll Up */
|
||||
if (st + $(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");
|
||||
topbarWrapper.removeClass("topbar-up").addClass("topbar-down");
|
||||
if (toc.length > 0) {
|
||||
toc.addClass("topbar-down");
|
||||
}
|
||||
if (access.length > 0) {
|
||||
access.addClass("topbar-down");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
* https://github.com/cotes2020/jekyll-theme-chirpy
|
||||
* © 2018-2019 Cotes Chung
|
||||
|
@ -8,9 +8,13 @@
|
|||
|
||||
$(function() {
|
||||
|
||||
var DEFAULT = $("#topbar-title").text().trim();
|
||||
var title = ($("div.post>h1").length > 0) ?
|
||||
$("div.post>h1").text().trim() : $("h1").text().trim();
|
||||
const topbarTitle = $("#topbar-title");
|
||||
const postTitle = $("div.post>h1");
|
||||
|
||||
const DEFAULT = topbarTitle.text().trim();
|
||||
|
||||
let title = (postTitle.length > 0) ?
|
||||
postTitle.text().trim() : $("h1").text().trim();
|
||||
|
||||
if ($("#page-category").length || $("#page-tag").length) {
|
||||
/* The title in Category or Tag page will be "<title> <count_of_posts>" */
|
||||
|
@ -22,25 +26,25 @@ $(function() {
|
|||
/* 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 */
|
||||
|| postTitle.is(":hidden") /* is tab pages */
|
||||
|| topbarTitle.is(":hidden") /* not mobile screens */
|
||||
|| $("#sidebar.sidebar-expand").length) { /* when the sidebar trigger is clicked */
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($(this).scrollTop() >= 95) {
|
||||
if ($("#topbar-title").text() !== title) {
|
||||
$("#topbar-title").text(title);
|
||||
if (topbarTitle.text() !== title) {
|
||||
topbarTitle.text(title);
|
||||
}
|
||||
} else {
|
||||
if ($("#topbar-title").text() !== DEFAULT) {
|
||||
$("#topbar-title").text(DEFAULT);
|
||||
if (topbarTitle.text() !== DEFAULT) {
|
||||
topbarTitle.text(DEFAULT);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/* Click title remove hover effect. */
|
||||
$("#topbar-title").click(function() {
|
||||
topbarTitle.click(function() {
|
||||
$("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,26 +7,27 @@
|
|||
*/
|
||||
|
||||
$(function() {
|
||||
var childPrefix = "l_";
|
||||
var parentPrefix = "h_";
|
||||
const childPrefix = "l_";
|
||||
const parentPrefix = "h_";
|
||||
const collapse = $(".collapse");
|
||||
|
||||
/* close up top-category */
|
||||
$(".collapse").on("hide.bs.collapse", function() { /* Bootstrap collapse events. */
|
||||
var parentId = parentPrefix + $(this).attr("id").substring(childPrefix.length);
|
||||
collapse.on("hide.bs.collapse", function () { /* Bootstrap collapse events. */
|
||||
const parentId = parentPrefix + $(this).attr("id").substring(childPrefix.length);
|
||||
if (parentId) {
|
||||
$("#" + parentId + " .far.fa-folder-open").attr("class", "far fa-folder fa-fw");
|
||||
$("#" + parentId + " i.fas").addClass("rotate");
|
||||
$("#" + parentId).removeClass("hide-border-bottom");
|
||||
$(`#${parentId} .far.fa-folder-open`).attr("class", "far fa-folder fa-fw");
|
||||
$(`#${parentId} i.fas`).addClass("rotate");
|
||||
$(`#${parentId}`).removeClass("hide-border-bottom");
|
||||
}
|
||||
});
|
||||
|
||||
/* expand the top category */
|
||||
$(".collapse").on("show.bs.collapse", function() {
|
||||
var parentId = parentPrefix + $(this).attr("id").substring(childPrefix.length);
|
||||
collapse.on("show.bs.collapse", function() {
|
||||
const parentId = parentPrefix + $(this).attr("id").substring(childPrefix.length);
|
||||
if (parentId) {
|
||||
$("#" + parentId + " .far.fa-folder").attr("class", "far fa-folder-open fa-fw");
|
||||
$("#" + parentId + " i.fas").removeClass("rotate");
|
||||
$("#" + parentId).addClass("hide-border-bottom");
|
||||
$(`#${parentId} .far.fa-folder`).attr("class", "far fa-folder-open fa-fw");
|
||||
$(`#${parentId} i.fas`).removeClass("rotate");
|
||||
$(`#${parentId}`).addClass("hide-border-bottom");
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -8,9 +8,6 @@
|
|||
*/
|
||||
|
||||
$(function() {
|
||||
|
||||
var MARK="img-hyperlink";
|
||||
|
||||
const MARK = "img-hyperlink";
|
||||
$("a:has(img)").addClass(MARK);
|
||||
|
||||
});
|
||||
|
|
|
@ -7,11 +7,11 @@ $(function() {
|
|||
const regex = new RegExp(`^${prefix}([a-z])+$`);
|
||||
|
||||
$(`div[class^=${prefix}`).each(function() {
|
||||
let clzsses = $(this).attr("class").split(" ");
|
||||
let classes = $(this).attr("class").split(" ");
|
||||
|
||||
clzsses.forEach((clzss) => {
|
||||
if (regex.test(clzss)) {
|
||||
let lang = clzss.substring(prefix.length);
|
||||
classes.forEach((_class) => {
|
||||
if (regex.test(_class)) {
|
||||
let lang = _class.substring(prefix.length);
|
||||
$(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
|
||||
* - countUp.js <https://github.com/inorganik/countUp.js>
|
||||
*
|
||||
|
@ -11,8 +11,8 @@
|
|||
* MIT License
|
||||
*/
|
||||
|
||||
var getInitStatus = (function () {
|
||||
var hasInit = false;
|
||||
const getInitStatus = (function () {
|
||||
let hasInit = false;
|
||||
return () => {
|
||||
let ret = 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_CREATION = "pv_created_date";
|
||||
const KEY_PV_SRC = "pv_source";
|
||||
|
||||
var Source = {
|
||||
const Source = {
|
||||
ORIGIN: "origin",
|
||||
PROXY: "proxy"
|
||||
};
|
||||
|
@ -43,17 +56,18 @@ var PvCache = (function () {
|
|||
|
||||
return {
|
||||
getData() {
|
||||
return JSON.parse(localStorage.getItem(KEY_PV) );
|
||||
// get data from browser cache
|
||||
return JSON.parse(localStorage.getItem(KEY_PV));
|
||||
},
|
||||
saveOriginCache(pv) {
|
||||
set(KEY_PV, pv);
|
||||
set(KEY_PV_SRC, Source.ORIGIN );
|
||||
set(KEY_CREATION, new Date().toJSON() );
|
||||
set(KEY_PV_SRC, Source.ORIGIN);
|
||||
set(KEY_CREATION, new Date().toJSON());
|
||||
},
|
||||
saveProxyCache(pv) {
|
||||
set(KEY_PV, pv);
|
||||
set(KEY_PV_SRC, Source.PROXY );
|
||||
set(KEY_CREATION, new Date().toJSON() );
|
||||
set(KEY_PV_SRC, Source.PROXY);
|
||||
set(KEY_CREATION, new Date().toJSON());
|
||||
},
|
||||
isFromOrigin() {
|
||||
return get(KEY_PV_SRC) === Source.ORIGIN;
|
||||
|
@ -62,23 +76,23 @@ var PvCache = (function () {
|
|||
return get(KEY_PV_SRC) === Source.PROXY;
|
||||
},
|
||||
isExpired() {
|
||||
if (PvCache.isFromOrigin() ) {
|
||||
if (PvCache.isFromOrigin()) {
|
||||
let date = new Date(get(KEY_CREATION));
|
||||
date.setDate(date.getDate() + 1); /* update origin records every day */
|
||||
return Date.now() >= date.getTime();
|
||||
|
||||
} else if (PvCache.isFromProxy() ) {
|
||||
let date = new Date(get(KEY_CREATION) );
|
||||
} else if (PvCache.isFromProxy()) {
|
||||
let date = new Date(get(KEY_CREATION));
|
||||
date.setHours(date.getHours() + 1); /* update proxy records per hour */
|
||||
return Date.now() >= date.getTime();
|
||||
}
|
||||
return false;
|
||||
},
|
||||
getAllPagevies() {
|
||||
getAllPageviews() {
|
||||
return PvCache.getData().totalsForAllResults["ga:pageviews"];
|
||||
},
|
||||
newerThan(pv) {
|
||||
return PvCache.getAllPagevies() > pv.totalsForAllResults["ga:pageviews"];
|
||||
return PvCache.getAllPageviews() > pv.totalsForAllResults["ga:pageviews"];
|
||||
},
|
||||
inspectKeys() {
|
||||
if (localStorage.getItem(KEY_PV) === null
|
||||
|
@ -91,9 +105,10 @@ var PvCache = (function () {
|
|||
|
||||
}()); /* PvCache */
|
||||
|
||||
|
||||
function countUp(min, max, destId) {
|
||||
if (min < max) {
|
||||
var numAnim = new CountUp(destId, min, max);
|
||||
let numAnim = new CountUp(destId, min, max);
|
||||
if (!numAnim.error) {
|
||||
numAnim.start();
|
||||
} else {
|
||||
|
@ -104,11 +119,11 @@ function countUp(min, max, destId) {
|
|||
|
||||
|
||||
function countPV(path, rows) {
|
||||
var count = 0;
|
||||
let count = 0;
|
||||
|
||||
if (typeof rows !== "undefined" ) {
|
||||
for (var i = 0; i < rows.length; ++i) {
|
||||
var gaPath = rows[parseInt(i, 10)][0];
|
||||
for (let i = 0; i < rows.length; ++i) {
|
||||
const gaPath = rows[parseInt(i, 10)][0];
|
||||
if (gaPath === path) { /* path format see: site.permalink */
|
||||
count += parseInt(rows[parseInt(i, 10)][1], 10);
|
||||
break;
|
||||
|
@ -121,13 +136,13 @@ function countPV(path, rows) {
|
|||
|
||||
|
||||
function tacklePV(rows, path, elem, hasInit) {
|
||||
var count = countPV(path, rows);
|
||||
let count = countPV(path, rows);
|
||||
count = (count === 0 ? 1 : count);
|
||||
|
||||
if (!hasInit) {
|
||||
elem.text(new Intl.NumberFormat().format(count));
|
||||
} else {
|
||||
var initCount = parseInt(elem.text().replace(/,/g, ""), 10);
|
||||
const initCount = parseInt(elem.text().replace(/,/g, ""), 10);
|
||||
if (count > initCount) {
|
||||
countUp(initCount, count, elem.attr("id"));
|
||||
}
|
||||
|
@ -140,17 +155,17 @@ function displayPageviews(data) {
|
|||
return;
|
||||
}
|
||||
|
||||
var hasInit = getInitStatus();
|
||||
var rows = data.rows; /* could be undefined */
|
||||
let hasInit = getInitStatus();
|
||||
const rows = data.rows; /* could be undefined */
|
||||
|
||||
if ($("#post-list").length > 0) { /* the Home page */
|
||||
$(".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);
|
||||
});
|
||||
|
||||
} else if ($(".post").length > 0) { /* the post */
|
||||
var path = window.location.pathname;
|
||||
const path = window.location.pathname;
|
||||
tacklePV(rows, path, $("#pv"), hasInit);
|
||||
}
|
||||
}
|
||||
|
@ -159,7 +174,7 @@ function displayPageviews(data) {
|
|||
function fetchProxyPageviews() {
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: proxyEndpoint, /* see: /assets/js/_pv-config.js */
|
||||
url: PvOpts.getProxyEndpoint(),
|
||||
dataType: "jsonp",
|
||||
jsonpCallback: "displayPageviews",
|
||||
success: (data, textStatus, jqXHR) => {
|
||||
|
@ -173,9 +188,8 @@ function fetchProxyPageviews() {
|
|||
|
||||
|
||||
function fetchPageviews(fetchOrigin = true, filterOrigin = false) {
|
||||
/* pvCacheEnabled, pvCacheData › see: /assets/js/_pv-config.js */
|
||||
if (pvCacheEnabled && fetchOrigin) {
|
||||
fetch(pvCacheData)
|
||||
if (PvOpts.isEnabled() && fetchOrigin) {
|
||||
fetch(PvOpts.getLocalData())
|
||||
.then((response) => response.json())
|
||||
.then((data) => {
|
||||
if (filterOrigin) {
|
||||
|
@ -196,9 +210,7 @@ function fetchPageviews(fetchOrigin = true, filterOrigin = false) {
|
|||
|
||||
|
||||
$(function() {
|
||||
|
||||
if ($(".pageviews").length > 0) {
|
||||
|
||||
PvCache.inspectKeys();
|
||||
let cache = PvCache.getData();
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
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/>
|
||||
|
||||
|
@ -13,8 +13,8 @@ $(function() {
|
|||
.not("[href='#0']")
|
||||
.click(function(event) {
|
||||
|
||||
if (location.pathname.replace(/^\//, "") === this.pathname.replace(/^\//, "")
|
||||
&& location.hostname === this.hostname) {
|
||||
if (this.pathname.replace(/^\//, "") === location.pathname.replace(/^\//, "")) {
|
||||
if (location.hostname === this.hostname) {
|
||||
|
||||
const REM = 16; /* 16px */
|
||||
|
||||
|
@ -22,7 +22,7 @@ $(function() {
|
|||
let isFnRef = RegExp(/^#fnref:/).test(hash);
|
||||
let isFn = RegExp(/^#fn:/).test(hash);
|
||||
let selector = hash.includes(":") ? hash.replace(/\:/, "\\:") : hash;
|
||||
const target = $(selector);
|
||||
let target = $(selector);
|
||||
|
||||
if (target.length) {
|
||||
event.preventDefault();
|
||||
|
@ -46,14 +46,14 @@ $(function() {
|
|||
scrollTop: destOffset
|
||||
}, 800, () => {
|
||||
|
||||
var $target = $(target);
|
||||
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);
|
||||
if ($(`[${SCROLL_MARK}=true]`).length) {
|
||||
$(`[${SCROLL_MARK}=true]`).attr(SCROLL_MARK, false);
|
||||
}
|
||||
|
||||
/* Clean :target links */
|
||||
|
@ -75,6 +75,7 @@ $(function() {
|
|||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}); /* click() */
|
||||
});
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Caculate the Timeago
|
||||
* Calculate the Timeago
|
||||
* v2.0
|
||||
* https://github.com/cotes2020/jekyll-theme-chirpy
|
||||
* © 2019 Cotes Chung
|
||||
|
@ -8,9 +8,11 @@
|
|||
|
||||
$(function() {
|
||||
|
||||
var toRefresh = $(".timeago").length;
|
||||
const timeagoElem = $(".timeago");
|
||||
|
||||
var intervalId = void 0;
|
||||
let toRefresh = timeagoElem.length;
|
||||
|
||||
let intervalId = void 0;
|
||||
|
||||
function timeago(iso, isLastmod) {
|
||||
let now = new Date();
|
||||
|
@ -57,10 +59,10 @@ $(function() {
|
|||
function updateTimeago() {
|
||||
$(".timeago").each(function() {
|
||||
if ($(this).children("i").length > 0) {
|
||||
var basic = $(this).text();
|
||||
var isLastmod = $(this).hasClass("lastmod");
|
||||
var node = $(this).children("i");
|
||||
var date = node.text(); /* ISO Date: "YYYY-MM-DDTHH:MM:SSZ" */
|
||||
$(this).text();
|
||||
let isLastmod = $(this).hasClass("lastmod");
|
||||
let node = $(this).children("i");
|
||||
let date = node.text(); /* ISO Date: "YYYY-MM-DDTHH:MM:SSZ" */
|
||||
$(this).text(timeago(date, isLastmod));
|
||||
$(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 = [
|
||||
|
||||
/*--- 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 }}',
|
||||
'{{ "/assets/css/style.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/categories.min.js" | relative_url }}',
|
||||
'{{ "/assets/js/dist/home.min.js" | relative_url }}',
|
||||
'{{ "/assets/js/dist/page.min.js" | relative_url }}',
|
||||
'{{ "/assets/js/dist/post.min.js" | relative_url }}',
|
||||
'{{ "/assets/js/dist/categories.min.js" | relative_url }}',
|
||||
|
||||
/*--- 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