Commit
•
7238311
1
Parent(s):
9d78425
chore: Format `app.js`
Browse files- assets/js/app.js +15 -12
assets/js/app.js
CHANGED
@@ -16,26 +16,29 @@
|
|
16 |
//
|
17 |
|
18 |
// Include phoenix_html to handle method=PUT/DELETE in forms and buttons.
|
19 |
-
import "phoenix_html"
|
20 |
// Establish Phoenix Socket and LiveView configuration.
|
21 |
-
import {Socket} from "phoenix"
|
22 |
-
import {LiveSocket} from "phoenix_live_view"
|
23 |
-
import topbar from "../vendor/topbar"
|
24 |
|
25 |
-
let csrfToken = document
|
26 |
-
|
|
|
|
|
|
|
|
|
27 |
|
28 |
// Show progress bar on live navigation and form submits
|
29 |
-
topbar.config({barColors: {0: "#29d"}, shadowColor: "rgba(0, 0, 0, .3)"})
|
30 |
-
window.addEventListener("phx:page-loading-start", _info => topbar.show(300))
|
31 |
-
window.addEventListener("phx:page-loading-stop", _info => topbar.hide())
|
32 |
|
33 |
// connect if there are any LiveViews on the page
|
34 |
-
liveSocket.connect()
|
35 |
|
36 |
// expose liveSocket on window for web console debug logs and latency simulation:
|
37 |
// >> liveSocket.enableDebug()
|
38 |
// >> liveSocket.enableLatencySim(1000) // enabled for duration of browser session
|
39 |
// >> liveSocket.disableLatencySim()
|
40 |
-
window.liveSocket = liveSocket
|
41 |
-
|
|
|
16 |
//
|
17 |
|
18 |
// Include phoenix_html to handle method=PUT/DELETE in forms and buttons.
|
19 |
+
import "phoenix_html";
|
20 |
// Establish Phoenix Socket and LiveView configuration.
|
21 |
+
import { Socket } from "phoenix";
|
22 |
+
import { LiveSocket } from "phoenix_live_view";
|
23 |
+
import topbar from "../vendor/topbar";
|
24 |
|
25 |
+
let csrfToken = document
|
26 |
+
.querySelector("meta[name='csrf-token']")
|
27 |
+
.getAttribute("content");
|
28 |
+
let liveSocket = new LiveSocket("/live", Socket, {
|
29 |
+
params: { _csrf_token: csrfToken },
|
30 |
+
});
|
31 |
|
32 |
// Show progress bar on live navigation and form submits
|
33 |
+
topbar.config({ barColors: { 0: "#29d" }, shadowColor: "rgba(0, 0, 0, .3)" });
|
34 |
+
window.addEventListener("phx:page-loading-start", (_info) => topbar.show(300));
|
35 |
+
window.addEventListener("phx:page-loading-stop", (_info) => topbar.hide());
|
36 |
|
37 |
// connect if there are any LiveViews on the page
|
38 |
+
liveSocket.connect();
|
39 |
|
40 |
// expose liveSocket on window for web console debug logs and latency simulation:
|
41 |
// >> liveSocket.enableDebug()
|
42 |
// >> liveSocket.enableLatencySim(1000) // enabled for duration of browser session
|
43 |
// >> liveSocket.disableLatencySim()
|
44 |
+
window.liveSocket = liveSocket;
|
|