diff options
Diffstat (limited to 'fixco_custom/static/src')
| -rw-r--r-- | fixco_custom/static/src/js/check_product_barcode.js | 76 |
1 files changed, 0 insertions, 76 deletions
diff --git a/fixco_custom/static/src/js/check_product_barcode.js b/fixco_custom/static/src/js/check_product_barcode.js deleted file mode 100644 index 38a9a59..0000000 --- a/fixco_custom/static/src/js/check_product_barcode.js +++ /dev/null @@ -1,76 +0,0 @@ -odoo.define('indoteknik_custom.buffered_scanner', function (require) { - 'use strict'; - console.log('✅ Mqdd_Custom JS Loaded'); - - var GAP_MS = 120; - var MIN_LEN = 3; - var COMMIT_TIMEOUT = 180; - - var buffer = ''; - var last = 0; - var timer = null; - - function reset() { - buffer = ''; - last = 0; - if (timer) { clearTimeout(timer); timer = null; } - } - - function isCodeProduct(el) { - return el && el instanceof HTMLInputElement && (el.name === 'code_product' || el.name === 'quantity'); - } - - function commit() { - var el = document.activeElement; - if (!isCodeProduct(el)) { reset(); return; } - if (buffer.length >= MIN_LEN) { - el.value = buffer; - el.dispatchEvent(new Event('input', { bubbles: true })); - el.dispatchEvent(new Event('change', { bubbles: true })); - } - reset(); - } - - document.addEventListener('keydown', function (e) { - var el = document.activeElement; - if (!isCodeProduct(el)) return; - - var key = e.key; - - // ENTER mengakhiri scan - if (key === 'Enter') { - e.preventDefault(); - commit(); - return; - } - - // abaikan tombol kontrol (Shift, Tab, Arrow, Backspace, dll.) - if (key.length !== 1) return; - - var now = performance.now(); - var gap = now - (last || now); - last = now; - - if (!buffer || gap <= GAP_MS) { - // bagian dari "scan cepat" → tangani sendiri (hindari karakter hilang) - e.preventDefault(); - buffer += key; - - if (timer) clearTimeout(timer); - timer = setTimeout(function () { - // auto-commit jika scanner tidak mengirim Enter - commit(); - }, COMMIT_TIMEOUT); - } else { - // jeda besar → kemungkinan manual. Kalau mau benar-benar melarang, - // buka komentar 2 baris di bawah. - // e.preventDefault(); - // e.stopPropagation(); - reset(); // keluar dari mode buffer agar manual normal - } - }, true); - - document.addEventListener('focusin', function (e) { - if (isCodeProduct(e.target)) reset(); - }, true); -});
\ No newline at end of file |
