You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@archiva.apache.org by ol...@apache.org on 2012/02/29 19:51:36 UTC
svn commit: r1295211 -
/archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/search.js
Author: olamy
Date: Wed Feb 29 18:51:36 2012
New Revision: 1295211
URL: http://svn.apache.org/viewvc?rev=1295211&view=rev
Log:
avoid duplicated code and use more generic solution for filtering
Modified:
archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/search.js
Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/search.js
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/search.js?rev=1295211&r1=1295210&r2=1295211&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/search.js (original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/search.js Wed Feb 29 18:51:36 2012
@@ -734,49 +734,9 @@ $(function() {
"simpleGrid: gridViewModel,simpleGridTemplate:'search-results-view-grid-tmpl',pageLinksId:'search-results-view-grid-pagination'");
ko.applyBindings(self.resultViewModel,searchResultsGrid.get(0));
}
- // FIXME something generic here !
-
- $( "#main-content #search-filter-auto-groupId" ).autocomplete({
- minLength: 1,
- source: function(request, response){
- var groupIds=[];
- $(self.resultViewModel.artifacts()).each(function(idx,artifact){
- if(artifact.groupId.startsWith(request.term)){
- groupIds.push(artifact.groupId);
- }
- });
- response(unifyArray(groupIds,true));
- }
- });
-
- $( "#main-content #search-filter-auto-artifactId" ).autocomplete({
- minLength: 1,
- source: function(request, response){
- var artifactIds=[];
- $(self.resultViewModel.artifacts()).each(function(idx,artifact){
- if(artifact.artifactId.startsWith(request.term)){
- artifactIds.push(artifact.artifactId);
- }
- });
- response(unifyArray(artifactIds,true));
- }
- });
-
- $( "#main-content #search-filter-auto-version" ).autocomplete({
- minLength: 1,
- source: function(request, response){
- var versions=[];
- $(self.resultViewModel.artifacts()).each(function(idx,artifact){
- if(artifact.version.startsWith(request.term)){
- versions.push(artifact.version);
- }
- });
- response(unifyArray(versions,true));
- }
- });
-
-
-
+ applyAutocompleteOnHeader('groupId');
+ applyAutocompleteOnHeader('artifactId');
+ applyAutocompleteOnHeader('version');
activateSearchResultsTab();
}
},
@@ -793,6 +753,21 @@ $(function() {
);
}
+ applyAutocompleteOnHeader=function(property){
+ $( "#main-content #search-filter-auto-"+property ).autocomplete({
+ minLength: 1,
+ source: function(request, response){
+ var founds=[];
+ $(self.resultViewModel.artifacts()).each(function(idx,artifact){
+ if(artifact[property].startsWith(request.term)){
+ founds.push(artifact[property]);
+ }
+ });
+ response(unifyArray(founds,true));
+ }
+ });
+ }
+
// olamy not used as we cannot filter on className etc...
filterResults=function(){
var filtered=[];