Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- document.addEventListener("DOMContentLoaded", () => {
- let btn = document.getElementById('btn-start');
- function asynchronousProcess(index) {
- new Promise( (resolve, reject) => {
- const protocol = "https:"
- const ipAddress = "192.168.0.160";
- const xmlHTTPRequestURLMain = `${protocol}${ipAddress}/cgi-bin/fpmate.cgi`;
- const dataCommand = `<printerCommand> <directIO command="4229" data="${index}" /> </printerCommand>`;
- //const dataCommand = `<printerCommand> <directIO command="4229" data="255" /> </printerCommand>`;
- const epos = new epson.fiscalPrint();
- // 4 229 - SCAN CODE REF
- // 4 229 - SCAN CODE REF | FUNCTION
- epos.onreceive = (result, tag_names_array, add_info, res_add) => {
- if (result.success == true) {
- resolve(add_info.responseData)
- //console.log(add_info.responseData)
- //fs.appendFileSync('message.json', add_info.responseData);
- //console.log(`N${i}: add_info.responseData`)
- }
- };
- epos.send(xmlHTTPRequestURLMain, dataCommand, 99000);
- });
- }
- btn.addEventListener('click', async () => {
- console.log("click")
- const j = 255;
- for (let i = 0; i < j; i++) {
- if ((i + "").length < 2) {
- index = "00" + i
- } else if ((i + "").length < 3) {
- index = "0" + i
- } else {
- index = i.toString()
- }
- await asynchronousProcess(i)
- }
- });
- });
Add Comment
Please, Sign In to add comment