Advertisement
Guest User

Untitled

a guest
Mar 29th, 2020
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.04 KB | None | 0 0
  1.  
  2. <!DOCTYPE html>
  3. <html lang="en">
  4.  
  5. <head>
  6. <meta charset="utf-8" />
  7. <meta name="viewport" content="width=device-width, initial-scale=1">
  8. <meta http-equiv="X-UA-Compatible" content="ie=edge">
  9. <style>
  10.  
  11. /* vedere w3schools per lo stile responsive */
  12.  
  13. #journalentryform {
  14. display: none;
  15. }
  16.  
  17. #apikeyform {
  18. display: none;
  19. }
  20.  
  21. #choosefirmform {
  22. display: none;
  23. }
  24.  
  25.  
  26. </style>
  27.  
  28. <title>Esercizio Categories</title>
  29.  
  30. <script>
  31.  
  32. var url = "http://erzickyinfo.altervista.org/photolibrary/index.php?action=list";
  33. var accountsEl;
  34. const http = new XMLHttpRequest();
  35. var categories;
  36. var template;
  37. async function fetchCategories() {
  38.  
  39. // let response= UrlFetchApp.fetch(url);
  40. // let content = response.getContentText();
  41. //Logger.log(content);
  42. // SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Foglio1").getRange(3,4).setValue("hello");
  43. //let items = JSON.parse(content);
  44. //let row = 2;
  45. /*items.forEach(function(item) {
  46.  
  47. cs.getRange(row,1).setValue(item.id);
  48. cs.getRange(row,2).setValue(item.Description);
  49. cs.getRange(row,3).setValue(item.Rank);
  50. row++;*/
  51. accountsEl.innerHTML = "Fetching...";
  52. http.open("GET", url);
  53. http.send();
  54. http.onload = function() {
  55. if(http.status != 200)
  56. {
  57. stateEl.innerHTML = "errore";
  58. }
  59. accountsEl.innerHTML = "Fetching complete";
  60. categories = JSON.parse(http.responseText);
  61. // console.log(categories);
  62. categories.forEach(function(category){
  63. var categoryTemplate = template.cloneNode(true).content;
  64. categoryTemplate.querySelector('.id').innerText = category.id;
  65. categoryTemplate.querySelector('.description').innerText = category.Description;
  66. categoryTemplate.querySelector('.rank').innerText = category.Rank;
  67. accountsEl.appendChild(categoryTemplate);
  68. });
  69. }
  70.  
  71.  
  72.  
  73.  
  74.  
  75. }
  76.  
  77. function setup() {
  78. accountsEl=document.getElementById("accounts");
  79. template = document.getElementById("categories_t");
  80.  
  81.  
  82. }
  83.  
  84.  
  85. </script>
  86.  
  87. </head>
  88.  
  89. <body onload="setup()">
  90.  
  91. <div class="container">
  92.  
  93. <h1>Rest</h1>
  94. <div class="">
  95. <button id="FetchButton" onclick="fetchCategories()" />Fetch</button>
  96. <div id="accounts">
  97. </div>
  98.  
  99. <template id = "categories_t">
  100. <p><tt class="id">{{Id}}</tt> ..... <em class="description">{{Description}}</em>: <em class="rank">{{Rank}}</em></p>
  101. </template>
  102.  
  103. </div>
  104.  
  105. </body>
  106.  
  107. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement