Skip to content

Commit 665bef3

Browse files
committed
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.
1 parent be03c4d commit 665bef3

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

js/search.js

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,20 @@ var fnFormatSearchResult = function(value, data, currentValue) {
77
return '<img src="https://www.gravatar.com/avatar/' + users[value]["email"] + '.jpg?s=25" /> ' + listing;
88
};
99

10-
$('input.search').autocomplete({
11-
minChars:2,
12-
maxHeight:400,
13-
fnFormatResult: fnFormatSearchResult,
14-
onSelect: function(value, data){
15-
if (window.location.host == 'master.php.net') {
16-
window.location = "/manage/users.php?username=" + users[value]["username"];
17-
} else {
18-
window.location = "/" + users[value]["username"];
19-
}
20-
},
21-
lookup: lookup
10+
$(document).ready(function() {
11+
$('input.search').autocomplete({
12+
minChars:2,
13+
maxHeight:400,
14+
fnFormatResult: fnFormatSearchResult,
15+
onSelect: function(value, data){
16+
if (window.location.host == 'master.php.net') {
17+
window.location = "/manage/users.php?username=" + users[value]["username"];
18+
} else {
19+
window.location = "/" + users[value]["username"];
20+
}
21+
},
22+
lookup: lookup
23+
});
2224
});
2325

2426
// vim: set expandtab shiftwidth=4 softtabstop=4 tabstop=4 :

0 commit comments

Comments
 (0)