set-footer.js 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. export default function setFooterData() {
  2. const dataPath = "data"
  3. const contractFooterFile = dataPath + "/more-data/php-partials/contract_footer.phpsrc"
  4. const contractCssFile = dataPath + "/style.min.css"
  5. const uiUnsigned = dataPath + "/more-data/html-partials/ui-unsigned.html.xml"
  6. const contractScriptUnsignedFile = dataPath + "/more-data/scripts/contract_script_unsigned.js"
  7. const uiSigned = dataPath + "/more-data/html-partials/ui-signed.html.xml"
  8. const contractScriptSignedFile = dataPath + "/more-data/scripts/contract_script_signed.js"
  9. const qrCodeScriptFile = dataPath + "/more-data/scripts/qr-code.js" // qrCode
  10. if (localStorage.getItem("contract_footer") === null) {
  11. fetch(contractFooterFile).then((response) => response.text()).then((data) => {
  12. localStorage.setItem("contract_footer", data)
  13. })
  14. }
  15. if (!localStorage.getItem("contract_css")) {
  16. fetch(contractCssFile).then((response) => response.text()).then((data) => {
  17. data = addSlashes(data)
  18. localStorage.setItem("contract_css", data)
  19. })
  20. }
  21. fetch(uiUnsigned).then((response) => response.text()).then((data) => {
  22. localStorage.setItem("ui_unsigned", data)
  23. })
  24. fetch(uiSigned).then((response) => response.text()).then((data) => {
  25. localStorage.setItem("ui_signed", data)
  26. })
  27. fetch(contractScriptUnsignedFile).then((response) => response.text()).then((data) => {
  28. localStorage.setItem("contract_script_unsigned", data)
  29. })
  30. fetch(contractScriptSignedFile).then((response) => response.text()).then((data) => {
  31. localStorage.setItem("contract_script_signed", data)
  32. })
  33. fetch(qrCodeScriptFile).then((response) => response.text()).then((data) => {
  34. localStorage.setItem("qr_code_script", data)
  35. })
  36. }
  37. const addSlashes = (str) => {
  38. return str
  39. .replace(/'/g, "\\'")
  40. }