|
1 | | -import * as htmx from 'htmx.org'; |
2 | | -import {showErrorToast} from './modules/toast.js'; |
3 | | -import 'htmx.org/dist/ext/ws.js'; |
| 1 | +import * as htmx from "htmx.org"; |
| 2 | +import { showErrorToast } from "./modules/toast.js"; |
| 3 | +import "htmx.org/dist/ext/ws.js"; |
4 | 4 |
|
5 | 5 | // https://github.com/bigskysoftware/idiomorph#htmx |
6 | | -import 'idiomorph/dist/idiomorph-ext.js'; |
| 6 | +import "idiomorph/dist/idiomorph-ext.js"; |
7 | 7 |
|
8 | 8 | // https://htmx.org/reference/#config |
9 | | -htmx.config.requestClass = 'is-loading'; |
| 9 | +htmx.config.requestClass = "is-loading"; |
10 | 10 | htmx.config.scrollIntoViewOnBoost = false; |
11 | 11 |
|
12 | 12 | // https://htmx.org/events/#htmx:sendError |
13 | | -document.body.addEventListener('htmx:sendError', (event) => { |
| 13 | +document.body.addEventListener("htmx:sendError", (event) => { |
14 | 14 | // TODO: add translations |
15 | | - showErrorToast(`Network error when calling ${event.detail.requestConfig.path}`); |
| 15 | + showErrorToast( |
| 16 | + `Network error when calling ${event.detail.requestConfig.path}` |
| 17 | + ); |
16 | 18 | }); |
17 | 19 |
|
18 | 20 | // https://htmx.org/events/#htmx:responseError |
19 | | -document.body.addEventListener('htmx:responseError', (event) => { |
| 21 | +document.body.addEventListener("htmx:responseError", (event) => { |
20 | 22 | // TODO: add translations |
21 | | - showErrorToast(`Error ${event.detail.xhr.status} when calling ${event.detail.requestConfig.path}`); |
| 23 | + showErrorToast( |
| 24 | + `Error ${event.detail.xhr.status} when calling ${event.detail.requestConfig.path}` |
| 25 | + ); |
22 | 26 | }); |
23 | 27 |
|
24 | 28 | // eslint-disable-next-line no-import-assign |
25 | 29 | htmx.createWebSocket = (url) => { |
26 | 30 | // TODO: reuse websocket from shared webworker |
27 | 31 | const sock = new WebSocket(url, []); |
28 | 32 | sock.binaryType = htmx.config.wsBinaryType; |
| 33 | + g; |
29 | 34 | return sock; |
30 | 35 | }; |
31 | | -document.body.addEventListener('htmx:wsOpen', (evt) => { |
32 | | - const socket = evt.detail.socketWrapper; |
33 | | - socket.send(JSON.stringify({action: 'subscribe', data: {url: window.location.href}})); |
| 36 | +document.body.addEventListener("htmx:wsOpen", (e) => { |
| 37 | + const socket = e.detail.socketWrapper; |
| 38 | + socket.send( |
| 39 | + JSON.stringify({ action: "subscribe", data: { url: window.location.href } }) |
| 40 | + ); |
34 | 41 | }); |
0 commit comments