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

azar.js 1.3KB

12345678910111213141516171819202122
  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()*32);
  9. //var azar = document.getElementById("azar");
  10. //var img = ons.createElement(`<img src="img/${aleatorio}.png">`);
  11. document.getElementById("image").innerHTML = `<img src="img/${aleatorio}.jpg" width="100%" height="300">`;
  12. //document.getElementById("Title").innerHTML = data[aleatorio].Renglones;
  13. document.getElementById("Content").innerHTML = data[aleatorio].Renglones + "<br>" + data[aleatorio].Artesano + "<br>" + data[aleatorio].Municipio;
  14. //azar.appendChild(img);
  15. });
  16. }
  17. request.send()