a new start
This commit is contained in:
38
_includes/scripts/cssrelpreload.min.js
vendored
Normal file
38
_includes/scripts/cssrelpreload.min.js
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
!(function (a) {
|
||||
if (a.loadCSS) {
|
||||
var b = (loadCSS.relpreload = {});
|
||||
if (
|
||||
((b.support = function () {
|
||||
try {
|
||||
return a.document.createElement("link").relList.supports("preload");
|
||||
} catch (b) {
|
||||
return !1;
|
||||
}
|
||||
}),
|
||||
(b.poly = function () {
|
||||
for (
|
||||
var b = a.document.getElementsByTagName("link"), c = 0;
|
||||
c < b.length;
|
||||
c++
|
||||
) {
|
||||
var d = b[c];
|
||||
"preload" === d.rel &&
|
||||
"style" === d.getAttribute("as") &&
|
||||
(a.loadCSS(d.href, d, d.getAttribute("media")), (d.rel = null));
|
||||
}
|
||||
}),
|
||||
!b.support())
|
||||
) {
|
||||
b.poly();
|
||||
var c = a.setInterval(b.poly, 300);
|
||||
a.addEventListener &&
|
||||
a.addEventListener("load", function () {
|
||||
b.poly(), a.clearInterval(c);
|
||||
}),
|
||||
a.attachEvent &&
|
||||
a.attachEvent("onload", function () {
|
||||
a.clearInterval(c);
|
||||
});
|
||||
}
|
||||
}
|
||||
})(this);
|
||||
11
_includes/scripts/dark-mode.js
Normal file
11
_includes/scripts/dark-mode.js
Normal file
@@ -0,0 +1,11 @@
|
||||
!(function (window, document) {
|
||||
var LM = "light-mode";
|
||||
var DM = "dark-mode";
|
||||
var h = new Date().getHours();
|
||||
if ("matchMedia" in window && window.matchMedia("(prefers-color-scheme)"))
|
||||
return;
|
||||
var m = h <= window._sunrise || h >= window._sunset ? DM : LM;
|
||||
var n = m === DM ? LM : DM;
|
||||
document.body.classList.add(m);
|
||||
document.body.classList.remove(n);
|
||||
})(window, document);
|
||||
9
_includes/scripts/dark-mode.min.js
vendored
Normal file
9
_includes/scripts/dark-mode.min.js
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
((e, s) => {
|
||||
var d = "light-mode",
|
||||
a = "dark-mode",
|
||||
o = new Date().getHours();
|
||||
("matchMedia" in e && e.matchMedia("(prefers-color-scheme)")) ||
|
||||
((e = (o = o <= e._sunrise || o >= e._sunset ? a : d) == a ? d : a),
|
||||
s.body.classList.add(o),
|
||||
s.body.classList.remove(e));
|
||||
})(window, document);
|
||||
62
_includes/scripts/load-js.js
Normal file
62
_includes/scripts/load-js.js
Normal file
@@ -0,0 +1,62 @@
|
||||
// Copyright (c) 2017 Florian Klampfer <https://qwtel.com/>
|
||||
//
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// This program is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
// Compress via uglify:
|
||||
// uglifyjs load-js.js -c -m > load-js.min.js
|
||||
!(function (window, document) {
|
||||
"use strict";
|
||||
|
||||
function addEvent(el, type, cb, opts) {
|
||||
if (el.addEventListener) el.addEventListener(type, cb, opts);
|
||||
else if (el.attachEvent) el.attachEvent("on" + type, cb);
|
||||
else el["on" + type] = cb;
|
||||
}
|
||||
|
||||
window.loadJS = function (src, cb) {
|
||||
var script = document.createElement("script");
|
||||
script.src = src;
|
||||
if (cb) addEvent(script, "load", cb, { once: true });
|
||||
var ref = document.scripts[0];
|
||||
ref.parentNode.insertBefore(script, ref);
|
||||
|
||||
return script;
|
||||
};
|
||||
|
||||
window._loaded = false;
|
||||
window.loadJSDeferred = function (src, cb) {
|
||||
var script = document.createElement("script");
|
||||
script.src = src;
|
||||
|
||||
function insert() {
|
||||
window._loaded = true;
|
||||
if (cb) addEvent(script, "load", cb, { once: true });
|
||||
var ref = document.scripts[0];
|
||||
ref.parentNode.insertBefore(script, ref);
|
||||
}
|
||||
|
||||
if (window._loaded) insert();
|
||||
else addEvent(window, "load", insert, { once: true });
|
||||
|
||||
return script;
|
||||
};
|
||||
|
||||
window.setRel = window.setRelStylesheet = function (id) {
|
||||
var link = document.getElementById(id);
|
||||
function set() {
|
||||
this.rel = "stylesheet";
|
||||
}
|
||||
addEvent(link, "load", set, { once: true });
|
||||
};
|
||||
})(window, document);
|
||||
35
_includes/scripts/load-js.min.js
vendored
Normal file
35
_includes/scripts/load-js.min.js
vendored
Normal file
@@ -0,0 +1,35 @@
|
||||
((r, a) => {
|
||||
function d(e, t, n, o) {
|
||||
e.addEventListener
|
||||
? e.addEventListener(t, n, o)
|
||||
: e.attachEvent
|
||||
? e.attachEvent("on" + t, n)
|
||||
: (e["on" + t] = n);
|
||||
}
|
||||
(r.loadJS = function (e, t) {
|
||||
var n = a.createElement("script"),
|
||||
e = ((n.src = e), t && d(n, "load", t, { once: !0 }), a.scripts[0]);
|
||||
return e.parentNode.insertBefore(n, e), n;
|
||||
}),
|
||||
(r._loaded = !1),
|
||||
(r.loadJSDeferred = function (e, t) {
|
||||
var n = a.createElement("script");
|
||||
function o() {
|
||||
(r._loaded = !0), t && d(n, "load", t, { once: !0 });
|
||||
var e = a.scripts[0];
|
||||
e.parentNode.insertBefore(n, e);
|
||||
}
|
||||
return (n.src = e), r._loaded ? o() : d(r, "load", o, { once: !0 }), n;
|
||||
}),
|
||||
(r.setRel = r.setRelStylesheet =
|
||||
function (e) {
|
||||
d(
|
||||
a.getElementById(e),
|
||||
"load",
|
||||
function () {
|
||||
this.rel = "stylesheet";
|
||||
},
|
||||
{ once: !0 },
|
||||
);
|
||||
});
|
||||
})(window, document);
|
||||
44
_includes/scripts/loadCSS.min.js
vendored
Normal file
44
_includes/scripts/loadCSS.min.js
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
!(function (a) {
|
||||
"use strict";
|
||||
var b = function (b, c, d) {
|
||||
function e(a) {
|
||||
return h.body
|
||||
? a()
|
||||
: void setTimeout(function () {
|
||||
e(a);
|
||||
});
|
||||
}
|
||||
function f() {
|
||||
i.addEventListener && i.removeEventListener("load", f),
|
||||
(i.media = d || "all");
|
||||
}
|
||||
var g,
|
||||
h = a.document,
|
||||
i = h.createElement("link");
|
||||
if (c) g = c;
|
||||
else {
|
||||
var j = (h.body || h.getElementsByTagName("head")[0]).childNodes;
|
||||
g = j[j.length - 1];
|
||||
}
|
||||
var k = h.styleSheets;
|
||||
(i.rel = "stylesheet"),
|
||||
(i.href = b),
|
||||
(i.media = "only x"),
|
||||
e(function () {
|
||||
g.parentNode.insertBefore(i, c ? g : g.nextSibling);
|
||||
});
|
||||
var l = function (a) {
|
||||
for (var b = i.href, c = k.length; c--; ) if (k[c].href === b) return a();
|
||||
setTimeout(function () {
|
||||
l(a);
|
||||
});
|
||||
};
|
||||
return (
|
||||
i.addEventListener && i.addEventListener("load", f),
|
||||
(i.onloadcssdefined = l),
|
||||
l(f),
|
||||
i
|
||||
);
|
||||
};
|
||||
"undefined" != typeof exports ? (exports.loadCSS = b) : (a.loadCSS = b);
|
||||
})("undefined" != typeof global ? global : this);
|
||||
25
_includes/scripts/nomodule.js
Normal file
25
_includes/scripts/nomodule.js
Normal file
@@ -0,0 +1,25 @@
|
||||
// `script[nomodule]` polyfill for Safari 10.1.
|
||||
// Source: https://gist.github.com/samthor/64b114e4a4f539915a95b91ffd340acc
|
||||
(function () {
|
||||
var check = document.createElement("script");
|
||||
if (!("noModule" in check) && "onbeforeload" in check) {
|
||||
var support = false;
|
||||
document.addEventListener(
|
||||
"beforeload",
|
||||
function (e) {
|
||||
if (e.target === check) {
|
||||
support = true;
|
||||
} else if (!e.target.hasAttribute("nomodule") || !support) {
|
||||
return;
|
||||
}
|
||||
e.preventDefault();
|
||||
},
|
||||
true,
|
||||
);
|
||||
|
||||
check.type = "module";
|
||||
check.src = ".";
|
||||
document.head.appendChild(check);
|
||||
check.remove();
|
||||
}
|
||||
})();
|
||||
20
_includes/scripts/nomodule.min.js
vendored
Normal file
20
_includes/scripts/nomodule.min.js
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
(() => {
|
||||
var t,
|
||||
n = document.createElement("script");
|
||||
!("noModule" in n) &&
|
||||
"onbeforeload" in n &&
|
||||
((t = !1),
|
||||
document.addEventListener(
|
||||
"beforeload",
|
||||
function (e) {
|
||||
if (e.target === n) t = !0;
|
||||
else if (!e.target.hasAttribute("nomodule") || !t) return;
|
||||
e.preventDefault();
|
||||
},
|
||||
!0,
|
||||
),
|
||||
(n.type = "module"),
|
||||
(n.src = "."),
|
||||
document.head.appendChild(n),
|
||||
n.remove());
|
||||
})();
|
||||
Reference in New Issue
Block a user