[PATCH 03 of 19] autocomplete: factor out matchGroups function
Thomas De Schampheleire
patrickdepinguin at gmail.com
Tue Jun 30 16:43:13 EDT 2015
# HG changeset patch
# User Thomas De Schampheleire <thomas.de.schampheleire at gmail.com>
# Date 1435259175 -7200
# Thu Jun 25 21:06:15 2015 +0200
# Node ID fca74929123428f02ade6d63c3f368368128619d
# Parent 29390aec8d12021642c13741a57da8901be9a9a4
autocomplete: factor out matchGroups function
diff --git a/kallithea/public/js/base.js b/kallithea/public/js/base.js
--- a/kallithea/public/js/base.js
+++ b/kallithea/public/js/base.js
@@ -1125,37 +1125,37 @@ var autocompleteMatchUsers = function (s
return matches;
};
+// 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 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 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) {
- // Case insensitive matching
- var query = sQuery.toLowerCase();
- var i = 0;
- var l = myGroups.length;
- var matches = [];
-
- // Match against each name of each contact
- for (; i < l; i++) {
- var matched_group = myGroups[i];
- if (matched_group.grname.toLowerCase().indexOf(query) > -1) {
- matches[matches.length] = matched_group;
- }
- }
- return matches;
- };
-
+ return autocompleteMatchGroups(sQuery, groups_list);
+ }
var matchAll = function (sQuery) {
- var u = matchUsers(sQuery);
- var g = matchGroups(sQuery);
- return u.concat(g);
- };
+ var u = matchUsers(sQuery);
+ var g = matchGroups(sQuery);
+ return u.concat(g);
+ };
// DataScheme for members
var memberDS = new YAHOO.util.FunctionDataSource(matchAll);
More information about the kallithea-general
mailing list