Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

[ticket/10737] Adding username suggestions in "Find a member" using AJAX #2009

Closed
wants to merge 19 commits into
from

Conversation

Projects
None yet
7 participants
Contributor

suheb commented Feb 6, 2014

Suggest usernames as the user types in "Find a member" using AJAX.
Ticket: http://tracker.phpbb.com/browse/PHPBB3-10737

@nickvergessen nickvergessen commented on an outdated diff Feb 6, 2014

phpBB/memberlist.php
@@ -30,7 +30,7 @@
$topic_id = request_var('t', 0);
// Check our mode...
-if (!in_array($mode, array('', 'group', 'viewprofile', 'email', 'contact', 'searchuser', 'leaders')))
+if (!in_array($mode, array('', 'group', 'viewprofile', 'email', 'contact', 'searchuser', 'leaders','livesearch')))
@nickvergessen

nickvergessen Feb 6, 2014

Contributor

missing space after , ;)

@nickvergessen nickvergessen commented on an outdated diff Feb 6, 2014

phpBB/memberlist.php
@@ -992,7 +992,44 @@
);
break;
-
+
+ case 'livesearch':
+ $q=request_var('q','');
@nickvergessen

nickvergessen Feb 6, 2014

Contributor

please use $request->variable('q', '', true);

@nickvergessen nickvergessen commented on an outdated diff Feb 6, 2014

phpBB/memberlist.php
@@ -992,7 +992,44 @@
);
break;
-
+
+ case 'livesearch':
+ $q=request_var('q','');
+ $hint="";
+ // Get us some users :D
+ $sql = "SELECT u.user_id
+ FROM " . USERS_TABLE . " u
+ WHERE u.user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ")";
@nickvergessen

nickvergessen Feb 6, 2014

Contributor

This needs limitation, we can not put all 100k or more users in an array...

@nickvergessen nickvergessen and 1 other commented on an outdated diff Feb 6, 2014

phpBB/memberlist.php
+ $hint="";
+ // Get us some users :D
+ $sql = "SELECT u.user_id
+ FROM " . USERS_TABLE . " u
+ WHERE u.user_type IN (" . USER_NORMAL . ', ' . USER_FOUNDER . ")";
+
+ $result = $db->sql_query($sql);
+ $user_list = array();
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $user_list[] = (int) $row['user_id'];
+ }
+ $db->sql_freeresult($result);
+ $sql = 'SELECT *
+ FROM ' . USERS_TABLE . '
+ WHERE ' . $db->sql_in_set('user_id', $user_list);
@nickvergessen

nickvergessen Feb 6, 2014

Contributor

merge with the query above...
and only display hints after 3 characters or something like that....

@prototech

prototech Feb 6, 2014

Contributor

There's no need to fetch all columns in the table. Should only need the username and user id. The search should also be done in the query instead of selecting all records and iterating through them in PHP to find those that match. The search code should also probably be in its own function as we probably want this elsewhere (eg the ACP, PMs, etc).

@prototech prototech and 1 other commented on an outdated diff Feb 6, 2014

