test: 🚧 Trying to tidy json

This commit is contained in:
Arek 2022-06-08 00:53:28 +02:00
parent 23c338fae6
commit 81b3b19fd1
2 changed files with 105 additions and 0 deletions

View File

@ -0,0 +1,88 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="styles.css">
<title>Document</title>
</head>
<body>
<div class="container">
<div class="nav">
</div>
<div class="tournament-name">
</div>
<div class="tournament-info" id="tournaments">
</div>
</div>
<script>
// function lodaDoc() {
// var xhttp = new XMLHttpRequest();
// xhttp.onreadystatechange = function () {
// if (this.readyState == 4 && this.status == 200) {
// document.getElementById("demo").innerHTML = this.responseText;
// }
// };
// xhttp.open("GET", "https://dragonmaster.pl/inz/tournaments");
// xhttp.send();
// }
// let response = fetch(URL);
const ul = document.getElementById('tournaments');
const list = document.createDocumentFragment();
const url = 'https://dragonmaster.pl/inz/tournaments'
let tablica;
fetch(url).then(function (response) {
return response.json();
}).then(function (obj) {
let id;
let count;
tablica = obj
console.log(obj);
for (id in tablica) {
console.log(tablica.name);
++count;
}
}).catch(function (error) {
console.error('Something went wrong!')
console.error(error);
});
// fetch(url)
// .then(response => response.json())
// .then((data) => {
// let tournaments = data;
// tournaments.map(function (tournament) {
// let li = document.createElement('li');
// let name = document.createElement('h2');
// let email = document.createElement('span');
// name.innerHTML = '${tournament.name}';
// id.innerHTML = '${tournament.id}';
// li.appendChild(name);
// li.appendChild(id);
// });
// })
// .catch(function (error) {
// console.log(error);
// });
// ul.appendChild(list);
// console.log(fetch('https://dragonmaster.pl/inz/tournaments'))
</script>
</body>
</html>

View File

@ -0,0 +1,17 @@
body {
margin: 0;
}
.nav {
height: 50px;
}
.tournament-name {
height: 150px;
background-color: #0B4D39;
}
.tournament-info {
height: auto;
background-color: lightblue;
}