aboutsummaryrefslogtreecommitdiffstats
path: root/view/js
diff options
context:
space:
mode:
authorStefan Parviainen <saparvia@caterva.eu>2015-01-04 12:54:23 +0100
committerStefan Parviainen <saparvia@caterva.eu>2015-01-04 12:54:23 +0100
commit386f361855663b445d1497bbbabcf87891ce94d9 (patch)
treee003894f63a59b8ca7b7f707d9d3bfab353b6204 /view/js
parent42773a11220a5bba7bdf3395e3f00913dce9f5a0 (diff)
downloadvolse-hubzilla-386f361855663b445d1497bbbabcf87891ce94d9.tar.gz
volse-hubzilla-386f361855663b445d1497bbbabcf87891ce94d9.tar.bz2
volse-hubzilla-386f361855663b445d1497bbbabcf87891ce94d9.zip
Autocmplete suggestions for non-local users, also suggest from visited channel's connections
Diffstat (limited to 'view/js')
-rw-r--r--view/js/autocomplete.js16
1 files changed, 12 insertions, 4 deletions
diff --git a/view/js/autocomplete.js b/view/js/autocomplete.js
index 7c3145769..204d3756f 100644
--- a/view/js/autocomplete.js
+++ b/view/js/autocomplete.js
@@ -3,13 +3,16 @@
*
* require jQuery, jquery.textcomplete
*/
-function mysearch(term, callback, backend_url) {
+function mysearch(term, callback, backend_url, extra_channels) {
var postdata = {
start:0,
count:100,
search:term,
type:'c',
}
+
+ if(extra_channels) {
+ postdata['extra_channels[]'] = extra_channels;
$.ajax({
type:'POST',
@@ -28,20 +31,25 @@ function format(item) {
function replace(item) {
// $2 ensures that prefix (@,@!) is preserved
- return '$1$2'+item.nick.replace(' ','') + '+' + item.id;
+ var id = item.id;
+ // 16 chars of hash should be enough. Full hash could be used if it can be done in a visually appealing way.
+ // 16 chars is also the minimum length in the backend (otherwise it's interpreted as a local id).
+ if(id.length > 16)
+ id = item.id.substring(0,16);
+ return '$1$2'+item.nick.replace(' ','') + '+' + id;
}
/**
* jQuery plugin 'contact_autocomplete'
*/
(function( $ ){
- $.fn.contact_autocomplete = function(backend_url) {
+ $.fn.contact_autocomplete = function(backend_url, extra_channels = null) {
// Autocomplete contacts
contacts = {
match: /(^|\s)(@\!*)([^ \n]+)$/,
index: 3,
- search: function(term, callback) { mysearch(term, callback, backend_url); },
+ search: function(term, callback) { mysearch(term, callback, backend_url, extra_channels); },
replace: replace,
template: format,
}