X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=plugins%2FAutocomplete%2FAutocomplete.js;h=c3f022702ac0fb107e11a29d67ec859df3be6306;hb=d6030714f3bbdfa63053040ca86655f4b4a6c83f;hp=e799c11e50ae14ced17c0bf9ddb3e58f2bee4cd5;hpb=b2664e1ae2e2cf66585cdd8696d88efdd053eb3b;p=quix0rs-gnu-social.git diff --git a/plugins/Autocomplete/Autocomplete.js b/plugins/Autocomplete/Autocomplete.js index e799c11e50..c3f022702a 100644 --- a/plugins/Autocomplete/Autocomplete.js +++ b/plugins/Autocomplete/Autocomplete.js @@ -1,38 +1,38 @@ $(document).ready(function(){ - $.getJSON($('address .url')[0].href+'/api/statuses/friends.json?user_id=' + current_user['id'] + '&lite=true&callback=?', - function(friends){ - $('#notice_data-text').autocomplete(friends, { - multiple: true, - multipleSeparator: " ", - minChars: 1, - formatItem: function(row, i, max){ - return '@' + row.screen_name + ' (' + row.name + ')'; - }, - formatMatch: function(row, i, max){ - return '@' + row.screen_name; - }, - formatResult: function(row){ - return '@' + row.screen_name; - } - }); + function fullName(row) { + if (typeof row.fullname == "string" && row.fullname != '') { + return row.nickname + ' (' + row.fullname + ')'; + } else { + return row.nickname; } - ); - $.getJSON($('address .url')[0].href+'/api/laconica/groups/list.json?user_id=' + current_user['id'] + '&callback=?', - function(groups){ - $('#notice_data-text').autocomplete(groups, { - multiple: true, - multipleSeparator: " ", - minChars: 1, - formatItem: function(row, i, max){ - return '!' + row.nickname + ' (' + row.fullname + ')'; - }, - formatMatch: function(row, i, max){ + } + $('#notice_data-text').autocomplete($('address .url')[0].href+'main/autocomplete/suggest', { + multiple: true, + multipleSeparator: " ", + minChars: 1, + formatItem: function(row, i, max){ + row = eval("(" + row + ")"); + // the display:inline is because our INSANE stylesheets + // override the standard display of all img tags for no + // good reason. + var div = $('
') + .find('img').attr('src', row.avatar).end() + .find('span').text(fullName(row)).end() + return div.html(); + }, + formatMatch: function(row, i, max){ + row = eval("(" + row + ")"); + return row.nickname; + }, + formatResult: function(row){ + row = eval("(" + row + ")"); + switch(row.type) + { + case 'user': + return '@' + row.nickname; + case 'group': return '!' + row.nickname; - }, - formatResult: function(row){ - return '!' + row.nickname; - } - }); + } } - ); + }); });