musora-content-services 1.0.9 → 1.0.10

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.
Files changed (31) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/docs/fonts/Montserrat/Montserrat-Bold.eot +0 -0
  3. package/docs/fonts/Montserrat/Montserrat-Bold.ttf +0 -0
  4. package/docs/fonts/Montserrat/Montserrat-Bold.woff +0 -0
  5. package/docs/fonts/Montserrat/Montserrat-Bold.woff2 +0 -0
  6. package/docs/fonts/Montserrat/Montserrat-Regular.eot +0 -0
  7. package/docs/fonts/Montserrat/Montserrat-Regular.ttf +0 -0
  8. package/docs/fonts/Montserrat/Montserrat-Regular.woff +0 -0
  9. package/docs/fonts/Montserrat/Montserrat-Regular.woff2 +0 -0
  10. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.eot +0 -0
  11. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.svg +978 -0
  12. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.ttf +0 -0
  13. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff +0 -0
  14. package/docs/fonts/Source-Sans-Pro/sourcesanspro-light-webfont.woff2 +0 -0
  15. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.eot +0 -0
  16. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.svg +1049 -0
  17. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.ttf +0 -0
  18. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff +0 -0
  19. package/docs/fonts/Source-Sans-Pro/sourcesanspro-regular-webfont.woff2 +0 -0
  20. package/docs/global.html +846 -931
  21. package/docs/index.html +27 -9
  22. package/docs/index.js.html +20 -8
  23. package/docs/scripts/collapse.js +39 -0
  24. package/docs/scripts/commonNav.js +28 -0
  25. package/docs/scripts/nav.js +12 -0
  26. package/docs/scripts/polyfill.js +4 -0
  27. package/docs/scripts/search.js +99 -265
  28. package/docs/styles/jsdoc.css +776 -0
  29. package/docs/styles/prettify.css +80 -0
  30. package/jsdoc.json +1 -1
  31. package/package.json +5 -4
package/docs/index.html CHANGED
@@ -1,18 +1,21 @@
1
1
  <!DOCTYPE html>
2
2
  <html lang="en">
3
3
  <head>
4
+
4
5
  <meta charset="utf-8">
5
- <meta name="viewport" content="width=device-width,initial-scale=1">
6
6
  <title>Home - Documentation</title>
7
-
7
+
8
+
8
9
  <script src="scripts/prettify/prettify.js"></script>
9
10
  <script src="scripts/prettify/lang-css.js"></script>
10
11
  <!--[if lt IE 9]>
11
12
  <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
12
13
  <![endif]-->
13
- <link type="text/css" rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
14
- <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
15
- <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
14
+ <link type="text/css" rel="stylesheet" href="styles/prettify.css">
15
+ <link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
16
+ <script src="scripts/nav.js" defer></script>
17
+
18
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
16
19
  </head>
17
20
  <body>
18
21
 
@@ -23,8 +26,11 @@
23
26
 
24
27
  <label for="nav-trigger" class="overlay"></label>
25
28
 
