diff --git a/Miguel/Ejercicio_Chartist/js/javascript.js b/Miguel/Ejercicio_Chartist/js/javascript.js
index 3f753521..7bd2f001 100644
--- a/Miguel/Ejercicio_Chartist/js/javascript.js
+++ b/Miguel/Ejercicio_Chartist/js/javascript.js
@@ -1,32 +1,30 @@
//Ejercicio gráfica de humedad y temperatura de madrid usando Chartist.
-//Variable donde se guardaran los datos de las etiquetas y las barras de la gráfica.
-var data = {
- labels: [],
- series: [ [],[],[] ]
-};
//Función para obtener datos y pintar la gráfica.
-function llamada(url){
- fetch(url)
- .then(res => res.json())
- .then(dat => {
- console.log(dat);
- let lista = dat.list;
- for(i = 0; i < lista.length; i++){
- if(lista[i].dt_txt.slice(11) == "15:00:00"){
- data.series[1].push(lista[i].main.temp_max);
- data.series[2].push(lista[i].main.humidity);
- data.labels.push(lista[i].dt_txt.slice(0,10));
- }else if(lista[i].dt_txt.slice(11) == "03:00:00"){
- data.series[0].push(lista[i].main.temp_min);
- }
- }
- var chart = new Chartist.Bar('.ct-chart', data, options, responsiveOptions);
- //Función para animar la grafica *MINIFICADA*
- var seq=0,delays=50,durations=500;chart.on("created",function(){seq=0}),chart.on("draw",function(e){if(seq++,"bar"===e.type)e.element.animate({opacity:{begin:seq*delays+1e3,dur:durations,from:0,to:1}});else if("label"===e.type&&"x"===e.axis)e.element.animate({y:{begin:seq*delays,dur:durations,from:e.y+100,to:e.y,easing:"easeOutQuart"}});else if("label"===e.type&&"y"===e.axis)e.element.animate({x:{begin:seq*delays,dur:durations,from:e.x-100,to:e.x,easing:"easeOutQuart"}});else if("point"===e.type)e.element.animate({x1:{begin:seq*delays,dur:durations,from:e.x-10,to:e.x,easing:"easeOutQuart"},x2:{begin:seq*delays,dur:durations,from:e.x-10,to:e.x,easing:"easeOutQuart"},opacity:{begin:seq*delays,dur:durations,from:0,to:1,easing:"easeOutQuart"}});else if("grid"===e.type){var a={begin:seq*delays,dur:durations,from:e[e.axis.units.pos+"1"]-30,to:e[e.axis.units.pos+"1"],easing:"easeOutQuart"},s={begin:seq*delays,dur:durations,from:e[e.axis.units.pos+"2"]-100,to:e[e.axis.units.pos+"2"],easing:"easeOutQuart"},t={};t[e.axis.units.pos+"1"]=a,t[e.axis.units.pos+"2"]=s,t.opacity={begin:seq*delays,dur:durations,from:0,to:1,easing:"easeOutQuart"},e.element.animate(t)}});
- })
- .catch(err => console.log(`Error: ${err}`));
-}
-//Opciones de la grafica *MINIFICADAS*
-var options={seriesBarDistance:30},responsiveOptions=[["screen and (min-width: 641px) and (max-width: 1024px)",{seriesBarDistance:10,axisX:{labelInterpolationFnc:function(n){return n}}}],["screen and (max-width: 640px)",{seriesBarDistance:5,axisX:{labelInterpolationFnc:function(n){return n[0]}}}]];
-//Llamada a la
-llamada("http://airemad.com/api/v1/weather/S002");
\ No newline at end of file
+(function getData() {
+ //Opciones de la grafica *MINIFICADAS*
+ var options={seriesBarDistance:30},responsiveOptions=[["screen and (min-width: 641px) and (max-width: 1024px)",{seriesBarDistance:10,axisX:{labelInterpolationFnc:function(n){return n}}}],["screen and (max-width: 640px)",{seriesBarDistance:5,axisX:{labelInterpolationFnc:function(n){return n[0]}}}]];
+ //Variable donde se guardaran los datos de las etiquetas y las barras de la gráfica.
+ var data = {
+ labels: [],
+ series: [ [],[],[] ]
+ }
+
+ fetch("http://airemad.com/api/v1/weather/S002")
+ .then(res => res.json())
+ .then(dat => {
+ let lista = dat.list;
+ for(i = 0; i < lista.length; i++){
+ if(lista[i].dt_txt.slice(11) == "15:00:00"){
+ data.series[1].push(lista[i].main.temp_max);
+ data.series[2].push(lista[i].main.humidity);
+ data.labels.push(lista[i].dt_txt.slice(0,10));
+ }else if(lista[i].dt_txt.slice(11) == "03:00:00"){
+ data.series[0].push(lista[i].main.temp_min);
+ }
+ }
+ var chart = new Chartist.Bar('.ct-chart', data, options, responsiveOptions);
+ //Función para animar la grafica *MINIFICADA*
+ var seq=0,delays=50,durations=500;chart.on("created",function(){seq=0}),chart.on("draw",function(e){if(seq++,"bar"===e.type)e.element.animate({opacity:{begin:seq*delays+1e3,dur:durations,from:0,to:1}});else if("label"===e.type&&"x"===e.axis)e.element.animate({y:{begin:seq*delays,dur:durations,from:e.y+100,to:e.y,easing:"easeOutQuart"}});else if("label"===e.type&&"y"===e.axis)e.element.animate({x:{begin:seq*delays,dur:durations,from:e.x-100,to:e.x,easing:"easeOutQuart"}});else if("point"===e.type)e.element.animate({x1:{begin:seq*delays,dur:durations,from:e.x-10,to:e.x,easing:"easeOutQuart"},x2:{begin:seq*delays,dur:durations,from:e.x-10,to:e.x,easing:"easeOutQuart"},opacity:{begin:seq*delays,dur:durations,from:0,to:1,easing:"easeOutQuart"}});else if("grid"===e.type){var a={begin:seq*delays,dur:durations,from:e[e.axis.units.pos+"1"]-30,to:e[e.axis.units.pos+"1"],easing:"easeOutQuart"},s={begin:seq*delays,dur:durations,from:e[e.axis.units.pos+"2"]-100,to:e[e.axis.units.pos+"2"],easing:"easeOutQuart"},t={};t[e.axis.units.pos+"1"]=a,t[e.axis.units.pos+"2"]=s,t.opacity={begin:seq*delays,dur:durations,from:0,to:1,easing:"easeOutQuart"},e.element.animate(t)}});
+ })
+ .catch(err => console.log(`Error: ${err}`));
+})()
diff --git a/Miguel/Ejercicio_NASA/js/javascript.js b/Miguel/Ejercicio_NASA/js/javascript.js
index 81e99442..f10df2a1 100644
--- a/Miguel/Ejercicio_NASA/js/javascript.js
+++ b/Miguel/Ejercicio_NASA/js/javascript.js
@@ -1,4 +1,3 @@
-
/**
* @file exercise to get photos of the curiosity robot from Mars
* @author Miguel Martin-Maestro Lopez
@@ -38,7 +37,7 @@ function NasaRequest(soles,limit){
}
});
}else{
- console.log("Límite de llamadas superado, intentelo de nuevo.")
+ reject("Límite de llamadas superado, intentelo de nuevo.")
};
});
};
@@ -49,7 +48,3 @@ async function init(){
document.getElementById("resultado").querySelector("img").src = currentValue.photos[0].img_src;
}
init();
-
-
-
-
diff --git a/Miguel/Ejercicio_Router/js/main.js b/Miguel/Ejercicio_Router/js/main.js
index 2a8e034f..4af655b5 100644
--- a/Miguel/Ejercicio_Router/js/main.js
+++ b/Miguel/Ejercicio_Router/js/main.js
@@ -57,13 +57,17 @@ function fetchAireMad(url,id){
};
//Crear una sub-lista dentro del último campo del menú con los valores de 'idList'
-const stationsIdList = ["P001", "P002", "P003", "S001", "S002", "S004", "S006", "S008", "S011", "S012", "S016", "S017", "S018", "S019", "S024", "S025", "S027", "S028", "S030", "S035", "S036", "S038", "S039", "S040", "S047", "S048", "S049", "S050", "S054", "S055", "S056", "S057", "S058", "S059", "S060"];
+function loadStations() {
+ const stationsIdList = ["P001", "P002", "P003", "S001", "S002", "S004", "S006", "S008", "S011", "S012", "S016", "S017", "S018", "S019", "S024", "S025", "S027", "S028", "S030", "S035", "S036", "S038", "S039", "S040", "S047", "S048", "S049", "S050", "S054", "S055", "S056", "S057", "S058", "S059", "S060"];
-stationsIdList.forEach(function(element){
- let li = document.createElement("li")
- let a = document.createElement("a");
- a.href = '/stations/:'+element;
- a.textContent = element;
- li.append(a);
- document.querySelector(".desplegable ul").append(li);
-})
\ No newline at end of file
+ stationsIdList.forEach(function(element){
+ let li = document.createElement("li")
+ let a = document.createElement("a");
+ a.href = '/stations/'+ element;
+ a.textContent = element;
+ li.append(a);
+ document.querySelector(".desplegable ul").append(li);
+ })
+}
+
+loadStations()
diff --git a/Miguel/Ejercicio_api_github/.gitignore b/Miguel/Ejercicio_api_github/.gitignore
index a9b8f360..453a202c 100644
--- a/Miguel/Ejercicio_api_github/.gitignore
+++ b/Miguel/Ejercicio_api_github/.gitignore
@@ -159,6 +159,7 @@ ehthumbs_vista.db
# Folder config file
[Dd]esktop.ini
+desktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
diff --git a/Miguel/Ejercicio_api_github/js/javascript.js b/Miguel/Ejercicio_api_github/js/javascript.js
index 70d81da9..20f5b3e7 100644
--- a/Miguel/Ejercicio_api_github/js/javascript.js
+++ b/Miguel/Ejercicio_api_github/js/javascript.js
@@ -1,68 +1,84 @@
/**
* @file exercise to get the data of a github user including his email from the events
* @author Miguel Martin-Maestro Lopez
- * @version 1.1.0
+ * @version 1.2.0
*/
-
/**
* @description fetch to get user data from the api of github
- * @param {string} url //url created in the listener below
+ * @param {string} url url created in the listener below
*/
function searchUser(url){
- fetch(url)
- .then(function(response){
- return response.json();
- })
- .then(function(data){
-
- document.getElementById("resultado").innerHTML = "";
-
- var nombre = data.name;
-
- var p = document.createElement("p");
- p.setAttribute("id","informacionDeUsuario");
- document.getElementById("resultado").append(p);
- p.innerText = "Nombre y Apellidos: " + data.name + "\n" + "Nombre de usuario: " + data.login + "\n" + "Bio: " + data.bio + "\n" + "GitHub: " + data.html_url + "\n" + "Ciudad: " + data.location;
- var img = document.createElement("img");
- img.src = data.avatar_url;
- p.insertAdjacentElement("afterend",img);
-
- var urlEvent = url + "/events";
-
- fetch(urlEvent)
- .then(function(response){
- return response.json();
- })
- .then(function(data){
-
- var email;
-
- for(i = 0; i < data.length; i++){
-
- var commits = data[i].payload.commits;
-
- if(commits){
-
- for(j = 0; j < commits.length; j++){
-
- if(commits[j].author.name == nombre){
-
- email = commits[j].author.email;
+ fetch(url)
+ .then(function(response){
+ if(response.status === 404) {
+ document.getElementById("resultado").innerHTML = "404 - USUARIO NO ENCONTRADO"
+ } else if (response.status === 200) {
+ response.json()
+ .then(function(data){
+
+ pintarDatos(data, url)
+
+ })
+ }
+ })
+ .catch(function(error) {console.error('Error-Usuario no encontrado:', error)
+ })
+}
+/**
+ * @description function to paint users data
+ * @param {object} data data received from searchUser function
+ * @param {string} url url of the last fetch needed to build the next fetch to users/events
+ */
+function pintarDatos(data, url) {
+ document.getElementById("resultado").innerHTML = ""
+ var p = document.createElement("p")
+ p.setAttribute("id","informacionDeUsuario")
+ document.getElementById("resultado").append(p)
+ p.innerText = "Nombre y Apellidos: " + data.name + "\n" + "Nombre de usuario: " + data.login + "\n" + "Bio: " + data.bio + "\n" + "GitHub: " + data.html_url + "\n" + "Ciudad: " + data.location
+ var img = document.createElement("img")
+ img.src = data.avatar_url
+ p.insertAdjacentElement("afterend",img)
+
+ if (data.email != null) {
+ document.getElementById("informacionDeUsuario").innerText += "\n" + "Email: " + email
+ } else {
+ var urlEvent = url + "/events"
+ var name = data.name
+ buscarEmail (urlEvent, name)
+ }
+}
- if(email != ""){
- document.getElementById("informacionDeUsuario").innerText += "\n" + "Email: " + email;
- }
- return;
- }
- }
- }
- }if(email == undefined){ document.getElementById("informacionDeUsuario").innerText += "\n" + "Email: No encontrado." ;}
- })
- })
- .catch(function(error){console.error('Error:', error)
- });
-};
+/**
+ * @description function to find the email
+ * @param {string} urlEvent the new url for fetch data about events
+ * @param {string} name name to verify authorship of the commits to find the correct email
+ */
+function buscarEmail(urlEvent, name) {
+ fetch(urlEvent)
+ .then(function(response) {
+ return response.json()
+ })
+ .then(function(data){
+ var email
+ for(i = 0; i < data.length; i++){
+ var commits = data[i].payload.commits
+
+ if(commits){
+ for(j = 0; j < commits.length; j++){
+ if(commits[j].author.name == name){
+ email = commits[j].author.email
+ if(email != ""){
+ document.getElementById("informacionDeUsuario").innerText += "\n" + "Email: " + email
+ }
+ return
+ }
+ }
+ }
+ }
+ if(email == undefined){ document.getElementById("informacionDeUsuario").innerText += "\n" + "Email: No encontrado." }
+ })
+}
/**
* @description it takes as part of the parameter of searchUser(url) the value entered by the user in the input
@@ -70,8 +86,6 @@ function searchUser(url){
* @fires btnUser#searchUser
*/
document.getElementById("btnUser").addEventListener("click", function(){
- var usuario = document.getElementById("textBox").value;
- searchUser("https://api.github.com/users/" + usuario);
-});
-
-
+ var usuario = document.getElementById("textBox").value
+ searchUser("https://api.github.com/users/" + usuario)
+})
diff --git a/Miguel/Ejercicio_api_github/out/global.html b/Miguel/Ejercicio_api_github/out/global.html
index 2d8f86e2..c6f9dd3f 100644
--- a/Miguel/Ejercicio_api_github/out/global.html
+++ b/Miguel/Ejercicio_api_github/out/global.html
@@ -98,6 +98,326 @@
Methods
+
+
+
+
+
+
+ buscarEmail(urlEvent, name)
+
+
+
+
+
+
+
+ function to find the email
+
+
+
+
+
+
+
+
+
+
+ Parameters:
+
+
+
+
+
+
+ Name
+
+
+ Type
+
+
+
+
+
+ Description
+
+
+
+
+
+
+
+
+ urlEvent
+
+
+
+
+
+string
+
+
+
+
+
+
+
+
+
+ the new url for fetch data about events
+
+
+
+
+
+
+ name
+
+
+
+
+
+string
+
+
+
+
+
+
+
+
+
+ name to verify authorship of the commits to find the correct email
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Source:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ pintarDatos(data, url)
+
+
+
+
+
+
+
+ function to paint users data
+
+
+
+
+
+
+
+
+
+
+ Parameters:
+
+
+
+
+
+
+ Name
+
+
+ Type
+
+
+
+
+
+ Description
+
+
+
+
+
+
+
+
+ data
+
+
+
+
+
+object
+
+
+
+
+
+
+
+
+
+ data received from searchUser function
+
+
+
+
+
+
+ url
+
+
+
+
+
+string
+
+
+
+
+
+
+
+
+
+ url of the last fetch needed to build the next fetch to users/events
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Source:
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -164,7 +484,7 @@ Parameters:
- //url created in the listener below
+ url created in the listener below
@@ -205,7 +525,7 @@ Parameters:
Source:
@@ -301,7 +621,7 @@ searchUser
Source:
@@ -348,13 +668,13 @@ Fires:
- Events Global
+ Events Global
- Documentation generated by JSDoc 3.6.3 on Tue Jan 14 2020 18:29:41 GMT+0100 (hora estándar de Europa central)
+ Documentation generated by JSDoc 3.6.5 on Tue Aug 11 2020 10:44:07 GMT+0200 (hora de verano de Europa central)
diff --git a/Miguel/Ejercicio_api_github/out/index.html b/Miguel/Ejercicio_api_github/out/index.html
index fb2021bf..f68e1683 100644
--- a/Miguel/Ejercicio_api_github/out/index.html
+++ b/Miguel/Ejercicio_api_github/out/index.html
@@ -73,7 +73,7 @@ javascript.js
Version:
-
+
@@ -153,13 +153,13 @@ javascript.js
- Events Global
+ Events Global
- Documentation generated by JSDoc 3.6.3 on Tue Jan 14 2020 18:29:41 GMT+0100 (hora estándar de Europa central)
+ Documentation generated by JSDoc 3.6.5 on Tue Aug 11 2020 10:44:07 GMT+0200 (hora de verano de Europa central)
diff --git a/Miguel/Ejercicio_api_github/out/javascript.js.html b/Miguel/Ejercicio_api_github/out/javascript.js.html
index a6dbe78e..1e8e38dc 100644
--- a/Miguel/Ejercicio_api_github/out/javascript.js.html
+++ b/Miguel/Ejercicio_api_github/out/javascript.js.html
@@ -29,68 +29,84 @@ Source: javascript.js
/**
* @file exercise to get the data of a github user including his email from the events
* @author Miguel Martin-Maestro Lopez
- * @version 1.1.0
+ * @version 1.2.0
*/
-
/**
* @description fetch to get user data from the api of github
- * @param {string} url //url created in the listener below
+ * @param {string} url url created in the listener below
*/
function searchUser(url){
- fetch(url)
- .then(function(response){
- return response.json();
- })
- .then(function(data){
-
- document.getElementById("resultado").innerHTML = "";
-
- var nombre = data.name;
-
- var p = document.createElement("p");
- p.setAttribute("id","informacionDeUsuario");
- document.getElementById("resultado").append(p);
- p.innerText = "Nombre y Apellidos: " + data.name + "\n" + "Nombre de usuario: " + data.login + "\n" + "Bio: " + data.bio + "\n" + "GitHub: " + data.html_url + "\n" + "Ciudad: " + data.location;
- var img = document.createElement("img");
- img.src = data.avatar_url;
- p.insertAdjacentElement("afterend",img);
-
- var urlEvent = url + "/events";
-
- fetch(urlEvent)
- .then(function(response){
- return response.json();
- })
- .then(function(data){
-
- var email;
-
- for(i = 0; i < data.length; i++){
-
- var commits = data[i].payload.commits;
-
- if(commits){
-
- for(j = 0; j < commits.length; j++){
-
- if(commits[j].author.name == nombre){
-
- email = commits[j].author.email;
+ fetch(url)
+ .then(function(response){
+ if(response.status === 404) {
+ document.getElementById("resultado").innerHTML = "404 - USUARIO NO ENCONTRADO"
+ } else if (response.status === 200) {
+ response.json()
+ .then(function(data){
+
+ pintarDatos(data, url)
+
+ })
+ }
+ })
+ .catch(function(error) {console.error('Error-Usuario no encontrado:', error)
+ })
+}
+/**
+ * @description function to paint users data
+ * @param {object} data data received from searchUser function
+ * @param {string} url url of the last fetch needed to build the next fetch to users/events
+ */
+function pintarDatos(data, url) {
+ document.getElementById("resultado").innerHTML = ""
+ var p = document.createElement("p")
+ p.setAttribute("id","informacionDeUsuario")
+ document.getElementById("resultado").append(p)
+ p.innerText = "Nombre y Apellidos: " + data.name + "\n" + "Nombre de usuario: " + data.login + "\n" + "Bio: " + data.bio + "\n" + "GitHub: " + data.html_url + "\n" + "Ciudad: " + data.location
+ var img = document.createElement("img")
+ img.src = data.avatar_url
+ p.insertAdjacentElement("afterend",img)
+
+ if (data.email != null) {
+ document.getElementById("informacionDeUsuario").innerText += "\n" + "Email: " + email
+ } else {
+ var urlEvent = url + "/events"
+ var name = data.name
+ buscarEmail (urlEvent, name)
+ }
+}
- if(email != ""){
- document.getElementById("informacionDeUsuario").innerText += "\n" + "Email: " + email;
- }
- return;
- }
- }
- }
- }if(email == undefined){ document.getElementById("informacionDeUsuario").innerText += "\n" + "Email: No encontrado." ;}
- })
- })
- .catch(function(error){console.error('Error:', error)
- });
-};
+/**
+ * @description function to find the email
+ * @param {string} urlEvent the new url for fetch data about events
+ * @param {string} name name to verify authorship of the commits to find the correct email
+ */
+function buscarEmail(urlEvent, name) {
+ fetch(urlEvent)
+ .then(function(response) {
+ return response.json()
+ })
+ .then(function(data){
+ var email
+ for(i = 0; i < data.length; i++){
+ var commits = data[i].payload.commits
+
+ if(commits){
+ for(j = 0; j < commits.length; j++){
+ if(commits[j].author.name == name){
+ email = commits[j].author.email
+ if(email != ""){
+ document.getElementById("informacionDeUsuario").innerText += "\n" + "Email: " + email
+ }
+ return
+ }
+ }
+ }
+ }
+ if(email == undefined){ document.getElementById("informacionDeUsuario").innerText += "\n" + "Email: No encontrado." }
+ })
+}
/**
* @description it takes as part of the parameter of searchUser(url) the value entered by the user in the input
@@ -98,11 +114,9 @@ Source: javascript.js
* @fires btnUser#searchUser
*/
document.getElementById("btnUser").addEventListener("click", function(){
- var usuario = document.getElementById("textBox").value;
- searchUser("https://api.github.com/users/" + usuario);
-});
-
-
+ var usuario = document.getElementById("textBox").value
+ searchUser("https://api.github.com/users/" + usuario)
+})
@@ -113,13 +127,13 @@ Source: javascript.js
- Events Global
+ Events Global
- Documentation generated by JSDoc 3.6.3 on Tue Jan 14 2020 18:29:41 GMT+0100 (hora estándar de Europa central)
+ Documentation generated by JSDoc 3.6.5 on Tue Aug 11 2020 10:44:07 GMT+0200 (hora de verano de Europa central)
diff --git a/Miguel/Ejercicio_cifradoCesar/css/styles.css b/Miguel/Ejercicio_cifradoCesar/css/styles.css
index 3a29e9a4..8ab916af 100644
--- a/Miguel/Ejercicio_cifradoCesar/css/styles.css
+++ b/Miguel/Ejercicio_cifradoCesar/css/styles.css
@@ -25,3 +25,18 @@ h1{
left: 50%;
transform: translateX(-50%);
}
+.error_info{
+ width: 70%;
+ background-color: rgb(255, 51, 0);
+ position: absolute;
+ top: 100%;
+ left: 50%;
+ transform: translate(-50%);
+ z-index: 1;
+ border-radius: 4px;
+ padding: 1% 2%;
+ color: white;
+ visibility: hidden;
+}
+
+
diff --git a/Miguel/Ejercicio_cifradoCesar/index.html b/Miguel/Ejercicio_cifradoCesar/index.html
index f70f4a31..5a5d4796 100644
--- a/Miguel/Ejercicio_cifradoCesar/index.html
+++ b/Miguel/Ejercicio_cifradoCesar/index.html
@@ -14,8 +14,10 @@ Cifrado de Cesar
Cifrar
diff --git a/Miguel/Ejercicio_cifradoCesar/js/javascript.js b/Miguel/Ejercicio_cifradoCesar/js/javascript.js
index 501d278f..6fde093b 100644
--- a/Miguel/Ejercicio_cifradoCesar/js/javascript.js
+++ b/Miguel/Ejercicio_cifradoCesar/js/javascript.js
@@ -27,12 +27,18 @@ function cesar(){
});
document.getElementById("resultado").innerText = resultado;
}else{
- throw new Error("Solo se puede introducir letras mayúsculas o minúsculas(excluidas 'ñ' y 'Ñ')en el texto y únicamente números del 1 al 9 en el desplazamiento");
+ document.querySelector('.error_info').style.visibility = "visible"
+ throw new Error();
}
};
//Listener al boton.
document.getElementById("btn").addEventListener("click",cesar);
+//Listener para oculatar el mensaje de error cuando se haga focus sobre el input de texto
+document.getElementById("textBox").addEventListener('focus', () => {
+ document.querySelector('.error_info').style.visibility = "hidden"
+})
+
//Funcion para obtener texto y movimiento.
function getTextAndMove(){
let content = document.getElementById("textBox").value;
@@ -51,5 +57,7 @@ function validar(txt,move){
const patronNum = /^[1-9]$/;
if(patronTxt.test(txt) && patronNum.test(move)){
return true;
+ } else {
+ return false
}
};
\ No newline at end of file
diff --git a/Miguel/Ejercicio_class/desktop.ini b/Miguel/Ejercicio_class/desktop.ini
deleted file mode 100644
index 8fac6f55..00000000
--- a/Miguel/Ejercicio_class/desktop.ini
+++ /dev/null
@@ -1,6 +0,0 @@
-[.ShellClassInfo]
-IconResource=C:\Windows\System32\SHELL32.dll,126
-[ViewState]
-Mode=
-Vid=
-FolderType=Documents
diff --git a/Miguel/Ejercicio_localStorage/js/javascript.js b/Miguel/Ejercicio_localStorage/js/javascript.js
index 66eef796..d1e87c81 100644
--- a/Miguel/Ejercicio_localStorage/js/javascript.js
+++ b/Miguel/Ejercicio_localStorage/js/javascript.js
@@ -3,8 +3,23 @@
const btn1 = document.getElementById("btn1");
btn1.addEventListener("click",function(){
let clave = document.getElementById("textBox1").value;
+ if(!/^[A-Za-z]{3,10}$/.test(clave)) {
+ console.warn("El nombre introducido no es valido")
+ return
+ }
+
let tlf = document.getElementById("textBox2").value;
+ if (!/^[0-9]{9}$/.test(tlf)) {
+ console.warn("El telefono introducido no es valido")
+ return
+ }
+
let mail = document.getElementById("textBox3").value;
+ if (!/^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)*$/.test(mail)) {
+ console.warn("El email introducido no es valido")
+ return
+ }
+
if(clave && tlf && mail){
let coincidencias = false;
for(let i in localStorage){
diff --git a/Miguel/Ejercicio_websocket/.gitignore b/Miguel/Ejercicio_websocket/.gitignore
new file mode 100644
index 00000000..a9b8f360
--- /dev/null
+++ b/Miguel/Ejercicio_websocket/.gitignore
@@ -0,0 +1,176 @@
+
+# Created by https://www.gitignore.io/api/node,macos,windows,visualstudiocode
+# Edit at https://www.gitignore.io/?templates=node,macos,windows,visualstudiocode
+
+### macOS ###
+# General
+.DS_Store
+.AppleDouble
+.LSOverride
+
+# Icon must end with two \r
+Icon
+
+# Thumbnails
+._*
+
+# Files that might appear in the root of a volume
+.DocumentRevisions-V100
+.fseventsd
+.Spotlight-V100
+.TemporaryItems
+.Trashes
+.VolumeIcon.icns
+.com.apple.timemachine.donotpresent
+
+# Directories potentially created on remote AFP share
+.AppleDB
+.AppleDesktop
+Network Trash Folder
+Temporary Items
+.apdisk
+
+### Node ###
+# Logs
+logs
+*.log
+npm-debug.log*
+yarn-debug.log*
+yarn-error.log*
+lerna-debug.log*
+
+# Diagnostic reports (https://nodejs.org/api/report.html)
+report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
+
+# Runtime data
+pids
+*.pid
+*.seed
+*.pid.lock
+
+# Directory for instrumented libs generated by jscoverage/JSCover
+lib-cov
+
+# Coverage directory used by tools like istanbul
+coverage
+*.lcov
+
+# nyc test coverage
+.nyc_output
+
+# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
+.grunt
+
+# Bower dependency directory (https://bower.io/)
+bower_components
+
+# node-waf configuration
+.lock-wscript
+
+# Compiled binary addons (https://nodejs.org/api/addons.html)
+build/Release
+
+# Dependency directories
+node_modules/
+jspm_packages/
+
+# TypeScript v1 declaration files
+typings/
+
+# TypeScript cache
+*.tsbuildinfo
+
+# Optional npm cache directory
+.npm
+
+# Optional eslint cache
+.eslintcache
+
+# Optional REPL history
+.node_repl_history
+
+# Output of 'npm pack'
+*.tgz
+
+# Yarn Integrity file
+.yarn-integrity
+
+# dotenv environment variables file
+.env
+.env.test
+
+# parcel-bundler cache (https://parceljs.org/)
+.cache
+
+# next.js build output
+.next
+
+# nuxt.js build output
+.nuxt
+
+# rollup.js default build output
+dist/
+
+# Uncomment the public line if your project uses Gatsby
+# https://nextjs.org/blog/next-9-1#public-directory-support
+# https://create-react-app.dev/docs/using-the-public-folder/#docsNav
+# public
+
+# Storybook build outputs
+.out
+.storybook-out
+
+# vuepress build output
+.vuepress/dist
+
+# Serverless directories
+.serverless/
+
+# FuseBox cache
+.fusebox/
+
+# DynamoDB Local files
+.dynamodb/
+
+# Temporary folders
+tmp/
+temp/
+
+### VisualStudioCode ###
+.vscode/*
+!.vscode/settings.json
+!.vscode/tasks.json
+!.vscode/launch.json
+!.vscode/extensions.json
+
+### VisualStudioCode Patch ###
+# Ignore all local history of files
+.history
+
+### Windows ###
+# Windows thumbnail cache files
+Thumbs.db
+Thumbs.db:encryptable
+ehthumbs.db
+ehthumbs_vista.db
+
+# Dump file
+*.stackdump
+
+# Folder config file
+[Dd]esktop.ini
+
+# Recycle Bin used on file shares
+$RECYCLE.BIN/
+
+# Windows Installer files
+*.cab
+*.msi
+*.msix
+*.msm
+*.msp
+
+# Windows shortcuts
+*.lnk
+
+# End of https://www.gitignore.io/api/node,macos,windows,visualstudiocode
\ No newline at end of file
diff --git a/Miguel/Ejercicio_websocket/css/styles.css b/Miguel/Ejercicio_websocket/css/styles.css
new file mode 100644
index 00000000..49e5e595
--- /dev/null
+++ b/Miguel/Ejercicio_websocket/css/styles.css
@@ -0,0 +1,40 @@
+/* a,abbr,acronym,address,applet,article,aside,audio,b,big,blockquote,body,canvas,caption,center,cite,code,dd,del,details,dfn,div,dl,dt,em,embed,fieldset,figcaption,figure,footer,form,h1,h2,h3,h4,h5,h6,header,hgroup,html,i,iframe,img,ins,kbd,label,legend,li,mark,menu,nav,object,ol,output,p,pre,q,ruby,s,samp,section,small,span,strike,strong,sub,summary,sup,table,tbody,td,tfoot,th,thead,time,tr,tt,u,ul,var,video{margin:0;padding:0;border:0;font-size:100%;font:inherit;vertical-align:baseline}article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section{display:block}body{line-height:1}nav ul{list-style-type:none}blockquote,q{quotes:none}blockquote:after,blockquote:before,q:after,q:before{content:'';content:none}table{border-collapse:collapse;border-spacing:0}img{display:block}video{display:block}a{text-decoration:none}div{box-sizing:border-box} */
+
+body{
+ padding: 1%;
+ background-color: #004A7C;
+ color: white;
+ font-family: calibri,helvetica,sans-serif;
+}
+
+.flexWrapper{
+ width: 70%;
+ margin: 0 auto;
+ display:flex;
+ justify-content: space-evenly;
+}
+
+.wrapper1{
+ padding: 0 30px ;
+ border: 2px solid white;
+ background-color: rgb(47, 128, 182);
+ border-radius: 4px;
+ height: fit-content;
+ text-align: center;
+ font-size: 1.4rem;
+}
+
+.wrapper2{
+ background-color: rgb(47, 128, 182);
+}
+
+#contador{
+ font-size: 3rem;
+ color: gold;
+}
+
+table, th, td{
+ border:1px solid white;
+ border-collapse: collapse;
+ padding: 10px;
+}
\ No newline at end of file
diff --git a/Miguel/Ejercicio_websocket/index.html b/Miguel/Ejercicio_websocket/index.html
new file mode 100644
index 00000000..65b81e6d
--- /dev/null
+++ b/Miguel/Ejercicio_websocket/index.html
@@ -0,0 +1,28 @@
+
+
+
+
+
+Web Socket
+
+
+
+
+
+
+
+
Transacciones de bitcoin
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Miguel/Ejercicio_websocket/js/main.js b/Miguel/Ejercicio_websocket/js/main.js
new file mode 100644
index 00000000..085bf2f9
--- /dev/null
+++ b/Miguel/Ejercicio_websocket/js/main.js
@@ -0,0 +1,54 @@
+//Ejercicio transacciones de bitcoins con websockets
+var contadorBtc = 0;
+var datosCambio;
+
+// REQUEST
+const request = new XMLHttpRequest();
+
+request.onreadystatechange = function(){
+
+ if(request.readyState === 4 && request.status === 200) {
+ datosCambio = JSON.parse(request.response);
+
+ for(let i in datosCambio){
+ document.getElementById("tabla").innerHTML += `
+
+ ${i}
+ ${datosCambio[i].buy} ${datosCambio[i].symbol}
+
+ `
+ }
+ }
+}
+
+request.open('GET','https://blockchain.info/es/ticker?cors=true');
+request.send();
+
+
+// WEBSOCKET
+var myWebSocket = new WebSocket('wss://ws.blockchain.info/inv');
+
+myWebSocket.onopen = function(){
+ console.log('Web Socket abierto');
+ myWebSocket.send(JSON.stringify({"op":"unconfirmed_sub"}));
+}
+
+myWebSocket.onmessage = function(message){
+ let datosJson = JSON.parse(message.data);
+ // console.log('Mensaje recibido: ', datosJson);
+
+ var transaccion = 0;
+ for(i = 0; i < datosJson.x.out.length; i++) {
+ transaccion += datosJson.x.out[i].value;
+ }
+
+ transaccionEnBTC = (transaccion/100000000);
+ contadorBtc += transaccionEnBTC;
+ // console.log(contadorBtc);
+
+ document.getElementById("contador").innerText = contadorBtc.toFixed(3);
+}
+
+myWebSocket.onerror = function(error) {
+ console.log('Error: ', error)
+}
\ No newline at end of file
diff --git "a/Miguel/Ejercicios_Geolocalizaci\303\263n/Mapa_con_GoogleMaps/js/javascript.js" "b/Miguel/Ejercicios_Geolocalizaci\303\263n/Mapa_con_GoogleMaps/js/javascript.js"
index c1144498..d8170506 100644
--- "a/Miguel/Ejercicios_Geolocalizaci\303\263n/Mapa_con_GoogleMaps/js/javascript.js"
+++ "b/Miguel/Ejercicios_Geolocalizaci\303\263n/Mapa_con_GoogleMaps/js/javascript.js"
@@ -1,20 +1,15 @@
//Ejercicio geolocalización con Google-Maps.
//Hay que introducir la API KEY obtenida de "https://developers.google.com/maps/documentation/javascript/get-api-key?hl=ES" en el script del HTML.
-//Variables para guardar latitud y longitud del ordenador y los datos del mapa creado con Google Maps.
-var map;
-var lat;
-var lon;
-
//Promesa para obtener disponibilidad de la geolocalización del ordenador y devolver los datos de latitud y longitud.
-function miPromesa(){
+function getGeolocation(){
return new Promise(function(resolve,reject){
if("geolocation" in navigator){
console.log("Geolocalización disponible.");
navigator.geolocation.getCurrentPosition(function(position){
- resolve(
- lat = position.coords.latitude,
- lon = position.coords.longitude
- )
+ resolve({
+ lat: position.coords.latitude,
+ lon: position.coords.longitude
+ })
})
}else{
reject(console.warn("ERROR, geolocalizacion no disponible."))
@@ -25,17 +20,18 @@ function miPromesa(){
//Función para crear el mapa de Google Maps centrado en la ubicación del ordenador y añadir un marker.
//La función es llamada en el script del HTML.
function initMap(){
- miPromesa()
- .then(function(){
- console.log(`Te encuentras en
- latitud: ${lat}
- longitud: ${lon}`)
+ var map
+ getGeolocation()
+ .then(function(obj){
+ console.log(`Te encuentras en :
+ latitud: ${obj.lat}
+ longitud: ${obj.lon}`)
map = new google.maps.Map(document.getElementById('map'), {
- center: {lat: lat, lng: lon},
+ center: {lat: obj.lat, lng: obj.lon},
zoom: 15
});
var marker = new google.maps.Marker({
- position: {lat: lat, lng: lon},
+ position: {lat: obj.lat, lng: obj.lon},
map: map,
title: "!Aquí estas¡"
});
diff --git "a/Miguel/Ejercicios_Geolocalizaci\303\263n/Mapa_con_Leaflet/js/javascript.js" "b/Miguel/Ejercicios_Geolocalizaci\303\263n/Mapa_con_Leaflet/js/javascript.js"
index c6e7bfef..69be5b62 100644
--- "a/Miguel/Ejercicios_Geolocalizaci\303\263n/Mapa_con_Leaflet/js/javascript.js"
+++ "b/Miguel/Ejercicios_Geolocalizaci\303\263n/Mapa_con_Leaflet/js/javascript.js"
@@ -1,8 +1,4 @@
-//Ejercicio ubicacion en el mapa con Leaflet.
-//Variables para guardar la latitud y la longitud del ordenador.
-var lat;
-var lon;
-
+//Ejercicio ubicación en el mapa con Leaflet.
//Crear icono de leaflet
var redIcon = L.icon({
iconUrl: 'https://leafletjs.com/examples/custom-icons/leaf-red.png',
@@ -15,15 +11,15 @@ var redIcon = L.icon({
});
//Promesa para comprobar acceso a la geolocalización del ordenador y obtener su latitud y longitud.
-function miPromesa(){
+function getGeolocation(){
return new Promise(function(resolve,reject){
if("geolocation" in navigator){
console.log("Geolocalización disponible.");
navigator.geolocation.getCurrentPosition(function(position){
- resolve(
- lat = position.coords.latitude,
- lon = position.coords.longitude
- )
+ resolve({
+ lat: position.coords.latitude,
+ lon: position.coords.longitude
+ })
})
}else{
reject(console.warn("Error, geolocalización no disponible."))
@@ -33,22 +29,18 @@ function miPromesa(){
//Funcion que ejecuta la promesa, crea el mapa con la ubicación del ordenador y añade un marker.
(function(){
- miPromesa()
- .then(()=>{
+ getGeolocation()
+ .then((obj) => {
var map = L.map('map').
- setView([lat,lon],
+ setView([obj.lat,obj.lon],
20);
console.log(`Tus coordenadas geográficas son:
- Latitud: ${lat}
- Longitud: ${lon}`);
+ Latitud: ${obj.lat}
+ Longitud: ${obj.lon}`);
L.tileLayer('http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
attribution: 'Map data © OpenStreetMap contributors, CC-BY-SA , Imagery © CloudMade ',
maxZoom: 18
}).addTo(map);
- L.marker([lat, lon], {icon: redIcon}).addTo(map).bindPopup("Estas aquí!!");
+ L.marker([obj.lat, obj.lon], {icon: redIcon}).addTo(map).bindPopup("Estas aquí!!");
})
})();
-
-
-
-
diff --git "a/Miguel/Ejercicios_Geolocalizaci\303\263n/Transportes_LA/js/javascript.js" "b/Miguel/Ejercicios_Geolocalizaci\303\263n/Transportes_LA/js/javascript.js"
index 718f97e7..4dcf87cb 100644
--- "a/Miguel/Ejercicios_Geolocalizaci\303\263n/Transportes_LA/js/javascript.js"
+++ "b/Miguel/Ejercicios_Geolocalizaci\303\263n/Transportes_LA/js/javascript.js"
@@ -25,7 +25,7 @@ function initMap(){
}
//Función para hacer fetch de los datos de ubicación de los vehículos y llamar a la funcion markers().
-function llamada(url){
+function fetchVehiclesData(url){
fetch(url)
.then(res => res.json())
.then(data => {
@@ -54,7 +54,7 @@ function markers(arr){
}
//Llamada a la función del fetch.
-llamada(url);
+fetchVehiclesData(url);
//Función para actualizar las posiciones de los vehiculos cada 30 segundos y remover los markers y clusters antiguos.
setInterval(() => {
@@ -64,13 +64,6 @@ setInterval(() => {
}
markersArr = [];
markerCluster.clearMarkers();
- llamada(url);
- console.log("Posición de los vehículos refrescada.");
+ fetchVehiclesData(url);
},30000
)
-
-
-
-
-
-
diff --git a/Miguel/Firebase_Authentication/index.html b/Miguel/Firebase_Authentication/index.html
index 931f25a5..c029949c 100644
--- a/Miguel/Firebase_Authentication/index.html
+++ b/Miguel/Firebase_Authentication/index.html
@@ -36,6 +36,6 @@ Lista de Usuarios
-
+