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

12345678910111213141516171819202122232425262728
  1. // begin accessing JSON data here
  2. var data = JSON.parse(localStorage.getItem("AZAR"));
  3. // grabs the page with home id
  4. var page = document.getElementById("home");
  5. // assigns a random number to randomly determine which image and information to display in the home page.
  6. // Then it grabs the image container of the card, and inserts the random image. It also garbs the content container
  7. // and puts the corresponding title and description. This section activates on application startup.
  8. var aleatorio = Math.floor(Math.random()*52);
  9. document.getElementById("image").innerHTML = `<img src="img/${aleatorio}.jpg" width="100%" height="350px">`;
  10. document.getElementById("Content").innerHTML = "<br><h4>" + data[aleatorio].titulo + "</h4>" + data[aleatorio].texto;
  11. // This section activates every time you switch back to the home tab. It first empties the content on the card
  12. // and then it newly assigns a new random number to fetch a new random image and description to display on home.
  13. page.addEventListener("show", function(event){
  14. document.getElementById("image").innerHTML='';
  15. document.getElementById("Content").innerHTML='';
  16. var aleatorio = Math.floor(Math.random()*32);
  17. document.getElementById("image").innerHTML = `<img src="img/${aleatorio}.jpg" width="100%" height="350px">`;
  18. document.getElementById("Content").innerHTML = "<br><h4>" + data[aleatorio].titulo + "</h4>" + data[aleatorio].texto;
  19. });