26
- <nav>
27
- <li class="nav-link nav-home-link"><a href="index.html">Home</a></li><li class="nav-heading"><a href="global.html">Globals</a></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#fetchAll">fetchAll</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#fetchAllFilterOptions">fetchAllFilterOptions</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#fetchAllSongs">fetchAllSongs</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#fetchArtists">fetchArtists</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#fetchByRailContentId">fetchByRailContentId</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#fetchByRailContentIds">fetchByRailContentIds</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#fetchChildren">fetchChildren</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#fetchLessonContent">fetchLessonContent</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#fetchMethodChildren">fetchMethodChildren</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#fetchMethodNextLesson">fetchMethodNextLesson</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#fetchNewReleases">fetchNewReleases</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#fetchNextPreviousLesson">fetchNextPreviousLesson</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#fetchPackAll">fetchPackAll</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#fetchPackChildren">fetchPackChildren</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#fetchRelatedLessons">fetchRelatedLessons</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#fetchRelatedSongs">fetchRelatedSongs</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#fetchSanity">fetchSanity</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#fetchSongArtistCount">fetchSongArtistCount</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#fetchSongById">fetchSongById</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#fetchSongCount">fetchSongCount</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#fetchSongFilterOptions">fetchSongFilterOptions</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#fetchUpcomingEvents">fetchUpcomingEvents</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#fetchWorkouts">fetchWorkouts</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#initializeSanityService">initializeSanityService</a></span></li>
29
+ <nav >
30
+
31
+
32
+ <h2><a href="index.html">Home</a></h2><h3>Global</h3><ul><li><a href="global.html#fetchAll">fetchAll</a></li><li><a href="global.html#fetchAllFilterOptions">fetchAllFilterOptions</a></li><li><a href="global.html#fetchAllSongs">fetchAllSongs</a></li><li><a href="global.html#fetchArtists">fetchArtists</a></li><li><a href="global.html#fetchByRailContentId">fetchByRailContentId</a></li><li><a href="global.html#fetchByRailContentIds">fetchByRailContentIds</a></li><li><a href="global.html#fetchChildren">fetchChildren</a></li><li><a href="global.html#fetchLessonContent">fetchLessonContent</a></li><li><a href="global.html#fetchMethodChildren">fetchMethodChildren</a></li><li><a href="global.html#fetchMethodNextLesson">fetchMethodNextLesson</a></li><li><a href="global.html#fetchNewReleases">fetchNewReleases</a></li><li><a href="global.html#fetchNextPreviousLesson">fetchNextPreviousLesson</a></li><li><a href="global.html#fetchPackAll">fetchPackAll</a></li><li><a href="global.html#fetchPackChildren">fetchPackChildren</a></li><li><a href="global.html#fetchRelatedLessons">fetchRelatedLessons</a></li><li><a href="global.html#fetchRelatedSongs">fetchRelatedSongs</a></li><li><a href="global.html#fetchSanity">fetchSanity</a></li><li><a href="global.html#fetchSongArtistCount">fetchSongArtistCount</a></li><li><a href="global.html#fetchSongById">fetchSongById</a></li><li><a href="global.html#fetchSongCount">fetchSongCount</a></li><li><a href="global.html#fetchSongFilterOptions">fetchSongFilterOptions</a></li><li><a href="global.html#fetchUpcomingEvents">fetchUpcomingEvents</a></li><li><a href="global.html#fetchWorkouts">fetchWorkouts</a></li><li><a href="global.html#initializeSanityService">initializeSanityService</a></li></ul>
33
+
28
34
  </nav>
29
35
 
30
36
  <div id="main">
@@ -37,6 +43,11 @@
37
43
 
38
44
 
39
45
 
46
+ <section class="package">
47
+ <h3> </h3>
48
+ </section>
49
+
50
+
40
51
 
41
52
 
42
53
 
@@ -47,7 +58,8 @@
47
58
 
48
59
 
49
60
 
50
- <section class="readme">
61
+
62
+ <section class="readme usertext">
51
63
  <article><h1>Musora Content Services</h1>
52
64
  <p>Welcome to the <strong>musora-content-services</strong> repository. This package provides a collection of utility functions designed to fetch and manage content from our Sanity Studio. These functions are tailored to interact with our Sanity backend, allowing you to easily retrieve, filter, and manipulate content for use in various applications.</p>
53
65
  <h2>Features</h2>
@@ -84,15 +96,21 @@ Run the following to execute the tests</p>
84
96
 
85
97
 
86
98
 
99
+
100
+
87
101
  </div>
88
102
 
89
103
  <br class="clear">
90
104
 
91
105
  <footer>
