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

azar.js 1.7KB

1234567891011121314151617181920212223242526272829
  1. var request = new XMLHttpRequest()
  2. request.open('GET', 'json/azar.json', true)
  3. request.onload = function() {
  4. // begin accessing JSON data here
  5. var data = JSON.parse(this.response)
  6. /*var page = document.getElementById("home");
  7. page.addEventListener("show", function(event){
  8. var aleatorio = Math.floor(Math.random()*10);
  9. document.getElementById("Title").innerHTML = "Tab " + Math.floor(Math.random() * 10);
  10. document.getElementById("Content").innerHTML = "Number" + Math.floor(Math.random() * 10);
  11. });*/
  12. var page = document.getElementById("home");
  13. page.addEventListener("show", function(event){
  14. var aleatorio = Math.floor(Math.random()*11);
  15. //var azar = document.getElementById("azar");
  16. //var img = ons.createElement(`<img src="img/${aleatorio}.png">`);
  17. document.getElementById("image").innerHTML = `<img src="img/${aleatorio}.png" width="100%" height="300">`;
  18. document.getElementById("Title").innerHTML = data[aleatorio].Artesanias;
  19. document.getElementById("Content").innerHTML = data[aleatorio].Info;
  20. //azar.appendChild(img);
  21. });
  22. }
  23. request.send()