mirror of
https://github.com/cryptpad/cryptpad.git
synced 2026-09-14 11:05:41 +05:00
refactor two mostly-identical functions
This commit is contained in:
parent
59eaf8187c
commit
c4e1b5f7d4
@ -148,20 +148,19 @@ define([
|
||||
send();
|
||||
};
|
||||
|
||||
common.setTabHref = function (href) {
|
||||
var ohc = window.onhashchange;
|
||||
window.onhashchange = function () {};
|
||||
window.location.href = href;
|
||||
window.onhashchange = ohc;
|
||||
ohc({reset: true});
|
||||
};
|
||||
common.setTabHash = function (hash) {
|
||||
var ohc = window.onhashchange;
|
||||
window.onhashchange = function () {};
|
||||
window.location.hash = hash;
|
||||
window.onhashchange = ohc;
|
||||
ohc({reset: true});
|
||||
};
|
||||
(function () {
|
||||
var bypassHashChange = function (key) {
|
||||
return function (value) {
|
||||
var ohc = window.onhashchange;
|
||||
window.onhashchange = function () {};
|
||||
window.location[key] = value;
|
||||
window.onhashchange = ohc;
|
||||
ohc({reset: true});
|
||||
};
|
||||
};
|
||||
common.setTabHref = bypassHashChange('href');
|
||||
common.setTabHash = bypassHashChange('hash');
|
||||
}());
|
||||
|
||||
// RESTRICTED
|
||||
// Settings only
|
||||
|
||||
Loading…
Reference in New Issue
Block a user