From 4515aae78d66d9c65e86eeab9da09101cb470308 Mon Sep 17 00:00:00 2001 From: Adrien Dupuis <61695653+adriendupuis@users.noreply.github.com> Date: Thu, 6 Mar 2025 15:20:43 +0100 Subject: [PATCH] rm docs/css/instantsearch.js probably a copy-paste error when adapting dev doc's one. --- docs/css/instantsearch.js | 166 -------------------------------------- 1 file changed, 166 deletions(-) delete mode 100644 docs/css/instantsearch.js diff --git a/docs/css/instantsearch.js b/docs/css/instantsearch.js deleted file mode 100644 index 8bf9d071..00000000 --- a/docs/css/instantsearch.js +++ /dev/null @@ -1,166 +0,0 @@ -(function(global, doc) { - let match; - const search_query = (match = doc.location.search.match(/sq=(.*?)(&|$)/)) ? match[1] : ''; - const parsed_search_query = decodeURI(search_query.replaceAll('+', ' ')); - const search_page = (match = doc.location.search.match(/p=(\d*?)(&|$)/)) ? match[1] : 1; - const parsed_search_page = parseInt(search_page); - let version = doc.location.pathname.split('/')[2]; - if (!/^\d+\.\d+$/.test(version) && version !== 'latest') { - version = 'master'; - } - const hitsContainer = '#hits'; - const statsContainer = '#stats'; - const paginationContainer = '#pagination'; - const search = instantsearch({ - indexName: 'ezplatform', - searchClient: algoliasearch('2DNYOU6YJZ', '21ce3e522455e18e7ee16cf7d66edb4b'), - initialUiState: { - ezplatform: { - query: parsed_search_query, - refinementList: { version: [version] }, - page: parsed_search_page, - }, - }, - searchFunction(helper) { - if (helper.state.query) { - helper.search(); - $(statsContainer).css('visibility', 'visible'); - $(paginationContainer).show(); - } else { - $(hitsContainer).empty(); - $(statsContainer).css('visibility', 'hidden'); - $(paginationContainer).hide(); - } - }, - }); - - getNextSearchURL = () => { - const searchInputElements = document.getElementsByClassName('ais-SearchBox-input'); - const text = searchInputElements[0].value.trim(); - const selectedPaginationItemElements = doc.getElementsByClassName('ais-Pagination-item--selected'); - const page = selectedPaginationItemElements.length ? parseInt(selectedPaginationItemElements[0].innerText) : 1; - const url = new URL(window.location); - url.searchParams.set('sq', text); - url.searchParams.set('p', page); - return url; - }; - - let idleTimer; - const startIdleTimer = (url) => { - stopIdleTimer(); - idleTimer = window.setTimeout(() => { - window.history.pushState({}, '', url); - }, 1500); - }; - const stopIdleTimer = () => { - window.clearTimeout(idleTimer); - }; - - doc.getElementById('searchbox').addEventListener('keyup', function(event) { - const url = getNextSearchURL(); - if (url.searchParams.get('sq') != (new URL(window.location)).searchParams.get('sq')) { - url.searchParams.set('p', 1); - startIdleTimer(url); - } - }); - - doc.getElementById('pagination').addEventListener('click', function(event) { - stopIdleTimer(); - const url = getNextSearchURL(); - window.history.pushState({}, '', url); - }); - - window.onpopstate = (event) => { - window.location.reload(); - }; - - search.addWidgets([ - instantsearch.widgets.configure({ - hitsPerPage: 10, - }), - instantsearch.widgets.stats({ - container: statsContainer, - templates: { - text: `