92
- Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Mon Aug 12 2024 13:37:15 GMT+0000 (Coordinated Universal Time) using the Minami theme.
106
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Mon Aug 12 2024 14:00:38 GMT+0000 (Coordinated Universal Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
93
107
  </footer>
94
108
 
95
109
  <script>prettyPrint();</script>
110
+ <script src="scripts/polyfill.js"></script>
96
111
  <script src="scripts/linenumber.js"></script>
112
+
113
+
114
+
97
115
  </body>
98
116
  </html>
@@ -1,18 +1,21 @@
1
1
  <!DOCTYPE html>
2
2
  <html lang="en">
3
3
  <head>
4
+
4
5
  <meta charset="utf-8">
5
- <meta name="viewport" content="width=device-width,initial-scale=1">
6
6
  <title>index.js - Documentation</title>
7
-
7
+
8
+
8
9
  <script src="scripts/prettify/prettify.js"></script>
9
10
  <script src="scripts/prettify/lang-css.js"></script>
10
11
  <!--[if lt IE 9]>
11
12
  <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
12
13
  <![endif]-->
13
- <link type="text/css" rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
14
- <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
15
- <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
14
+ <link type="text/css" rel="stylesheet" href="styles/prettify.css">
15
+ <link type="text/css" rel="stylesheet" href="styles/jsdoc.css">
16
+ <script src="scripts/nav.js" defer></script>
17
+
18
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
16
19
  </head>
17
20
  <body>
18
21
 
@@ -23,8 +26,11 @@
23
26
 
24
27
  <label for="nav-trigger" class="overlay"></label>
25
28
 
26
- <nav>
27
- <li class="nav-link nav-home-link"><a href="index.html">Home</a></li><li class="nav-heading"><a href="global.html">Globals</a></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#fetchAll">fetchAll</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#fetchAllFilterOptions">fetchAllFilterOptions</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#fetchAllSongs">fetchAllSongs</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#fetchArtists">fetchArtists</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#fetchByRailContentId">fetchByRailContentId</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#fetchByRailContentIds">fetchByRailContentIds</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#fetchChildren">fetchChildren</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#fetchLessonContent">fetchLessonContent</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#fetchMethodChildren">fetchMethodChildren</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#fetchMethodNextLesson">fetchMethodNextLesson</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#fetchNewReleases">fetchNewReleases</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#fetchNextPreviousLesson">fetchNextPreviousLesson</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#fetchPackAll">fetchPackAll</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#fetchPackChildren">fetchPackChildren</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#fetchRelatedLessons">fetchRelatedLessons</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#fetchRelatedSongs">fetchRelatedSongs</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#fetchSanity">fetchSanity</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#fetchSongArtistCount">fetchSongArtistCount</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#fetchSongById">fetchSongById</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#fetchSongCount">fetchSongCount</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#fetchSongFilterOptions">fetchSongFilterOptions</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#fetchUpcomingEvents">fetchUpcomingEvents</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#fetchWorkouts">fetchWorkouts</a></span></li><li class="nav-item"><span class="nav-item-type type-function">F</span><span class="nav-item-name"><a href="global.html#initializeSanityService">initializeSanityService</a></span></li>
29
+ <nav >
30
+
31
+
32
+ <h2><a href="index.html">Home</a></h2><h3>Global</h3><ul><li><a href="global.html#fetchAll">fetchAll</a></li><li><a href="global.html#fetchAllFilterOptions">fetchAllFilterOptions</a></li><li><a href="global.html#fetchAllSongs">fetchAllSongs</a></li><li><a href="global.html#fetchArtists">fetchArtists</a></li><li><a href="global.html#fetchByRailContentId">fetchByRailContentId</a></li><li><a href="global.html#fetchByRailContentIds">fetchByRailContentIds</a></li><li><a href="global.html#fetchChildren">fetchChildren</a></li><li><a href="global.html#fetchLessonContent">fetchLessonContent</a></li><li><a href="global.html#fetchMethodChildren">fetchMethodChildren</a></li><li><a href="global.html#fetchMethodNextLesson">fetchMethodNextLesson</a></li><li><a href="global.html#fetchNewReleases">fetchNewReleases</a></li><li><a href="global.html#fetchNextPreviousLesson">fetchNextPreviousLesson</a></li><li><a href="global.html#fetchPackAll">fetchPackAll</a></li><li><a href="global.html#fetchPackChildren">fetchPackChildren</a></li><li><a href="global.html#fetchRelatedLessons">fetchRelatedLessons</a></li><li><a href="global.html#fetchRelatedSongs">fetchRelatedSongs</a></li><li><a href="global.html#fetchSanity">fetchSanity</a></li><li><a href="global.html#fetchSongArtistCount">fetchSongArtistCount</a></li><li><a href="global.html#fetchSongById">fetchSongById</a></li><li><a href="global.html#fetchSongCount">fetchSongCount</a></li><li><a href="global.html#fetchSongFilterOptions">fetchSongFilterOptions</a></li><li><a href="global.html#fetchUpcomingEvents">fetchUpcomingEvents</a></li><li><a href="global.html#fetchWorkouts">fetchWorkouts</a></li><li><a href="global.html#initializeSanityService">initializeSanityService</a></li></ul>
33
+
28
34
  </nav>
29
35
 
30
36
  <div id="main">
@@ -945,15 +951,21 @@ module.exports = {
945
951
 
946
952
 
947
953
 
954
+
955
+
948
956
  </div>
949
957
 
950
958
  <br class="clear">
951
959
 
952
960
  <footer>
953
- Generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Mon Aug 12 2024 13:37:15 GMT+0000 (Coordinated Universal Time) using the Minami theme.
961
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.3</a> on Mon Aug 12 2024 14:00:38 GMT+0000 (Coordinated Universal Time) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
954
962
  </footer>
955
963
 
956
964
  <script>prettyPrint();</script>
965
+ <script src="scripts/polyfill.js"></script>
957
966
  <script src="scripts/linenumber.js"></script>
967
+
968
+
969
+
958
970
  </body>
959
971
  </html>
@@ -0,0 +1,39 @@
1
+ function hideAllButCurrent(){
2
+ //by default all submenut items are hidden
3
+ //but we need to rehide them for search
4
+ document.querySelectorAll("nav > ul").forEach(function(parent) {
5
+ if (parent.className.indexOf("collapse_top") !== -1) {
6
+ parent.style.display = "none";
7
+ }
8
+ });
9
+ document.querySelectorAll("nav > ul > li > ul li").forEach(function(parent) {
10
+ parent.style.display = "none";
11
+ });
12
+ document.querySelectorAll("nav > h3").forEach(function(section) {
13
+ if (section.className.indexOf("collapsed_header") !== -1) {
14
+ section.addEventListener("click", function(){
15
+ if (section.nextSibling.style.display === "none") {
16
+ section.nextSibling.style.display = "block";
17
+ } else {
18
+ section.nextSibling.style.display = "none";
19
+ }
20
+ });
21
+ }
22
+ });
23
+
24
+ //only current page (if it exists) should be opened
25
+ var file = window.location.pathname.split("/").pop().replace(/\.html/, '');
26
+ document.querySelectorAll("nav > ul > li > a").forEach(function(parent) {
27
+ var href = parent.attributes.href.value.replace(/\.html/, '');
28
+ if (file === href) {
29
+ if (parent.parentNode.parentNode.className.indexOf("collapse_top") !== -1) {
30
+ parent.parentNode.parentNode.style.display = "block";
31
+ }
32
+ parent.parentNode.querySelectorAll("ul li").forEach(function(elem) {
33
+ elem.style.display = "block";
34
+ });
35
+ }
36
+ });
37
+ }
38
+
39
+ hideAllButCurrent();
@@ -0,0 +1,28 @@
1
+ if (typeof fetch === 'function') {
2
+ const init = () => {
3
+ if (typeof scrollToNavItem !== 'function') return false
4
+ scrollToNavItem()
5
+ // hideAllButCurrent not always loaded
6
+ if (typeof hideAllButCurrent === 'function') hideAllButCurrent()
7
+ return true
8
+ }
9
+ fetch('./nav.inc.html')
10
+ .then(response => response.ok ? response.text() : `${response.url} => ${response.status} ${response.statusText}`)
11
+ .then(body => {
12
+ document.querySelector('nav').innerHTML += body
13
+ // nav.js should be quicker to load than nav.inc.html, a fallback just in case
14
+ return init()
15
+ })
16
+ .then(done => {
17
+ if (done) return
18
+ let i = 0
19
+ ;(function waitUntilNavJs () {
20
+ if (init()) return
21
+ if (i++ < 100) return setTimeout(waitUntilNavJs, 300)
22
+ console.error(Error('nav.js not loaded after 30s waiting for it'))
23
+ })()
24
+ })
25
+ .catch(error => console.error(error))
26
+ } else {
27
+ console.error(Error('Browser too old to display commonNav (remove commonNav docdash option)'))
28
+ }
@@ -0,0 +1,12 @@
1
+ function scrollToNavItem() {
2
+ var path = window.location.href.split('/').pop().replace(/\.html/, '');
3
+ document.querySelectorAll('nav a').forEach(function(link) {
4
+ var href = link.attributes.href.value.replace(/\.html/, '');
5
+ if (path === href) {
6
+ link.scrollIntoView({block: 'center'});
7
+ return;
8
+ }
9
+ })
10
+ }
11
+
12
+ scrollToNavItem();
@@ -0,0 +1,4 @@
1
+ //IE Fix, src: https://www.reddit.com/r/programminghorror/comments/6abmcr/nodelist_lacks_foreach_in_internet_explorer/
2
+ if (typeof(NodeList.prototype.forEach)!==typeof(alert)){
3
+ NodeList.prototype.forEach=Array.prototype.forEach;
4
+ }
@@ -1,265 +1,99 @@
1
- /* global document */
2
-
3
- const searchId = 'LiBfqbJVcV';
4
- const searchHash = '#' + searchId;
5
- const searchContainer = document.querySelector('#PkfLWpAbet');
6
- const searchWrapper = document.querySelector('#iCxFxjkHbP');
7
- const searchCloseButton = document.querySelector('#VjLlGakifb');
8
- const searchInput = document.querySelector('#vpcKVYIppa');
9
- const resultBox = document.querySelector('#fWwVHRuDuN');
10
-
11
- function showResultText(text) {
12
- resultBox.innerHTML = `<span class="search-result-c-text">${text}</span>`;
13
- }
14
-
15
- function hideSearch() {
16
- // eslint-disable-next-line no-undef
17
- if (window.location.hash === searchHash) {
18
- // eslint-disable-next-line no-undef
19
- history.go(-1);
20
- }
21
-
22
- // eslint-disable-next-line no-undef
23
- window.onhashchange = null;
24
-
25
- if (searchContainer) {
26
- searchContainer.style.display = 'none';
27
- }
28
- }
29
-
30
- function listenCloseKey(event) {
31
- if (event.key === 'Escape') {
32
- hideSearch();
33
- // eslint-disable-next-line no-undef
34
- window.removeEventListener('keyup', listenCloseKey);
35
- }
36
- }
37
-
38
- function showSearch() {
39
- try {
40
- // Closing mobile menu before opening
41
- // search box.
42
- // It is defined in core.js
43
- // eslint-disable-next-line no-undef
44
- hideMobileMenu();
45
- } catch (error) {
46
- console.error(error);
47
- }
48
-
49
- // eslint-disable-next-line no-undef
50
- window.onhashchange = hideSearch;
51
-
52
- // eslint-disable-next-line no-undef
53
- if (window.location.hash !== searchHash) {
54
- // eslint-disable-next-line no-undef
55
- history.pushState(null, null, searchHash);
56
- }
57
-
58
- if (searchContainer) {
59
- searchContainer.style.display = 'flex';
60
- // eslint-disable-next-line no-undef
61
- window.addEventListener('keyup', listenCloseKey);
62
- }
63
-
64
- if (searchInput) {
65
- searchInput.focus();
66
- }
67
- }
68
-
69
- async function fetchAllData() {
70
- // eslint-disable-next-line no-undef
71
- const { hostname, protocol, port } = location;
72
-
73
- // eslint-disable-next-line no-undef
74
- const base = protocol + '//' + hostname + (port !== '' ? ':' + port : '') + baseURL;
75
- // eslint-disable-next-line no-undef
76
- const url = new URL('data/search.json', base);
77
- const result = await fetch(url);
78
- const { list } = await result.json();
79
-
80
- return list;
81
- }
82
-
83
- // eslint-disable-next-line no-unused-vars
84
- function onClickSearchItem(event) {
85
- const target = event.currentTarget;
86
-
87
- if (target) {
88
- const href = target.getAttribute('href') || '';
89
- let elementId = href.split('#')[1] || '';
90
- let element = document.getElementById(elementId);
91
-
92
- if (!element) {
93
- elementId = decodeURI(elementId);
94
- element = document.getElementById(elementId);
95
- }
96
-
97
- if (element) {
98
- setTimeout(function() {
99
- // eslint-disable-next-line no-undef
100
- bringElementIntoView(element); // defined in core.js
101
- }, 100);
102
- }
103
- }
104
- }
105
-
106
- function buildSearchResult(result) {
107
- let output = '';
108
- const removeHTMLTagsRegExp = /(<([^>]+)>)/ig;
109
-
110
- for (const res of result) {
111
- const { title = '', description = '' } = res.item;
112
-
113
- const _link = res.item.link.replace('<a href="', '').replace(/">.*/, '');
114
- const _title = title.replace(removeHTMLTagsRegExp, "");
115
- const _description = description.replace(removeHTMLTagsRegExp, "");
116
-
117
- output += `
118
- <a onclick="onClickSearchItem(event)" href="${_link}" class="search-result-item">
119
- <div class="search-result-item-title">${_title}</div>
120
- <div class="search-result-item-p">${_description || 'No description available.'}</div>
121
- </a>
122
- `;
123
- }
124
-
125
- return output;
126
- }
127
-
128
- function getSearchResult(list, keys, searchKey) {
129
- const defaultOptions = {
130
- shouldSort: true,
131
- threshold: 0.4,
132
- location: 0,
133
- distance: 100,
134
- maxPatternLength: 32,
135
- minMatchCharLength: 1,
136
- keys: keys
137
- };
138
-
139
- const options = { ...defaultOptions };
140
-
141
- // eslint-disable-next-line no-undef
142
- const searchIndex = Fuse.createIndex(options.keys, list);
143
-
144
- // eslint-disable-next-line no-undef
145
- const fuse = new Fuse(list, options, searchIndex);
146
-
147
- const result = fuse.search(searchKey);
148
-
149
- if (result.length > 20) {
150
- return result.slice(0, 20);
151
- }
152
-
153
- return result;
154
- }
155
-
156
- function debounce(func, wait, immediate) {
157
- let timeout;
158
-
159
- return function() {
160
- const args = arguments;
161
-
162
- clearTimeout(timeout);
163
- timeout = setTimeout(() => {
164
- timeout = null;
165
- if (!immediate) {
166
- // eslint-disable-next-line consistent-this, no-invalid-this
167
- func.apply(this, args);
168
- }
169
- }, wait);
170
-
171
- if (immediate && !timeout) {
172
- // eslint-disable-next-line consistent-this, no-invalid-this
173
- func.apply(this, args);
174
- }
175
- };
176
- }
177
-
178
- let searchData;
179
-
180
- async function search(event) {
181
- const value = event.target.value;
182
- const keys = ['title', 'description'];
183
-
184
- if (!resultBox) {
185
- console.error('Search result container not found');
186
-
187
- return;
188
- }
189
-
190
- if (!value) {
191
- showResultText('Type anything to view search result');
192
-
193
- return;
194
- }
195
-
196
- if (!searchData) {
197
- showResultText('Loading...');
198
-
199
- try {
200
- // eslint-disable-next-line require-atomic-updates
201
- searchData = await fetchAllData();
202
- } catch (e) {
203
- console.log(e);
204
- showResultText('Failed to load result.');
205
-
206
- return;
207
- }
208
- }
209
-
210
- const result = getSearchResult(searchData, keys, value);
211
-
212
- if (!result.length) {
213
- showResultText('No result found! Try some different combination.');
214
-
215
- return;
216
- }
217
-
218
- // eslint-disable-next-line require-atomic-updates
219
- resultBox.innerHTML = buildSearchResult(result);
220
- }
221
-
222
- function onDomContentLoaded() {
223
- const searchButton = document.querySelectorAll('.search-button');
224
- const debouncedSearch = debounce(search, 300);
225
-
226
- if (searchCloseButton) {
227
- searchCloseButton.addEventListener('click', hideSearch);
228
- }
229
-
230
- if (searchButton) {
231
- searchButton.forEach(function(item) {
232
- item.addEventListener('click', showSearch);
233
- });
234
- }
235
-
236
- if (searchContainer) {
237
- searchContainer.addEventListener('click', hideSearch);
238
- }
239
-
240
- if (searchWrapper) {
241
- searchWrapper.addEventListener('click', function(event) {
242
- event.stopPropagation();
243
- });
244
- }
245
-
246
- if (searchInput) {
247
- searchInput.addEventListener('keyup', debouncedSearch);
248
- }
249
-
250
- // eslint-disable-next-line no-undef
251
- if (window.location.hash === searchHash) {
252
- showSearch();
253
- }
254
- }
255
-
256
- // eslint-disable-next-line no-undef
257
- window.addEventListener('DOMContentLoaded', onDomContentLoaded);
258
-
259
- // eslint-disable-next-line no-undef
260
- window.addEventListener('hashchange', function() {
261
- // eslint-disable-next-line no-undef
262
- if (window.location.hash === searchHash) {
263
- showSearch();
264
- }
265
- });
1
+
2
+ var searchAttr = 'data-search-mode';
3
+ function contains(a,m){
4
+ return (a.textContent || a.innerText || "").toUpperCase().indexOf(m) !== -1;
5
+ };
6
+
7
+ //on search
8
+ document.getElementById("nav-search").addEventListener("keyup", function(event) {
9
+ var search = this.value.toUpperCase();
10
+
11
+ if (!search) {
12
+ //no search, show all results
13
+ document.documentElement.removeAttribute(searchAttr);
14
+
15
+ document.querySelectorAll("nav > ul > li:not(.level-hide)").forEach(function(elem) {
16
+ elem.style.display = "block";
17
+ });
18
+
19
+ if (typeof hideAllButCurrent === "function"){
20
+ //let's do what ever collapse wants to do
21
+ hideAllButCurrent();
22
+ } else {
23
+ //menu by default should be opened
24
+ document.querySelectorAll("nav > ul > li > ul li").forEach(function(elem) {
25
+ elem.style.display = "block";
26
+ });
27
+ }
28
+ } else {
29
+ //we are searching
30
+ document.documentElement.setAttribute(searchAttr, '');
31
+
32
+ //show all parents
33
+ document.querySelectorAll("nav > ul > li").forEach(function(elem) {
34
+ elem.style.display = "block";
35
+ });
36
+ document.querySelectorAll("nav > ul").forEach(function(elem) {
37
+ elem.style.display = "block";
38
+ });
39
+ //hide all results
40
+ document.querySelectorAll("nav > ul > li > ul li").forEach(function(elem) {
41
+ elem.style.display = "none";
42
+ });
43
+ //show results matching filter
44
+ document.querySelectorAll("nav > ul > li > ul a").forEach(function(elem) {
45
+ if (!contains(elem.parentNode, search)) {
46
+ return;
47
+ }
48
+ elem.parentNode.style.display = "block";
49
+ });
50
+ //hide parents without children
51
+ document.querySelectorAll("nav > ul > li").forEach(function(parent) {
52
+ var countSearchA = 0;
53
+ parent.querySelectorAll("a").forEach(function(elem) {
54
+ if (contains(elem, search)) {
55
+ countSearchA++;
56
+ }
57
+ });
58
+
59
+ var countUl = 0;
60
+ var countUlVisible = 0;
61
+ parent.querySelectorAll("ul").forEach(function(ulP) {
62
+ // count all elements that match the search
63
+ if (contains(ulP, search)) {
64
+ countUl++;
65
+ }
66
+
67
+ // count all visible elements
68
+ var children = ulP.children
69
+ for (i=0; i<children.length; i++) {
70
+ var elem = children[i];
71
+ if (elem.style.display != "none") {
72
+ countUlVisible++;
73
+ }
74
+ }
75
+ });
76
+
77
+ if (countSearchA == 0 && countUl === 0){
78
+ //has no child at all and does not contain text
79
+ parent.style.display = "none";
80
+ } else if(countSearchA == 0 && countUlVisible == 0){
81
+ //has no visible child and does not contain text
82
+ parent.style.display = "none";
83
+ }
84
+ });
85
+ document.querySelectorAll("nav > ul.collapse_top").forEach(function(parent) {
86
+ var countVisible = 0;
87
+ parent.querySelectorAll("li").forEach(function(elem) {
88
+ if (elem.style.display !== "none") {
89
+ countVisible++;
90
+ }
91
+ });
92
+
93
+ if (countVisible == 0) {
94
+ //has no child at all and does not contain text
95
+ parent.style.display = "none";
96
+ }
97
+ });
98
+ }
99
+ });