Changeset - 63be69bd33cf
[Not reviewed]
default
0 1 0
Thomas De Schampheleire - 10 years ago 2015-06-25 21:06:15
thomas.de.schampheleire@gmail.com
autocomplete: factor out matchGroups function
1 file changed with 11 insertions and 11 deletions:
0 comments (0 inline, 0 general)
kallithea/public/js/base.js
Show inline comments
 
@@ -1122,50 +1122,50 @@ var autocompleteMatchUsers = function (s
 
    // Match against each name of each contact
 
    for (; i < l; i++) {
 
        var contact = myUsers[i];
 
        if (((contact.fname+"").toLowerCase().indexOf(query) > -1) ||
 
             ((contact.lname+"").toLowerCase().indexOf(query) > -1) ||
 
             ((contact.nname) && ((contact.nname).toLowerCase().indexOf(query) > -1))) {
 
            matches[matches.length] = contact;
 
        }
 
    }
 
    return matches;
 
};
 

	
 

	
 
var _MembersAutoComplete = function (divid, cont, users_list, groups_list) {
 
    var myGroups = groups_list;
 

	
 
    var matchUsers = function (sQuery) {
 
        return autocompleteMatchUsers(sQuery, users_list);
 
    }
 

	
 
    // Define a custom search function for the DataSource of userGroups
 
    var matchGroups = function (sQuery) {
 
// Custom search function for the DataSource of userGroups
 
var autocompleteMatchGroups = function (sQuery, myGroups) {
 
            // Case insensitive matching
 
            var query = sQuery.toLowerCase();
 
            var i = 0;
 
            var l = myGroups.length;
 
            var matches = [];
 

	
 
            // Match against each name of each contact
 
    // Match against each name of each group
 
            for (; i < l; i++) {
 
                var matched_group = myGroups[i];
 
                if (matched_group.grname.toLowerCase().indexOf(query) > -1) {
 
                    matches[matches.length] = matched_group;
 
                }
 
            }
 
            return matches;
 
        };
 

	
 
var _MembersAutoComplete = function (divid, cont, users_list, groups_list) {
 

	
 
    var matchUsers = function (sQuery) {
 
        return autocompleteMatchUsers(sQuery, users_list);
 
    }
 
    var matchGroups = function (sQuery) {
 
        return autocompleteMatchGroups(sQuery, groups_list);
 
    }
 
    var matchAll = function (sQuery) {
 
            var u = matchUsers(sQuery);
 
            var g = matchGroups(sQuery);
 
            return u.concat(g);
 
        };
 

	
 
    // DataScheme for members
 
    var memberDS = new YAHOO.util.FunctionDataSource(matchAll);
 
    memberDS.responseSchema = {
 
        fields: ["id", "fname", "lname", "nname", "grname", "grmembers", "gravatar_lnk", "gravatar_size"]
 
    };
 

	
0 comments (0 inline, 0 general)