From 665bef3b9af6a0f3182bb9a819975d5357fb5400 Mon Sep 17 00:00:00 2001 From: Peter Kokot Date: Thu, 18 Oct 2018 22:59:22 +0200 Subject: [PATCH] Wrap search functionality in $( document ).ready() Modern browsers load scripts at any part of the document asynchronously. This could be disabled per script basis but this simple jQuery way can be done to avoid too much changes at the moment. So this should work in browsers over https since the userlisting.php script is not loaded before the search.js. --- js/search.js | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/js/search.js b/js/search.js index b61f3f3..3c8afcf 100644 --- a/js/search.js +++ b/js/search.js @@ -7,18 +7,20 @@ var fnFormatSearchResult = function(value, data, currentValue) { return ' ' + listing; }; -$('input.search').autocomplete({ - minChars:2, - maxHeight:400, - fnFormatResult: fnFormatSearchResult, - onSelect: function(value, data){ - if (window.location.host == 'master.php.net') { - window.location = "/manage/users.php?username=" + users[value]["username"]; - } else { - window.location = "/" + users[value]["username"]; - } - }, - lookup: lookup +$(document).ready(function() { + $('input.search').autocomplete({ + minChars:2, + maxHeight:400, + fnFormatResult: fnFormatSearchResult, + onSelect: function(value, data){ + if (window.location.host == 'master.php.net') { + window.location = "/manage/users.php?username=" + users[value]["username"]; + } else { + window.location = "/" + users[value]["username"]; + } + }, + lookup: lookup + }); }); // vim: set expandtab shiftwidth=4 softtabstop=4 tabstop=4 :