Commit:    665bef3b9af6a0f3182bb9a819975d5357fb5400
Author:    Peter Kokot <peterko...@gmail.com>         Thu, 18 Oct 2018 22:59:22 
+0200
Parents:   be03c4db2e7c18d56223d9b70880dbfa786bce2f
Branches:  master

Link:       
http://git.php.net/?p=web/people.git;a=commitdiff;h=665bef3b9af6a0f3182bb9a819975d5357fb5400

Log:
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.

Changed paths:
  M  js/search.js


Diff:
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 '<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 :


--
PHP Webmaster List Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to