Improve *_hash_arguments methods

main
Bofh 2023-01-13 02:00:43 +01:00
parent 961808d59c
commit 6d1de167b5
1 changed files with 6 additions and 0 deletions

View File

@ -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;