clean-jsdoc-theme 4.2.16 → 4.2.18
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/README.md +17 -2
- package/css-property-order-fix.js +56 -0
- package/jsdoc-config.json +1 -0
- package/minify.js +20 -8
- package/package.json +1 -2
- package/publish.js +5 -2
- package/static/scripts/core.js +24 -0
- package/static/scripts/core.min.js +23 -23
- package/static/styles/clean-jsdoc-theme-base.css +643 -457
- package/static/styles/clean-jsdoc-theme-dark.css +15 -10
- package/static/styles/clean-jsdoc-theme-light.css +196 -102
- package/static/styles/clean-jsdoc-theme-scrollbar.css +30 -0
- package/static/styles/clean-jsdoc-theme-without-scrollbar.min.css +1 -0
- package/static/styles/clean-jsdoc-theme.min.css +1 -1
- package/tmpl/layout.tmpl +7 -1
- package/tmpl/tutorial.tmpl +17 -8
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# clean-jsdoc-theme
|
|
2
2
|
|
|
3
|
-
[](https://github.com/ankitskvmdam/clean-jsdoc-theme) [](https://github.com/ankitskvmdam/clean-jsdoc-theme/fork) ](https://github.com/ankitskvmdam/clean-jsdoc-theme) [](https://github.com/ankitskvmdam/clean-jsdoc-theme/fork)  [](https://github.com/ankitskvmdam/clean-jsdoc-theme/issues) [](https://github.com/ankitskvmdam/clean-jsdoc-theme/graphs/contributors) [](https://travis-ci.org/ankitskvmdam/clean-jsdoc-theme) [](https://github.com/ankitskvmdam/clean-jsdoc-theme/blob/master/LICENSE)
|
|
4
4
|
<br>
|
|
5
5
|
|
|
6
6
|
`clean-jsdoc-theme` is a beautifully crafted theme for JSDoc 3/JSDoc 4. It is a clean and fully responsive theme with loads of
|
|
@@ -250,7 +250,7 @@ of `meta` tags into `head`.
|
|
|
250
250
|
'Mixins',
|
|
251
251
|
'Tutorials',
|
|
252
252
|
'Interfaces',
|
|
253
|
-
'Global'
|
|
253
|
+
'Global',
|
|
254
254
|
];
|
|
255
255
|
```
|
|
256
256
|
|
|
@@ -537,6 +537,20 @@ To exclude inherited symbols. Example:
|
|
|
537
537
|
|
|
538
538
|
This will remove all symbols (members, methods ...) that come from inherited parents.
|
|
539
539
|
|
|
540
|
+
### To remove styled applied to scrollbar
|
|
541
|
+
|
|
542
|
+
By default `clean-jsdoc-theme` applies some styles to browser's scroll bar. However if you want to remove this style do the following
|
|
543
|
+
|
|
544
|
+
```json
|
|
545
|
+
{
|
|
546
|
+
"theme_opts": {
|
|
547
|
+
"shouldRemoveScrollbarStyle": false
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
```
|
|
551
|
+
|
|
552
|
+
This will remove all symbols (members, methods ...) that come from inherited parents.
|
|
553
|
+
|
|
540
554
|
## Cheat sheet
|
|
541
555
|
|
|
542
556
|
| name | default | use case | expected value(s) |
|
|
@@ -562,6 +576,7 @@ This will remove all symbols (members, methods ...) that come from inherited par
|
|
|
562
576
|
| `displayModuleHeader` | `false` | If you want the module name to appear on its page | `boolean` |
|
|
563
577
|
| `includeFilesListInHomepage` | `false` | If you want to add or remove the list of files in homepage | `boolean` |
|
|
564
578
|
| `sort` | `true` | To sort the output members/methods/events | `boolean` |
|
|
579
|
+
| `shouldRemoveScrollbarStyle` | `false` | To remove styles applied to browser's scrollbar | `boolean` |
|
|
565
580
|
|
|
566
581
|
Don't forget to add the following in your jsdoc config file, otherwise toc will not work on some pages.
|
|
567
582
|
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
|
|
4
|
+
function parseCSS(cssContent) {
|
|
5
|
+
// Implement your CSS parsing logic here
|
|
6
|
+
// You can use regular expressions, string manipulation, or a CSS parsing library
|
|
7
|
+
|
|
8
|
+
// Example: Simple parsing using regular expressions to extract CSS rules
|
|
9
|
+
const cssRules = [];
|
|
10
|
+
const ruleRegex = /(.+?)\s*{\s*(.*?)\s*}/gs;
|
|
11
|
+
let match;
|
|
12
|
+
|
|
13
|
+
while ((match = ruleRegex.exec(cssContent)) !== null) {
|
|
14
|
+
const selector = match[1].trim();
|
|
15
|
+
const declarations = match[2].split(';').map((declaration) => {
|
|
16
|
+
const parts = declaration.split(':').map((part) => part.trim());
|
|
17
|
+
|
|
18
|
+
return {
|
|
19
|
+
property: parts[0],
|
|
20
|
+
value: parts[1],
|
|
21
|
+
};
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
cssRules.push({
|
|
25
|
+
selector,
|
|
26
|
+
declarations: declarations
|
|
27
|
+
.sort((a, b) => a.property.localeCompare(b.property))
|
|
28
|
+
.filter((declaration) => declaration.property !== ''),
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return cssRules;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const cssFile = fs.readFileSync(
|
|
36
|
+
path.join('.', 'static', 'styles', 'clean-jsdoc-theme-light.css')
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
const parsed = parseCSS(cssFile);
|
|
40
|
+
|
|
41
|
+
let output = '';
|
|
42
|
+
|
|
43
|
+
for (const parse of parsed) {
|
|
44
|
+
output += `${parse.selector} {\n`;
|
|
45
|
+
|
|
46
|
+
for (const declaration of parse.declarations) {
|
|
47
|
+
output += `\t${declaration.property}: ${declaration.value};\n`;
|
|
48
|
+
}
|
|
49
|
+
output += '\n}\n\n';
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
fs.writeFileSync(
|
|
53
|
+
path.join('.', 'static', 'styles', 'clean-jsdoc-theme-list.update.css'),
|
|
54
|
+
output
|
|
55
|
+
);
|
|
56
|
+
|
package/jsdoc-config.json
CHANGED
package/minify.js
CHANGED
|
@@ -10,30 +10,30 @@ const cssPath = path.join(pwd, 'static', 'styles');
|
|
|
10
10
|
const uglifyFiles = [
|
|
11
11
|
{
|
|
12
12
|
src: path.join(scriptsPath, 'core.js'),
|
|
13
|
-
dest: path.join(scriptsPath, 'core.min.js')
|
|
13
|
+
dest: path.join(scriptsPath, 'core.min.js'),
|
|
14
14
|
},
|
|
15
15
|
{
|
|
16
16
|
src: path.join(scriptsPath, 'search.js'),
|
|
17
|
-
dest: path.join(scriptsPath, 'search.min.js')
|
|
17
|
+
dest: path.join(scriptsPath, 'search.min.js'),
|
|
18
18
|
},
|
|
19
19
|
{
|
|
20
20
|
src: path.join(scriptsPath, 'third-party', 'hljs-original.js'),
|
|
21
|
-
dest: path.join(scriptsPath, 'third-party', 'hljs.js')
|
|
21
|
+
dest: path.join(scriptsPath, 'third-party', 'hljs.js'),
|
|
22
22
|
},
|
|
23
23
|
{
|
|
24
24
|
src: path.join(scriptsPath, 'third-party', 'hljs-line-num-original.js'),
|
|
25
|
-
dest: path.join(scriptsPath, 'third-party', 'hljs-line-num.js')
|
|
25
|
+
dest: path.join(scriptsPath, 'third-party', 'hljs-line-num.js'),
|
|
26
26
|
},
|
|
27
27
|
{
|
|
28
28
|
src: path.join(scriptsPath, 'third-party', 'tocbot.js'),
|
|
29
|
-
dest: path.join(scriptsPath, 'third-party', 'tocbot.min.js')
|
|
30
|
-
}
|
|
29
|
+
dest: path.join(scriptsPath, 'third-party', 'tocbot.min.js'),
|
|
30
|
+
},
|
|
31
31
|
];
|
|
32
32
|
|
|
33
33
|
const cssFilePaths = [
|
|
34
34
|
path.join(cssPath, 'clean-jsdoc-theme-base.css'),
|
|
35
35
|
path.join(cssPath, 'clean-jsdoc-theme-dark.css'),
|
|
36
|
-
path.join(cssPath, 'clean-jsdoc-theme-light.css')
|
|
36
|
+
path.join(cssPath, 'clean-jsdoc-theme-light.css'),
|
|
37
37
|
];
|
|
38
38
|
|
|
39
39
|
let css = '';
|
|
@@ -42,10 +42,22 @@ for (const p of cssFilePaths) {
|
|
|
42
42
|
css += fs.readFileSync(p, 'utf-8');
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
+
const cssWithScrollbar =
|
|
46
|
+
css +
|
|
47
|
+
fs.readFileSync(path.join(cssPath, 'clean-jsdoc-theme-scrollbar.css'));
|
|
48
|
+
|
|
45
49
|
const minifiedCss = csso.minify(css, { restructure: false });
|
|
50
|
+
const minifiedCssWithScrollbar = csso.minify(cssWithScrollbar, {
|
|
51
|
+
restructure: false,
|
|
52
|
+
});
|
|
46
53
|
|
|
47
54
|
fs.writeFileSync(
|
|
48
55
|
path.join(cssPath, 'clean-jsdoc-theme.min.css'),
|
|
56
|
+
minifiedCssWithScrollbar.css
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
fs.writeFileSync(
|
|
60
|
+
path.join(cssPath, 'clean-jsdoc-theme-without-scrollbar.min.css'),
|
|
49
61
|
minifiedCss.css
|
|
50
62
|
);
|
|
51
63
|
|
|
@@ -53,7 +65,7 @@ for (const f of uglifyFiles) {
|
|
|
53
65
|
const data = fs.readFileSync(f.src, 'utf-8');
|
|
54
66
|
|
|
55
67
|
const out = uglify.minify(data, {
|
|
56
|
-
compress: true
|
|
68
|
+
compress: true,
|
|
57
69
|
});
|
|
58
70
|
|
|
59
71
|
fs.writeFileSync(f.dest, out.code);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clean-jsdoc-theme",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.18",
|
|
4
4
|
"description": "A beautifully crafted theme/template for JSDoc 3. This theme/template looks and feels like a premium theme/template. This is a fully mobile responsive theme and also fully customizable theme.",
|
|
5
5
|
"main": "publish.js",
|
|
6
6
|
"scripts": {
|
|
@@ -50,7 +50,6 @@
|
|
|
50
50
|
"html-minifier-terser": "^7.2.0",
|
|
51
51
|
"klaw-sync": "^6.0.0",
|
|
52
52
|
"lodash": "^4.17.21",
|
|
53
|
-
"nanoid": "^3.3.4",
|
|
54
53
|
"showdown": "^2.1.0"
|
|
55
54
|
}
|
|
56
55
|
}
|
package/publish.js
CHANGED
|
@@ -6,7 +6,6 @@ const logger = require('jsdoc/util/logger');
|
|
|
6
6
|
const path = require('jsdoc/path');
|
|
7
7
|
const { taffy } = require('@jsdoc/salty');
|
|
8
8
|
const template = require('jsdoc/template');
|
|
9
|
-
const nanoid = require('nanoid').nanoid;
|
|
10
9
|
const htmlMinify = require('html-minifier-terser');
|
|
11
10
|
|
|
12
11
|
const {
|
|
@@ -429,7 +428,7 @@ function buildSidebarMembers({
|
|
|
429
428
|
const navProps = {
|
|
430
429
|
name: itemHeading,
|
|
431
430
|
items: [],
|
|
432
|
-
id:
|
|
431
|
+
id: `sidebar-${itemHeading.toLowerCase()}`,
|
|
433
432
|
};
|
|
434
433
|
|
|
435
434
|
if (items.length) {
|
|
@@ -733,6 +732,7 @@ exports.publish = async function (taffyData, opts, tutorials) {
|
|
|
733
732
|
};
|
|
734
733
|
});
|
|
735
734
|
}
|
|
735
|
+
|
|
736
736
|
if (doclet.see) {
|
|
737
737
|
doclet.see.forEach(function (seeItem, i) {
|
|
738
738
|
doclet.see[i] = hashToLink(doclet, seeItem);
|
|
@@ -897,6 +897,9 @@ exports.publish = async function (taffyData, opts, tutorials) {
|
|
|
897
897
|
view.codepen = codepen(themeOpts);
|
|
898
898
|
view.excludeInherited = Boolean(themeOpts.exclude_inherited);
|
|
899
899
|
view.baseURL = getBaseURL(themeOpts);
|
|
900
|
+
view.shouldRemoveScrollbarStyle = Boolean(
|
|
901
|
+
themeOpts.shouldRemoveScrollbarStyle
|
|
902
|
+
);
|
|
900
903
|
attachModuleSymbols(
|
|
901
904
|
find({ longname: { left: 'module:' } }),
|
|
902
905
|
members.modules
|
package/static/scripts/core.js
CHANGED
|
@@ -632,6 +632,29 @@ function addHrefToSidebarTitle() {
|
|
|
632
632
|
});
|
|
633
633
|
}
|
|
634
634
|
|
|
635
|
+
function highlightActiveLinkInSidebar() {
|
|
636
|
+
const list = document.location.href.split('/');
|
|
637
|
+
const targetURL = list[list.length - 1];
|
|
638
|
+
let element = document.querySelector(`.sidebar a[href*='${targetURL}']`);
|
|
639
|
+
|
|
640
|
+
if (!element) {
|
|
641
|
+
try {
|
|
642
|
+
element = document.querySelector(
|
|
643
|
+
`.sidebar a[href*='${targetURL.split('#')[0]}']`
|
|
644
|
+
);
|
|
645
|
+
} catch (e) {
|
|
646
|
+
console.error(e);
|
|
647
|
+
|
|
648
|
+
return;
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
if (!element) return;
|
|
653
|
+
|
|
654
|
+
element.parentElement.classList.add('active');
|
|
655
|
+
element.scrollIntoView();
|
|
656
|
+
}
|
|
657
|
+
|
|
635
658
|
function onDomContentLoaded() {
|
|
636
659
|
var themeButton = document.querySelectorAll('.theme-toggle');
|
|
637
660
|
|
|
@@ -676,6 +699,7 @@ function onDomContentLoaded() {
|
|
|
676
699
|
initTooltip();
|
|
677
700
|
fixTable();
|
|
678
701
|
addHrefToSidebarTitle();
|
|
702
|
+
highlightActiveLinkInSidebar();
|
|
679
703
|
}
|
|
680
704
|
|
|
681
705
|
// eslint-disable-next-line no-undef
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
var accordionLocalStorageKey="accordion-id",themeLocalStorageKey="theme",fontSizeLocalStorageKey="font-size",html=document.querySelector("html"),MAX_FONT_SIZE=30,MIN_FONT_SIZE=10,localStorage=window.localStorage;function getTheme(){var e=localStorage.getItem(themeLocalStorageKey);if(e)return e;switch(e=document.body.getAttribute("data-theme")){case"dark":case"light":return e;case"fallback-dark":return window.matchMedia("(prefers-color-scheme)").matches&&window.matchMedia("(prefers-color-scheme: light)").matches?"light":"dark";case"fallback-light":return window.matchMedia("(prefers-color-scheme)").matches&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";default:return"dark"}}function localUpdateTheme(e){var t=document.body,o=document.querySelectorAll(".theme-svg-use"),n="dark"===e?"#light-theme-icon":"#dark-theme-icon";t.setAttribute("data-theme",e),t.classList.remove("dark","light"),t.classList.add(e),o.forEach(function(e){e.setAttribute("xlink:href",n)})}function updateTheme(e){localUpdateTheme(e),localStorage.setItem(themeLocalStorageKey,e)}function toggleTheme(){updateTheme("dark"===document.body.getAttribute("data-theme")?"light":"dark")}function setAccordionIdToLocalStorage(e){var t=JSON.parse(localStorage.getItem(accordionLocalStorageKey));t[e]=e,localStorage.setItem(accordionLocalStorageKey,JSON.stringify(t))}function removeAccordionIdFromLocalStorage(e){var t=JSON.parse(localStorage.getItem(accordionLocalStorageKey));delete t[e],localStorage.setItem(accordionLocalStorageKey,JSON.stringify(t))}function getAccordionIdsFromLocalStorage(){return JSON.parse(localStorage.getItem(accordionLocalStorageKey))||{}}function toggleAccordion(e){"false"===e.getAttribute("data-isopen")?(e.setAttribute("data-isopen","true"),setAccordionIdToLocalStorage(e.id)):(e.setAttribute("data-isopen","false"),removeAccordionIdFromLocalStorage(e.id))}function initAccordion(){void 0!==localStorage.getItem(accordionLocalStorageKey)&&null!==localStorage.getItem(accordionLocalStorageKey)||localStorage.setItem(accordionLocalStorageKey,"{}");var e=document.querySelectorAll(".sidebar-section-title"),t=getAccordionIdsFromLocalStorage();e.forEach(function(e){e.addEventListener("click",function(){toggleAccordion(e)}),e.id in t&&toggleAccordion(e)})}function isSourcePage(){return Boolean(document.querySelector("#source-page"))}function bringElementIntoView(e,t=!0){var o,n,i,c;e&&(tocbotInstance&&setTimeout(()=>tocbotInstance.updateTocListActiveElement(e),60),o=document.querySelector(".navbar-container"),n=document.querySelector(".main-content"),i=e.getBoundingClientRect().top,c=16,o&&(c+=o.scrollHeight),n&&n.scrollBy(0,i-c),t&&history.pushState(null,null,"#"+e.id))}function bringLinkToView(e){e.preventDefault(),e.stopPropagation();var e=e.currentTarget.getAttribute("href");!e||(e=document.getElementById(e.slice(1)))&&bringElementIntoView(e)}function bringIdToViewOnMount(){var e,t;isSourcePage()||""!==(e=window.location.hash)&&((t=document.getElementById(e.slice(1)))||(e=decodeURI(e),t=document.getElementById(e.slice(1))),t&&bringElementIntoView(t,!1))}function createAnchorElement(e){var t=document.createElement("a");return t.textContent="#",t.href="#"+e,t.classList.add("link-anchor"),t.onclick=bringLinkToView,t}function addAnchor(){var e=document.querySelector(".main-content").querySelector("section");[e.querySelectorAll("h1"),e.querySelectorAll("h2"),e.querySelectorAll("h3"),e.querySelectorAll("h4")].forEach(function(e){e.forEach(function(e){var t=createAnchorElement(e.id);e.classList.add("has-anchor"),e.append(t)})})}function copy(e){const t=document.createElement("textarea");t.value=e,document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t)}function showTooltip(e){var t=document.getElementById(e);t.classList.add("show-tooltip"),setTimeout(function(){t.classList.remove("show-tooltip")},3e3)}function copyFunction(e){var t=document.getElementById(e);copy((t.querySelector(".linenums")||t.querySelector("code")).innerText.trim().replace(/(^\t)/gm,"")),showTooltip("tooltip-"+e)}function hideTocOnSourcePage(){isSourcePage()&&(document.querySelector(".toc-container").style.display="none")}function getPreTopBar(e,t=""){e='<button aria-label="copy code" class="icon-button copy-code" onclick="copyFunction(\''+e+'\')"><svg class="sm-icon" alt="click to copy"><use xlink:href="#copy-icon"></use></svg>'+('<div class="tooltip" id="tooltip-'+e+'">Copied!</div>')+"</button>";return'<div class="pre-top-bar-container">'+('<div class="code-lang-name-container"><div class="code-lang-name">'+t.toLocaleUpperCase()+"</div></div>")+e+"</div>"}function getPreDiv(){var e=document.createElement("div");return e.classList.add("pre-div"),e}function processAllPre(){var e=document.querySelectorAll("pre"),t=document.querySelector("#PeOAagUepe"),o=document.querySelector("#VuAckcnZhf"),n=0,i=0,c=(t&&(i=t.getBoundingClientRect().height),o&&(n=o.getBoundingClientRect().height),window.innerHeight-n-i-250);e.forEach(function(e,t){var o,n=e.parentNode;n&&"true"===n.getAttribute("data-skip-pre-process")||(n=getPreDiv(),o=getPreTopBar(t="ScDloZOMdL"+t,e.getAttribute("data-lang")||"code"),n.innerHTML=o,e.style.maxHeight=c+"px",e.id=t,e.classList.add("prettyprint"),e.parentNode.insertBefore(n,e),n.appendChild(e))})}function highlightAndBringLineIntoView(){var e=window.location.hash.replace("#line","");try{var t='[data-line-number="'+e+'"',o=document.querySelector(t);o.scrollIntoView(),o.parentNode.classList.add("selected")}catch(e){console.error(e)}}function getFontSize(){var e=16;try{e=Number.parseInt(html.style.fontSize.split("px")[0],10)}catch(e){console.log(e)}return e}function localUpdateFontSize(e){html.style.fontSize=e+"px";var t=document.querySelector("#b77a68a492f343baabea06fad81f651e");t&&(t.innerHTML=e)}function updateFontSize(e){localUpdateFontSize(e),localStorage.setItem(fontSizeLocalStorageKey,e)}function incrementFont(e){var t=getFontSize();t<MAX_FONT_SIZE&&updateFontSize(t+1)}function decrementFont(e){var t=getFontSize();MIN_FONT_SIZE<t&&updateFontSize(t-1)}function fontSizeTooltip(){var e=getFontSize();return`
|
|
2
|
-
<div class="font-size-tooltip">
|
|
3
|
-
<button aria-label="decrease-font-size" class="icon-button ${MAX_FONT_SIZE<=e?"disabled":""}" onclick="decrementFont(event)">
|
|
4
|
-
<svg>
|
|
5
|
-
<use xlink:href="#minus-icon"></use>
|
|
6
|
-
</svg>
|
|
7
|
-
</button>
|
|
8
|
-
<div class="font-size-text" id="b77a68a492f343baabea06fad81f651e">
|
|
9
|
-
${e}
|
|
10
|
-
</div>
|
|
11
|
-
<button aria-label="increase-font-size" class="icon-button ${e<=MIN_FONT_SIZE?"disabled":""}" onclick="incrementFont(event)">
|
|
12
|
-
<svg>
|
|
13
|
-
<use xlink:href="#add-icon"></use>
|
|
14
|
-
</svg>
|
|
15
|
-
</button>
|
|
16
|
-
<button class="icon-button" onclick="updateFontSize(16)">
|
|
17
|
-
<svg>
|
|
18
|
-
<use xlink:href="#reset-icon"></use>
|
|
19
|
-
</svg>
|
|
20
|
-
</button>
|
|
21
|
-
</div>
|
|
22
|
-
|
|
23
|
-
`}function initTooltip(){tippy(".theme-toggle",{content:"Toggle Theme",delay:500}),tippy(".search-button",{content:"Search",delay:500}),tippy(".font-size",{content:"Change font size",delay:500}),tippy(".codepen-button",{content:"Open code in CodePen",placement:"left"}),tippy(".copy-code",{content:"Copy this code",placement:"left"}),tippy(".font-size",{content:fontSizeTooltip(),trigger:"click",interactive:!0,allowHTML:!0,placement:"left"})}function fixTable(){for(const t of document.querySelectorAll("table")){if(t.classList.contains("hljs-ln"))return;var e=document.createElement("div");e.classList.add("table-div"),t.parentNode.insertBefore(e,t),e.appendChild(t)}}function hideMobileMenu(){var e=document.querySelector("#mobile-sidebar"),t=document.querySelector("#mobile-menu"),o=t.querySelector("use");e&&e.classList.remove("show"),t&&t.setAttribute("data-isopen","false"),o&&o.setAttribute("xlink:href","#menu-icon")}function showMobileMenu(){var e=document.querySelector("#mobile-sidebar"),t=document.querySelector("#mobile-menu"),o=t.querySelector("use");e&&e.classList.add("show"),t&&t.setAttribute("data-isopen","true"),o&&o.setAttribute("xlink:href","#close-icon")}function onMobileMenuClick(){("true"===document.querySelector("#mobile-menu").getAttribute("data-isopen")?hideMobileMenu:showMobileMenu)()}function initMobileMenu(){var e=document.querySelector("#mobile-menu");e&&e.addEventListener("click",onMobileMenuClick)}function addHrefToSidebarTitle(){document.querySelectorAll(".sidebar-title-anchor").forEach(function(e){e.setAttribute("href",baseURL)})}function onDomContentLoaded(){var e=document.querySelectorAll(".theme-toggle");initMobileMenu(),e&&e.forEach(function(e){e.addEventListener("click",toggleTheme)}),hljs.addPlugin({"after:highlightElement":function(e){e.el.parentNode.setAttribute("data-lang","code")}}),hljs.highlightAll(),hljs.initLineNumbersOnLoad({singleLine:!0}),initAccordion(),addAnchor(),processAllPre(),hideTocOnSourcePage(),setTimeout(function(){bringIdToViewOnMount(),isSourcePage()&&highlightAndBringLineIntoView()},1e3),initTooltip(),fixTable(),addHrefToSidebarTitle()}updateTheme(getTheme()),function(){var e=getFontSize(),t=localStorage.getItem(fontSizeLocalStorageKey);t?(t=Number.parseInt(t,10))!==e&&updateFontSize(t):updateFontSize(e)}(),window.addEventListener("DOMContentLoaded",onDomContentLoaded),window.addEventListener("hashchange",e=>{e=new URL(e.newURL);""!==e.hash&&bringIdToViewOnMount(e.hash)}),window.addEventListener("storage",e=>{"undefined"!==e.newValue&&(initTooltip(),e.key===themeLocalStorageKey&&localUpdateTheme(e.newValue),e.key===fontSizeLocalStorageKey&&localUpdateFontSize(e.newValue))});
|
|
1
|
+
var accordionLocalStorageKey="accordion-id",themeLocalStorageKey="theme",fontSizeLocalStorageKey="font-size",html=document.querySelector("html"),MAX_FONT_SIZE=30,MIN_FONT_SIZE=10,localStorage=window.localStorage;function getTheme(){var e=localStorage.getItem(themeLocalStorageKey);if(e)return e;switch(e=document.body.getAttribute("data-theme")){case"dark":case"light":return e;case"fallback-dark":return window.matchMedia("(prefers-color-scheme)").matches&&window.matchMedia("(prefers-color-scheme: light)").matches?"light":"dark";case"fallback-light":return window.matchMedia("(prefers-color-scheme)").matches&&window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light";default:return"dark"}}function localUpdateTheme(e){var t=document.body,o=document.querySelectorAll(".theme-svg-use"),n="dark"===e?"#light-theme-icon":"#dark-theme-icon";t.setAttribute("data-theme",e),t.classList.remove("dark","light"),t.classList.add(e),o.forEach(function(e){e.setAttribute("xlink:href",n)})}function updateTheme(e){localUpdateTheme(e),localStorage.setItem(themeLocalStorageKey,e)}function toggleTheme(){updateTheme("dark"===document.body.getAttribute("data-theme")?"light":"dark")}function setAccordionIdToLocalStorage(e){var t=JSON.parse(localStorage.getItem(accordionLocalStorageKey));t[e]=e,localStorage.setItem(accordionLocalStorageKey,JSON.stringify(t))}function removeAccordionIdFromLocalStorage(e){var t=JSON.parse(localStorage.getItem(accordionLocalStorageKey));delete t[e],localStorage.setItem(accordionLocalStorageKey,JSON.stringify(t))}function getAccordionIdsFromLocalStorage(){return JSON.parse(localStorage.getItem(accordionLocalStorageKey))||{}}function toggleAccordion(e){"false"===e.getAttribute("data-isopen")?(e.setAttribute("data-isopen","true"),setAccordionIdToLocalStorage(e.id)):(e.setAttribute("data-isopen","false"),removeAccordionIdFromLocalStorage(e.id))}function initAccordion(){void 0!==localStorage.getItem(accordionLocalStorageKey)&&null!==localStorage.getItem(accordionLocalStorageKey)||localStorage.setItem(accordionLocalStorageKey,"{}");var e=document.querySelectorAll(".sidebar-section-title"),t=getAccordionIdsFromLocalStorage();e.forEach(function(e){e.addEventListener("click",function(){toggleAccordion(e)}),e.id in t&&toggleAccordion(e)})}function isSourcePage(){return Boolean(document.querySelector("#source-page"))}function bringElementIntoView(e,t=!0){var o,n,i,c;e&&(tocbotInstance&&setTimeout(()=>tocbotInstance.updateTocListActiveElement(e),60),o=document.querySelector(".navbar-container"),n=document.querySelector(".main-content"),i=e.getBoundingClientRect().top,c=16,o&&(c+=o.scrollHeight),n&&n.scrollBy(0,i-c),t&&history.pushState(null,null,"#"+e.id))}function bringLinkToView(e){e.preventDefault(),e.stopPropagation();var e=e.currentTarget.getAttribute("href");!e||(e=document.getElementById(e.slice(1)))&&bringElementIntoView(e)}function bringIdToViewOnMount(){var e,t;isSourcePage()||""!==(e=window.location.hash)&&((t=document.getElementById(e.slice(1)))||(e=decodeURI(e),t=document.getElementById(e.slice(1))),t&&bringElementIntoView(t,!1))}function createAnchorElement(e){var t=document.createElement("a");return t.textContent="#",t.href="#"+e,t.classList.add("link-anchor"),t.onclick=bringLinkToView,t}function addAnchor(){var e=document.querySelector(".main-content").querySelector("section");[e.querySelectorAll("h1"),e.querySelectorAll("h2"),e.querySelectorAll("h3"),e.querySelectorAll("h4")].forEach(function(e){e.forEach(function(e){var t=createAnchorElement(e.id);e.classList.add("has-anchor"),e.append(t)})})}function copy(e){const t=document.createElement("textarea");t.value=e,document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t)}function showTooltip(e){var t=document.getElementById(e);t.classList.add("show-tooltip"),setTimeout(function(){t.classList.remove("show-tooltip")},3e3)}function copyFunction(e){var t=document.getElementById(e);copy((t.querySelector(".linenums")||t.querySelector("code")).innerText.trim().replace(/(^\t)/gm,"")),showTooltip("tooltip-"+e)}function hideTocOnSourcePage(){isSourcePage()&&(document.querySelector(".toc-container").style.display="none")}function getPreTopBar(e,t=""){e='<button aria-label="copy code" class="icon-button copy-code" onclick="copyFunction(\''+e+'\')"><svg class="sm-icon" alt="click to copy"><use xlink:href="#copy-icon"></use></svg>'+('<div class="tooltip" id="tooltip-'+e+'">Copied!</div>')+"</button>";return'<div class="pre-top-bar-container">'+('<div class="code-lang-name-container"><div class="code-lang-name">'+t.toLocaleUpperCase()+"</div></div>")+e+"</div>"}function getPreDiv(){var e=document.createElement("div");return e.classList.add("pre-div"),e}function processAllPre(){var e=document.querySelectorAll("pre"),t=document.querySelector("#PeOAagUepe"),o=document.querySelector("#VuAckcnZhf"),n=0,i=0,c=(t&&(i=t.getBoundingClientRect().height),o&&(n=o.getBoundingClientRect().height),window.innerHeight-n-i-250);e.forEach(function(e,t){var o,n=e.parentNode;n&&"true"===n.getAttribute("data-skip-pre-process")||(n=getPreDiv(),o=getPreTopBar(t="ScDloZOMdL"+t,e.getAttribute("data-lang")||"code"),n.innerHTML=o,e.style.maxHeight=c+"px",e.id=t,e.classList.add("prettyprint"),e.parentNode.insertBefore(n,e),n.appendChild(e))})}function highlightAndBringLineIntoView(){var e=window.location.hash.replace("#line","");try{var t='[data-line-number="'+e+'"',o=document.querySelector(t);o.scrollIntoView(),o.parentNode.classList.add("selected")}catch(e){console.error(e)}}function getFontSize(){var e=16;try{e=Number.parseInt(html.style.fontSize.split("px")[0],10)}catch(e){console.log(e)}return e}function localUpdateFontSize(e){html.style.fontSize=e+"px";var t=document.querySelector("#b77a68a492f343baabea06fad81f651e");t&&(t.innerHTML=e)}function updateFontSize(e){localUpdateFontSize(e),localStorage.setItem(fontSizeLocalStorageKey,e)}function incrementFont(e){var t=getFontSize();t<MAX_FONT_SIZE&&updateFontSize(t+1)}function decrementFont(e){var t=getFontSize();MIN_FONT_SIZE<t&&updateFontSize(t-1)}function fontSizeTooltip(){var e=getFontSize();return`
|
|
2
|
+
<div class="font-size-tooltip">
|
|
3
|
+
<button aria-label="decrease-font-size" class="icon-button ${MAX_FONT_SIZE<=e?"disabled":""}" onclick="decrementFont(event)">
|
|
4
|
+
<svg>
|
|
5
|
+
<use xlink:href="#minus-icon"></use>
|
|
6
|
+
</svg>
|
|
7
|
+
</button>
|
|
8
|
+
<div class="font-size-text" id="b77a68a492f343baabea06fad81f651e">
|
|
9
|
+
${e}
|
|
10
|
+
</div>
|
|
11
|
+
<button aria-label="increase-font-size" class="icon-button ${e<=MIN_FONT_SIZE?"disabled":""}" onclick="incrementFont(event)">
|
|
12
|
+
<svg>
|
|
13
|
+
<use xlink:href="#add-icon"></use>
|
|
14
|
+
</svg>
|
|
15
|
+
</button>
|
|
16
|
+
<button class="icon-button" onclick="updateFontSize(16)">
|
|
17
|
+
<svg>
|
|
18
|
+
<use xlink:href="#reset-icon"></use>
|
|
19
|
+
</svg>
|
|
20
|
+
</button>
|
|
21
|
+
</div>
|
|
22
|
+
|
|
23
|
+
`}function initTooltip(){tippy(".theme-toggle",{content:"Toggle Theme",delay:500}),tippy(".search-button",{content:"Search",delay:500}),tippy(".font-size",{content:"Change font size",delay:500}),tippy(".codepen-button",{content:"Open code in CodePen",placement:"left"}),tippy(".copy-code",{content:"Copy this code",placement:"left"}),tippy(".font-size",{content:fontSizeTooltip(),trigger:"click",interactive:!0,allowHTML:!0,placement:"left"})}function fixTable(){for(const t of document.querySelectorAll("table")){if(t.classList.contains("hljs-ln"))return;var e=document.createElement("div");e.classList.add("table-div"),t.parentNode.insertBefore(e,t),e.appendChild(t)}}function hideMobileMenu(){var e=document.querySelector("#mobile-sidebar"),t=document.querySelector("#mobile-menu"),o=t.querySelector("use");e&&e.classList.remove("show"),t&&t.setAttribute("data-isopen","false"),o&&o.setAttribute("xlink:href","#menu-icon")}function showMobileMenu(){var e=document.querySelector("#mobile-sidebar"),t=document.querySelector("#mobile-menu"),o=t.querySelector("use");e&&e.classList.add("show"),t&&t.setAttribute("data-isopen","true"),o&&o.setAttribute("xlink:href","#close-icon")}function onMobileMenuClick(){("true"===document.querySelector("#mobile-menu").getAttribute("data-isopen")?hideMobileMenu:showMobileMenu)()}function initMobileMenu(){var e=document.querySelector("#mobile-menu");e&&e.addEventListener("click",onMobileMenuClick)}function addHrefToSidebarTitle(){document.querySelectorAll(".sidebar-title-anchor").forEach(function(e){e.setAttribute("href",baseURL)})}function highlightActiveLinkInSidebar(){var e=document.location.href.split("/");const t=e[e.length-1];let o=document.querySelector(`.sidebar a[href*='${t}']`);if(!o)try{o=document.querySelector(`.sidebar a[href*='${t.split("#")[0]}']`)}catch(e){return void console.error(e)}o&&(o.parentElement.classList.add("active"),o.scrollIntoView())}function onDomContentLoaded(){var e=document.querySelectorAll(".theme-toggle");initMobileMenu(),e&&e.forEach(function(e){e.addEventListener("click",toggleTheme)}),hljs.addPlugin({"after:highlightElement":function(e){e.el.parentNode.setAttribute("data-lang","code")}}),hljs.highlightAll(),hljs.initLineNumbersOnLoad({singleLine:!0}),initAccordion(),addAnchor(),processAllPre(),hideTocOnSourcePage(),setTimeout(function(){bringIdToViewOnMount(),isSourcePage()&&highlightAndBringLineIntoView()},1e3),initTooltip(),fixTable(),addHrefToSidebarTitle(),highlightActiveLinkInSidebar()}updateTheme(getTheme()),function(){var e=getFontSize(),t=localStorage.getItem(fontSizeLocalStorageKey);t?(t=Number.parseInt(t,10))!==e&&updateFontSize(t):updateFontSize(e)}(),window.addEventListener("DOMContentLoaded",onDomContentLoaded),window.addEventListener("hashchange",e=>{e=new URL(e.newURL);""!==e.hash&&bringIdToViewOnMount(e.hash)}),window.addEventListener("storage",e=>{"undefined"!==e.newValue&&(initTooltip(),e.key===themeLocalStorageKey&&localUpdateTheme(e.newValue),e.key===fontSizeLocalStorageKey&&localUpdateFontSize(e.newValue))});
|