mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 14:18:52 +00:00
[ticket/10737] Code fixes in AJAX search feature
PHPBB3-10737
This commit is contained in:
parent
bc67377400
commit
b5ee81dae6
3 changed files with 32 additions and 33 deletions
|
@ -982,14 +982,17 @@ switch ($mode)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'livesearch':
|
case 'livesearch':
|
||||||
$q=request_var('q', '', true);
|
$username_chars = $request->variable('q', '', true);
|
||||||
$hint = "";
|
$hint = "";
|
||||||
$sql = "SELECT username, user_id
|
|
||||||
FROM " . USERS_TABLE . " u
|
$sql = 'SELECT username, user_id
|
||||||
WHERE username LIKE '".$q."%' AND u.user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ")";
|
FROM ' . USERS_TABLE . '
|
||||||
$result = $db->sql_query($sql);
|
WHERE ' . $db->sql_in_set('user_type', array(USER_NORMAL, USER_FOUNDER)) . '
|
||||||
|
AND username ' . $db->sql_like_expression($username_chars . $db->any_char);
|
||||||
|
$result = $db->sql_query_limit($sql, 10);
|
||||||
|
|
||||||
$i = 1;
|
$i = 1;
|
||||||
while ($i<=10 && $row = $db->sql_fetchrow($result))
|
while ($row = $db->sql_fetchrow($result))
|
||||||
{
|
{
|
||||||
$j = ($i%2)+1;
|
$j = ($i%2)+1;
|
||||||
$hint.= "<tr class='bg".$j." row".$j."'><td><a href='" .
|
$hint.= "<tr class='bg".$j." row".$j."'><td><a href='" .
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
<script>
|
<script>
|
||||||
function showHint(str)
|
function showHint(str) {
|
||||||
{
|
if (str.length<3) {
|
||||||
if (str.length<3)
|
|
||||||
{
|
|
||||||
document.getElementById("livesearch").innerHTML="";
|
document.getElementById("livesearch").innerHTML="";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -14,10 +12,10 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
function clearSearch() {
|
||||||
function clearSearch()
|
setTimeout(function () {
|
||||||
{
|
|
||||||
document.getElementById("livesearch").innerHTML="";
|
document.getElementById("livesearch").innerHTML="";
|
||||||
|
}, 500);
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -32,7 +30,7 @@
|
||||||
<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" onkeyup="showHint(this.value)" onblur="clearSearch()" /> <table class="table1" id="livesearch"></table> </dd>
|
<dd><input type="text" name="username" id="username" value="{USERNAME}" class="inputbox" autocomplete="off" onkeyup="showHint(this.value)" onblur="clearSearch()" /> <table class="table1" id="livesearch"></table> </dd>
|
||||||
</dl>
|
</dl>
|
||||||
<!-- IF S_EMAIL_SEARCH_ALLOWED -->
|
<!-- IF S_EMAIL_SEARCH_ALLOWED -->
|
||||||
<dl>
|
<dl>
|
||||||
|
|
|
@ -65,10 +65,8 @@
|
||||||
<!-- ENDIF -->
|
<!-- ENDIF -->
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
function showHint(str)
|
function showHint(str) {
|
||||||
{
|
if (str.length<3) {
|
||||||
if (str.length<3)
|
|
||||||
{
|
|
||||||
document.getElementById("livesearch").innerHTML="";
|
document.getElementById("livesearch").innerHTML="";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -80,10 +78,10 @@
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
function clearSearch() {
|
||||||
function clearSearch()
|
setTimeout(function () {
|
||||||
{
|
|
||||||
document.getElementById("livesearch").innerHTML="";
|
document.getElementById("livesearch").innerHTML="";
|
||||||
|
}, 500);
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -98,7 +96,7 @@
|
||||||
</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" type="text" name="username" value="{USERNAME}" onkeyup="showHint(this.value)" onblur="clearSearch()" /> <table class="tablebg" id="livesearch"></table> </td>
|
<td class="row2"><input class="post" type="text" name="username" value="{USERNAME}" autocomplete="off" onkeyup="showHint(this.value)" onblur="clearSearch()" /> <table class="tablebg" id="livesearch"></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>
|
||||||
|
|
Loading…
Add table
Reference in a new issue