summaryrefslogtreecommitdiff
path: root/plugins/Autocomplete/Autocomplete.js
blob: dfadea0045c0887a2078f8f68bb00e7e116a995b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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;
                }
            });
        }
    );
    $.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;
                }
            });
        }
    );
});