diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js index 2eaa2687a..66c212e3e 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js @@ -156,19 +156,6 @@ $(function() { }); } - // handle url with registration link - $(document).ready(function() { - var validateMeId = $.urlParam('validateMe'); - if (validateMeId) { - validateKey(validateMeId); - } - - var browse = $.urlParam('browse'); - if (browse){ - displayBrowseGroupId(browse); - } - }); - startArchivaApplication = function(){ $.log("startArchivaApplication"); $('#topbar-menu-container').html($("#topbar-menu")); @@ -206,11 +193,28 @@ $(function() { } }); - // by default display search screen - displaySearch(); + } startArchivaApplication(); + + + // handle url with registration link + $(document).ready(function() { + var validateMeId = $.urlParam('validateMe'); + if (validateMeId) { + validateKey(validateMeId); + return; + } + + var browse = $.urlParam('browse'); + if (browse){ + displayBrowseGroupId(browse); + return; + } + // by default display search screen + displaySearch(); + }); }) }); diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/search.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/search.js index a075c1529..fa5ab42cd 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/search.js +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/search.js @@ -180,6 +180,101 @@ $(function() { ko.applyBindings(browseViewModel,mainContent.find("#browse_result").get(0)); } }); + enableAutocompleBrowse(); + } + + enableAutocompleBrowse=function(){ + // browse-autocomplete + $( "#main-content #browse-autocomplete" ).autocomplete({ + minLength: 3, + source: function(request, response){ + var query = ""; + if (request.term.indexOf('.')<0){ + // try with rootGroups then filtered + $.get("restServices/archivaServices/browseService/rootGroups", + function(data) { + var browseResultEntries = mapbrowseResultEntries(data); + var filetered = []; + for(var i=0;i=0){ + if (dotEnd){ + query= request.term.substring(0, request.term.length-1); + } else { + // substring before last + query=request.term.substringBeforeLast("."); + } + } else { + query=request.term; + } + $.get("restServices/archivaServices/browseService/browseGroupId/"+encodeURIComponent(query), + function(data) { + var browseResultEntries = mapbrowseResultEntries(data); + if (dotEnd){ + response(browseResultEntries); + } else { + var filetered = []; + for(var i=0;i" ) + .data( "item.autocomplete", item ) + .append( "" + item.name + "" ) + .appendTo( ul ); + };; + } + + /** + * called if browser url contains queryParam browse=groupId + * @param groupId + */ + displayBrowseGroupIdFromAutoComplete=function(groupId){ + clearUserMessages(); + var mainContent = $("#main-content"); + //mainContent.html($("#browse-tmpl" ).tmpl()); + mainContent.find("#browse_result").html(mediumSpinnerImg()); + var parentBrowseViewModel=new BrowseViewModel(null,null,null); + displayGroupDetail(groupId,parentBrowseViewModel,null); + enableAutocompleBrowse(); } /** @@ -192,7 +287,8 @@ $(function() { mainContent.html($("#browse-tmpl" ).tmpl()); mainContent.find("#browse_result").html(mediumSpinnerImg()); var parentBrowseViewModel=new BrowseViewModel(null,null,null); - displayGroupDetail(groupId,parentBrowseViewModel,null) + displayGroupDetail(groupId,parentBrowseViewModel,null); + enableAutocompleBrowse(); } diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/search.html b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/search.html index bc230baef..44719b627 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/search.html +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/search.html @@ -24,6 +24,7 @@
+
diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/utils.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/utils.js index 5dda40089..c0ac9f7e3 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/utils.js +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/utils.js @@ -329,6 +329,19 @@ mapStringList=function(data){ return []; } +// utils +String.prototype.endsWith = function(str) { + return (this.match(str+"$")==str) +} + +String.prototype.startsWith = function(str) { + return (this.match("^"+str)==str) +} + +String.prototype.substringBeforeLast = function(str) { + return this.substring(0,this.lastIndexOf(str)); +} + // extends jquery tmpl to support var def $.extend($.tmpl.tag, { "var": {