Create methods to add/remove/modify hash arguments
This commit is contained in:
parent
3cb026382f
commit
d7baccabe8
18
js/base.php
18
js/base.php
|
@ -131,6 +131,24 @@ function _get_func_params(func) {
|
|||
return params;
|
||||
}
|
||||
|
||||
function del_hash_argument(key) {
|
||||
var hash = window.location.hash;
|
||||
hash = hash.replace(new RegExp(';?'+key+'=[^;]+'),'');
|
||||
hash = hash.replace('/;','/');
|
||||
window.location.hash = hash;
|
||||
}
|
||||
|
||||
function set_hash_argument(key, val) {
|
||||
var hargs = get_hash_arguments();
|
||||
if (hargs[key] === undefined) {
|
||||
window.location.hash += ';'+key+'='+val;
|
||||
return;
|
||||
}
|
||||
var hash = window.location.hash;
|
||||
hash = hash.replace(new RegExp(key+'=[^;]+'),`${key}=${val}`);
|
||||
window.location.hash = hash;
|
||||
}
|
||||
|
||||
function get_hash_arguments() {
|
||||
var args = window.location.hash.substring(1).trim().split('/');
|
||||
if (args.length > 0 && args[0].trim() === '')
|
||||
|
|
|
@ -70,6 +70,8 @@ window.view.instance = {
|
|||
case 'settings':
|
||||
return window.view.instance.show_config();
|
||||
default:
|
||||
set_hash_argument('content', content);
|
||||
E.element('#window-instance #container').innerHTML = '';
|
||||
return window.view.instance
|
||||
.load[content.replaceAll('-','_')]();
|
||||
}
|
||||
|
@ -123,6 +125,8 @@ function load__instance(args) {
|
|||
}
|
||||
return html;
|
||||
});
|
||||
if (hargs['content'] !== undefined)
|
||||
window.view.instance.load_content(hargs['content']);
|
||||
};
|
||||
|
||||
const _main = function() {
|
||||
|
|
Loading…
Reference in New Issue