]> source.dussan.org Git - archiva.git/commitdiff
avoid duplicate code
authorOlivier Lamy <olamy@apache.org>
Fri, 23 Mar 2012 14:24:34 +0000 (14:24 +0000)
committerOlivier Lamy <olamy@apache.org>
Fri, 23 Mar 2012 14:24:34 +0000 (14:24 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1304367 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/main.js
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/search.js

index e4bfc985c64c91362881287a0e12507f44e0b640..ac7e7cb4d02bb7b738dc21b1ae5906ee9b44451f 100644 (file)
@@ -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"));
index 3757d8be6e47a639d9e15faaee597adf49540006..7d39f2172f721fa844489768edd72a2591771a93 100644 (file)
@@ -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;