@xiee/utils 1.1.8 → 1.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/js/load-typekit.js +16 -0
- package/js/toggle-notes.js +12 -0
- package/package.json +1 -1
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
(function(d) {
|
|
2
|
+
// https://www.kirupa.com/html5/detect_whether_font_is_installed.htm
|
|
3
|
+
var canvas = d.createElement("canvas");
|
|
4
|
+
var context = canvas.getContext("2d");
|
|
5
|
+
var text = "abcdefghijklmnopqrstuvwxyz0123456789";
|
|
6
|
+
context.font = "72px monospace";
|
|
7
|
+
var size = context.measureText(text).width;
|
|
8
|
+
var fonts = [' SC', ' CN', ' TC', ' TW', ''];
|
|
9
|
+
for (var i = 0; i < fonts.length; i++) {
|
|
10
|
+
context.font = "72px '" + 'Source Han Serif' + fonts[i] + "', monospace";
|
|
11
|
+
// no need to load TypeKit if Source Hans Serif has been installed
|
|
12
|
+
if (context.measureText(text).width != size) return;
|
|
13
|
+
}
|
|
14
|
+
var config = {kitId: 'kwz5xar', scriptTimeout: 3000, async: true},
|
|
15
|
+
h=d.documentElement,t=setTimeout(function(){h.className=h.className.replace(/\bwf-loading\b/g,"")+" wf-inactive";},config.scriptTimeout),tk=d.createElement("script"),f=false,s=d.getElementsByTagName("script")[0],a;h.className+=" wf-loading";tk.src='https://use.typekit.net/'+config.kitId+'.js';tk.async=true;tk.onload=tk.onreadystatechange=function(){a=this.readyState;if(f||a&&a!="complete"&&a!="loaded")return;f=true;clearTimeout(t);try{Typekit.load(config)}catch(e){}};s.parentNode.insertBefore(tk,s)
|
|
16
|
+
})(document);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
(function(d) {
|
|
2
|
+
if (!d.body.classList.contains('has-notes')) return;
|
|
3
|
+
const h = d.querySelector('.title > hr');
|
|
4
|
+
if (!h) return;
|
|
5
|
+
h.classList.add('toggle-notes');
|
|
6
|
+
h.onclick = function(e) {
|
|
7
|
+
const s = d.body.classList.toggle('hide-notes');
|
|
8
|
+
try { sessionStorage.setItem('hide-notes', s); } catch (e) {};
|
|
9
|
+
};
|
|
10
|
+
const s = sessionStorage.getItem('hide-notes');
|
|
11
|
+
if (s !== null) d.body.classList.toggle('hide-notes', s === 'true');
|
|
12
|
+
})(document);
|