Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- 7.000 ( S14 -> 1-64 flags | S14 -> 1-25 flags )
- 7.020 ( S14 -> 1-64 flags | S14 -> 1-25 flags )
- 7.030 ( S14 -> 1-65 flags | S14 -> 1-25 flags )
- 10.02 ( S14 -> 1-67 flags | S14 -> 1-26 flags )
- */
- const fs = require('fs');
- const { get } = require('jquery');
- const btn_get = document.getElementById('btn-get-backup')
- btn_get.addEventListener('click', (e) => {
- getAllData();
- })
- const STORED_DATA = {
- eft_pos_config : "",
- flags : "",
- config : "",
- };
- getEftPos = () => {
- return 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="4231" data="" /> </printerCommand>`;
- const epos = new epson.fiscalPrint();
- epos.onreceive = (result, tag_names_array, add_info, res_add) => {
- if (result.success == true) {
- //console.log(add_info.responseData)
- resolve(add_info.responseData)
- }
- };
- epos.onerror = (result) => {
- if (!result.success) {
- //console.log(result)
- reject(result)
- }
- };
- epos.send(xmlHTTPRequestURLMain, dataCommand, 200000, false);
- })
- }
- /* ------------------------------------------------------------------------------------ */
- runFetchData2 = () => {
- return new Promise ((resolve, reject) => {
- setTimeout(() => {
- resolve("...!!...")
- }, 3000);
- })
- }
- /* ------------------------------------------------------------------------------------ */
- /* H1=4; H2=214 – GET FLAGS */
- async function getFlags() {
- let data = []
- for (i = 1; i < 70; i++) {
- if ((i + "").length < 2) {
- index = "0" + i
- } else {
- index = i.toString()
- }
- await getFlagsPromise(index);
- }
- function getFlagsPromise (id) {
- return 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="4214" data="${id}" /> </printerCommand>`;
- const epos = new epson.fiscalPrint();
- epos.onreceive = (result, tag_names_array, add_info, res_add) => {
- if (result.success) {
- data.push(add_info.responseData)
- console.log(`FLAGS --> ${index} --> ${add_info.responseData}`)
- resolve(data)
- }
- };
- epos.onerror = (result) => {
- if (!result.success) {
- console.log(result)
- reject(result)
- }
- };
- epos.send(xmlHTTPRequestURLMain, dataCommand, 200000, false);
- });
- }
- }
- async function getConfig() {
- let data = []
- for (i = 1; i < 70; i++) {
- if ((i + "").length < 2) {
- index = "0" + i
- } else {
- index = i.toString()
- }
- await getConfigPromise(index)
- }
- function getConfigPromise (id) {
- return 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="4215" data="${id}" /> </printerCommand>`;
- const epos = new epson.fiscalPrint();
- epos.onreceive = (result, tag_names_array, add_info, res_add) => {
- if (result.success) {
- data.push(add_info.responseData)
- console.log(`CONFIG --> ${index} --> ${add_info.responseData}`)
- resolve(data)
- }
- };
- epos.onerror = (result) => {
- if (!result.success) {
- console.log(result)
- reject(result)
- }
- };
- epos.send(xmlHTTPRequestURLMain, dataCommand, 200000, false);
- });
- }
- }
- async function getKeyboard() {
- let data = []
- for (i = 1; i < 256; i++) {
- if ((i + "").length < 2) {
- index = "00" + i
- } else if ((i + "").length < 3) {
- index = "0" + i
- } else {
- index = i.toString()
- }
- await getKeyboardPromise(index)
- }
- function getKeyboardPromise (id) {
- return 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="${id}" /> </printerCommand>`;
- const epos = new epson.fiscalPrint();
- epos.onreceive = (result, tag_names_array, add_info, res_add) => {
- if (result.success) {
- data.push(add_info.responseData)
- console.log(`CONFIG --> ${index} --> ${add_info.responseData}`)
- resolve(data)
- }
- };
- epos.onerror = (result) => {
- if (!result.success) {
- console.log(result)
- reject(result)
- }
- };
- epos.send(xmlHTTPRequestURLMain, dataCommand, 200000, false);
- });
- }
- }
Add Comment
Please, Sign In to add comment