clean-jsdoc-theme 4.2.6 → 4.2.8
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 +13 -1
- package/jsdoc-config.json +2 -1
- package/package.json +3 -3
- package/publish.js +96 -51
- package/static/scripts/core.js +24 -4
- package/static/scripts/core.min.js +23 -23
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
|
|
@@ -417,6 +417,17 @@ To include js files. Example:
|
|
|
417
417
|
It will include the js files to the output dir and also attach a script tag to the html pointing to the included js
|
|
418
418
|
file.
|
|
419
419
|
|
|
420
|
+
### To ignore sorting
|
|
421
|
+
|
|
422
|
+
To ignore the sorting of members/methods/event in the page. If it is `false` then the order of
|
|
423
|
+
members/methods/events will be in the order they are in code/source.
|
|
424
|
+
|
|
425
|
+
```json
|
|
426
|
+
"theme_opts": {
|
|
427
|
+
"sort": false
|
|
428
|
+
}
|
|
429
|
+
```
|
|
430
|
+
|
|
420
431
|
### Footer
|
|
421
432
|
|
|
422
433
|
```json
|
|
@@ -459,6 +470,7 @@ This will remove all symbols (members, methods ...) that come from inherited par
|
|
|
459
470
|
| `sections` | `["Modules", "Classes", "Externals", "Events", "Namespaces", "Mixins", "Tutorials", "Interfaces", "Global"]` | To order navbar/sidebar sections or to hide/remove navbar/sidebar sections | `Array<SECTION_TYPE>` |
|
|
460
471
|
| `displayModuleHeader` | `false` | If you want the module name to appear on its page | `boolean` |
|
|
461
472
|
| `includeFilesListInHomepage` | `false` | If you want to add or remove the list of files in homepage | `boolean` |
|
|
473
|
+
| `sort` | `true` | To sort the output members/methods/events | `boolean` |
|
|
462
474
|
|
|
463
475
|
Don't forget to add the following in your jsdoc config file, otherwise toc will not work on some pages.
|
|
464
476
|
|
package/jsdoc-config.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "clean-jsdoc-theme",
|
|
3
|
-
"version": "4.2.
|
|
3
|
+
"version": "4.2.8",
|
|
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": {
|
|
@@ -45,9 +45,9 @@
|
|
|
45
45
|
"uglify-js": "^3.16.0"
|
|
46
46
|
},
|
|
47
47
|
"dependencies": {
|
|
48
|
-
"@jsdoc/salty": "^0.2.
|
|
48
|
+
"@jsdoc/salty": "^0.2.4",
|
|
49
49
|
"fs-extra": "^10.1.0",
|
|
50
|
-
"html-minifier": "^
|
|
50
|
+
"html-minifier-terser": "^7.2.0",
|
|
51
51
|
"klaw-sync": "^6.0.0",
|
|
52
52
|
"lodash": "^4.17.21",
|
|
53
53
|
"nanoid": "^3.3.4",
|
package/publish.js
CHANGED
|
@@ -7,7 +7,7 @@ const path = require('jsdoc/path');
|
|
|
7
7
|
const { taffy } = require('@jsdoc/salty');
|
|
8
8
|
const template = require('jsdoc/template');
|
|
9
9
|
const nanoid = require('nanoid').nanoid;
|
|
10
|
-
const htmlMinify = require('html-minifier');
|
|
10
|
+
const htmlMinify = require('html-minifier-terser');
|
|
11
11
|
|
|
12
12
|
const {
|
|
13
13
|
buildFooter,
|
|
@@ -284,7 +284,39 @@ function getPathFromDoclet({ meta }) {
|
|
|
284
284
|
: meta.filename;
|
|
285
285
|
}
|
|
286
286
|
|
|
287
|
-
function
|
|
287
|
+
function createPrettyAnchor(elementType, ancestor, name, href) {
|
|
288
|
+
return `<${elementType} ${href ? `href="${href}"` : ''} class="has-anchor">
|
|
289
|
+
<span class="ancestors">
|
|
290
|
+
${ancestor}~
|
|
291
|
+
</span>
|
|
292
|
+
${name}
|
|
293
|
+
</${elementType}>`;
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
function prefixModuleToItemAnchor(item) {
|
|
297
|
+
let { anchor } = item;
|
|
298
|
+
|
|
299
|
+
let anchorLink = anchor.split('href="')[1].split('"')[0];
|
|
300
|
+
let cleanLink = anchorLink.replace(/\.html$/, '');
|
|
301
|
+
|
|
302
|
+
let prettyAnchor;
|
|
303
|
+
|
|
304
|
+
cleanLink.replace(
|
|
305
|
+
/module-([^-]+)(?:-|\.)(.*)/,
|
|
306
|
+
(_match, modulename, methodname) => {
|
|
307
|
+
prettyAnchor = createPrettyAnchor(
|
|
308
|
+
'a',
|
|
309
|
+
modulename,
|
|
310
|
+
methodname,
|
|
311
|
+
anchorLink
|
|
312
|
+
);
|
|
313
|
+
}
|
|
314
|
+
);
|
|
315
|
+
|
|
316
|
+
return prettyAnchor || anchor;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
async function generate(title, docs, filename, resolveLinks) {
|
|
288
320
|
let docData;
|
|
289
321
|
let html;
|
|
290
322
|
let outpath;
|
|
@@ -302,11 +334,9 @@ function generate(title, docs, filename, resolveLinks) {
|
|
|
302
334
|
html = helper.resolveLinks(html); // turn {@link foo} into <a href="foodoc.html">foo</a>
|
|
303
335
|
}
|
|
304
336
|
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
'utf8'
|
|
309
|
-
);
|
|
337
|
+
const minifiedHtml = await htmlMinify.minify(html, HTML_MINIFY_OPTIONS);
|
|
338
|
+
|
|
339
|
+
fs.writeFileSync(outpath, minifiedHtml, 'utf8');
|
|
310
340
|
}
|
|
311
341
|
|
|
312
342
|
function generateSourceFiles(sourceFiles, encoding = 'utf8') {
|
|
@@ -455,8 +485,8 @@ function buildSearchListForData() {
|
|
|
455
485
|
searchList.push({
|
|
456
486
|
title: item.longname,
|
|
457
487
|
link: linkto(item.longname, item.name),
|
|
458
|
-
description: item.description
|
|
459
|
-
})
|
|
488
|
+
description: item.description,
|
|
489
|
+
});
|
|
460
490
|
}
|
|
461
491
|
});
|
|
462
492
|
}
|
|
@@ -605,7 +635,7 @@ function buildSidebar(members) {
|
|
|
605
635
|
nav.sections.push(sections[section]);
|
|
606
636
|
} else {
|
|
607
637
|
const errorMsg = `While building nav. Section name: ${section} is not recognized.
|
|
608
|
-
Accepted sections are: ${defaultSections.join(', ')}
|
|
638
|
+
Accepted sections are: ${defaultSections.join(', ')}
|
|
609
639
|
`;
|
|
610
640
|
|
|
611
641
|
throw new Error(errorMsg);
|
|
@@ -620,7 +650,7 @@ function buildSidebar(members) {
|
|
|
620
650
|
@param {object} opts
|
|
621
651
|
@param {Tutorial} tutorials
|
|
622
652
|
*/
|
|
623
|
-
exports.publish = function (taffyData, opts, tutorials) {
|
|
653
|
+
exports.publish = async function (taffyData, opts, tutorials) {
|
|
624
654
|
let classes;
|
|
625
655
|
let conf;
|
|
626
656
|
let externals;
|
|
@@ -669,7 +699,12 @@ exports.publish = function (taffyData, opts, tutorials) {
|
|
|
669
699
|
helper.setTutorials(tutorials);
|
|
670
700
|
|
|
671
701
|
data = helper.prune(data);
|
|
672
|
-
|
|
702
|
+
|
|
703
|
+
// eslint-disable-next-line no-extra-boolean-cast, no-implicit-coercion
|
|
704
|
+
if (themeOpts.sort !== false) {
|
|
705
|
+
data.sort('longname, version, since');
|
|
706
|
+
}
|
|
707
|
+
|
|
673
708
|
helper.addEventListeners(data);
|
|
674
709
|
|
|
675
710
|
data().each((doclet) => {
|
|
@@ -866,13 +901,23 @@ exports.publish = function (taffyData, opts, tutorials) {
|
|
|
866
901
|
members.modules
|
|
867
902
|
);
|
|
868
903
|
|
|
904
|
+
if (themeOpts.prefixModuleToSidebarItems_experimental) {
|
|
905
|
+
view.sidebar.sections.forEach((section, i) => {
|
|
906
|
+
view.sidebar.sections[i].items = section.items.map((item) => {
|
|
907
|
+
item.anchor = prefixModuleToItemAnchor(item);
|
|
908
|
+
|
|
909
|
+
return item;
|
|
910
|
+
});
|
|
911
|
+
});
|
|
912
|
+
}
|
|
913
|
+
|
|
869
914
|
// generate the pretty-printed source files first so other pages can link to them
|
|
870
915
|
if (outputSourceFiles) {
|
|
871
916
|
generateSourceFiles(sourceFiles, opts.encoding);
|
|
872
917
|
}
|
|
873
918
|
|
|
874
919
|
if (members.globals.length) {
|
|
875
|
-
generate('Global', [{ kind: 'globalobj' }], globalUrl);
|
|
920
|
+
await generate('Global', [{ kind: 'globalobj' }], globalUrl);
|
|
876
921
|
}
|
|
877
922
|
|
|
878
923
|
// index page displays information from package.json and lists files
|
|
@@ -883,7 +928,7 @@ exports.publish = function (taffyData, opts, tutorials) {
|
|
|
883
928
|
const includeFilesListInHomepage =
|
|
884
929
|
themeOpts.includeFilesListInHomepage || false;
|
|
885
930
|
|
|
886
|
-
generate(
|
|
931
|
+
await generate(
|
|
887
932
|
homepageTitle,
|
|
888
933
|
packages
|
|
889
934
|
.concat([
|
|
@@ -907,7 +952,7 @@ exports.publish = function (taffyData, opts, tutorials) {
|
|
|
907
952
|
externals = taffy(members.externals);
|
|
908
953
|
interfaces = taffy(members.interfaces);
|
|
909
954
|
|
|
910
|
-
Object.keys(helper.longnameToUrl).forEach(function (longname) {
|
|
955
|
+
Object.keys(helper.longnameToUrl).forEach(async function (longname) {
|
|
911
956
|
const myClasses = helper.find(classes, { longname: longname });
|
|
912
957
|
const myExternals = helper.find(externals, { longname: longname });
|
|
913
958
|
const myInterfaces = helper.find(interfaces, { longname: longname });
|
|
@@ -916,7 +961,7 @@ exports.publish = function (taffyData, opts, tutorials) {
|
|
|
916
961
|
const myNamespaces = helper.find(namespaces, { longname: longname });
|
|
917
962
|
|
|
918
963
|
if (myModules.length) {
|
|
919
|
-
generate(
|
|
964
|
+
await generate(
|
|
920
965
|
`Module: ${myModules[0].name}`,
|
|
921
966
|
myModules,
|
|
922
967
|
helper.longnameToUrl[longname]
|
|
@@ -924,7 +969,7 @@ exports.publish = function (taffyData, opts, tutorials) {
|
|
|
924
969
|
}
|
|
925
970
|
|
|
926
971
|
if (myClasses.length) {
|
|
927
|
-
generate(
|
|
972
|
+
await generate(
|
|
928
973
|
`Class: ${myClasses[0].name}`,
|
|
929
974
|
myClasses,
|
|
930
975
|
helper.longnameToUrl[longname]
|
|
@@ -932,7 +977,7 @@ exports.publish = function (taffyData, opts, tutorials) {
|
|
|
932
977
|
}
|
|
933
978
|
|
|
934
979
|
if (myNamespaces.length) {
|
|
935
|
-
generate(
|
|
980
|
+
await generate(
|
|
936
981
|
`Namespace: ${myNamespaces[0].name}`,
|
|
937
982
|
myNamespaces,
|
|
938
983
|
helper.longnameToUrl[longname]
|
|
@@ -940,7 +985,7 @@ exports.publish = function (taffyData, opts, tutorials) {
|
|
|
940
985
|
}
|
|
941
986
|
|
|
942
987
|
if (myMixins.length) {
|
|
943
|
-
generate(
|
|
988
|
+
await generate(
|
|
944
989
|
`Mixin: ${myMixins[0].name}`,
|
|
945
990
|
myMixins,
|
|
946
991
|
helper.longnameToUrl[longname]
|
|
@@ -948,7 +993,7 @@ exports.publish = function (taffyData, opts, tutorials) {
|
|
|
948
993
|
}
|
|
949
994
|
|
|
950
995
|
if (myExternals.length) {
|
|
951
|
-
generate(
|
|
996
|
+
await generate(
|
|
952
997
|
`External: ${myExternals[0].name}`,
|
|
953
998
|
myExternals,
|
|
954
999
|
helper.longnameToUrl[longname]
|
|
@@ -956,7 +1001,7 @@ exports.publish = function (taffyData, opts, tutorials) {
|
|
|
956
1001
|
}
|
|
957
1002
|
|
|
958
1003
|
if (myInterfaces.length) {
|
|
959
|
-
generate(
|
|
1004
|
+
await generate(
|
|
960
1005
|
`Interface: ${myInterfaces[0].name}`,
|
|
961
1006
|
myInterfaces,
|
|
962
1007
|
helper.longnameToUrl[longname]
|
|
@@ -965,7 +1010,7 @@ exports.publish = function (taffyData, opts, tutorials) {
|
|
|
965
1010
|
});
|
|
966
1011
|
|
|
967
1012
|
// TODO: move the tutorial functions to templateHelper.js
|
|
968
|
-
function generateTutorial(title, tutorial, filename) {
|
|
1013
|
+
async function generateTutorial(title, tutorial, filename) {
|
|
969
1014
|
const tutorialData = {
|
|
970
1015
|
title: title,
|
|
971
1016
|
header: tutorial.title,
|
|
@@ -979,49 +1024,49 @@ exports.publish = function (taffyData, opts, tutorials) {
|
|
|
979
1024
|
// yes, you can use {@link} in tutorials too!
|
|
980
1025
|
html = helper.resolveLinks(html); // turn {@link foo} into <a href="foodoc.html">foo</a>
|
|
981
1026
|
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
'utf8'
|
|
986
|
-
);
|
|
1027
|
+
const minifiedHTML = await htmlMinify.minify(html, HTML_MINIFY_OPTIONS);
|
|
1028
|
+
|
|
1029
|
+
fs.writeFileSync(tutorialPath, minifiedHTML, 'utf8');
|
|
987
1030
|
|
|
988
1031
|
// added by clean-jsdoc-theme-devs
|
|
989
1032
|
// adding support for tutorial
|
|
990
|
-
if(!hasSearch) return
|
|
1033
|
+
if (!hasSearch) return;
|
|
991
1034
|
|
|
992
|
-
try{
|
|
993
|
-
const baseName = path.basename(tutorialPath)
|
|
994
|
-
let body = /<body.*?>([\s\S]*)<\/body>/.exec(tutorialData.content)
|
|
995
|
-
let description = ''
|
|
1035
|
+
try {
|
|
1036
|
+
const baseName = path.basename(tutorialPath);
|
|
1037
|
+
let body = /<body.*?>([\s\S]*)<\/body>/.exec(tutorialData.content);
|
|
1038
|
+
let description = '';
|
|
996
1039
|
|
|
997
|
-
if(!Array.isArray(body)) {
|
|
998
|
-
body = /<article.*?>([\s\S]*)<\/article>/.exec(
|
|
1040
|
+
if (!Array.isArray(body)) {
|
|
1041
|
+
body = /<article.*?>([\s\S]*)<\/article>/.exec(
|
|
1042
|
+
tutorialData.content
|
|
1043
|
+
);
|
|
999
1044
|
}
|
|
1000
1045
|
|
|
1001
|
-
if(Array.isArray(body) && typeof body[1] === 'string') {
|
|
1046
|
+
if (Array.isArray(body) && typeof body[1] === 'string') {
|
|
1002
1047
|
description = body[1]
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1048
|
+
// Replacing all html tags
|
|
1049
|
+
.replace(/(<([^>]+)>)/g, '')
|
|
1050
|
+
// Replacing all kind of line breaks
|
|
1051
|
+
.replace(/(\r\n|\n|\r)/gm, ' ')
|
|
1052
|
+
// Replacing all multi spaces with single space
|
|
1053
|
+
.replace(/\s+/gm, ' ')
|
|
1054
|
+
// Taking only first 100 characters
|
|
1055
|
+
.substring(0, 100);
|
|
1011
1056
|
}
|
|
1012
1057
|
|
|
1013
|
-
if(typeof baseName === 'string' && baseName) {
|
|
1058
|
+
if (typeof baseName === 'string' && baseName) {
|
|
1014
1059
|
searchList.push({
|
|
1015
1060
|
title: tutorialData.header,
|
|
1016
1061
|
link: `<a href="${baseName}">${baseName}</a>`,
|
|
1017
1062
|
description,
|
|
1018
|
-
})
|
|
1063
|
+
});
|
|
1019
1064
|
}
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
console.error(error)
|
|
1065
|
+
} catch (error) {
|
|
1066
|
+
console.error(
|
|
1067
|
+
'There was some error while creating search array for tutorial.'
|
|
1068
|
+
);
|
|
1069
|
+
console.error(error);
|
|
1025
1070
|
}
|
|
1026
1071
|
}
|
|
1027
1072
|
|
|
@@ -1042,7 +1087,7 @@ exports.publish = function (taffyData, opts, tutorials) {
|
|
|
1042
1087
|
// added by clean-jsdoc-theme-devs
|
|
1043
1088
|
// output search file if search
|
|
1044
1089
|
if (hasSearch) {
|
|
1045
|
-
buildSearchListForData()
|
|
1090
|
+
buildSearchListForData();
|
|
1046
1091
|
mkdirSync(path.join(outdir, 'data'));
|
|
1047
1092
|
fs.writeFileSync(
|
|
1048
1093
|
path.join(outdir, 'data', 'search.json'),
|
package/static/scripts/core.js
CHANGED
|
@@ -16,7 +16,7 @@ function getTheme() {
|
|
|
16
16
|
return body.getAttribute('data-theme');
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
function
|
|
19
|
+
function localUpdateTheme(theme) {
|
|
20
20
|
var body = document.body;
|
|
21
21
|
var svgUse = document.querySelectorAll('.theme-svg-use');
|
|
22
22
|
var iconID = theme === 'dark' ? '#light-theme-icon' : '#dark-theme-icon';
|
|
@@ -28,7 +28,10 @@ function updateTheme(theme) {
|
|
|
28
28
|
svgUse.forEach(function (svg) {
|
|
29
29
|
svg.setAttribute('xlink:href', iconID);
|
|
30
30
|
});
|
|
31
|
+
}
|
|
31
32
|
|
|
33
|
+
function updateTheme(theme) {
|
|
34
|
+
localUpdateTheme(theme);
|
|
32
35
|
localStorage.setItem(themeLocalStorageKey, theme);
|
|
33
36
|
}
|
|
34
37
|
|
|
@@ -145,7 +148,7 @@ function bringElementIntoView(element, updateHistory = true) {
|
|
|
145
148
|
/**
|
|
146
149
|
* tocbotInstance is defined in layout.tmpl
|
|
147
150
|
* It is defined when we are initializing tocbot.
|
|
148
|
-
*
|
|
151
|
+
*
|
|
149
152
|
*/
|
|
150
153
|
// eslint-disable-next-line no-undef
|
|
151
154
|
if (tocbotInstance) {
|
|
@@ -401,9 +404,9 @@ function getFontSize() {
|
|
|
401
404
|
return currentFontSize;
|
|
402
405
|
}
|
|
403
406
|
|
|
404
|
-
function
|
|
407
|
+
function localUpdateFontSize(fontSize) {
|
|
405
408
|
html.style.fontSize = fontSize + 'px';
|
|
406
|
-
|
|
409
|
+
|
|
407
410
|
var fontSizeText = document.querySelector(
|
|
408
411
|
'#b77a68a492f343baabea06fad81f651e'
|
|
409
412
|
);
|
|
@@ -413,6 +416,11 @@ function updateFontSize(fontSize) {
|
|
|
413
416
|
}
|
|
414
417
|
}
|
|
415
418
|
|
|
419
|
+
function updateFontSize(fontSize) {
|
|
420
|
+
localUpdateFontSize(fontSize);
|
|
421
|
+
localStorage.setItem(fontSizeLocalStorageKey, fontSize);
|
|
422
|
+
}
|
|
423
|
+
|
|
416
424
|
(function () {
|
|
417
425
|
var fontSize = getFontSize();
|
|
418
426
|
var fontSizeInLocalStorage = localStorage.getItem(fontSizeLocalStorageKey);
|
|
@@ -653,3 +661,15 @@ window.addEventListener('hashchange', (event) => {
|
|
|
653
661
|
bringIdToViewOnMount(url.hash);
|
|
654
662
|
}
|
|
655
663
|
});
|
|
664
|
+
|
|
665
|
+
// eslint-disable-next-line no-undef
|
|
666
|
+
window.addEventListener('storage', event => {
|
|
667
|
+
if (event.newValue === 'undefined') return;
|
|
668
|
+
|
|
669
|
+
initTooltip();
|
|
670
|
+
|
|
671
|
+
if (event.key === themeLocalStorageKey)
|
|
672
|
+
localUpdateTheme(event.newValue);
|
|
673
|
+
if (event.key === fontSizeLocalStorageKey)
|
|
674
|
+
localUpdateFontSize(event.newValue);
|
|
675
|
+
});
|
|
@@ -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(){return document.body.getAttribute("data-theme")}function
|
|
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()}!function(){var e=getTheme(),t=localStorage.getItem(themeLocalStorageKey);t?e!==t&&updateTheme(t):localStorage.setItem(themeLocalStorageKey,e)}(),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)});
|
|
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(){return document.body.getAttribute("data-theme")}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){console.log(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()}!function(){var e=getTheme(),t=localStorage.getItem(themeLocalStorageKey);t?e!==t&&updateTheme(t):localStorage.setItem(themeLocalStorageKey,e)}(),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))});
|