rx-player 4.0.0-beta.1 → 4.0.0-beta.2
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/CHANGELOG.md +40 -0
- package/CONTRIBUTING.md +48 -168
- package/FILES.md +40 -92
- package/VERSION +1 -1
- package/dist/_esm5.processed/compat/browser_detection.d.ts +3 -1
- package/dist/_esm5.processed/compat/browser_detection.js +7 -2
- package/dist/_esm5.processed/compat/eme/load_session.js +1 -1
- package/dist/_esm5.processed/compat/has_issues_with_high_media_source_duration.d.ts +21 -0
- package/dist/_esm5.processed/compat/has_issues_with_high_media_source_duration.js +26 -0
- package/dist/_esm5.processed/config.d.ts +2 -0
- package/dist/_esm5.processed/core/adaptive/adaptive_representation_selector.js +5 -4
- package/dist/_esm5.processed/core/adaptive/buffer_based_chooser.d.ts +18 -1
- package/dist/_esm5.processed/core/adaptive/buffer_based_chooser.js +106 -25
- package/dist/_esm5.processed/core/adaptive/guess_based_chooser.js +6 -6
- package/dist/_esm5.processed/core/adaptive/network_analyzer.js +8 -5
- package/dist/_esm5.processed/core/adaptive/utils/representation_score_calculator.d.ts +19 -1
- package/dist/_esm5.processed/core/adaptive/utils/representation_score_calculator.js +1 -1
- package/dist/_esm5.processed/core/api/debug/render.js +1 -1
- package/dist/_esm5.processed/core/api/playback_observer.js +1 -0
- package/dist/_esm5.processed/core/api/public_api.d.ts +54 -1
- package/dist/_esm5.processed/core/api/public_api.js +232 -35
- package/dist/_esm5.processed/core/api/track_management/media_element_tracks_store.js +10 -1
- package/dist/_esm5.processed/core/api/track_management/track_dispatcher.d.ts +13 -1
- package/dist/_esm5.processed/core/api/track_management/track_dispatcher.js +30 -15
- package/dist/_esm5.processed/core/api/track_management/tracks_store.d.ts +3 -1
- package/dist/_esm5.processed/core/api/track_management/tracks_store.js +67 -152
- package/dist/_esm5.processed/core/api/utils.d.ts +10 -0
- package/dist/_esm5.processed/core/api/utils.js +20 -0
- package/dist/_esm5.processed/core/decrypt/session_events_listener.js +7 -1
- package/dist/_esm5.processed/core/decrypt/utils/clean_old_loaded_sessions.js +2 -0
- package/dist/_esm5.processed/core/decrypt/utils/loaded_sessions_store.js +5 -1
- package/dist/_esm5.processed/core/init/directfile_content_initializer.js +1 -1
- package/dist/_esm5.processed/core/init/media_source_content_initializer.js +47 -10
- package/dist/_esm5.processed/core/init/types.d.ts +9 -1
- package/dist/_esm5.processed/core/init/utils/content_time_boundaries_observer.d.ts +28 -1
- package/dist/_esm5.processed/core/init/utils/content_time_boundaries_observer.js +22 -9
- package/dist/_esm5.processed/core/init/utils/media_source_duration_updater.d.ts +58 -0
- package/dist/_esm5.processed/core/init/utils/{media_duration_updater.js → media_source_duration_updater.js} +84 -87
- package/dist/_esm5.processed/core/init/utils/rebuffering_controller.d.ts +36 -2
- package/dist/_esm5.processed/core/init/utils/rebuffering_controller.js +82 -2
- package/dist/_esm5.processed/core/segment_buffers/implementations/audio_video/audio_video_segment_buffer.d.ts +18 -7
- package/dist/_esm5.processed/core/segment_buffers/implementations/audio_video/audio_video_segment_buffer.js +31 -40
- package/dist/_esm5.processed/core/segment_buffers/implementations/text/html/html_text_segment_buffer.d.ts +8 -0
- package/dist/_esm5.processed/core/segment_buffers/implementations/text/html/html_text_segment_buffer.js +12 -0
- package/dist/_esm5.processed/core/segment_buffers/implementations/text/native/native_text_segment_buffer.d.ts +8 -0
- package/dist/_esm5.processed/core/segment_buffers/implementations/text/native/native_text_segment_buffer.js +12 -0
- package/dist/_esm5.processed/core/segment_buffers/implementations/types.d.ts +11 -4
- package/dist/_esm5.processed/core/segment_buffers/index.d.ts +2 -2
- package/dist/_esm5.processed/core/stream/adaptation/utils/create_representation_estimator.d.ts +47 -0
- package/dist/_esm5.processed/core/stream/adaptation/utils/create_representation_estimator.js +70 -0
- package/dist/_esm5.processed/core/stream/orchestrator/stream_orchestrator.js +15 -8
- package/dist/_esm5.processed/core/stream/period/period_stream.js +1 -1
- package/dist/_esm5.processed/core/stream/representation/representation_stream.js +22 -13
- package/dist/_esm5.processed/core/stream/representation/utils/append_segment_to_buffer.d.ts +4 -2
- package/dist/_esm5.processed/core/stream/representation/utils/append_segment_to_buffer.js +2 -2
- package/dist/_esm5.processed/core/stream/representation/utils/push_init_segment.d.ts +3 -2
- package/dist/_esm5.processed/core/stream/representation/utils/push_init_segment.js +8 -8
- package/dist/_esm5.processed/core/stream/representation/utils/push_media_segment.d.ts +2 -2
- package/dist/_esm5.processed/core/stream/representation/utils/push_media_segment.js +2 -3
- package/dist/_esm5.processed/default_config.d.ts +25 -0
- package/dist/_esm5.processed/default_config.js +27 -2
- package/dist/_esm5.processed/errors/index.d.ts +2 -2
- package/dist/_esm5.processed/errors/media_error.d.ts +23 -1
- package/dist/_esm5.processed/errors/media_error.js +18 -5
- package/dist/_esm5.processed/experimental/tools/VideoThumbnailLoader/load_and_push_segment.d.ts +1 -1
- package/dist/_esm5.processed/experimental/tools/VideoThumbnailLoader/load_and_push_segment.js +8 -7
- package/dist/_esm5.processed/experimental/tools/VideoThumbnailLoader/video_thumbnail_loader.js +17 -9
- package/dist/_esm5.processed/experimental/tools/mediaCapabilitiesProber/index.js +0 -2
- package/dist/_esm5.processed/manifest/adaptation.d.ts +21 -2
- package/dist/_esm5.processed/manifest/adaptation.js +76 -1
- package/dist/_esm5.processed/manifest/manifest.js +1 -1
- package/dist/_esm5.processed/manifest/period.js +2 -2
- package/dist/_esm5.processed/manifest/representation.d.ts +33 -2
- package/dist/_esm5.processed/manifest/representation.js +21 -0
- package/dist/_esm5.processed/manifest/utils.js +1 -3
- package/dist/_esm5.processed/parsers/manifest/dash/js-parser/parse_from_document.d.ts +1 -1
- package/dist/_esm5.processed/parsers/manifest/dash/js-parser/parse_from_document.js +1 -1
- package/dist/_esm5.processed/parsers/manifest/dash/wasm-parser/ts/dash-wasm-parser.js +1 -0
- package/dist/_esm5.processed/public_types.d.ts +13 -3
- package/dist/_esm5.processed/tools/TextTrackRenderer/text_track_renderer.js +1 -1
- package/dist/_esm5.processed/transports/smooth/isobmff/create_boxes.d.ts +4 -6
- package/dist/_esm5.processed/transports/smooth/isobmff/create_boxes.js +4 -6
- package/dist/_esm5.processed/utils/is_null_or_undefined.d.ts +1 -1
- package/dist/_esm5.processed/utils/is_null_or_undefined.js +1 -1
- package/dist/mpd-parser.wasm +0 -0
- package/dist/rx-player.js +4709 -4218
- package/dist/rx-player.min.js +1 -1
- package/package.json +42 -36
- package/scripts/build/generate_build.js +1 -1
- package/scripts/fast_demo_build.js +4 -3
- package/scripts/generate_full_demo.js +1 -1
- package/sonar-project.properties +1 -1
- package/src/compat/browser_detection.ts +7 -1
- package/src/compat/eme/load_session.ts +1 -1
- package/src/compat/has_issues_with_high_media_source_duration.ts +27 -0
- package/src/core/adaptive/__tests__/buffer_based_chooser.test.ts +147 -48
- package/src/core/adaptive/adaptive_representation_selector.ts +7 -4
- package/src/core/adaptive/buffer_based_chooser.ts +144 -26
- package/src/core/adaptive/guess_based_chooser.ts +9 -8
- package/src/core/adaptive/network_analyzer.ts +9 -4
- package/src/core/adaptive/utils/representation_score_calculator.ts +22 -2
- package/src/core/api/debug/render.ts +1 -1
- package/src/core/api/playback_observer.ts +1 -0
- package/src/core/api/public_api.ts +277 -44
- package/src/core/api/track_management/media_element_tracks_store.ts +17 -8
- package/src/core/api/track_management/track_dispatcher.ts +37 -14
- package/src/core/api/track_management/tracks_store.ts +77 -167
- package/src/core/api/utils.ts +26 -0
- package/src/core/decrypt/session_events_listener.ts +6 -1
- package/src/core/decrypt/utils/clean_old_loaded_sessions.ts +2 -1
- package/src/core/decrypt/utils/loaded_sessions_store.ts +8 -1
- package/src/core/init/directfile_content_initializer.ts +1 -0
- package/src/core/init/media_source_content_initializer.ts +52 -9
- package/src/core/init/types.ts +9 -1
- package/src/core/init/utils/content_time_boundaries_observer.ts +46 -10
- package/src/core/init/utils/{media_duration_updater.ts → media_source_duration_updater.ts} +100 -112
- package/src/core/init/utils/rebuffering_controller.ts +114 -3
- package/src/core/segment_buffers/implementations/audio_video/audio_video_segment_buffer.ts +56 -55
- package/src/core/segment_buffers/implementations/text/html/html_text_segment_buffer.ts +16 -0
- package/src/core/segment_buffers/implementations/text/native/native_text_segment_buffer.ts +16 -0
- package/src/core/segment_buffers/implementations/types.ts +16 -4
- package/src/core/segment_buffers/index.ts +2 -0
- package/src/core/stream/adaptation/utils/create_representation_estimator.ts +114 -0
- package/src/core/stream/orchestrator/stream_orchestrator.ts +16 -8
- package/src/core/stream/period/period_stream.ts +2 -1
- package/src/core/stream/representation/representation_stream.ts +34 -22
- package/src/core/stream/representation/utils/append_segment_to_buffer.ts +8 -3
- package/src/core/stream/representation/utils/push_init_segment.ts +11 -6
- package/src/core/stream/representation/utils/push_media_segment.ts +3 -3
- package/src/default_config.ts +29 -2
- package/src/errors/__tests__/media_error.test.ts +6 -6
- package/src/errors/index.ts +4 -1
- package/src/errors/media_error.ts +67 -1
- package/src/experimental/tools/VideoThumbnailLoader/load_and_push_segment.ts +10 -7
- package/src/experimental/tools/VideoThumbnailLoader/video_thumbnail_loader.ts +17 -6
- package/src/experimental/tools/mediaCapabilitiesProber/index.ts +0 -4
- package/src/manifest/__tests__/manifest.test.ts +7 -7
- package/src/manifest/__tests__/period.test.ts +90 -45
- package/src/manifest/adaptation.ts +89 -1
- package/src/manifest/manifest.ts +1 -1
- package/src/manifest/period.ts +4 -2
- package/src/manifest/representation.ts +67 -1
- package/src/manifest/utils.ts +1 -3
- package/src/parsers/manifest/dash/js-parser/parse_from_document.ts +1 -1
- package/src/parsers/manifest/dash/wasm-parser/ts/dash-wasm-parser.ts +1 -0
- package/src/parsers/texttracks/ttml/parse_ttml.ts +1 -1
- package/src/public_types.ts +16 -1
- package/src/tools/TextTrackRenderer/text_track_renderer.ts +1 -1
- package/src/transports/smooth/isobmff/create_boxes.ts +4 -6
- package/src/typings/globals.d.ts +20 -20
- package/src/utils/is_null_or_undefined.ts +1 -1
- package/dist/_esm5.processed/core/init/utils/media_duration_updater.d.ts +0 -56
- package/scripts/doc-generator/construct_table_of_contents.js +0 -76
- package/scripts/doc-generator/convert_MD_to_HMTL.js +0 -26
- package/scripts/doc-generator/create_documentation.js +0 -331
- package/scripts/doc-generator/create_documentation_page.js +0 -209
- package/scripts/doc-generator/create_page.js +0 -210
- package/scripts/doc-generator/generate_header_html.js +0 -147
- package/scripts/doc-generator/generate_page_html.js +0 -115
- package/scripts/doc-generator/generate_page_list_html.js +0 -92
- package/scripts/doc-generator/generate_sidebar_html.js +0 -85
- package/scripts/doc-generator/get_search_data_for_content.js +0 -137
- package/scripts/doc-generator/index.js +0 -34
- package/scripts/doc-generator/parse_doc_configs.js +0 -327
- package/scripts/doc-generator/scripts/lunr.js +0 -10
- package/scripts/doc-generator/scripts/script.js +0 -451
- package/scripts/doc-generator/styles/code.css +0 -99
- package/scripts/doc-generator/styles/style.css +0 -835
- package/scripts/doc-generator/utils.js +0 -74
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* elasticlunr - http://weixsong.github.io
|
|
3
|
-
* Lightweight full-text search engine in Javascript for browser search and offline search. - 0.9.5
|
|
4
|
-
*
|
|
5
|
-
* Copyright (C) 2017 Oliver Nightingale
|
|
6
|
-
* Copyright (C) 2017 Wei Song
|
|
7
|
-
* MIT Licensed
|
|
8
|
-
* @license
|
|
9
|
-
*/
|
|
10
|
-
!function(){function e(e){if(null===e||"object"!=typeof e)return e;var t=e.constructor();for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n]);return t}var t=function(e){var n=new t.Index;return n.pipeline.add(t.trimmer,t.stopWordFilter,t.stemmer),e&&e.call(n,n),n};t.version="0.9.5",lunr=t,t.utils={},t.utils.warn=function(e){return function(t){e.console&&console.warn&&console.warn(t)}}(this),t.utils.toString=function(e){return void 0===e||null===e?"":e.toString()},t.EventEmitter=function(){this.events={}},t.EventEmitter.prototype.addListener=function(){var e=Array.prototype.slice.call(arguments),t=e.pop(),n=e;if("function"!=typeof t)throw new TypeError("last argument must be a function");n.forEach(function(e){this.hasHandler(e)||(this.events[e]=[]),this.events[e].push(t)},this)},t.EventEmitter.prototype.removeListener=function(e,t){if(this.hasHandler(e)){var n=this.events[e].indexOf(t);-1!==n&&(this.events[e].splice(n,1),0==this.events[e].length&&delete this.events[e])}},t.EventEmitter.prototype.emit=function(e){if(this.hasHandler(e)){var t=Array.prototype.slice.call(arguments,1);this.events[e].forEach(function(e){e.apply(void 0,t)},this)}},t.EventEmitter.prototype.hasHandler=function(e){return e in this.events},t.tokenizer=function(e){if(!arguments.length||null===e||void 0===e)return[];if(Array.isArray(e)){var n=e.filter(function(e){return null===e||void 0===e?!1:!0});n=n.map(function(e){return t.utils.toString(e).toLowerCase()});var i=[];return n.forEach(function(e){var n=e.split(t.tokenizer.seperator);i=i.concat(n)},this),i}return e.toString().trim().toLowerCase().split(t.tokenizer.seperator)},t.tokenizer.defaultSeperator=/[\s\-]+/,t.tokenizer.seperator=t.tokenizer.defaultSeperator,t.tokenizer.setSeperator=function(e){null!==e&&void 0!==e&&"object"==typeof e&&(t.tokenizer.seperator=e)},t.tokenizer.resetSeperator=function(){t.tokenizer.seperator=t.tokenizer.defaultSeperator},t.tokenizer.getSeperator=function(){return t.tokenizer.seperator},t.Pipeline=function(){this._queue=[]},t.Pipeline.registeredFunctions={},t.Pipeline.registerFunction=function(e,n){n in t.Pipeline.registeredFunctions&&t.utils.warn("Overwriting existing registered function: "+n),e.label=n,t.Pipeline.registeredFunctions[n]=e},t.Pipeline.getRegisteredFunction=function(e){return e in t.Pipeline.registeredFunctions!=!0?null:t.Pipeline.registeredFunctions[e]},t.Pipeline.warnIfFunctionNotRegistered=function(e){var n=e.label&&e.label in this.registeredFunctions;n||t.utils.warn("Function is not registered with pipeline. This may cause problems when serialising the index.\n",e)},t.Pipeline.load=function(e){var n=new t.Pipeline;return e.forEach(function(e){var i=t.Pipeline.getRegisteredFunction(e);if(!i)throw new Error("Cannot load un-registered function: "+e);n.add(i)}),n},t.Pipeline.prototype.add=function(){var e=Array.prototype.slice.call(arguments);e.forEach(function(e){t.Pipeline.warnIfFunctionNotRegistered(e),this._queue.push(e)},this)},t.Pipeline.prototype.after=function(e,n){t.Pipeline.warnIfFunctionNotRegistered(n);var i=this._queue.indexOf(e);if(-1===i)throw new Error("Cannot find existingFn");this._queue.splice(i+1,0,n)},t.Pipeline.prototype.before=function(e,n){t.Pipeline.warnIfFunctionNotRegistered(n);var i=this._queue.indexOf(e);if(-1===i)throw new Error("Cannot find existingFn");this._queue.splice(i,0,n)},t.Pipeline.prototype.remove=function(e){var t=this._queue.indexOf(e);-1!==t&&this._queue.splice(t,1)},t.Pipeline.prototype.run=function(e){for(var t=[],n=e.length,i=this._queue.length,o=0;n>o;o++){for(var r=e[o],s=0;i>s&&(r=this._queue[s](r,o,e),void 0!==r&&null!==r);s++);void 0!==r&&null!==r&&t.push(r)}return t},t.Pipeline.prototype.reset=function(){this._queue=[]},t.Pipeline.prototype.get=function(){return this._queue},t.Pipeline.prototype.toJSON=function(){return this._queue.map(function(e){return t.Pipeline.warnIfFunctionNotRegistered(e),e.label})},t.Index=function(){this._fields=[],this._ref="id",this.pipeline=new t.Pipeline,this.documentStore=new t.DocumentStore,this.index={},this.eventEmitter=new t.EventEmitter,this._idfCache={},this.on("add","remove","update",function(){this._idfCache={}}.bind(this))},t.Index.prototype.on=function(){var e=Array.prototype.slice.call(arguments);return this.eventEmitter.addListener.apply(this.eventEmitter,e)},t.Index.prototype.off=function(e,t){return this.eventEmitter.removeListener(e,t)},t.Index.load=function(e){e.version!==t.version&&t.utils.warn("version mismatch: current "+t.version+" importing "+e.version);var n=new this;n._fields=e.fields,n._ref=e.ref,n.documentStore=t.DocumentStore.load(e.documentStore),n.pipeline=t.Pipeline.load(e.pipeline),n.index={};for(var i in e.index)n.index[i]=t.InvertedIndex.load(e.index[i]);return n},t.Index.prototype.addField=function(e){return this._fields.push(e),this.index[e]=new t.InvertedIndex,this},t.Index.prototype.setRef=function(e){return this._ref=e,this},t.Index.prototype.saveDocument=function(e){return this.documentStore=new t.DocumentStore(e),this},t.Index.prototype.addDoc=function(e,n){if(e){var n=void 0===n?!0:n,i=e[this._ref];this.documentStore.addDoc(i,e),this._fields.forEach(function(n){var o=this.pipeline.run(t.tokenizer(e[n]));this.documentStore.addFieldLength(i,n,o.length);var r={};o.forEach(function(e){e in r?r[e]+=1:r[e]=1},this);for(var s in r){var u=r[s];u=Math.sqrt(u),this.index[n].addToken(s,{ref:i,tf:u})}},this),n&&this.eventEmitter.emit("add",e,this)}},t.Index.prototype.removeDocByRef=function(e){if(e&&this.documentStore.isDocStored()!==!1&&this.documentStore.hasDoc(e)){var t=this.documentStore.getDoc(e);this.removeDoc(t,!1)}},t.Index.prototype.removeDoc=function(e,n){if(e){var n=void 0===n?!0:n,i=e[this._ref];this.documentStore.hasDoc(i)&&(this.documentStore.removeDoc(i),this._fields.forEach(function(n){var o=this.pipeline.run(t.tokenizer(e[n]));o.forEach(function(e){this.index[n].removeToken(e,i)},this)},this),n&&this.eventEmitter.emit("remove",e,this))}},t.Index.prototype.updateDoc=function(e,t){var t=void 0===t?!0:t;this.removeDocByRef(e[this._ref],!1),this.addDoc(e,!1),t&&this.eventEmitter.emit("update",e,this)},t.Index.prototype.idf=function(e,t){var n="@"+t+"/"+e;if(Object.prototype.hasOwnProperty.call(this._idfCache,n))return this._idfCache[n];var i=this.index[t].getDocFreq(e),o=1+Math.log(this.documentStore.length/(i+1));return this._idfCache[n]=o,o},t.Index.prototype.getFields=function(){return this._fields.slice()},t.Index.prototype.search=function(e,n){if(!e)return[];e="string"==typeof e?{any:e}:JSON.parse(JSON.stringify(e));var i=null;null!=n&&(i=JSON.stringify(n));for(var o=new t.Configuration(i,this.getFields()).get(),r={},s=Object.keys(e),u=0;u<s.length;u++){var a=s[u];r[a]=this.pipeline.run(t.tokenizer(e[a]))}var l={};for(var c in o){var d=r[c]||r.any;if(d){var f=this.fieldSearch(d,c,o),h=o[c].boost;for(var p in f)f[p]=f[p]*h;for(var p in f)p in l?l[p]+=f[p]:l[p]=f[p]}}var v,g=[];for(var p in l)v={ref:p,score:l[p]},this.documentStore.hasDoc(p)&&(v.doc=this.documentStore.getDoc(p)),g.push(v);return g.sort(function(e,t){return t.score-e.score}),g},t.Index.prototype.fieldSearch=function(e,t,n){var i=n[t].bool,o=n[t].expand,r=n[t].boost,s=null,u={};return 0!==r?(e.forEach(function(e){var n=[e];1==o&&(n=this.index[t].expandToken(e));var r={};n.forEach(function(n){var o=this.index[t].getDocs(n),a=this.idf(n,t);if(s&&"AND"==i){var l={};for(var c in s)c in o&&(l[c]=o[c]);o=l}n==e&&this.fieldSearchStats(u,n,o);for(var c in o){var d=this.index[t].getTermFrequency(n,c),f=this.documentStore.getFieldLength(c,t),h=1;0!=f&&(h=1/Math.sqrt(f));var p=1;n!=e&&(p=.15*(1-(n.length-e.length)/n.length));var v=d*a*h*p;c in r?r[c]+=v:r[c]=v}},this),s=this.mergeScores(s,r,i)},this),s=this.coordNorm(s,u,e.length)):void 0},t.Index.prototype.mergeScores=function(e,t,n){if(!e)return t;if("AND"==n){var i={};for(var o in t)o in e&&(i[o]=e[o]+t[o]);return i}for(var o in t)o in e?e[o]+=t[o]:e[o]=t[o];return e},t.Index.prototype.fieldSearchStats=function(e,t,n){for(var i in n)i in e?e[i].push(t):e[i]=[t]},t.Index.prototype.coordNorm=function(e,t,n){for(var i in e)if(i in t){var o=t[i].length;e[i]=e[i]*o/n}return e},t.Index.prototype.toJSON=function(){var e={};return this._fields.forEach(function(t){e[t]=this.index[t].toJSON()},this),{version:t.version,fields:this._fields,ref:this._ref,documentStore:this.documentStore.toJSON(),index:e,pipeline:this.pipeline.toJSON()}},t.Index.prototype.use=function(e){var t=Array.prototype.slice.call(arguments,1);t.unshift(this),e.apply(this,t)},t.DocumentStore=function(e){this._save=null===e||void 0===e?!0:e,this.docs={},this.docInfo={},this.length=0},t.DocumentStore.load=function(e){var t=new this;return t.length=e.length,t.docs=e.docs,t.docInfo=e.docInfo,t._save=e.save,t},t.DocumentStore.prototype.isDocStored=function(){return this._save},t.DocumentStore.prototype.addDoc=function(t,n){this.hasDoc(t)||this.length++,this.docs[t]=this._save===!0?e(n):null},t.DocumentStore.prototype.getDoc=function(e){return this.hasDoc(e)===!1?null:this.docs[e]},t.DocumentStore.prototype.hasDoc=function(e){return e in this.docs},t.DocumentStore.prototype.removeDoc=function(e){this.hasDoc(e)&&(delete this.docs[e],delete this.docInfo[e],this.length--)},t.DocumentStore.prototype.addFieldLength=function(e,t,n){null!==e&&void 0!==e&&0!=this.hasDoc(e)&&(this.docInfo[e]||(this.docInfo[e]={}),this.docInfo[e][t]=n)},t.DocumentStore.prototype.updateFieldLength=function(e,t,n){null!==e&&void 0!==e&&0!=this.hasDoc(e)&&this.addFieldLength(e,t,n)},t.DocumentStore.prototype.getFieldLength=function(e,t){return null===e||void 0===e?0:e in this.docs&&t in this.docInfo[e]?this.docInfo[e][t]:0},t.DocumentStore.prototype.toJSON=function(){return{docs:this.docs,docInfo:this.docInfo,length:this.length,save:this._save}},t.stemmer=function(){var e={ational:"ate",tional:"tion",enci:"ence",anci:"ance",izer:"ize",bli:"ble",alli:"al",entli:"ent",eli:"e",ousli:"ous",ization:"ize",ation:"ate",ator:"ate",alism:"al",iveness:"ive",fulness:"ful",ousness:"ous",aliti:"al",iviti:"ive",biliti:"ble",logi:"log"},t={icate:"ic",ative:"",alize:"al",iciti:"ic",ical:"ic",ful:"",ness:""},n="[^aeiou]",i="[aeiouy]",o=n+"[^aeiouy]*",r=i+"[aeiou]*",s="^("+o+")?"+r+o,u="^("+o+")?"+r+o+"("+r+")?$",a="^("+o+")?"+r+o+r+o,l="^("+o+")?"+i,c=new RegExp(s),d=new RegExp(a),f=new RegExp(u),h=new RegExp(l),p=/^(.+?)(ss|i)es$/,v=/^(.+?)([^s])s$/,g=/^(.+?)eed$/,m=/^(.+?)(ed|ing)$/,y=/.$/,S=/(at|bl|iz)$/,x=new RegExp("([^aeiouylsz])\\1$"),w=new RegExp("^"+o+i+"[^aeiouwxy]$"),I=/^(.+?[^aeiou])y$/,b=/^(.+?)(ational|tional|enci|anci|izer|bli|alli|entli|eli|ousli|ization|ation|ator|alism|iveness|fulness|ousness|aliti|iviti|biliti|logi)$/,E=/^(.+?)(icate|ative|alize|iciti|ical|ful|ness)$/,D=/^(.+?)(al|ance|ence|er|ic|able|ible|ant|ement|ment|ent|ou|ism|ate|iti|ous|ive|ize)$/,F=/^(.+?)(s|t)(ion)$/,_=/^(.+?)e$/,P=/ll$/,k=new RegExp("^"+o+i+"[^aeiouwxy]$"),z=function(n){var i,o,r,s,u,a,l;if(n.length<3)return n;if(r=n.substr(0,1),"y"==r&&(n=r.toUpperCase()+n.substr(1)),s=p,u=v,s.test(n)?n=n.replace(s,"$1$2"):u.test(n)&&(n=n.replace(u,"$1$2")),s=g,u=m,s.test(n)){var z=s.exec(n);s=c,s.test(z[1])&&(s=y,n=n.replace(s,""))}else if(u.test(n)){var z=u.exec(n);i=z[1],u=h,u.test(i)&&(n=i,u=S,a=x,l=w,u.test(n)?n+="e":a.test(n)?(s=y,n=n.replace(s,"")):l.test(n)&&(n+="e"))}if(s=I,s.test(n)){var z=s.exec(n);i=z[1],n=i+"i"}if(s=b,s.test(n)){var z=s.exec(n);i=z[1],o=z[2],s=c,s.test(i)&&(n=i+e[o])}if(s=E,s.test(n)){var z=s.exec(n);i=z[1],o=z[2],s=c,s.test(i)&&(n=i+t[o])}if(s=D,u=F,s.test(n)){var z=s.exec(n);i=z[1],s=d,s.test(i)&&(n=i)}else if(u.test(n)){var z=u.exec(n);i=z[1]+z[2],u=d,u.test(i)&&(n=i)}if(s=_,s.test(n)){var z=s.exec(n);i=z[1],s=d,u=f,a=k,(s.test(i)||u.test(i)&&!a.test(i))&&(n=i)}return s=P,u=d,s.test(n)&&u.test(n)&&(s=y,n=n.replace(s,"")),"y"==r&&(n=r.toLowerCase()+n.substr(1)),n};return z}(),t.Pipeline.registerFunction(t.stemmer,"stemmer"),t.stopWordFilter=function(e){return e&&t.stopWordFilter.stopWords[e]!==!0?e:void 0},t.clearStopWords=function(){t.stopWordFilter.stopWords={}},t.addStopWords=function(e){null!=e&&Array.isArray(e)!==!1&&e.forEach(function(e){t.stopWordFilter.stopWords[e]=!0},this)},t.resetStopWords=function(){t.stopWordFilter.stopWords=t.defaultStopWords},t.defaultStopWords={"":!0,a:!0,able:!0,about:!0,across:!0,after:!0,all:!0,almost:!0,also:!0,am:!0,among:!0,an:!0,and:!0,any:!0,are:!0,as:!0,at:!0,be:!0,because:!0,been:!0,but:!0,by:!0,can:!0,cannot:!0,could:!0,dear:!0,did:!0,"do":!0,does:!0,either:!0,"else":!0,ever:!0,every:!0,"for":!0,from:!0,get:!0,got:!0,had:!0,has:!0,have:!0,he:!0,her:!0,hers:!0,him:!0,his:!0,how:!0,however:!0,i:!0,"if":!0,"in":!0,into:!0,is:!0,it:!0,its:!0,just:!0,least:!0,let:!0,like:!0,likely:!0,may:!0,me:!0,might:!0,most:!0,must:!0,my:!0,neither:!0,no:!0,nor:!0,not:!0,of:!0,off:!0,often:!0,on:!0,only:!0,or:!0,other:!0,our:!0,own:!0,rather:!0,said:!0,say:!0,says:!0,she:!0,should:!0,since:!0,so:!0,some:!0,than:!0,that:!0,the:!0,their:!0,them:!0,then:!0,there:!0,these:!0,they:!0,"this":!0,tis:!0,to:!0,too:!0,twas:!0,us:!0,wants:!0,was:!0,we:!0,were:!0,what:!0,when:!0,where:!0,which:!0,"while":!0,who:!0,whom:!0,why:!0,will:!0,"with":!0,would:!0,yet:!0,you:!0,your:!0},t.stopWordFilter.stopWords=t.defaultStopWords,t.Pipeline.registerFunction(t.stopWordFilter,"stopWordFilter"),t.trimmer=function(e){if(null===e||void 0===e)throw new Error("token should not be undefined");return e.replace(/^\W+/,"").replace(/\W+$/,"")},t.Pipeline.registerFunction(t.trimmer,"trimmer"),t.InvertedIndex=function(){this.root={docs:{},df:0}},t.InvertedIndex.load=function(e){var t=new this;return t.root=e.root,t},t.InvertedIndex.prototype.addToken=function(e,t,n){for(var n=n||this.root,i=0;i<=e.length-1;){var o=e[i];o in n||(n[o]={docs:{},df:0}),i+=1,n=n[o]}var r=t.ref;n.docs[r]?n.docs[r]={tf:t.tf}:(n.docs[r]={tf:t.tf},n.df+=1)},t.InvertedIndex.prototype.hasToken=function(e){if(!e)return!1;for(var t=this.root,n=0;n<e.length;n++){if(!t[e[n]])return!1;t=t[e[n]]}return!0},t.InvertedIndex.prototype.getNode=function(e){if(!e)return null;for(var t=this.root,n=0;n<e.length;n++){if(!t[e[n]])return null;t=t[e[n]]}return t},t.InvertedIndex.prototype.getDocs=function(e){var t=this.getNode(e);return null==t?{}:t.docs},t.InvertedIndex.prototype.getTermFrequency=function(e,t){var n=this.getNode(e);return null==n?0:t in n.docs?n.docs[t].tf:0},t.InvertedIndex.prototype.getDocFreq=function(e){var t=this.getNode(e);return null==t?0:t.df},t.InvertedIndex.prototype.removeToken=function(e,t){if(e){var n=this.getNode(e);null!=n&&t in n.docs&&(delete n.docs[t],n.df-=1)}},t.InvertedIndex.prototype.expandToken=function(e,t,n){if(null==e||""==e)return[];var t=t||[];if(void 0==n&&(n=this.getNode(e),null==n))return t;n.df>0&&t.push(e);for(var i in n)"docs"!==i&&"df"!==i&&this.expandToken(e+i,t,n[i]);return t},t.InvertedIndex.prototype.toJSON=function(){return{root:this.root}},t.Configuration=function(e,n){var e=e||"";if(void 0==n||null==n)throw new Error("fields should not be null");this.config={};var i;try{i=JSON.parse(e),this.buildUserConfig(i,n)}catch(o){t.utils.warn("user configuration parse failed, will use default configuration"),this.buildDefaultConfig(n)}},t.Configuration.prototype.buildDefaultConfig=function(e){this.reset(),e.forEach(function(e){this.config[e]={boost:1,bool:"OR",expand:!1}},this)},t.Configuration.prototype.buildUserConfig=function(e,n){var i="OR",o=!1;if(this.reset(),"bool"in e&&(i=e.bool||i),"expand"in e&&(o=e.expand||o),"fields"in e)for(var r in e.fields)if(n.indexOf(r)>-1){var s=e.fields[r],u=o;void 0!=s.expand&&(u=s.expand),this.config[r]={boost:s.boost||0===s.boost?s.boost:1,bool:s.bool||i,expand:u}}else t.utils.warn("field name in user configuration not found in index instance fields");else this.addAllFields2UserConfig(i,o,n)},t.Configuration.prototype.addAllFields2UserConfig=function(e,t,n){n.forEach(function(n){this.config[n]={boost:1,bool:e,expand:t}},this)},t.Configuration.prototype.get=function(){return this.config},t.Configuration.prototype.reset=function(){this.config={}},lunr.SortedSet=function(){this.length=0,this.elements=[]},lunr.SortedSet.load=function(e){var t=new this;return t.elements=e,t.length=e.length,t},lunr.SortedSet.prototype.add=function(){var e,t;for(e=0;e<arguments.length;e++)t=arguments[e],~this.indexOf(t)||this.elements.splice(this.locationFor(t),0,t);this.length=this.elements.length},lunr.SortedSet.prototype.toArray=function(){return this.elements.slice()},lunr.SortedSet.prototype.map=function(e,t){return this.elements.map(e,t)},lunr.SortedSet.prototype.forEach=function(e,t){return this.elements.forEach(e,t)},lunr.SortedSet.prototype.indexOf=function(e){for(var t=0,n=this.elements.length,i=n-t,o=t+Math.floor(i/2),r=this.elements[o];i>1;){if(r===e)return o;e>r&&(t=o),r>e&&(n=o),i=n-t,o=t+Math.floor(i/2),r=this.elements[o]}return r===e?o:-1},lunr.SortedSet.prototype.locationFor=function(e){for(var t=0,n=this.elements.length,i=n-t,o=t+Math.floor(i/2),r=this.elements[o];i>1;)e>r&&(t=o),r>e&&(n=o),i=n-t,o=t+Math.floor(i/2),r=this.elements[o];return r>e?o:e>r?o+1:void 0},lunr.SortedSet.prototype.intersect=function(e){for(var t=new lunr.SortedSet,n=0,i=0,o=this.length,r=e.length,s=this.elements,u=e.elements;;){if(n>o-1||i>r-1)break;s[n]!==u[i]?s[n]<u[i]?n++:s[n]>u[i]&&i++:(t.add(s[n]),n++,i++)}return t},lunr.SortedSet.prototype.clone=function(){var e=new lunr.SortedSet;return e.elements=this.toArray(),e.length=e.elements.length,e},lunr.SortedSet.prototype.union=function(e){var t,n,i;this.length>=e.length?(t=this,n=e):(t=e,n=this),i=t.clone();for(var o=0,r=n.toArray();o<r.length;o++)i.add(r[o]);return i},lunr.SortedSet.prototype.toJSON=function(){return this.toArray()},function(e,t){"function"==typeof define&&define.amd?define(t):"object"==typeof exports?module.exports=t():e.elasticlunr=t()}(this,function(){return t})}();
|
|
@@ -1,451 +0,0 @@
|
|
|
1
|
-
const rootUrl = window.rootUrl;
|
|
2
|
-
|
|
3
|
-
const searchParams = new URLSearchParams(window.location.search);
|
|
4
|
-
|
|
5
|
-
// =========== Initialize search ===========
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Last searched text.
|
|
9
|
-
* `null` if nothing was yet searched in the current searching session.
|
|
10
|
-
* @type {string|null}
|
|
11
|
-
*/
|
|
12
|
-
let lastSearch = null;
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Status of the search initialization (loading + building of the index).
|
|
16
|
-
* Can be:
|
|
17
|
-
* 1. "not-loaded": when... not loaded.
|
|
18
|
-
* 2. "loading": when in the process of being loaded (e.g. the index request
|
|
19
|
-
* is pending).
|
|
20
|
-
* 3. "loaded": Search is initialized with success. This is the only state
|
|
21
|
-
* under which search operations can be performed.
|
|
22
|
-
* 4. "failed": Search initialization failed.
|
|
23
|
-
* @type {string}
|
|
24
|
-
*/
|
|
25
|
-
let searchInitStatus = "not-loaded";
|
|
26
|
-
|
|
27
|
-
/**
|
|
28
|
-
* Contains the links to search results.
|
|
29
|
-
* The elements of this array are in this same order than `elasticlunr`'s index.
|
|
30
|
-
* @type {Array.<Object>}
|
|
31
|
-
*/
|
|
32
|
-
let searchIndexLinks = [];
|
|
33
|
-
|
|
34
|
-
/** Parent element to search-related dynamic elements (input + results ...) */
|
|
35
|
-
const searchWrapperElt = document.getElementById("search-wrapper");
|
|
36
|
-
|
|
37
|
-
/** All search icon elements in the page (hopefully, there's only one). */
|
|
38
|
-
const searchIconElts = document.getElementsByClassName("search-icon");
|
|
39
|
-
|
|
40
|
-
/** The Element corresponding to the search input. */
|
|
41
|
-
const searchBarElt = document.getElementById("searchbar");
|
|
42
|
-
|
|
43
|
-
/** The Element containing the search results. */
|
|
44
|
-
const searchResultsElt = document.getElementById("search-results");
|
|
45
|
-
|
|
46
|
-
const searchEngine = elasticlunr(function () {
|
|
47
|
-
this.addField("h1");
|
|
48
|
-
this.addField("h2");
|
|
49
|
-
this.addField("h3");
|
|
50
|
-
this.addField("body");
|
|
51
|
-
this.setRef("id");
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
if (searchIconElts.length > 0) {
|
|
55
|
-
for (let i = 0; i < searchIconElts.length; i++) {
|
|
56
|
-
const searchIconElt = searchIconElts[i];
|
|
57
|
-
searchIconElt.onclick = function() {
|
|
58
|
-
lastSearch = null;
|
|
59
|
-
searchResultsElt.innerHTML = "";
|
|
60
|
-
searchBarElt.value = "";
|
|
61
|
-
if (searchWrapperElt.classList.contains("active")) {
|
|
62
|
-
searchParams.delete("search");
|
|
63
|
-
history.replaceState(null, null, window.location.href.split("?")[0])
|
|
64
|
-
searchWrapperElt.classList.remove("active");
|
|
65
|
-
searchIconElt.classList.remove("active");
|
|
66
|
-
} else {
|
|
67
|
-
if (searchInitStatus === "not-loaded") {
|
|
68
|
-
initializeSearchEngine().then(() => {
|
|
69
|
-
updateSearchResults();
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
window.scrollTo(0, 0);
|
|
73
|
-
searchWrapperElt.classList.add("active");
|
|
74
|
-
searchIconElt.classList.add("active");
|
|
75
|
-
searchBarElt.focus();
|
|
76
|
-
updateSearchResults();
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
{
|
|
83
|
-
const initialSearch = searchParams.get("search");
|
|
84
|
-
if (initialSearch !== null) {
|
|
85
|
-
searchWrapperElt.classList.add("active");
|
|
86
|
-
for (let i = 0; i < searchIconElts.length; i++) {
|
|
87
|
-
searchIconElts[i].classList.add("active");
|
|
88
|
-
}
|
|
89
|
-
searchBarElt.value = initialSearch;
|
|
90
|
-
searchBarElt.focus();
|
|
91
|
-
searchBarElt.selectionStart = searchBarElt.selectionEnd = searchBarElt.value.length;
|
|
92
|
-
updateSearchResults();
|
|
93
|
-
initializeSearchEngine().then(() => {
|
|
94
|
-
updateSearchResults();
|
|
95
|
-
});
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
function initializeSearchEngine() {
|
|
100
|
-
searchInitStatus = "loading";
|
|
101
|
-
return fetch(rootUrl + "/searchIndex.json")
|
|
102
|
-
.then(res => res.json())
|
|
103
|
-
.then(res => {
|
|
104
|
-
if (!Array.isArray(res)) {
|
|
105
|
-
console.error("Failed to initialize search: index has an invalid format.");
|
|
106
|
-
return;
|
|
107
|
-
}
|
|
108
|
-
searchIndexLinks = [];
|
|
109
|
-
let id = 0;
|
|
110
|
-
for (let i = 0; i < res.length; i++) {
|
|
111
|
-
for (let j = 0; j < res[i].index.length; j++) {
|
|
112
|
-
const elt = res[i].index[j];
|
|
113
|
-
searchIndexLinks.push({
|
|
114
|
-
file: res[i].file,
|
|
115
|
-
anchorH1: elt.anchorH1,
|
|
116
|
-
anchorH2: elt.anchorH2,
|
|
117
|
-
anchorH3: elt.anchorH3,
|
|
118
|
-
});
|
|
119
|
-
searchEngine.addDoc({
|
|
120
|
-
h1: elt.h1,
|
|
121
|
-
h2: elt.h2,
|
|
122
|
-
h3: elt.h3,
|
|
123
|
-
body: elt.body,
|
|
124
|
-
id: id,
|
|
125
|
-
});
|
|
126
|
-
id++;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
searchInitStatus = "loaded";
|
|
130
|
-
})
|
|
131
|
-
.catch(err => {
|
|
132
|
-
searchInitStatus = "failed";
|
|
133
|
-
console.error("Could not initialize search:", err);
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
if (searchBarElt !== null) {
|
|
138
|
-
searchBarElt.oninput = function() {
|
|
139
|
-
searchParams.set("search", searchBarElt.value);
|
|
140
|
-
history.replaceState(null, null, "?" + searchParams.toString());
|
|
141
|
-
updateSearchResults();
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
function updateSearchResults() {
|
|
146
|
-
const value = searchBarElt.value;
|
|
147
|
-
if (value === lastSearch) {
|
|
148
|
-
return;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
if (value === "") {
|
|
152
|
-
lastSearch = "";
|
|
153
|
-
searchResultsElt.innerHTML = "<div class=\"message\">" +
|
|
154
|
-
"Enter text to search in all documentation pages." +
|
|
155
|
-
"</div>";
|
|
156
|
-
return;
|
|
157
|
-
}
|
|
158
|
-
if (searchInitStatus === "not-loaded") {
|
|
159
|
-
lastSearch = null;
|
|
160
|
-
searchResultsElt.innerHTML = "<div class=\"message\">" +
|
|
161
|
-
"Loading the search index..." +
|
|
162
|
-
"</div>";
|
|
163
|
-
return;
|
|
164
|
-
}
|
|
165
|
-
if (searchInitStatus === "failed") {
|
|
166
|
-
lastSearch = null;
|
|
167
|
-
searchResultsElt.innerHTML = "<div class=\"message\">" +
|
|
168
|
-
"Error: an error happened while initializing the search index" +
|
|
169
|
-
"</div>";
|
|
170
|
-
return;
|
|
171
|
-
}
|
|
172
|
-
lastSearch = value;
|
|
173
|
-
|
|
174
|
-
const searchResults = searchEngine.search(value, {
|
|
175
|
-
fields: {
|
|
176
|
-
h1: { boost: 5, bool: "AND" },
|
|
177
|
-
h2: { boost: 4, bool: "AND" },
|
|
178
|
-
h3: { boost: 3, bool: "AND" },
|
|
179
|
-
body: { boost: 1 }
|
|
180
|
-
},
|
|
181
|
-
expand: true,
|
|
182
|
-
});
|
|
183
|
-
if (searchResults.length === 0) {
|
|
184
|
-
searchResultsElt.innerHTML = "<div class=\"message\">" +
|
|
185
|
-
"No result for that search." +
|
|
186
|
-
"</div>";
|
|
187
|
-
return;
|
|
188
|
-
}
|
|
189
|
-
searchResultsElt.innerHTML = "";
|
|
190
|
-
for (let resIdx = 0; resIdx < searchResults.length && resIdx < 30; resIdx++) {
|
|
191
|
-
const res = searchResults[resIdx];
|
|
192
|
-
const links = searchIndexLinks[+res.ref];
|
|
193
|
-
const contentDiv = document.createElement("div");
|
|
194
|
-
contentDiv.className = "search-result-item";
|
|
195
|
-
|
|
196
|
-
const locationDiv = document.createElement("div");
|
|
197
|
-
locationDiv.className = "search-result-location";
|
|
198
|
-
if (res.doc.h1 !== undefined && res.doc.h1 !== "") {
|
|
199
|
-
let linkH1;
|
|
200
|
-
if (links.anchorH1 !== undefined) {
|
|
201
|
-
const href = rootUrl + "/" + links.file + "#" + links.anchorH1;
|
|
202
|
-
linkH1 = document.createElement("a");
|
|
203
|
-
linkH1.href = href;
|
|
204
|
-
} else {
|
|
205
|
-
linkH1 = document.createElement("span");
|
|
206
|
-
}
|
|
207
|
-
linkH1.className = "h1";
|
|
208
|
-
linkH1.textContent = res.doc.h1;
|
|
209
|
-
locationDiv.appendChild(linkH1);
|
|
210
|
-
if (res.doc.h2 !== undefined && res.doc.h2 !== "") {
|
|
211
|
-
const separatorSpan = document.createElement("span");
|
|
212
|
-
separatorSpan.textContent = " > ";
|
|
213
|
-
locationDiv.appendChild(separatorSpan);
|
|
214
|
-
let linkH2;
|
|
215
|
-
if (links.anchorH2 !== undefined) {
|
|
216
|
-
const href = rootUrl + "/" + links.file + "#" + links.anchorH2;
|
|
217
|
-
linkH2 = document.createElement("a");
|
|
218
|
-
linkH2.href = href;
|
|
219
|
-
} else {
|
|
220
|
-
linkH2 = document.createElement("span");
|
|
221
|
-
}
|
|
222
|
-
linkH2.className = "h2";
|
|
223
|
-
linkH2.textContent = res.doc.h2;
|
|
224
|
-
locationDiv.appendChild(linkH2);
|
|
225
|
-
if (res.doc.h3 !== undefined && res.doc.h3 !== "") {
|
|
226
|
-
const separatorSpan = document.createElement("span");
|
|
227
|
-
separatorSpan.textContent = " > ";
|
|
228
|
-
locationDiv.appendChild(separatorSpan);
|
|
229
|
-
let linkH3;
|
|
230
|
-
if (links.anchorH3 !== undefined) {
|
|
231
|
-
const href = rootUrl + "/" + links.file + "#" + links.anchorH3;
|
|
232
|
-
linkH3 = document.createElement("a");
|
|
233
|
-
linkH3.href = href;
|
|
234
|
-
} else {
|
|
235
|
-
linkH3 = document.createElement("span");
|
|
236
|
-
}
|
|
237
|
-
linkH3.className = "h3";
|
|
238
|
-
linkH3.textContent = res.doc.h3;
|
|
239
|
-
locationDiv.appendChild(linkH3);
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
const bodyDiv = document.createElement("div");
|
|
244
|
-
bodyDiv.className = "search-result-body";
|
|
245
|
-
let body = res.doc.body ?? "";
|
|
246
|
-
if (body.length > 300) {
|
|
247
|
-
body = body.substring(0, 300) + "...";
|
|
248
|
-
}
|
|
249
|
-
bodyDiv.textContent = body;
|
|
250
|
-
|
|
251
|
-
contentDiv.appendChild(locationDiv);
|
|
252
|
-
contentDiv.appendChild(bodyDiv);
|
|
253
|
-
searchResultsElt.appendChild(contentDiv);
|
|
254
|
-
}
|
|
255
|
-
return;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
// ========= Sidebar + PageList opening / closing ===========
|
|
259
|
-
|
|
260
|
-
const sidebarGroupElts = document.getElementsByClassName("sidebar-item-group");
|
|
261
|
-
const pageListGroupElts = document.getElementsByClassName("page-list-group");
|
|
262
|
-
const groupElts = [];
|
|
263
|
-
for (let i = 0; i < sidebarGroupElts.length; i++) {
|
|
264
|
-
groupElts.push(sidebarGroupElts[i]);
|
|
265
|
-
}
|
|
266
|
-
for (let i = 0; i < pageListGroupElts.length; i++) {
|
|
267
|
-
groupElts.push(pageListGroupElts[i]);
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
for (let groupElt of groupElts) {
|
|
271
|
-
const wrapper = groupElt.parentElement;
|
|
272
|
-
const ulElt = wrapper.getElementsByTagName("ul")[0];
|
|
273
|
-
const pageGroupElt = ulElt.previousSibling;
|
|
274
|
-
let status = "closed";
|
|
275
|
-
let openingTimeout;
|
|
276
|
-
let closingTimeout;
|
|
277
|
-
|
|
278
|
-
if (ulElt !== undefined) {
|
|
279
|
-
if (pageGroupElt.classList.contains("opened")) {
|
|
280
|
-
// already opened sidebar group
|
|
281
|
-
status = "opened";
|
|
282
|
-
ulElt.style.display = "block";
|
|
283
|
-
ulElt.style.height = `auto`;
|
|
284
|
-
}
|
|
285
|
-
ulElt.addEventListener("transitionend", onTransitionEnd);
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
groupElt.onclick = function () {
|
|
289
|
-
if (pageGroupElt.classList.contains("opened")) {
|
|
290
|
-
progressivelyHideElt();
|
|
291
|
-
} else {
|
|
292
|
-
progressivelyDisplayElt();
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
function progressivelyDisplayElt() {
|
|
297
|
-
clearTimeout(openingTimeout);
|
|
298
|
-
clearTimeout(closingTimeout);
|
|
299
|
-
pageGroupElt.classList.add("opened");
|
|
300
|
-
if (ulElt === undefined) {
|
|
301
|
-
return;
|
|
302
|
-
}
|
|
303
|
-
ulElt.style.display = "block";
|
|
304
|
-
ulElt.style.height = "auto";
|
|
305
|
-
const height = ulElt.offsetHeight;
|
|
306
|
-
ulElt.style.height = "0px";
|
|
307
|
-
const transitionDuration = getTransitionDuration(height);
|
|
308
|
-
ulElt.style.transition = `height ${transitionDuration}ms ease-in-out 0s`;
|
|
309
|
-
openingTimeout = setTimeout(() => {
|
|
310
|
-
status = "opening";
|
|
311
|
-
ulElt.style.height = `${height}px`;
|
|
312
|
-
});
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
function progressivelyHideElt() {
|
|
316
|
-
clearTimeout(openingTimeout);
|
|
317
|
-
clearTimeout(closingTimeout);
|
|
318
|
-
pageGroupElt.classList.remove("opened");
|
|
319
|
-
if (ulElt === undefined) {
|
|
320
|
-
return;
|
|
321
|
-
}
|
|
322
|
-
const height = ulElt.offsetHeight;
|
|
323
|
-
ulElt.style.height = `${height}px`;
|
|
324
|
-
closingTimeout = setTimeout(() => {
|
|
325
|
-
status = "closing";
|
|
326
|
-
const transitionDuration = getTransitionDuration(ulElt.offsetHeight);
|
|
327
|
-
ulElt.style.transition = `height ${transitionDuration}ms ease-in-out 0s`;
|
|
328
|
-
ulElt.style.height = "0px";
|
|
329
|
-
});
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
function onTransitionEnd() {
|
|
333
|
-
if (status === "closing") {
|
|
334
|
-
ulElt.style.transition = "";
|
|
335
|
-
ulElt.style.display = "none";
|
|
336
|
-
ulElt.style.height = "auto";
|
|
337
|
-
status = "closed";
|
|
338
|
-
} else if (status === "opening") {
|
|
339
|
-
status = "opened";
|
|
340
|
-
ulElt.style.height = "auto";
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
function getTransitionDuration(height) {
|
|
345
|
-
return Math.max(300, height / 2);
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
// ======= Scroll to right sidebar element =======
|
|
350
|
-
|
|
351
|
-
const active = document.querySelector(".sidebar-link.active");
|
|
352
|
-
|
|
353
|
-
if (active !== null) {
|
|
354
|
-
const activeRect = active.getBoundingClientRect();
|
|
355
|
-
if (activeRect.y + activeRect.height + 20 > window.innerHeight) {
|
|
356
|
-
const sidebarWrapperElt = document.getElementsByClassName("sidebar-wrapper")[0];
|
|
357
|
-
const scrollYBy = activeRect.y + activeRect.height - window.innerHeight + 50;
|
|
358
|
-
sidebarWrapperElt.scrollTo(0, scrollYBy);
|
|
359
|
-
}
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
// ======= Hide / show header on scroll =======
|
|
363
|
-
|
|
364
|
-
let prevScroll = window.scrollY;
|
|
365
|
-
let isHeaderShown = true;
|
|
366
|
-
const headerElt = document.getElementsByClassName("navbar-parent")[0];
|
|
367
|
-
|
|
368
|
-
window.addEventListener("scroll", onScroll);
|
|
369
|
-
|
|
370
|
-
function onScroll() {
|
|
371
|
-
const curScroll = window.scrollY;
|
|
372
|
-
if (curScroll === 0) {
|
|
373
|
-
showHeader();
|
|
374
|
-
return;
|
|
375
|
-
}
|
|
376
|
-
|
|
377
|
-
if (Math.abs(curScroll - prevScroll) < 5) {
|
|
378
|
-
return;
|
|
379
|
-
}
|
|
380
|
-
if (curScroll > prevScroll) {
|
|
381
|
-
hideHeader();
|
|
382
|
-
} else if (curScroll < prevScroll) {
|
|
383
|
-
showHeader();
|
|
384
|
-
}
|
|
385
|
-
prevScroll = curScroll;
|
|
386
|
-
};
|
|
387
|
-
|
|
388
|
-
function hideHeader() {
|
|
389
|
-
if (isHeaderShown) {
|
|
390
|
-
headerElt.classList.add("hidden");
|
|
391
|
-
isHeaderShown = false;
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
function showHeader() {
|
|
396
|
-
if (!isHeaderShown) {
|
|
397
|
-
headerElt.classList.remove("hidden");
|
|
398
|
-
isHeaderShown = true;
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
// Work-arounds to make sure the header doesn't go on top
|
|
403
|
-
// of a link
|
|
404
|
-
if (window.location.hash !== "") {
|
|
405
|
-
hideHeader();
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
window.onhashchange = function() {
|
|
409
|
-
hideHeader();
|
|
410
|
-
prevScroll = window.scrollY;
|
|
411
|
-
};
|
|
412
|
-
|
|
413
|
-
// ======= Hamburger menu ========
|
|
414
|
-
|
|
415
|
-
let opacityTimeout;
|
|
416
|
-
const overlay = document.createElement("div");
|
|
417
|
-
overlay.className = "overlay";
|
|
418
|
-
|
|
419
|
-
const hamburgerOpenerElt = document.getElementsByClassName("hamburger-opener")[0];
|
|
420
|
-
const hamburgerBarElt = document.getElementsByClassName("hamburger-bar")[0];
|
|
421
|
-
const hamburgerCloserElt = document.getElementsByClassName("hamburger-bar-closer")[0];
|
|
422
|
-
|
|
423
|
-
hamburgerOpenerElt.onclick = openMenu;
|
|
424
|
-
hamburgerCloserElt.onclick = closeMenu;
|
|
425
|
-
|
|
426
|
-
let isOverlayVisible = false;
|
|
427
|
-
overlay.onclick = function() {
|
|
428
|
-
if (isOverlayVisible) {
|
|
429
|
-
closeMenu();
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
function openMenu() {
|
|
434
|
-
clearTimeout(opacityTimeout);
|
|
435
|
-
document.body.style.overflowY = "hidden";
|
|
436
|
-
document.body.appendChild(overlay);
|
|
437
|
-
opacityTimeout = setTimeout(() => {
|
|
438
|
-
overlay.style.opacity = "1";
|
|
439
|
-
isOverlayVisible = true;
|
|
440
|
-
});
|
|
441
|
-
hamburgerBarElt.classList.add("opened");
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
function closeMenu() {
|
|
445
|
-
clearTimeout(opacityTimeout);
|
|
446
|
-
document.body.style.overflowY = "auto";
|
|
447
|
-
overlay.style.opacity = "0";
|
|
448
|
-
isOverlayVisible = false;
|
|
449
|
-
document.body.removeChild(overlay);
|
|
450
|
-
hamburgerBarElt.classList.remove("opened");
|
|
451
|
-
}
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
|
|
3
|
-
github.com style (c) Vasily Polovnyov <vast@whiteants.net>
|
|
4
|
-
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
.hljs {
|
|
8
|
-
display: block;
|
|
9
|
-
overflow-x: auto;
|
|
10
|
-
padding: 0.5em;
|
|
11
|
-
color: #333;
|
|
12
|
-
background: #f8f8f8;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
.hljs-comment,
|
|
16
|
-
.hljs-quote {
|
|
17
|
-
color: #998;
|
|
18
|
-
font-style: italic;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
.hljs-keyword,
|
|
22
|
-
.hljs-selector-tag,
|
|
23
|
-
.hljs-subst {
|
|
24
|
-
color: #333;
|
|
25
|
-
font-weight: bold;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
.hljs-number,
|
|
29
|
-
.hljs-literal,
|
|
30
|
-
.hljs-variable,
|
|
31
|
-
.hljs-template-variable,
|
|
32
|
-
.hljs-tag .hljs-attr {
|
|
33
|
-
color: #008080;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
.hljs-string,
|
|
37
|
-
.hljs-doctag {
|
|
38
|
-
color: #d14;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
.hljs-title,
|
|
42
|
-
.hljs-section,
|
|
43
|
-
.hljs-selector-id {
|
|
44
|
-
color: #900;
|
|
45
|
-
font-weight: bold;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
.hljs-subst {
|
|
49
|
-
font-weight: normal;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
.hljs-type,
|
|
53
|
-
.hljs-class .hljs-title {
|
|
54
|
-
color: #458;
|
|
55
|
-
font-weight: bold;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
.hljs-tag,
|
|
59
|
-
.hljs-name,
|
|
60
|
-
.hljs-attribute {
|
|
61
|
-
color: #000080;
|
|
62
|
-
font-weight: normal;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
.hljs-regexp,
|
|
66
|
-
.hljs-link {
|
|
67
|
-
color: #009926;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
.hljs-symbol,
|
|
71
|
-
.hljs-bullet {
|
|
72
|
-
color: #990073;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
.hljs-built_in,
|
|
76
|
-
.hljs-builtin-name {
|
|
77
|
-
color: #0086b3;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
.hljs-meta {
|
|
81
|
-
color: #999;
|
|
82
|
-
font-weight: bold;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
.hljs-deletion {
|
|
86
|
-
background: #fdd;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
.hljs-addition {
|
|
90
|
-
background: #dfd;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
.hljs-emphasis {
|
|
94
|
-
font-style: italic;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
.hljs-strong {
|
|
98
|
-
font-weight: bold;
|
|
99
|
-
}
|