summaryrefslogtreecommitdiff
path: root/plugins/Autocomplete/Autocomplete.js
diff options
context:
space:
mode:
authorZach Copley <zach@status.net>2009-09-25 16:59:51 -0700
committerZach Copley <zach@status.net>2009-09-25 16:59:51 -0700
commitccc7caf932735a5ba245db5df36615b02e0af9e3 (patch)
treed5ed728d8d67e3e327ecccd942a063564da36520 /plugins/Autocomplete/Autocomplete.js
parentde5ff19713a990af197330dd8e4314de465ffe76 (diff)
parent150cf8c045e8e091a70440d1b833fa19aaf31419 (diff)
Merge branch 'refactor-api' of git@gitorious.org:~zcopley/statusnet/zcopleys-clone into refactor-api
Diffstat (limited to 'plugins/Autocomplete/Autocomplete.js')
-rw-r--r--plugins/Autocomplete/Autocomplete.js51
1 files changed, 25 insertions, 26 deletions
diff --git a/plugins/Autocomplete/Autocomplete.js b/plugins/Autocomplete/Autocomplete.js
index dfadea004..3eff685a8 100644
--- a/plugins/Autocomplete/Autocomplete.js
+++ b/plugins/Autocomplete/Autocomplete.js
@@ -1,38 +1,37 @@
$(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, {
+ $('#notice_data-text').autocomplete($('address .url')[0].href+'/plugins/Autocomplete/autocomplete.json', {
multiple: true,
multipleSeparator: " ",
minChars: 1,
formatItem: function(row, i, max){
- return '@' + row.screen_name + ' (' + row.name + ')';
+ row = eval("(" + row + ")");
+ switch(row.type)
+ {
+ case 'user':
+ return row.nickname + ' (' + row.fullname + ')';
+ case 'group':
+ return row.nickname + ' (' + row.fullname + ')';
+ }
},
formatMatch: function(row, i, max){
- return '@' + row.screen_name;
+ row = eval("(" + row + ")");
+ switch(row.type)
+ {
+ case 'user':
+ return row.nickname;
+ case 'group':
+ return row.nickname;
+ }
},
formatResult: function(row){
- return '@' + row.screen_name;
+ row = eval("(" + row + ")");
+ switch(row.type)
+ {
+ case 'user':
+ return '@' + row.nickname;
+ case 'group':
+ return '!' + row.nickname;
+ }
}
});
- }
- );
- $.getJSON($('address .url')[0].href+'/api/statusnet/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){
- return '!' + row.nickname;
- },
- formatResult: function(row){
- return '!' + row.nickname;
- }
- });
- }
- );
});