-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
137 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
class Agenda{ | ||
|
||
constructor(){ | ||
this.url = "http://ergast.com/api/f1/current"; | ||
this.last_api_call = null; | ||
this.las_api_result = null; | ||
} | ||
|
||
cargarDatos(){ | ||
$.ajax({ | ||
dataType: "xml", | ||
url: this.url, | ||
method: 'GET', | ||
success: function(datos){ | ||
//$("h5").text((new XMLSerializer()).serializeToString(datos)); | ||
|
||
//Presentación de los datos contenidos en XML | ||
$.each($('Race',datos), function(item){ | ||
var stringDatos = "<ul><li>Carrera: " + $('RaceName',item).text() + "</li>"; | ||
stringDatos += "<li>Circuito: " + $('CircuitName',item).text() + "</li>"; | ||
stringDatos += "<li>Coordenadas: [" + $('Location',item).attr('lat') + "," + $('Location',datos).attr('long') + "]</li>"; | ||
stringDatos += "<li>Fecha: " + $('Date',item).text() + "</li>"; | ||
stringDatos += "<li>Hora: " + $('Time',item).text() + "</li>"; | ||
|
||
$("pre").html(stringDatos); | ||
}); | ||
|
||
}, | ||
error:function(){ | ||
$("h4").remove(); | ||
//$("h5").remove(); | ||
$("pre").remove(); | ||
} | ||
}); | ||
} | ||
|
||
crearElemento(tipoElemento, texto, insertarAntesDe){ | ||
// Crea un nuevo elemento modificando el árbol DOM | ||
// El elemnto creado es de 'tipoElemento' con un 'texto' | ||
// El elemnto se coloca antes del elemnto 'insertarAntesDe' | ||
var elemento = document.createElement(tipoElemento); | ||
elemento.innerHTML = texto; | ||
$(insertarAntesDe).before(elemento); | ||
} | ||
|
||
verXML(){ | ||
|
||
//Muestra el archivo XML recibido | ||
this.crearElemento("h4", "Datos", "footer") | ||
//this.crearElemento("h5", "", "h4") | ||
this.crearElemento("pre","","footer"); // Crea un elemento con DOM para el string con JSON | ||
this.cargarDatos(); | ||
$("button").attr("disabled","disabled"); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<?xml-stylesheet type="text/xsl" href="/schemas/mrd-1.5.xsl"?> | ||
<MRData xmlns="http://ergast.com/mrd/1.5" series="f1" url="http://ergast.com/api/f1/current" limit="30" offset="0" total="22"> | ||
<RaceTable season="2023"> | ||
<Race season="2023" round="1" url="https://en.wikipedia.org/wiki/2023_Bahrain_Grand_Prix"> | ||
<RaceName>Bahrain Grand Prix</RaceName> | ||
<Circuit circuitId="bahrain" url="http://en.wikipedia.org/wiki/Bahrain_International_Circuit"> | ||
<CircuitName>Bahrain International Circuit</CircuitName> | ||
<Location lat="26.0325" long="50.5106"> | ||
<Locality>Sakhir</Locality> | ||
<Country>Bahrain</Country> | ||
</Location> | ||
</Circuit> | ||
<Date>2023-03-05</Date> | ||
<Time>15:00:00Z</Time> | ||
<FirstPractice> | ||
<Date>2023-03-03</Date> | ||
<Time>11:30:00Z</Time> | ||
</FirstPractice> | ||
<SecondPractice> | ||
<Date>2023-03-03</Date> | ||
<Time>15:00:00Z</Time> | ||
</SecondPractice> | ||
<ThirdPractice> | ||
<Date>2023-03-04</Date> | ||
<Time>11:30:00Z</Time> | ||
</ThirdPractice> | ||
<Qualifying> | ||
<Date>2023-03-04</Date> | ||
<Time>15:00:00Z</Time> | ||
</Qualifying> | ||
</Race> | ||
<!-- ... (resto de las carreras) ... --> | ||
<Race season="2023" round="22" url="https://en.wikipedia.org/wiki/2023_Abu_Dhabi_Grand_Prix"> | ||
<RaceName>Abu Dhabi Grand Prix</RaceName> | ||
<Circuit circuitId="yas_marina" url="http://en.wikipedia.org/wiki/Yas_Marina_Circuit"> | ||
<CircuitName>Yas Marina Circuit</CircuitName> | ||
<Location lat="24.4672" long="54.6031"> | ||
<Locality>Abu Dhabi</Locality> | ||
<Country>UAE</Country> | ||
</Location> | ||
</Circuit> | ||
<Date>2023-11-26</Date> | ||
<Time>13:00:00Z</Time> | ||
<FirstPractice> | ||
<Date>2023-11-24</Date> | ||
<Time>09:30:00Z</Time> | ||
</FirstPractice> | ||
<SecondPractice> | ||
<Date>2023-11-24</Date> | ||
<Time>13:00:00Z</Time> | ||
</SecondPractice> | ||
<ThirdPractice> | ||
<Date>2023-11-25</Date> | ||
<Time>10:30:00Z</Time> | ||
</ThirdPractice> | ||
<Qualifying> | ||
<Date>2023-11-25</Date> | ||
<Time>14:00:00Z</Time> | ||
</Qualifying> | ||
</Race> | ||
</RaceTable> | ||
</MRData> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -50,5 +50,7 @@ <h2>Meteorología</h2> | |
pais.verJSON(); | ||
</script> | ||
|
||
<footer></footer> | ||
|
||
</body> | ||
</html> |