phpBB/memberlist.php
+ }
+ $db->sql_freeresult($result);
+ $sql = 'SELECT *
+ FROM ' . USERS_TABLE . '
+ WHERE ' . $db->sql_in_set('user_id', $user_list);
+ $result = $db->sql_query($sql);
+ $i=1;
+ while ($row = $db->sql_fetchrow($result))
+ { $j=($i%2)+1;
+ if(stripos($row['username'],$q)===0)
+ {
+ $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>";
+ $i++;
@prototech

prototech Feb 6, 2014

Contributor

This should simply be returning the list of users in JSON format instead of hard-coding HTML.

@suheb

suheb Feb 6, 2014

Contributor

@prototech So I should send a simple JSON response and use it to create table rows in JavaScript?

@prototech

prototech Feb 6, 2014

Contributor

The template itself should define the HTML. So what you want to do is have a hidden element within the table in memberlist_search.html. For example:

<tr id="user-search-row-tpl" style="display: none;">
    <td><a class="user-search-link user-search-name" target='_blank'></a></td>
</tr>

Then clone that and insert the relevant data using the classes as selectors.

@prototech prototech commented on an outdated diff Feb 6, 2014

phpBB/memberlist.php
+ $i=1;
+ while ($row = $db->sql_fetchrow($result))
+ { $j=($i%2)+1;
+ if(stripos($row['username'],$q)===0)
+ {
+ $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>";
+ $i++;
+ }
+ else
+ $hint.="";
+ }
+ echo $hint;
+ exit();
@prototech

prototech Feb 6, 2014

Contributor

Use the send method in the \phpbb\json_response class.

@prototech prototech commented on an outdated diff Feb 6, 2014

phpBB/memberlist.php
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $user_list[] = (int) $row['user_id'];
+ }
+ $db->sql_freeresult($result);
+ $sql = 'SELECT *
+ FROM ' . USERS_TABLE . '
+ WHERE ' . $db->sql_in_set('user_id', $user_list);
+ $result = $db->sql_query($sql);
+ $i=1;
+ while ($row = $db->sql_fetchrow($result))
+ { $j=($i%2)+1;
+ if(stripos($row['username'],$q)===0)
+ {
+ $hint.="<tr class='bg".$j." row".$j."'><td><a href='" .
+ $phpbb_root_path."memberlist.$phpEx". "?mode=viewprofile&u=" . $row['user_id'] .
@prototech

prototech Feb 6, 2014

Contributor

This should be passed through append_sid()

@prototech prototech commented on an outdated diff Feb 6, 2014

phpBB/styles/prosilver/template/memberlist_search.html
+ if (xmlhttp.readyState==4 && xmlhttp.status==200)
+ {
+ document.getElementById("livesearch").innerHTML=xmlhttp.responseText;
+ document.getElementById("livesearch").style.border="0px";
+ }
+ }
+ xmlhttp.open("GET",'{S_LIVE_SEARCH_ACTION}'+"&q="+str,true);
+ xmlhttp.send();
+ }
+
+ function clearSearch()
+ {
+ document.getElementById("livesearch").innerHTML="";
+ }
+</script>
+
@prototech

prototech Feb 6, 2014

Contributor

jQuery is included in the core, so you should be use it to send the request. This should also be in assets/javascript/core.js so it can be reused elsewhere and by all styles.

@prototech prototech commented on an outdated diff Feb 6, 2014

phpBB/styles/prosilver/template/memberlist_search.html
@@ -1,3 +1,38 @@
+<script>
+ function showHint(str)
+ {
+ if (str.length==0)
+ {
+ document.getElementById("livesearch").innerHTML="";
+ document.getElementById("livesearch").style.border="0px";
@prototech

prototech Feb 6, 2014

Contributor

If there's a need to do this, it should be done in the stylesheet rather than here.

@prototech prototech commented on an outdated diff Feb 6, 2014

phpBB/styles/prosilver/template/memberlist_search.html
@@ -9,7 +44,7 @@ <h2 class="solo">{L_FIND_USERNAME}</h2>
<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" /></dd>
+ <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>
@prototech

prototech Feb 6, 2014

Contributor

Use jQuery events.

@prototech

prototech Feb 6, 2014

Contributor

This should also have autocomplete="off" otherwise the browser's own suggestions will be overlayed on top.

Contributor

prototech commented Feb 6, 2014

Clicking on one of the usernames doesn't do anything at the moment which makes the usefulness of this rather limited. It should actually fill in the field with that value. If you have to continue typing in the whole username after it has suggested the one that you want, then you're sending unnecessary requests to the server. I see that it's supposed to open the user's profile in another window, but that also doesn't work.

Contributor

suheb commented Feb 6, 2014

@prototech I have added the link of user's profile with the username. Clicking on it opens the user's profile. It's working on my system.

Contributor

prototech commented Feb 6, 2014

I tested in Firefox, Chrome, Opera, and Safari and that doesn't work in any of them.

@prototech prototech and 1 other commented on an outdated diff Feb 6, 2014

phpBB/memberlist.php
@@ -992,7 +992,28 @@
);
break;
-
+
+ case 'livesearch':
+ $q=request_var('q', '', true);
@prototech

prototech Feb 6, 2014

Contributor

This is still not using the request class.

@suheb

suheb Feb 6, 2014

Contributor

Ohh.. I missed that.. will do it in next commit.

@prototech

prototech Feb 6, 2014

Contributor

The variable name needs to be more descriptive and there should be a space before and after = - http://area51.phpbb.com/phpBB/docs/coding-guidelines.html#namingvars http://area51.phpbb.com/phpBB/docs/coding-guidelines.html#codelayout

Contributor

suheb commented Feb 6, 2014

screenshot1
@protech See, here's the screenshot. Clicking on username opens user's profile

@prototech prototech commented on an outdated diff Feb 6, 2014

phpBB/memberlist.php
@@ -992,7 +992,28 @@
);
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 . ")";
@prototech

prototech Feb 6, 2014

Contributor

Tabbing and quotations are incorrect - see http://area51.phpbb.com/phpBB/docs/coding-guidelines.html#sql. The user_type check should be done first and use $db->sql_in_set(). The LIKE statement contains a SQL injection. -you should be using $db->sql_like_expression(). Proper format:

    $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($q . $db->any_char);

@prototech prototech commented on an outdated diff Feb 6, 2014

phpBB/memberlist.php
@@ -992,7 +992,28 @@
);
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))
@prototech

