[ticket/10737] Avoid hard-coding table row and use case-insensitive search.

PHPBB3-10737
This commit is contained in:
Suhaib Khan 2014-02-23 00:22:52 +05:30 committed by Cesar G
parent e644c67dcf
commit aa23cf64ca
5 changed files with 36 additions and 13 deletions

View file

@ -515,26 +515,34 @@ phpbb.timezonePreselectSelect = function(forceSelector) {
// Listen live search box events // Listen live search box events
$('.liveinput').keyup(function() { $('.liveinput').keyup(function() {
var str = this.value; var str = this.value;
var j = 0;
if (str.length < 3) { if (str.length < 3) {
$("#livesearch").innerHTML=""; return;
return; }
} var link, name;
var clone = $("#user-search-row-tpl").clone();
$("#livesearch").html("");
clone.appendTo("#livesearch");
$.ajax({ $.ajax({
url:'memberlist.php?mode=livesearch&'+"&q="+str, url:'memberlist.php?mode=livesearch&'+"&q="+str,
success:function(result) { success:function(result) {
$.each(result, function(idx, elem) { $.each(result, function(idx, elem) {
j = (idx%2)+1; link = "memberlist.php?mode=viewprofile&u=" + elem.id;
$("#livesearch").append("<tr class='bg" + j + " row" + j + "'><td><a href='memberlist.php?mode=viewprofile&u=" + elem.id + "' target='_blank'>" + elem.name + "</a></td></tr>"); 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() { $('.liveinput').blur(function() {
setTimeout(function () { setTimeout(function () {
document.getElementById("livesearch").innerHTML=""; var clone = $("#user-search-row-tpl").clone();
$("#livesearch").html("");
clone.appendTo("#livesearch");
}, 500); }, 500);
}); });

View file

@ -983,11 +983,12 @@ switch ($mode)
case 'livesearch': case 'livesearch':
$username_chars = $request->variable('q', '', true); $username_chars = $request->variable('q', '', true);
$username_chars = strtolower($username_chars);
$sql = 'SELECT username, user_id $sql = 'SELECT username, user_id
FROM ' . USERS_TABLE . ' FROM ' . USERS_TABLE . '
WHERE ' . $db->sql_in_set('user_type', array(USER_NORMAL, USER_FOUNDER)) . ' WHERE ' . $db->sql_in_set('user_type', array(USER_NORMAL, USER_FOUNDER)) . '
AND username ' . $db->sql_like_expression($username_chars . $db->any_char); AND LOWER(username) ' . $db->sql_like_expression($username_chars . $db->any_char);
$result = $db->sql_query_limit($sql, 10); $result = $db->sql_query_limit($sql, 10);
$user_list = array(); $user_list = array();

View file

@ -9,7 +9,13 @@
<fieldset class="fields1 column1"> <fieldset class="fields1 column1">
<dl> <dl>
<dt><label for="username">{L_USERNAME}{L_COLON}</label></dt> <dt><label for="username">{L_USERNAME}{L_COLON}</label></dt>
<dd><input type="text" name="username" id="username" value="{USERNAME}" class="inputbox liveinput" autocomplete="off" /> <table class="table1" id="livesearch"></table></dd> <dd><input type="text" name="username" id="username" value="{USERNAME}" class="inputbox liveinput" autocomplete="off" />
<table class="table1 zebra-list" id="livesearch">
<tr id="user-search-row-tpl" style="display: none;">
<td><a class="user-search-link user-search-name" target='_blank'></a></td>
</tr>
</table>
</dd>
</dl> </dl>
<!-- IF S_EMAIL_SEARCH_ALLOWED --> <!-- IF S_EMAIL_SEARCH_ALLOWED -->
<dl> <dl>

View file

@ -75,7 +75,14 @@
</tr> </tr>
<tr> <tr>
<td class="row1"><b class="genmed">{L_USERNAME}{L_COLON}</b></td> <td class="row1"><b class="genmed">{L_USERNAME}{L_COLON}</b></td>
<td class="row2"><input class="post liveinput" type="text" name="username" value="{USERNAME}" autocomplete="off" /> <table class="tablebg" id="livesearch"></table></td> <td class="row2">
<input class="post liveinput" type="text" name="username" value="{USERNAME}" autocomplete="off" />
<table class="tablebg" id="livesearch">
<tr id="user-search-row-tpl" style="display: none;">
<td><a class="user-search-link user-search-name" target='_blank'></a></td>
</tr>
</table>
</td>
<!-- IF S_EMAIL_SEARCH_ALLOWED --> <!-- IF S_EMAIL_SEARCH_ALLOWED -->
<td class="row1"><b class="genmed">{L_EMAIL}{L_COLON}</b></td> <td class="row1"><b class="genmed">{L_EMAIL}{L_COLON}</b></td>
<td class="row2"><input class="post" type="email" name="email" value="{EMAIL}" /></td> <td class="row2"><input class="post" type="email" name="email" value="{EMAIL}" /></td>

View file

@ -708,6 +708,7 @@ pre {
margin: 0px; margin: 0px;
position: absolute; position: absolute;
box-shadow: 1px 2px 5px rgb(175,167,167); box-shadow: 1px 2px 5px rgb(175,167,167);
border-spacing: 0px;
z-index: 999; z-index: 999;
overflow: auto; overflow: auto;
} }