Skip to content

Commit

Permalink
Wrap search functionality in $( document ).ready()
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
petk committed Oct 18, 2018
1 parent be03c4d commit 665bef3
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions js/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,20 @@ var fnFormatSearchResult = function(value, data, currentValue) {
return '<img src="https://www.gravatar.com/avatar/' + users[value]["email"] + '.jpg?s=25" /> ' + 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 :

0 comments on commit 665bef3

Please sign in to comment.