Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 117 additions & 0 deletions css/style.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
html,
body {
margin: 0;
padding: 0;
height: 100%;
background-color: white;
}
main {
display: flex;
align-items: center;
justify-content: center;
height: 100%;
flex-direction: column;
justify-content: space-between;
}
.meteo {
display: flex;
flex-direction: row;
margin-top: 10px;
text-align: start;
font-family: Verdana, Geneva, Tahoma, sans-serif;
font-size: small;
color: rgb(15, 0, 100);
align-items: center;
width: 95%;
}
.colizq{
display: flex;
flex-direction: column;
justify-content: center;
min-width: 200px;
background-image: url("../image/blob2.svg");
background-repeat: no-repeat;
background-position: bottom;
}
.colder{
display: flex;
flex-direction: column;
min-width: 200px;
background-image: url("../image/blob3.svg");
background-repeat: no-repeat;
}
.master{
display: flex;
flex-direction: row;
justify-content: space-around;
height: 80%;
}
.container {
display: flex;
flex-direction: column;
align-items: center;
padding: 20px;
margin-top: -50px;
min-width: 800px;
max-width: 1200px;
width: 100%;
height: 100%;
background-image: url("../image/blob.svg");
background-repeat: no-repeat;
background-size: 100%;
background-position: center;
justify-content: center;
}
.container div {
padding: 10px;
}
.title {
margin-top: 40px;
text-align: center;
font-family: Verdana, Geneva, Tahoma, sans-serif;
font-size: large;
font-weight: bold;
text-shadow: 2px 2px black;
color: rgb(255, 255, 255);
}
.joke {
/* margin-top: 10px; */
text-align: center;
font-family: Verdana, Geneva, Tahoma, sans-serif;
font-size: medium;
color: rgb(240, 240, 240);
max-width: 500px;
}
.rateButtons {
display: flex;
flex-direction: row;
margin-top: 20px;
justify-content: space-around;
width: 20%;
}
.rateButtons :hover {
cursor: pointer;
}
.nextButton {
background-color: #edc951;
color: black;
font-family: Verdana, Geneva, Tahoma, sans-serif;
font-weight: bold;
padding: 5px 20px;
border: solid;
border-color: black;
border-width: 3px;
border-radius: 25px;
text-transform: uppercase;
}
.nextButton:hover {
background-color: black;
color: #edc951;
border-color: #edc951;
}
.rateok{
text-align: center;
font-family: Verdana, Geneva, Tahoma, sans-serif;
font-size: small;
color: #edc951;
}
Binary file added image/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added image/11.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added image/12.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added image/13.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added image/14.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added image/15.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added image/16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added image/17.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added image/18.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added image/19.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added image/2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added image/20.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added image/21.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added image/22.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added image/23.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added image/3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added image/33.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added image/34.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added image/35.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added image/36.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added image/37.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added image/38.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added image/39.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added image/4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added image/40.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added image/41.png
Binary file added image/42.png
Binary file added image/43.png
Binary file added image/44.png
Binary file added image/5.png
Binary file added image/6.png
Binary file added image/7.png
Binary file added image/8.png
4 changes: 4 additions & 0 deletions image/blob.svg
4 changes: 4 additions & 0 deletions image/blob2.svg
4 changes: 4 additions & 0 deletions image/blob3.svg
42 changes: 42 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<!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">
<title>Sprint 5 - TypeScript & Api's</title>
<link href="https://afeld.github.io/emoji-css/emoji.css" rel="stylesheet">
<link rel="stylesheet" href="./css/style.css" />
</head>
<body onload="loadApiWeather()">
<main>
<div class="meteo">
<div class="icono" id="icono"></div>
<div class="temp" id="temp"></div>
</div>
<div class="master">
<div class="colizq"></div>
<div class="container">
<div class="title">
<p>'World's bad jokes. The very best.'</p>
</div>
<div class="joke">
<h4 id="writeJoke"></h4>
</div>
<div class="rateButtons">
<i class="em em-flushed" id="1" onclick="rate(1)"></i>
<i class="em em-grinning" id="2" onclick="rate(2)"></i>
<i class="em em-joy" id="3" onclick="rate(3)"></i>
</div>
<div class="rateok" id="rateok" style="visibility:hidden;"></div>
<div class="buttonNext">
<input type="button" class="nextButton" value="Next Joke" onclick="changeFunc()">
</div>
</div>
<div class="colder"></div>
</div>
<div></div>
</main>
<script src="./js/main.js"></script>
</body>
</html>
80 changes: 80 additions & 0 deletions js/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@

const CALLINGJOKES = "https://icanhazdadjoke.com/";
const CALLINGWEATHER = "http://dataservice.accuweather.com/forecasts/v1/daily/1day/307297?apikey=jDRJs43fxDcQlMD5etovQZTl7GXiJozS";
const CALLINGCHUCK = "https://api.chucknorris.io/jokes/random"
let reportJokes = [];
let printJoke, printIcon, printTemp;
let date = new Date();

// Llamada a la API Chistes
let loadApi = async() =>{
try{
let response = await fetch(CALLINGJOKES, {
headers: {
'Accept': "application/json"
}
});
const data = await response.json();
printJoke = data.joke;
console.log (printJoke);
document.getElementById("writeJoke").innerHTML = printJoke;

} catch(error){
console.log(error);
}
}

// Creación de la clase Register
class Register {
constructor(joke, score, date) {
this.joke = joke;
this.score = score;
this.date = date;
}
}
// Obtención de la puntuación del chiste y creación de la instancia que se añade al array.
function rate(id){
let joke = printJoke;
let score = id;
let dateIso = date.toISOString();
let newRegister = new Register (joke, score, dateIso);
reportJokes.push(newRegister);
document.getElementById("rateok").style.visibility = "visible";
document.getElementById("rateok").innerHTML = `Thanks for rating (<b>${score}</b>)`;
console.table(reportJokes)
}

// Llamada a la API Meteo
let loadApiWeather = async() =>{
try{
let response = await fetch(CALLINGWEATHER);
const data = await response.json();
let tempF = data.DailyForecasts[0].Temperature.Maximum.Value;
printIcon = data.DailyForecasts[0].Day.Icon;
printTemp = ((tempF - 32) * 5/9).toFixed(1);
let icono = `<img src="./image/${printIcon}.png">`;
document.getElementById("icono").innerHTML = icono;
document.getElementById("temp").innerHTML = `Max ºC: <b>${printTemp} </b>`;
} catch(error){
console.log(error);
}
}
// Llamada a la API Chuck Norris
let loadChuck = async() =>{
try{
let response = await fetch(CALLINGCHUCK);
const data = await response.json();
printJoke= data.value;
document.getElementById("writeJoke").innerHTML = printJoke;

} catch(error){
console.log(error);
}
}
// Intercambio de funciones al pulsar el botón de nuevo chiste
let toggle = true;
function changeFunc(){
document.getElementById("rateok").style.visibility = "hidden";
toggle ? loadApi() : loadChuck();
toggle = !toggle;
}