Define BarcodeScanner Hook

This commit is contained in:
Claudio Ortolina
2025-02-13 14:45:56 +00:00
parent 39de4149fa
commit db5fec1a3b
2 changed files with 12 additions and 4 deletions
+6 -2
View File
@@ -21,12 +21,16 @@ import "phoenix_html"
import { Socket } from "phoenix"
import { LiveSocket } from "phoenix_live_view"
import topbar from "../vendor/topbar"
import "./barcode-scanner"
import BarcodeScannerHook from "./barcode-scanner"
let Hooks = {}
Hooks.BarcodeScanner = BarcodeScannerHook;
let csrfToken = document.querySelector("meta[name='csrf-token']").getAttribute("content")
let liveSocket = new LiveSocket("/live", Socket, {
longPollFallbackMs: 2500,
params: { _csrf_token: csrfToken }
params: { _csrf_token: csrfToken },
hooks: { Hooks }
})
// Show progress bar on live navigation and form submits
+6 -2
View File
@@ -1,6 +1,6 @@
import { BarcodeDetector } from "barcode-detector/ponyfill";
const run = async function () {
const barcodeTest = async function () {
// check supported formats
const supportedFormats = await BarcodeDetector.getSupportedFormats();
console.log(supportedFormats);
@@ -17,4 +17,8 @@ const run = async function () {
barcodeDetector.detect(imageFile).then(console.log);
}
run();
export default {
mounted() {
console.log(this.el);
}
}