Repositorio del curso CCOM4030 el semestre B91 del proyecto Artesanías con el Instituto de Cultura

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. var storage = window.localStorage;
  2. function loadFile(filePath) {
  3. var result = null;
  4. var xmlhttp = new XMLHttpRequest();
  5. xmlhttp.open("GET", filePath, false);
  6. xmlhttp.send();
  7. if (xmlhttp.status==200) {
  8. result = xmlhttp.responseText;
  9. }
  10. return result;
  11. }
  12. function checkDate() {
  13. var date = loadFile("https://136.145.181.12/date.txt");
  14. if (window.localStorage.getItem("DATE") == null || window.localStorage.getItem("DATE") != date) {
  15. window.localStorage.setItem("DATE", date);
  16. return false;
  17. }
  18. else {
  19. return true;
  20. }
  21. }
  22. try {
  23. if (checkDate() == false) {
  24. window.localStorage.setItem("RENGLONES", loadFile("https://136.145.181.12/renglones.json"));
  25. window.localStorage.setItem("TODOS", loadFile("https://136.145.181.12/artesanias.json"))
  26. var renglones = JSON.parse(window.localStorage.getItem("RENGLONES"));
  27. for (var i = 0; i < renglones.length; i++) {
  28. window.localStorage.setItem(renglones[i].Renglones, loadFile("https://136.145.181.12/" + renglones[i].Renglones + ".json"));
  29. }
  30. }
  31. } catch {
  32. console.log("error");
  33. }