]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Start tweaking Autocomplete js
authorBrion Vibber <brion@pobox.com>
Tue, 7 Dec 2010 00:20:54 +0000 (16:20 -0800)
committerBrion Vibber <brion@pobox.com>
Tue, 7 Dec 2010 00:20:54 +0000 (16:20 -0800)
plugins/Autocomplete/Autocomplete.js

index 3eff685a8dff5c002e5a161f48de506764992760..f39c1a7a7233437477f290ddab7929c4cc4d4827 100644 (file)
@@ -1,27 +1,22 @@
 $(document).ready(function(){
+    function fullName(row) {
+        if (typeof row.fullname == "string" && row.fullname != '') {
+            return row.nickname + ' (' + row.fullname + ')';
+        } else {
+            return row.nickname;
+        }
+    }
             $('#notice_data-text').autocomplete($('address .url')[0].href+'/plugins/Autocomplete/autocomplete.json', {
                 multiple: true,
                 multipleSeparator: " ",
                 minChars: 1,
                 formatItem: function(row, i, max){
                     row = eval("(" + row + ")");
-                    switch(row.type)
-                    {
-                        case 'user':
-                            return row.nickname + ' (' + row.fullname + ')';
-                        case 'group':
-                            return row.nickname + ' (' + row.fullname + ')';
-                    }
+                    return fullName(row);
                 },
                 formatMatch: function(row, i, max){
                     row = eval("(" + row + ")");
-                    switch(row.type)
-                    {
-                        case 'user':
-                            return row.nickname;
-                        case 'group':
-                            return row.nickname;
-                    }
+                    return row.nickname;
                 },
                 formatResult: function(row){
                     row = eval("(" + row + ")");