diff options
author | RedMatrix <info@friendica.com> | 2015-01-05 07:30:07 +1100 |
---|---|---|
committer | RedMatrix <info@friendica.com> | 2015-01-05 07:30:07 +1100 |
commit | ebb1a616849e275111cd24a20d08031aff4c4161 (patch) | |
tree | 72a12265027374eef1fb04a12abaa34c284c7337 /view/js/autocomplete.js | |
parent | cb181993a8c63cca8f13c7890a6ab1544f44676f (diff) | |
parent | ac4c17dd4c4df70b31fd7246108fdbc9d6f2a593 (diff) | |
download | volse-hubzilla-ebb1a616849e275111cd24a20d08031aff4c4161.tar.gz volse-hubzilla-ebb1a616849e275111cd24a20d08031aff4c4161.tar.bz2 volse-hubzilla-ebb1a616849e275111cd24a20d08031aff4c4161.zip |
Merge pull request #816 from pafcu/acl
Autocomplete improvements
Diffstat (limited to 'view/js/autocomplete.js')
-rw-r--r-- | view/js/autocomplete.js | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/view/js/autocomplete.js b/view/js/autocomplete.js index 7c3145769..259dca1bc 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, } |