mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 06:08: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,17 +982,20 @@ switch ($mode)
|
|||
break;
|
||||
|
||||
case 'livesearch':
|
||||
$q=request_var('q', '', true);
|
||||
$hint="";
|
||||
$sql = "SELECT username, user_id
|
||||
FROM " . USERS_TABLE . " u
|
||||
WHERE username LIKE '".$q."%' AND u.user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ")";
|
||||
$result = $db->sql_query($sql);
|
||||
$i=1;
|
||||
while ($i<=10 && $row = $db->sql_fetchrow($result))
|
||||
$username_chars = $request->variable('q', '', true);
|
||||
$hint = "";
|
||||
|
||||
$sql = 'SELECT username, user_id
|
||||
FROM ' . USERS_TABLE . '
|
||||
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;
|
||||
while ($row = $db->sql_fetchrow($result))
|
||||
{
|
||||
$j=($i%2)+1;
|
||||
$hint.="<tr class='bg".$j." row".$j."'><td><a href='" .
|
||||
$j = ($i%2)+1;
|
||||
$hint.= "<tr class='bg".$j." row".$j."'><td><a href='" .
|
||||
$phpbb_root_path."memberlist.$phpEx". "?mode=viewprofile&u=" . $row['user_id'] .
|
||||
"' target='_blank'>" .
|
||||
$row['username'] . "</a></td></tr>";
|
||||
|
|
|
@ -1,23 +1,21 @@
|
|||
<script>
|
||||
function showHint(str)
|
||||
{
|
||||
if (str.length<3)
|
||||
{
|
||||
function showHint(str) {
|
||||
if (str.length<3) {
|
||||
document.getElementById("livesearch").innerHTML="";
|
||||
return;
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
url:'{S_LIVE_SEARCH_ACTION}'+"&q="+str,
|
||||
success:function(result){
|
||||
success:function(result) {
|
||||
$("#livesearch").html(result);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function clearSearch()
|
||||
{
|
||||
function clearSearch() {
|
||||
setTimeout(function () {
|
||||
document.getElementById("livesearch").innerHTML="";
|
||||
}, 500);
|
||||
}
|
||||
</script>
|
||||
|
||||
|
@ -32,7 +30,7 @@
|
|||
<fieldset class="fields1 column1">
|
||||
<dl>
|
||||
<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>
|
||||
<!-- IF S_EMAIL_SEARCH_ALLOWED -->
|
||||
<dl>
|
||||
|
|
|
@ -65,25 +65,23 @@
|
|||
<!-- ENDIF -->
|
||||
|
||||
<script>
|
||||
function showHint(str)
|
||||
{
|
||||
if (str.length<3)
|
||||
{
|
||||
function showHint(str) {
|
||||
if (str.length<3) {
|
||||
document.getElementById("livesearch").innerHTML="";
|
||||
return;
|
||||
}
|
||||
|
||||
$.ajax({
|
||||
url:'{S_LIVE_SEARCH_ACTION}'+"&q="+str,
|
||||
success:function(result){
|
||||
success:function(result) {
|
||||
$("#livesearch").html(result);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function clearSearch()
|
||||
{
|
||||
function clearSearch() {
|
||||
setTimeout(function () {
|
||||
document.getElementById("livesearch").innerHTML="";
|
||||
}, 500);
|
||||
}
|
||||
</script>
|
||||
|
||||
|
@ -98,7 +96,7 @@
|
|||
</tr>
|
||||
<tr>
|
||||
<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 -->
|
||||
<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>
|
||||
|
|
Loading…
Add table
Reference in a new issue