init.js 1008 B

12345678910111213141516171819202122232425262728293031
  1. let request = new XMLHttpRequest();
  2. request.open('GET', 'https://restcountries.eu/rest/v2/lang/es', true);
  3. request.onload = function () {
  4. const array = JSON.parse(this.response);
  5. let countryModalLoop = document.querySelector('.country-modal');
  6. let countryLoop = document.querySelector('.country-container');
  7. let item = 0;
  8. array.forEach(function(obj){
  9. /* populate array in home */
  10. countryLoop.insertAdjacentHTML('beforeend',
  11. countryItem(obj,
  12. item));
  13. /* modal */
  14. countryModalLoop.insertAdjacentHTML('beforeend',
  15. countryModal(obj,
  16. basicsTable(obj),
  17. translationTable(obj.translations),
  18. item));
  19. /* set click gestures */
  20. clickGestures(item);
  21. item++;
  22. });
  23. };
  24. request.send();