Skip to content

Commit

Permalink
Primer intento de fondo
Browse files Browse the repository at this point in the history
  • Loading branch information
UO291047 committed Nov 22, 2023
1 parent db636dd commit ba4315d
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
6 changes: 5 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
integrity="sha256-/JqT3SQfawRcv/BIHPThkBvs0OEvtFFmqPF/lYI/Cxo="
crossorigin="anonymous"></script>
<script src="js/fondo.js"></script>
<script src="js/pais.js"></script>

</head>

Expand All @@ -41,7 +42,10 @@ <h2>Índice</h2>
<section>

<script>
const memoria = new Memoria();
const pais = new Pais("Tanzania", "Dodoma", 65_500_000);
pais.rellenarAtributosSecundarios("Partitocracia", [-6.17221,35.73947], "Cristianismo");
const fondo = new Fondo(pais.getNombrePais(), pais.getNombreCapital(), pais.getCoords());
fondo.setFondo();
</script>

</section>
Expand Down
16 changes: 16 additions & 0 deletions js/fondo.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,20 @@ class Fondo{
this.nombre_capital = nombre_capital;
this.coords = coords;
}

setFondo() {
var flickrAPI = "http://api.flickr.com/services/feeds/photos_public.gne?jsoncallback=?";
$.getJSON(flickrAPI,
{
tags: this.nombre_capital,
tagmode: "any",
format: "json"
})
.done(function(data) {
$.each(data.items, function(item) {
$("body").css("background-image", item);
return;
});
});
}
}
4 changes: 4 additions & 0 deletions js/pais.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ class Pais {
return this.religion;
}

getCoords(){
return this.coords_capital;
}

getExtraInfo(){
return "<ul>" +
"<li>" + "Población: " + this.poblacion + "</li>" +
Expand Down
2 changes: 1 addition & 1 deletion meteorologia.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ <h2>Meteorología</h2>

<script>
var pais = new Pais("Tanzania", "Dodoma", 65_500_000);
pais.rellenarAtributosSecundarios("Monarquía", [0,0], "Cristianismo");
pais.rellenarAtributosSecundarios("Partitocracia", [-6.17221,35.73947], "Cristianismo");
document.write("<p>" + "País: " + pais.getNombrePais() + "</p>");
document.write("<p>" + "Capital: " + pais.getNombreCapital() + "</p>");
document.write(pais.getExtraInfo());
Expand Down

0 comments on commit ba4315d

Please sign in to comment.