prototech Feb 6, 2014

Contributor

The limit should occur in the query itself, not afterwards. Use $db->sql_query_limit($sql, 10) instead of $db->sql_query($sql).

Contributor

prototech commented Feb 6, 2014

The problem seems to occur because the onblur events fires before onclick, so the link no longer exists once the click registers.

@prototech prototech and 1 other commented on an outdated diff Feb 6, 2014

phpBB/memberlist.php
@@ -1484,7 +1505,8 @@
'S_JOINED_TIME_OPTIONS' => $s_find_join_time,
'S_ACTIVE_TIME_OPTIONS' => $s_find_active_time,
'S_GROUP_SELECT' => $s_group_select,
- 'S_USER_SEARCH_ACTION' => append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=searchuser&amp;form=$form&amp;field=$field"))
+ 'S_USER_SEARCH_ACTION' => append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=searchuser&amp;form=$form&amp;field=$field"),
+ 'S_LIVE_SEARCH_ACTION' => append_sid("{$phpbb_root_path}memberlist.$phpEx", "mode=livesearch", $is_amp = false))
@prototech

prototech Feb 6, 2014

Contributor

$is_amp = false is unnecessary.

@suheb

suheb Feb 7, 2014

Contributor

@prototech No, this is for subsilver2 style, for which it returns "phpbb/memberlist.php?style=2&amp';'mode=livesearch" without $is_amp=false. And that wasn't working.

Contributor

EXreaction commented Feb 21, 2014

@prototech bump

@VSEphpbb VSEphpbb commented on an outdated diff Feb 21, 2014

phpBB/styles/prosilver/template/memberlist_search.html
@@ -1,3 +1,24 @@
+<script>
+ function showHint(str) {
+ if (str.length<3) {
@VSEphpbb

VSEphpbb Feb 21, 2014

Member

spaces?: str.length < 3
same below in subsilver

@nickvergessen nickvergessen commented on an outdated diff Feb 22, 2014

phpBB/memberlist.php
@@ -992,7 +992,30 @@
);
break;
-
+
+ case 'livesearch':
+ $username_chars = $request->variable('q', '', true);
+
+ $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);
@nickvergessen

nickvergessen Feb 22, 2014

Contributor

I would like to see this compared wiht lowercase. Sometimes you cant remember how SuPeRuSeR1234 capitalized his name.

@nickvergessen nickvergessen commented on an outdated diff Feb 22, 2014

phpBB/assets/javascript/core.js
@@ -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>");
@nickvergessen

nickvergessen Feb 22, 2014

Contributor

can we add the table row to the template and then just clone the element.

@nickvergessen

nickvergessen Feb 22, 2014

Contributor

Also instead of bgJ and rowJ the table itself should be table.zebra-list

Contributor

suheb commented Feb 23, 2014

@nickvergessen what about subsilver2? I guess zebra-list does not work in it.

gooof commented Feb 23, 2014

What about a delay for the keyup function? Like: http://stackoverflow.com/questions/1909441/jquery-keyup-delay

@gooof gooof and 1 other commented on an outdated diff Feb 23, 2014

phpBB/styles/prosilver/template/memberlist_search.html
@@ -9,7 +9,13 @@ <h2 class="solo">{L_FIND_USERNAME}</h2>
<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" /></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>
@gooof

gooof Feb 23, 2014

Don't mix ' and ".
Same for subsilver.
And the <a> has no href="#"

@nickvergessen

nickvergessen Feb 24, 2014

Contributor

also dont use target, let the user decide how to open the link

@gooof gooof commented on an outdated diff Feb 23, 2014

