From aa23cf64cae6710f556c8d43528d28cff6d6a775 Mon Sep 17 00:00:00 2001 From: Suhaib Khan Date: Sun, 23 Feb 2014 00:22:52 +0530 Subject: [ticket/10737] Avoid hard-coding table row and use case-insensitive search. PHPBB3-10737 --- phpBB/assets/javascript/core.js | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) (limited to 'phpBB/assets/javascript') diff --git a/phpBB/assets/javascript/core.js b/phpBB/assets/javascript/core.js index c2291c7001..82c78ae715 100644 --- a/phpBB/assets/javascript/core.js +++ b/phpBB/assets/javascript/core.js @@ -515,26 +515,34 @@ phpbb.timezonePreselectSelect = function(forceSelector) { // Listen live search box events $('.liveinput').keyup(function() { var str = this.value; - var j = 0; if (str.length < 3) { - $("#livesearch").innerHTML=""; - return; - } - + return; + } + var link, name; + var clone = $("#user-search-row-tpl").clone(); + $("#livesearch").html(""); + clone.appendTo("#livesearch"); $.ajax({ url:'memberlist.php?mode=livesearch&'+"&q="+str, success:function(result) { $.each(result, function(idx, elem) { - j = (idx%2)+1; - $("#livesearch").append("" + elem.name + ""); - }) - } + link = "memberlist.php?mode=viewprofile&u=" + elem.id; + name = elem.name; + clone = $("#user-search-row-tpl").clone(); + clone.find(".user-search-link").attr("href", link); + clone.find(".user-search-name").html(name); + clone.attr("style", ""); + clone.appendTo("#livesearch"); + }); + } }); }); $('.liveinput').blur(function() { setTimeout(function () { - document.getElementById("livesearch").innerHTML=""; + var clone = $("#user-search-row-tpl").clone(); + $("#livesearch").html(""); + clone.appendTo("#livesearch"); }, 500); }); -- cgit v1.2.1