rickyc81

Untitled

Nov 5th, 2020
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.  
  3. 7.000 ( S14 -> 1-64 flags | S14 -> 1-25 flags )
  4. 7.020 ( S14 -> 1-64 flags | S14 -> 1-25 flags )
  5. 7.030 ( S14 -> 1-65 flags | S14 -> 1-25 flags )
  6. 10.02 ( S14 -> 1-67 flags | S14 -> 1-26 flags )
  7.  
  8. */
  9. const fs  = require('fs');
  10. const { get } = require('jquery');
  11.  
  12. const btn_get = document.getElementById('btn-get-backup')
  13.  
  14. btn_get.addEventListener('click', (e) => {
  15.   getAllData();
  16.  
  17. })
  18.  
  19. const STORED_DATA = {
  20.   eft_pos_config : "",
  21.   flags : "",
  22.   config : "",
  23. };
  24.  
  25. getEftPos = () => {
  26.   return new Promise((resolve, reject) => {
  27.  
  28.       const protocol = "https:"
  29.       const ipAddress = "192.168.0.160";
  30.       const xmlHTTPRequestURLMain = `${protocol}${ipAddress}/cgi-bin/fpmate.cgi`;
  31.       const dataCommand = `<printerCommand> <directIO command="4231" data="" /> </printerCommand>`;
  32.      
  33.       const epos = new epson.fiscalPrint();
  34.  
  35.       epos.onreceive = (result, tag_names_array, add_info, res_add) => {
  36.           if (result.success == true) {
  37.               //console.log(add_info.responseData)
  38.              
  39.               resolve(add_info.responseData)
  40.           }
  41.       };
  42.       epos.onerror = (result) => {
  43.           if (!result.success) {
  44.             //console.log(result)
  45.               reject(result)
  46.           }
  47.       };
  48.       epos.send(xmlHTTPRequestURLMain, dataCommand, 200000, false);
  49.   })
  50. }
  51.  
  52.  
  53. /* ------------------------------------------------------------------------------------ */
  54.  
  55. runFetchData2 = () => {
  56.   return new Promise ((resolve, reject) => {
  57.     setTimeout(() => {
  58.       resolve("...!!...")
  59.     }, 3000);
  60.    
  61.   })
  62. }
  63.  
  64. /* ------------------------------------------------------------------------------------ */
  65.  
  66.  
  67.  
  68. /* H1=4; H2=214 – GET FLAGS */
  69.  
  70. async function getFlags() {
  71.   let data = []
  72.  
  73.   for (i = 1; i < 70; i++) {
  74.     if ((i + "").length < 2) {
  75.         index = "0" + i
  76.     } else {
  77.         index = i.toString()
  78.     }
  79.    await getFlagsPromise(index);
  80.   }
  81.  
  82.   function getFlagsPromise (id) {
  83.  
  84.     return new Promise((resolve, reject) => {
  85.  
  86.       const protocol = "https:"
  87.       const ipAddress = "192.168.0.160";
  88.       const xmlHTTPRequestURLMain = `${protocol}${ipAddress}/cgi-bin/fpmate.cgi`;
  89.       const dataCommand = `<printerCommand> <directIO command="4214" data="${id}" /> </printerCommand>`;
  90.       const epos = new epson.fiscalPrint();
  91.  
  92.       epos.onreceive = (result, tag_names_array, add_info, res_add) => {
  93.           if (result.success) {
  94.               data.push(add_info.responseData)
  95.               console.log(`FLAGS --> ${index} --> ${add_info.responseData}`)
  96.               resolve(data)
  97.           }
  98.       };
  99.       epos.onerror = (result) => {
  100.           if (!result.success) {
  101.             console.log(result)
  102.               reject(result)
  103.           }
  104.       };
  105.       epos.send(xmlHTTPRequestURLMain, dataCommand, 200000, false);
  106.     });
  107.   }
  108. }
  109.  
  110. async function getConfig() {
  111.   let data = []
  112.  
  113.   for (i = 1; i < 70; i++) {
  114.     if ((i + "").length < 2) {
  115.       index = "0" + i
  116.     } else {
  117.       index = i.toString()
  118.     }
  119.    await getConfigPromise(index)
  120.   }
  121.  
  122.   function getConfigPromise (id) {
  123.  
  124.     return new Promise((resolve, reject) => {
  125.  
  126.       const protocol = "https:"
  127.       const ipAddress = "192.168.0.160";
  128.       const xmlHTTPRequestURLMain = `${protocol}${ipAddress}/cgi-bin/fpmate.cgi`;
  129.       const dataCommand = `<printerCommand> <directIO command="4215" data="${id}" /> </printerCommand>`;
  130.       const epos = new epson.fiscalPrint();
  131.  
  132.       epos.onreceive = (result, tag_names_array, add_info, res_add) => {
  133.           if (result.success) {
  134.               data.push(add_info.responseData)
  135.               console.log(`CONFIG --> ${index} --> ${add_info.responseData}`)
  136.               resolve(data)
  137.           }
  138.       };
  139.       epos.onerror = (result) => {
  140.           if (!result.success) {
  141.             console.log(result)
  142.               reject(result)
  143.           }
  144.       };
  145.       epos.send(xmlHTTPRequestURLMain, dataCommand, 200000, false);
  146.     });
  147.   }
  148. }
  149.  
  150. async function getKeyboard() {
  151.   let data = []
  152.   for (i = 1; i < 256; i++) {
  153.   if ((i + "").length < 2) {
  154.       index = "00" + i
  155.   } else if ((i + "").length < 3) {
  156.       index = "0" + i
  157.   } else {
  158.       index = i.toString()
  159.   }
  160.    await getKeyboardPromise(index)
  161.   }
  162.  
  163.   function getKeyboardPromise (id) {
  164.  
  165.     return new Promise((resolve, reject) => {
  166.  
  167.       const protocol = "https:"
  168.       const ipAddress = "192.168.0.160";
  169.       const xmlHTTPRequestURLMain = `${protocol}${ipAddress}/cgi-bin/fpmate.cgi`;
  170.       const dataCommand = `<printerCommand> <directIO command="4229" data="${id}" /> </printerCommand>`;
  171.       const epos = new epson.fiscalPrint();
  172.  
  173.       epos.onreceive = (result, tag_names_array, add_info, res_add) => {
  174.           if (result.success) {
  175.               data.push(add_info.responseData)
  176.               console.log(`CONFIG --> ${index} --> ${add_info.responseData}`)
  177.               resolve(data)
  178.           }
  179.       };
  180.       epos.onerror = (result) => {
  181.           if (!result.success) {
  182.             console.log(result)
  183.               reject(result)
  184.           }
  185.       };
  186.       epos.send(xmlHTTPRequestURLMain, dataCommand, 200000, false);
  187.     });
  188.   }
  189. }
Add Comment
Please, Sign In to add comment