phpBB/assets/javascript/core.js
@@ -512,6 +512,40 @@ phpbb.timezonePreselectSelect = function(forceSelector) {
}
};
+// Listen live search box events
+$('.liveinput').keyup(function() {
@gooof

gooof Feb 23, 2014

Is here a better name possible e.g.: member-live-search

@gooof gooof and 1 other commented on an outdated diff Feb 23, 2014

phpBB/styles/prosilver/template/memberlist_search.html
@@ -9,7 +9,13 @@ <h2 class="solo">{L_FIND_USERNAME}</h2>
<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" /></dd>
+ <dd><input type="text" name="username" id="username" value="{USERNAME}" class="inputbox liveinput" autocomplete="off" />
+ <table class="table1 zebra-list" id="livesearch">
@gooof

gooof Feb 23, 2014

display:none for the table possible?

@suheb

suheb Feb 23, 2014

Contributor

@gooof Well, the table is already empty as it only contains a hidden element. So, I not sure how useful would it be.

@gooof

gooof Feb 23, 2014

Ok, i hope this will work correctly in any browser. Could not find a fault with empty tables at the moment.

@gooof gooof commented on an outdated diff Feb 23, 2014

phpBB/memberlist.php
+
+ case 'livesearch':
+ $username_chars = $request->variable('q', '', true);
+ $username_chars = strtolower($username_chars);
+
+ $sql = 'SELECT username, user_id
+ FROM ' . USERS_TABLE . '
+ WHERE ' . $db->sql_in_set('user_type', array(USER_NORMAL, USER_FOUNDER)) . '
+ AND LOWER(username) ' . $db->sql_like_expression($username_chars . $db->any_char);
+ $result = $db->sql_query_limit($sql, 10);
+
+ $user_list = array();
+ $i = 1;
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $j = ($i%2)+1;
@gooof

gooof Feb 23, 2014

no longer used, same for the two $i lines

@gooof gooof commented on an outdated diff Feb 23, 2014

phpBB/memberlist.php
+
+ $sql = 'SELECT username, user_id
+ FROM ' . USERS_TABLE . '
+ WHERE ' . $db->sql_in_set('user_type', array(USER_NORMAL, USER_FOUNDER)) . '
+ AND LOWER(username) ' . $db->sql_like_expression($username_chars . $db->any_char);
+ $result = $db->sql_query_limit($sql, 10);
+
+ $user_list = array();
+ $i = 1;
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $j = ($i%2)+1;
+ $user_list[] = array("id" => $row['user_id'], "name" => $row['username']);
+ $i++;
+ }
+
@gooof

gooof Feb 23, 2014

$db->sql_freeresult($result);

@gooof gooof commented on an outdated diff Feb 23, 2014

phpBB/memberlist.php
+ WHERE ' . $db->sql_in_set('user_type', array(USER_NORMAL, USER_FOUNDER)) . '
+ AND LOWER(username) ' . $db->sql_like_expression($username_chars . $db->any_char);
+ $result = $db->sql_query_limit($sql, 10);
+
+ $user_list = array();
+ $i = 1;
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $j = ($i%2)+1;
+ $user_list[] = array("id" => $row['user_id'], "name" => $row['username']);
+ $i++;
+ }
+
+ $json_response = new \phpbb\json_response();
+ echo $json_response->send($user_list);
+ exit();
@gooof

gooof Feb 23, 2014

never reached... not used

@gooof gooof commented on an outdated diff Feb 23, 2014

phpBB/memberlist.php
+ FROM ' . USERS_TABLE . '
+ WHERE ' . $db->sql_in_set('user_type', array(USER_NORMAL, USER_FOUNDER)) . '
+ AND LOWER(username) ' . $db->sql_like_expression($username_chars . $db->any_char);
+ $result = $db->sql_query_limit($sql, 10);
+
+ $user_list = array();
+ $i = 1;
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $j = ($i%2)+1;
+ $user_list[] = array("id" => $row['user_id'], "name" => $row['username']);
+ $i++;
+ }
+
+ $json_response = new \phpbb\json_response();
+ echo $json_response->send($user_list);

@nickvergessen nickvergessen commented on an outdated diff Feb 24, 2014

phpBB/memberlist.php
@@ -992,7 +992,27 @@
);
break;
-
+
+ case 'livesearch':
+ $username_chars = $request->variable('q', '', true);
+ $username_chars = strtolower($username_chars);
+
+ $sql = 'SELECT username, user_id
+ FROM ' . USERS_TABLE . '
+ WHERE ' . $db->sql_in_set('user_type', array(USER_NORMAL, USER_FOUNDER)) . '
+ AND LOWER(username) ' . $db->sql_like_expression($username_chars . $db->any_char);
@nickvergessen

