From 7c6a48f6c614f38c9ae76bac9836dc26e58c8b77 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Weber?= Date: Sun, 29 Jan 2023 17:04:20 +0100 Subject: [PATCH] search: remove jQuery #452 --- static/js/search.js | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/static/js/search.js b/static/js/search.js index 717a93c579..25af6243bb 100644 --- a/static/js/search.js +++ b/static/js/search.js @@ -80,14 +80,20 @@ function initLunrJson() { // backward compatiblity if the user did not // define the SEARCH output format for the homepage if( window.index_json_url && !window.index_js_url ){ - $.getJSON(index_json_url) - .done(function(index) { - initLunrIndex(index); - }) - .fail(function(jqxhr, textStatus, error) { - var err = textStatus + ', ' + error; - console.error('Error getting Hugo index file:', err); - }); + xhr = new XMLHttpRequest; + xhr.onreadystatechange = function(){ + if( xhr.readyState == 4 ){ + if( xhr.status == 200 ){ + initLunrIndex( JSON.parse( xhr.responseText ) ); + } + else{ + var err = xhr.status; + console.error( 'Error getting Hugo index file: ', err ); + } + } + } + xhr.open( 'GET', index_json_url ); + xhr.send(); } }