From: Olivier Lamy Date: Fri, 23 Mar 2012 14:24:34 +0000 (+0000) Subject: avoid duplicate code X-Git-Tag: archiva-1.4-M3~969 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=e90a94f273ea74e297cdfb7766109c4b95121569;p=archiva.git avoid duplicate code git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1304367 13f79535-47bb-0310-9956-ffa450edef68 --- 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 e4bfc985c..ac7e7cb4d 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 @@ -95,23 +95,7 @@ $(function() { displayBrowseArtifactDetail(splitted[0],splitted[1],null,null); return; } else if (splitted.length==3) { - var mainContent=$("#main-content"); - mainContent.html($("#browse-tmpl" ).tmpl()); - mainContent.find("#browse_result" ).hide(); - mainContent.find("#browse_artifact_detail").show(); - mainContent.find("#browse_artifact_detail").html(mediumSpinnerImg()); - mainContent.find("#browse_breadcrumb" ).show(); - mainContent.find("#browse_breadcrumb" ).html(mediumSpinnerImg()); - $.ajax("restServices/archivaServices/browseService/userRepositories", { - type: "GET", - dataType: 'json', - success: function(data) { - mainContent.find("#selected_repository" ).html($("#selected_repository_tmpl" ).tmpl({repositories:data,selected:repositoryId})); - var artifactVersionDetailViewModel=new ArtifactVersionDetailViewModel(splitted[0],splitted[1],splitted[2]); - artifactVersionDetailViewModel.display(true); - } - }); - + generaldisplayArtifactDetailsVersionView(splitted[0],splitted[1],splitted[2],repositoryId); return; } else { displayWarningMessage( $.i18n.prop("shortcut.artifact.illegal")); 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 3757d8be6..7d39f2172 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 @@ -1027,34 +1027,34 @@ $(function() { }); groupIdView=function(artifact){ - $.log("groupIdView:"+artifact.groupId); displayBrowseGroupId(artifact.groupId); } artifactIdView=function(artifact){ - $.log("artifactIdView:"+artifact.groupId); displayBrowseArtifactDetail(artifact.groupId,artifact.artifactId,null,null); } artifactDetailView=function(artifact){ - $.log("artifactDetailView:"+artifact.groupId); - var mainContent=$("#main-content"); - mainContent.html($("#browse-tmpl" ).tmpl()); - mainContent.find("#browse_result" ).hide(); - mainContent.find("#browse_artifact_detail").show(); - mainContent.find("#browse_artifact_detail").html(mediumSpinnerImg()); - mainContent.find("#browse_breadcrumb" ).show(); - mainContent.find("#browse_breadcrumb" ).html(mediumSpinnerImg()); - $.ajax("restServices/archivaServices/browseService/userRepositories", { - type: "GET", - dataType: 'json', - success: function(data) { - mainContent.find("#selected_repository" ).html($("#selected_repository_tmpl" ).tmpl({repositories:data,selected:null})); - var artifactVersionDetailViewModel=new ArtifactVersionDetailViewModel(artifact.groupId,artifact.artifactId,artifact.version); - artifactVersionDetailViewModel.display(true); - } - }); + generaldisplayArtifactDetailsVersionView(artifact.groupId,artifact.artifactId,artifact.version,null); } } + generaldisplayArtifactDetailsVersionView=function(groupId,artifactId,version,repositoryId){ + var mainContent=$("#main-content"); + mainContent.html($("#browse-tmpl" ).tmpl()); + mainContent.find("#browse_result" ).hide(); + mainContent.find("#browse_artifact_detail").show(); + mainContent.find("#browse_artifact_detail").html(mediumSpinnerImg()); + mainContent.find("#browse_breadcrumb" ).show(); + mainContent.find("#browse_breadcrumb" ).html(mediumSpinnerImg()); + $.ajax("restServices/archivaServices/browseService/userRepositories", { + type: "GET", + dataType: 'json', + success: function(data) { + mainContent.find("#selected_repository" ).html($("#selected_repository_tmpl" ).tmpl({repositories:data,selected:repositoryId})); + var artifactVersionDetailViewModel=new ArtifactVersionDetailViewModel(groupId,artifactId,version); + artifactVersionDetailViewModel.display(true); + } + }); + } SearchViewModel=function(){ var self=this;