mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-28 14:18:52 +00:00
[ticket/10737] Using JQuery events and JSON response.
PHPBB3-10737
This commit is contained in:
parent
b5ee81dae6
commit
dd07efcac7
4 changed files with 33 additions and 50 deletions
|
@ -512,6 +512,32 @@ 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url:'memberlist.php?mode=livesearch&'+"&q="+str,
|
||||||
|
success:function(result) {
|
||||||
|
$.each(result, function(idx, elem) {
|
||||||
|
j = (idx%2)+1;
|
||||||
|
$("#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>");
|
||||||
|
})
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
$('.liveinput').blur(function() {
|
||||||
|
setTimeout(function () {
|
||||||
|
document.getElementById("livesearch").innerHTML="";
|
||||||
|
}, 500);
|
||||||
|
});
|
||||||
|
|
||||||
// Toggle notification list
|
// Toggle notification list
|
||||||
$('#notification_list_button').click(function(e) {
|
$('#notification_list_button').click(function(e) {
|
||||||
$('#notification_list').toggle();
|
$('#notification_list').toggle();
|
||||||
|
|
|
@ -983,7 +983,6 @@ switch ($mode)
|
||||||
|
|
||||||
case 'livesearch':
|
case 'livesearch':
|
||||||
$username_chars = $request->variable('q', '', true);
|
$username_chars = $request->variable('q', '', true);
|
||||||
$hint = "";
|
|
||||||
|
|
||||||
$sql = 'SELECT username, user_id
|
$sql = 'SELECT username, user_id
|
||||||
FROM ' . USERS_TABLE . '
|
FROM ' . USERS_TABLE . '
|
||||||
|
@ -991,17 +990,17 @@ switch ($mode)
|
||||||
AND username ' . $db->sql_like_expression($username_chars . $db->any_char);
|
AND 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();
|
||||||
$i = 1;
|
$i = 1;
|
||||||
while ($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='" .
|
$user_list[] = array("id" => $row['user_id'], "name" => $row['username']);
|
||||||
$phpbb_root_path."memberlist.$phpEx". "?mode=viewprofile&u=" . $row['user_id'] .
|
|
||||||
"' target='_blank'>" .
|
|
||||||
$row['username'] . "</a></td></tr>";
|
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
echo $hint;
|
|
||||||
|
$json_response = new \phpbb\json_response();
|
||||||
|
echo $json_response->send($user_list);
|
||||||
exit();
|
exit();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
|
@ -1,24 +1,3 @@
|
||||||
<script>
|
|
||||||
function showHint(str) {
|
|
||||||
if (str.length<3) {
|
|
||||||
document.getElementById("livesearch").innerHTML="";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$.ajax({
|
|
||||||
url:'{S_LIVE_SEARCH_ACTION}'+"&q="+str,
|
|
||||||
success:function(result) {
|
|
||||||
$("#livesearch").html(result);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
function clearSearch() {
|
|
||||||
setTimeout(function () {
|
|
||||||
document.getElementById("livesearch").innerHTML="";
|
|
||||||
}, 500);
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<h2 class="solo">{L_FIND_USERNAME}</h2>
|
<h2 class="solo">{L_FIND_USERNAME}</h2>
|
||||||
|
|
||||||
<form method="post" action="{S_MODE_ACTION}" id="search_memberlist">
|
<form method="post" action="{S_MODE_ACTION}" id="search_memberlist">
|
||||||
|
@ -30,7 +9,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" autocomplete="off" 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 liveinput" autocomplete="off" /> <table class="table1" id="livesearch"></table></dd>
|
||||||
</dl>
|
</dl>
|
||||||
<!-- IF S_EMAIL_SEARCH_ALLOWED -->
|
<!-- IF S_EMAIL_SEARCH_ALLOWED -->
|
||||||
<dl>
|
<dl>
|
||||||
|
|
|
@ -64,27 +64,6 @@
|
||||||
</script>
|
</script>
|
||||||
<!-- ENDIF -->
|
<!-- ENDIF -->
|
||||||
|
|
||||||
<script>
|
|
||||||
function showHint(str) {
|
|
||||||
if (str.length<3) {
|
|
||||||
document.getElementById("livesearch").innerHTML="";
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
$.ajax({
|
|
||||||
url:'{S_LIVE_SEARCH_ACTION}'+"&q="+str,
|
|
||||||
success:function(result) {
|
|
||||||
$("#livesearch").html(result);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
function clearSearch() {
|
|
||||||
setTimeout(function () {
|
|
||||||
document.getElementById("livesearch").innerHTML="";
|
|
||||||
}, 500);
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<form method="post" action="{S_MODE_ACTION}" name="search">
|
<form method="post" action="{S_MODE_ACTION}" name="search">
|
||||||
|
|
||||||
<table class="tablebg" width="100%" cellspacing="1">
|
<table class="tablebg" width="100%" cellspacing="1">
|
||||||
|
@ -96,7 +75,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}" autocomplete="off" onkeyup="showHint(this.value)" onblur="clearSearch()" /> <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"></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