From 198a4d74ae7546ac23068a0a1e26170e8bcfe95b Mon Sep 17 00:00:00 2001 From: Aditya Telange <21258296+adityatelange@users.noreply.github.com> Date: Sat, 20 Aug 2022 14:20:51 +0530 Subject: [PATCH] Fix Code Smell: Unexpected var, use let or const instead. https://sonarcloud.io/project/issues?issues=AYEpqxwP3DjyH4ZzxfLw&open=AYEpqxwP3DjyH4ZzxfLw&id=adityatelange_hugo-PaperMod --- assets/js/fastsearch.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/assets/js/fastsearch.js b/assets/js/fastsearch.js index ea110221..02d1396a 100644 --- a/assets/js/fastsearch.js +++ b/assets/js/fastsearch.js @@ -1,21 +1,21 @@ import * as params from '@params'; -var fuse; // holds our search engine -var resList = document.getElementById('searchResults'); -var sInput = document.getElementById('searchInput'); -var first, last, current_elem = null -var resultsAvailable = false; +let fuse; // holds our search engine +let resList = document.getElementById('searchResults'); +let sInput = document.getElementById('searchInput'); +let first, last, current_elem = null +let resultsAvailable = false; // load our search index window.onload = function () { - var xhr = new XMLHttpRequest(); + let xhr = new XMLHttpRequest(); xhr.onreadystatechange = function () { if (xhr.readyState === 4) { if (xhr.status === 200) { - var data = JSON.parse(xhr.responseText); + let data = JSON.parse(xhr.responseText); if (data) { // fuse.js options; check fuse.js website for details - var options = { + let options = { distance: 100, threshold: 0.4, ignoreLocation: true, @@ -106,12 +106,12 @@ sInput.addEventListener('search', function (e) { // kb bindings document.onkeydown = function (e) { let key = e.key; - var ae = document.activeElement; + let ae = document.activeElement; let inbox = document.getElementById("searchbox").contains(ae) if (ae === sInput) { - var elements = document.getElementsByClassName('focus'); + let elements = document.getElementsByClassName('focus'); while (elements.length > 0) { elements[0].classList.remove('focus'); }