From 52fd2926a09fe62798ecec57bc300532e0384de5 Mon Sep 17 00:00:00 2001 From: Alexander_Kabui Date: Thu, 9 Mar 2023 06:01:32 +0300 Subject: delete recent search handler --- .../static/new/javascript/search_autocomplete.js | 25 +- wqflask/wqflask/templates/base.html | 503 ++++++++++----------- 2 files changed, 270 insertions(+), 258 deletions(-) diff --git a/wqflask/wqflask/static/new/javascript/search_autocomplete.js b/wqflask/wqflask/static/new/javascript/search_autocomplete.js index 04634f9b..10c22c95 100644 --- a/wqflask/wqflask/static/new/javascript/search_autocomplete.js +++ b/wqflask/wqflask/static/new/javascript/search_autocomplete.js @@ -1,4 +1,9 @@ //replace with gn search hints + + + + + function autocomplete(inp, arr) { /*the autocomplete function takes two arguments, the text field element and an array of possible autocompleted values:*/ @@ -6,6 +11,8 @@ /*execute a function when someone writes in the text field:*/ inp.addEventListener("focus", function(e) { + + var a, b, i, val = this.value; closeAllLists(); currentFocus = -1; @@ -15,9 +22,10 @@ this.parentNode.appendChild(a); let historySearch = retrieveSearchHistory().splice(0, 5) let text_title = document.createElement("DIV") - text_title.innerHTML = "RECENT SEARCH"; + text_title.innerHTML = "RECENT SEARCH"; text_title.setAttribute("class", "recent-search-title") text_title.setAttribute('disabled', true); + a.appendChild(text_title); for (i = 0; i < historySearch.length; i++) { b = document.createElement("DIV"); @@ -32,6 +40,12 @@ a.appendChild(b); } + document.getElementById("clear_all").addEventListener("click",(event)=>{ + + + deleteSearchHistory() + }) + }); @@ -136,8 +150,9 @@ } function retrieveSearchHistory() { - let results = JSON.parse(localStorage.getItem("gn_search_history")) - return results ? results : [] + let results = localStorage.getItem("gn_search_history") + + return results ? JSON.parse(results) : [] } @@ -151,4 +166,8 @@ localStorage.setItem("gn_search_history", JSON.stringify([...new Set(search)].splice(0,8))) + } + + function deleteSearchHistory(){ + localStorage.setItem("gn_search_history", []) } \ No newline at end of file diff --git a/wqflask/wqflask/templates/base.html b/wqflask/wqflask/templates/base.html index 116d9b7c..beafba08 100644 --- a/wqflask/wqflask/templates/base.html +++ b/wqflask/wqflask/templates/base.html @@ -4,13 +4,11 @@ - {% block title %}{% endblock %} GeneNetwork 2 - @@ -18,17 +16,14 @@ - + - - - - + + + {% block css %} {% endblock %} - -