fix hash when changing repository

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1370415 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2012-08-07 18:13:44 +00:00
parent e12e0e6f50
commit ae610b03b7
2 changed files with 15 additions and 1 deletions

View File

@ -756,8 +756,14 @@ define("archiva.search",["jquery","i18n","jquery.tmpl","choosen","knockout","kno
changeBrowseRepository=function(){
var selectedRepository=getSelectedBrowsingRepository();
// #browse~internal/org.apache.maven
// or #artifact~snapshots/org.apache.maven.plugins/maven-compiler-plugin
var currentHash=window.location.hash;
var newLocation = "#browse";
$.log("currentHash:"+currentHash);
var newLocation = currentHash.substringBeforeFirst("/");// "#browse";
if (selectedRepository){
newLocation+="~"+selectedRepository;
}

View File

@ -402,6 +402,14 @@ define("utils",["jquery","i18n","jquery.tmpl"], function() {
return this.substring(0,this.lastIndexOf(str));
}
String.prototype.substringBeforeFirst = function(str) {
var idx = this.indexOf(str);
if(idx<0){
return this;
}
return this.substring(0,idx);
}
String.prototype.substringAfterLast = function(str) {
return this.substring(this.lastIndexOf(str)+1);
}