nickvergessen Feb 24, 2014

Contributor

or even better, use:
AND username_clean ' . $db->sql_like_expression(utf8_clean_string($username_chars) . $db->any_char);

@nickvergessen nickvergessen commented on an outdated diff Feb 24, 2014

phpBB/memberlist.php
@@ -992,7 +992,27 @@
);
break;
-
+
+ case 'livesearch':
+ $username_chars = $request->variable('q', '', true);
+ $username_chars = strtolower($username_chars);
@nickvergessen

nickvergessen Feb 24, 2014

Contributor

use utf8_strtolower()

@nickvergessen nickvergessen commented on an outdated diff Feb 24, 2014

phpBB/memberlist.php
-
+
+ case 'livesearch':
+ $username_chars = $request->variable('q', '', true);
+ $username_chars = strtolower($username_chars);
+
+ $sql = 'SELECT username, user_id
+ FROM ' . USERS_TABLE . '
+ WHERE ' . $db->sql_in_set('user_type', array(USER_NORMAL, USER_FOUNDER)) . '
+ AND LOWER(username) ' . $db->sql_like_expression($username_chars . $db->any_char);
+ $result = $db->sql_query_limit($sql, 10);
+
+ $user_list = array();
+ while ($row = $db->sql_fetchrow($result))
+ {
+ $user_list[] = array("id" => $row['user_id'], "name" => $row['username']);
@nickvergessen

nickvergessen Feb 24, 2014

Contributor

Single quote ' for id and name

@nickvergessen nickvergessen commented on an outdated diff Feb 24, 2014

phpBB/styles/prosilver/template/memberlist_search.html
@@ -9,7 +9,13 @@ <h2 class="solo">{L_FIND_USERNAME}</h2>
<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" /></dd>
+ <dd><input type="text" name="username" id="username" value="{USERNAME}" class="inputbox live-search-input" 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>
@nickvergessen

nickvergessen Feb 24, 2014

Contributor

No target, let the user decide, where to open it

@nickvergessen nickvergessen commented on the diff Feb 24, 2014

phpBB/styles/prosilver/template/memberlist_search.html
@@ -9,7 +9,13 @@ <h2 class="solo">{L_FIND_USERNAME}</h2>
<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" /></dd>
+ <dd><input type="text" name="username" id="username" value="{USERNAME}" class="inputbox live-search-input" autocomplete="off" />
+ <table class="table1 zebra-list" id="livesearch">
@nickvergessen

nickvergessen Feb 24, 2014

Contributor

Can we use the dropdown system here @prototech

@nickvergessen nickvergessen commented on an outdated diff Feb 24, 2014

phpBB/assets/javascript/core.js
@@ -512,6 +512,40 @@ phpbb.timezonePreselectSelect = function(forceSelector) {
}
};
+// Listen live search box events
+$('.live-search-input').keyup(function() {
+ var str = this.value;
+ if (str.length < 3) {
+ return;
+ }
+ var link, name;
+ var clone = $("#user-search-row-tpl").clone();
+ $("#livesearch").html("");
+ clone.appendTo("#livesearch");
@nickvergessen

nickvergessen Feb 24, 2014

Contributor

I'm not a fan of hardcoded ID usage here. This makes it possible to only use one suggestion per page.
Better add a ajax data attribute to the field

Contributor

nickvergessen commented Feb 24, 2014

👍 for delayed keyup

Contributor

prototech commented Feb 24, 2014

@suheb Please hold off on fixing the JS issues. :) I've made some changes locally to make the live search implementation more generic and usable in conjunction with phpbb.ajaxify. I'll send a PR against your branch tomorrow.

@nickvergessen nickvergessen referenced this pull request Feb 24, 2014

Closed

Ticket/10737 #1634

Contributor

suheb commented Feb 26, 2014

@prototech As you asked, I'm holding off on fixing JS issues while waiting for your PR.

Contributor

suheb commented Mar 10, 2014

Sorry, I did some rebasing.. that's why all these commits.
@prototech You were gonna send a PR against my branch to make this feature more generic. What happened?

Contributor

nickvergessen commented Mar 29, 2014

@prototech bump? :) Would like to see this in b2/b3

Contributor

nickvergessen commented Apr 15, 2014

Replaced by #2267

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment