29 lines
1.1 KiB
JavaScript
29 lines
1.1 KiB
JavaScript
import { Socket } from "../common/phx.js";
|
|
import { LiveSocket } from "../common/lv.js";
|
|
import "../common/vendor/topbar.js";
|
|
import { emojiPickerHook } from "./emoji-picker.js";
|
|
import { screenshotDownloadHook } from "./screenshot.js";
|
|
|
|
let csrfToken = document.querySelector("meta[name='csrf-token']").getAttribute("content");
|
|
|
|
const hooks = {
|
|
EmojiPicker: emojiPickerHook,
|
|
ScreenshotDownload: screenshotDownloadHook,
|
|
}
|
|
|
|
let liveSocket = new LiveSocket("/live", Socket, { hooks, params: { _csrf_token: csrfToken } });
|
|
|
|
// Show progress bar on live navigation and form submits
|
|
topbar.config({ barColors: { 0: "#29d" }, shadowColor: "rgba(0, 0, 0, .3)" });
|
|
window.addEventListener("phx:page-loading-start", info => topbar.show());
|
|
window.addEventListener("phx:page-loading-stop", info => topbar.hide());
|
|
|
|
// connect if there are any LiveViews on the page
|
|
liveSocket.connect();
|
|
|
|
// expose liveSocket on window for web console debug logs and latency simulation:
|
|
// >> liveSocket.enableDebug()
|
|
// >> liveSocket.enableLatencySim(1000) // enabled for duration of browser session
|
|
// >> liveSocket.disableLatencySim()
|
|
window.liveSocket = liveSocket;
|
|
|