/* * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ $("#savebtn").click(function () { localStorage.setItem("linewidth", $("#linewidthinput").val()); localStorage.setItem("devtype", $("#devtypeinput").val()); localStorage.setItem("device", $("#deviceinput").val()); loadSettings(); }); $("#testprintbtn").click(function () { $.ajax("http://127.0.0.1:64269/print", { data: JSON.stringify({ header: [ { text: "NickelBridge".padEnd(linewidth), format: ["bold"] }, { text: "Test Print".padEnd(linewidth), format: ["bold"] } ], lines: [ { text: "If you can see this, your printer", format: ["plain"] }, { text: "is configured properly.", format: ["plain"] }, { text: "-----", format: ["hr"] }, { text: "Line Width: " + linewidth, format: ["plain"] }, { text: "Device: " + device, format: ["plain"] }, { text: "Type: " + devtype, format: ["plain"] }, { text: "-----", format: ["hr"] }, { text: "12345678901234567890123456789012345678901234567890123456789012345678901234567890", format: ["plain"] } ], footer: [ { text: "End Test Print".padEnd(linewidth), format: ["bold"] } ] }), contentType: 'application/json', type: 'POST', success: function (resp) { console.log(resp); alert("Test print sent."); } }).fail(function (resp) { console.log(resp); alert("Error: " + JSON.stringify(resp)); }); }); $("#opendrawerbtn").click(function () { $.post("http://127.0.0.1:64269/opendrawer", {}, function (resp) { console.log(resp); alert("Cash drawer open command sent."); }).fail(function (resp) { console.log(resp); }); }); $(document).ready(function () { $("#deviceinput").val(device); $("#linewidthinput").val(linewidth); $("#devtypeinput").val(devtype); });