diff --git a/public/pos/epos-print.js b/public/pos/epos-print.js new file mode 100644 index 0000000..ce78a98 --- /dev/null +++ b/public/pos/epos-print.js @@ -0,0 +1,28 @@ +// Network (ePOS-Print) thermal printing for Epson TM-series Ethernet +// printers. Runs alongside the existing Web Bluetooth path in +// receipt.html — the till picks a transport in Printer settings. +// +// The printer's ePOS-Print endpoint is served over HTTPS with a +// self-signed cert and open CORS (`Access-Control-Allow-Origin: *`), +// confirmed by direct testing against the shop's TM-T20II. Each till +// device must visit `https://` once in its browser and +// accept the certificate warning before fetch() calls here succeed. +window.EposPrint = (function () { + 'use strict'; + + const SETTINGS_KEY = 'pos.printerSettings'; + + function getSettings() { + try { + return JSON.parse(localStorage.getItem(SETTINGS_KEY)) || { type: 'bluetooth', ip: '' }; + } catch (e) { + return { type: 'bluetooth', ip: '' }; + } + } + + function setSettings(settings) { + localStorage.setItem(SETTINGS_KEY, JSON.stringify(settings)); + } + + return { getSettings, setSettings }; +})();