Improve *_hash_arguments methods
This commit is contained in:
parent
961808d59c
commit
6d1de167b5
|
@ -256,6 +256,8 @@ function del_hash_argument(key, fireevent) {
|
|||
var hash = window.location.hash;
|
||||
hash = hash.replace(new RegExp(';?'+key+'=[^;]+'),'');
|
||||
hash = hash.replace('/;','/');
|
||||
if (hash.charAt(hash.length-1) === '/')
|
||||
hash = hash.substr(0, hash.length-1);
|
||||
window.location.hash = hash;
|
||||
}
|
||||
|
||||
|
@ -268,6 +270,10 @@ function set_hash_argument(key, val, fireevent) {
|
|||
else window.hash_argument_nofirechange = true;
|
||||
|
||||
var hargs = get_hash_arguments();
|
||||
if (Object.keys(hargs).length === 0) {
|
||||
window.location.hash += '/'+key+'='+val;
|
||||
return;
|
||||
}
|
||||
if (hargs[key] === undefined) {
|
||||
window.location.hash += ';'+key+'='+val;
|
||||
return;
|
||||
|
|
Loading…
Reference in New Issue