Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
Ilta Riikonen committed Dec 8, 2024
1 parent 1e773a8 commit 18b6a9f
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 6 deletions.
2 changes: 1 addition & 1 deletion 3b/junat.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</a>
</div>

<div id="sisalto"></div>
<div id="vastaus"></div>

<script>
function myFunction() {
Expand Down
2 changes: 1 addition & 1 deletion 3b/liikennekamera.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</a>
</div>

<div id="sisalto"></div>
<div id="vastaus"></div>

<script>
function myFunction() {
Expand Down
2 changes: 1 addition & 1 deletion 3b/saa.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</a>
</div>

<div id="sisalto"></div>
<div id="vastaus"></div>

<script>
function myFunction() {
Expand Down
4 changes: 2 additions & 2 deletions 3b/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ body {
display: none;
}

#sisalto {
padding: 1% 3%;
#vastaus {
padding: 1% 7% 1% 3%;
}

@media screen and (max-width: 600px) {
Expand Down
3 changes: 2 additions & 1 deletion 3b/tapahtumat.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<link rel="stylesheet" href="style.css">
<script src="tapahtumat.js"></script>
<title>Tapahtumat</title>
</head>
<body>
Expand All @@ -18,7 +19,7 @@
</a>
</div>

<div id="sisalto"></div>
<div id="vastaus"></div>

<script>
function myFunction() {
Expand Down
26 changes: 26 additions & 0 deletions 3b/tapahtumat.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
fetch("https://api.visittampere.com/api/v1/visittampere/event/all/")
.then(function(response) {
return response.json();
})
.then(function(responseJson) {
kerro(responseJson);
})
.catch(function(error) {
document.getElementById("vastaus").innerHTML =
"<p>Tietoa ei pystytä hakemaan</p>";
});

function kerro(data) {
let teksti = "<h1>Tampereella tapahtuu</h1>";
data.forEach(t => {
let tiedot = t.pirkanmaaevents_event;
let linkki = tiedot.provider_link;

teksti += "<h3>" + tiedot.name[1].text +"</h3>";
teksti += "<p>" + tiedot.description[1].text +"</p>";
if (linkki != "") {
teksti += "<p><a href=" + linkki + ">" + linkki + "</a></p>";
}
});
document.getElementById("vastaus").innerHTML = teksti;
}

0 comments on commit 18b6a9f

Please sign in to comment.