fix code duplication

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1304361 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2012-03-23 14:15:58 +00:00
parent 819c12759a
commit e79c008baf
1 changed files with 25 additions and 41 deletions

View File

@ -779,26 +779,7 @@ $(function() {
this.version=version;
this.crumbEntries=function(){
var splitted = self.groupId.split(".");
var breadCrumbEntries=[];
var curGroupId="";
for (var i=0;i<splitted.length;i++){
curGroupId+=splitted[i];
breadCrumbEntries.push(new BreadCrumbEntry(curGroupId,splitted[i]));
curGroupId+="."
}
var crumbEntryArtifact=new BreadCrumbEntry(self.groupId,self.artifactId);
crumbEntryArtifact.artifactId=self.artifactId;
crumbEntryArtifact.artifact=true;
breadCrumbEntries.push(crumbEntryArtifact);
var crumbEntryVersion=new BreadCrumbEntry(self.groupId,self.version);
crumbEntryVersion.artifactId=self.artifactId;
crumbEntryVersion.artifact=false;
crumbEntryVersion.version=self.version;
breadCrumbEntries.push(crumbEntryVersion);
return breadCrumbEntries;
return calculateCrumbEntries(self.groupId,self.artifactId,self.version);
}
}
@ -887,9 +868,14 @@ $(function() {
//private String fileExtension;
this.fileExtension=fileExtension;
// FIXME it's a copy an paste from Dependency we must extract an "abstract" class with common fields
this.crumbEntries=function(){
var splitted = self.groupId.split(".");
return calculateCrumbEntries(self.groupId,self.artifactId,self.version);
}
}
calculateCrumbEntries=function(groupId,artifactId,version){
var splitted = groupId.split(".");
var breadCrumbEntries=[];
var curGroupId="";
for (var i=0;i<splitted.length;i++){
@ -897,22 +883,20 @@ $(function() {
breadCrumbEntries.push(new BreadCrumbEntry(curGroupId,splitted[i]));
curGroupId+="."
}
var crumbEntryArtifact=new BreadCrumbEntry(self.groupId,self.artifactId);
crumbEntryArtifact.artifactId=self.artifactId;
var crumbEntryArtifact=new BreadCrumbEntry(groupId,artifactId);
crumbEntryArtifact.artifactId=artifactId;
crumbEntryArtifact.artifact=true;
breadCrumbEntries.push(crumbEntryArtifact);
var crumbEntryVersion=new BreadCrumbEntry(self.groupId,self.version);
crumbEntryVersion.artifactId=self.artifactId;
var crumbEntryVersion=new BreadCrumbEntry(groupId,version);
crumbEntryVersion.artifactId=artifactId;
crumbEntryVersion.artifact=false;
crumbEntryVersion.version=self.version;
crumbEntryVersion.version=version;
breadCrumbEntries.push(crumbEntryVersion);
return breadCrumbEntries;
}
}
mapArtifacts=function(data){
if (data){
return $.isArray(data )? $.map(data,function(item){return mapArtifact(item)}) : [data];