timezone handling now moved to a separate script that does not leak any symbols.
This commit is contained in:
parent
00a9a91788
commit
3bbebd0dda
@ -25,8 +25,6 @@ templ BasePage(tab int) {
|
||||
<script src="../static/js/htmx.1.9.12.js"></script>
|
||||
<script src="../static/js/htmx.ws.1.9.12.js"></script>
|
||||
<script type="module" src="../static/js/modules.js"></script>
|
||||
<script src="../static/js/persistentforms.js"></script>
|
||||
|
||||
|
||||
<title>Converge</title>
|
||||
</head>
|
||||
@ -46,32 +44,7 @@ templ BasePage(tab int) {
|
||||
<!-- script>
|
||||
htmx.logAll();
|
||||
</script -->
|
||||
<script>
|
||||
function getTimezone() {
|
||||
return Intl.DateTimeFormat().resolvedOptions().timeZone;
|
||||
}
|
||||
if (!window.originalWebSocket) {
|
||||
window.originalWebSocket = htmx.createWebSocket
|
||||
htmx.createWebSocket = function(url) {
|
||||
url = new URL(url, window.location.href).href
|
||||
url = url.replace(/^http/, 'ws');
|
||||
let modifiedUrl = url + "?timezone=" + getTimezone()
|
||||
return window.originalWebSocket(modifiedUrl)
|
||||
}
|
||||
}
|
||||
|
||||
document.body.addEventListener(
|
||||
"htmx:configRequest",
|
||||
function(evt) {
|
||||
//console.log("Adding timezone to htmx request headers and making URL absolute");
|
||||
evt.detail.headers["X-Timezone"] = getTimezone();
|
||||
}
|
||||
);
|
||||
</script>
|
||||
|
||||
|
||||
<script src="../static/js/bootstrap.bundle.min.js"
|
||||
crossorigin="anonymous"></script>
|
||||
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
@ -106,6 +79,11 @@ templ BasePage(tab int) {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<script src="../static/js/bootstrap.bundle.min.js"></script>
|
||||
<script src="../static/js/persistentforms.js"></script>
|
||||
<script src="../static/js/timezonehandling.js"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
}
|
22
static/js/timezonehandling.js
Normal file
22
static/js/timezonehandling.js
Normal file
@ -0,0 +1,22 @@
|
||||
|
||||
(() => {
|
||||
function getTimezone() {
|
||||
return Intl.DateTimeFormat().resolvedOptions().timeZone;
|
||||
}
|
||||
if (!window.originalWebSocket) {
|
||||
window.originalWebSocket = htmx.createWebSocket
|
||||
htmx.createWebSocket = function(url) {
|
||||
url = new URL(url, window.location.href).href
|
||||
url = url.replace(/^http/, 'ws');
|
||||
let modifiedUrl = url + "?timezone=" + getTimezone()
|
||||
return window.originalWebSocket(modifiedUrl)
|
||||
}
|
||||
}
|
||||
document.body.addEventListener(
|
||||
"htmx:configRequest",
|
||||
function(evt) {
|
||||
//console.log("Adding timezone to htmx request headers and making URL absolute");
|
||||
evt.detail.headers["X-Timezone"] = getTimezone();
|
||||
}
|
||||
);
|
||||
})()
|
Loading…
Reference in New Issue
Block a user