From 18178e5abb5aecf74fa7c4b5f0e2deb6d6f576af Mon Sep 17 00:00:00 2001 From: Seth Clydesdale Date: Wed, 25 Dec 2024 18:41:42 -0500 Subject: [PATCH] test 2 completely remove quick search for debug test --- resources/javascript/homepage.js | 128 ------------------------------- 1 file changed, 128 deletions(-) diff --git a/resources/javascript/homepage.js b/resources/javascript/homepage.js index 9b83070..69afcb5 100644 --- a/resources/javascript/homepage.js +++ b/resources/javascript/homepage.js @@ -9,134 +9,6 @@ }*/ - // # QUICK SEARCH # - if (false) { - window.QuickSearcher = { - grammarIndex : /grammar-index/.test(window.location.href), - search : document.getElementById('quick-search'), - results : document.getElementById('quick-search-results'), - hitsCounter : document.getElementById('quick-search-hits'), - - // set after definition - li : null, - exLen : null, - - // search for the specified value - query : function (value) { - // clear existing timeout - if (window.GenkiSearchTimeout) { - window.clearTimeout(GenkiSearchTimeout); - } - - // wait 300ms before submitting search, just in case the user is still typing - window.GenkiSearchTimeout = window.setTimeout(function() { - var frag = document.createDocumentFragment(), - hits = 0, - i = 0, - clone; - - // clear prior searches - QuickSearcher.results.innerHTML = ''; - - // loop over the exercises if a value is present - if (value) { - for (; i < QuickSearcher.exLen; i++) { - if ((QuickSearcher.li[i].innerHTML.replace(/||<.*?>/g, '').toLowerCase().indexOf(value.toLowerCase()) != -1 || (QuickSearcher.li[i].dataset && QuickSearcher.li[i].dataset.keywords && QuickSearcher.li[i].dataset.keywords.toLowerCase().indexOf(value.toLowerCase()) != -1)) && QuickSearcher.li[i].getElementsByTagName('A')[0] && !/note/.test(QuickSearcher.li[i].id)) { - // clone the link (if on homepage) or create a new link (if on the grammar index) - if (QuickSearcher.grammarIndex) { - clone = document.createElement('LI'); - clone.innerHTML = '' + QuickSearcher.li[i].innerHTML.replace(/||.*?<\/a>/g, '') + ''; - } else { - clone = QuickSearcher.li[i].cloneNode(true); // clone the match for displaying in the results node - } - - // add lesson number to exercise or grammar point - clone.dataset.lesson = QuickSearcher.grammarIndex ? 'L' + QuickSearcher.li[i].id.replace(/l(\d+)-p\d+/, '$1') : clone.getElementsByTagName('A')[0].href.replace(/.*?\/(lesson-\d+).*|.*?\/(study-tools).*|.*?\/(appendix).*/, function (Match, $1, $2, $3) { - if ($1) { - return $1.charAt(0).toUpperCase() + $1.split('-').pop(); - - } else if ($2) { - return 'tool' - - } else if ($3) { - return 'appendix' - } - }); - - // add tooltip in case the text gets cut off - clone.title = clone.innerText; - - // add the clone to the fragment if it's valid - if (!/^file|^http/.test(clone.dataset.lesson)) { - frag.appendChild(clone); - hits++; // increment hits - } - } - } - } - - // append the matched exercises or display an error message/hide the search results - if (frag.childNodes.length) { - QuickSearcher.results.appendChild(frag); - - } else { - QuickSearcher.results.innerHTML = value ? '
  • No results found for "' + value + '".
  • ' : ''; - } - - // update the hits counter and add a button to copy the search link - QuickSearcher.hitsCounter.innerHTML = hits ? '(' + hits + ') '+ - '' : ''; - - delete window.GenkiSearchTimeout; - }, 300); - } - }; - - // set remaining data for search functionality - QuickSearcher.li = document.querySelectorAll(QuickSearcher.grammarIndex ? '.workbook-title' : '.lesson-exercises li'); - QuickSearcher.exLen = QuickSearcher.li.length; - - - // set the value of the search field via the url (e.g. ?search=kanji) - if (window.location.search) { - var query = window.location.search.slice(1).split('&'), - i = 0, - j = query.length, - keyVal; - - for (; i < j; i++) { - keyVal = query[i].split('='); - - if (/^search$/i.test(keyVal[0])) { - QuickSearcher.search.value = decodeURIComponent(keyVal[1]); - break; - } - } - } - - // search for exercises when the user inputs text - QuickSearcher.search.oninput = function () { - QuickSearcher.query(this.value); - }; - - // resume previous searches (in the event the user goes back in history) or those initiated by ?search=query - if (QuickSearcher.search.value) { - QuickSearcher.query(QuickSearcher.search.value); - } - } - - // # QUICK NAV SUB-SECTIONS # // Adds buttons for showing sub-sections in each lesson. for (var a = document.querySelectorAll('#quick-nav-list a'), i = 0, j = a.length, l; i < j; i++) {