-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
144 lines (128 loc) · 5.43 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Imagenes Random Desde API</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha384-DfXdz2htPH0lsSSs5nCTpuj/zy4C+OGpamoFVy38MVBnE+IbbVYUew+OrCXaRkfj" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js" integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI" crossorigin="anonymous"></script>
<link href="https://fonts.googleapis.com/css2?family=Michroma&display=swap" rel="stylesheet">
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.26.0/moment.min.js" integrity="sha256-5oApc/wMda1ntIEK4qoWJ4YItnV4fBHMwywunj8gPqc=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.26.0/locale/es.js"></script>
<style>
body {
background-color: black;
}
#reloj, h2{
font-family: 'Michroma', sans-serif;
font-size: 35px;
}
h2{
font-family: 'Michroma', sans-serif;
font-size: 20px;
}
</style>
</head>
<body>
<div class="mx-5">
<div class="row">
<div class="col-md-8">
<img class="img-fluid mt-3" id="imagen" src="https://picsum.photos/800/600?grayscale">
</div>
<div class="col-md-4">
<h2 class="text-white text-center mt-3" id="saludo"></h2>
<div>
<h3 id="fecha" class="text-white text-center"></h3>
</div>
<div>
<h1 id="reloj" class="text-white text-center">TIME</h1>
</div>
<div>
<h2 class="mt-5 text-white">Consejo del Dia:</h2>
<p id="consejo" class="text-muted text-white">El Consejo va aqui.</p>
<button class="btn btn-light" onclick="consejoDelDia()">Nuevo Consejo</button>
</div>
<div>
<h2 class="mt-5 text-white">Para Informáticos:</h2>
<p id="frase" class="text-muted text-white">Frase.</p>
<button class="btn btn-light" onclick="paraInformaticos()">Nueva Frase</button>
</div>
<div class="mt-5 row"><hr>
<div class="col">
<a href="#" class="text-white" onclick="mostrarOcultar()">Personalizar</a>
<div id="personalizar">
<input type="text" id="mifrase">
<button class="btn btn-light btn-sm" onclick="actualizar()">Guardar</button>
</div>
</div>
<div class="col">
<a class="text-white mt-5" href="https://github.com/arnoldou/random-image-api-clock-momentjs-bootstrap">@arnoldou</a>
</div>
</div>
</div>
</div>
</div>
<script>
document.getElementById('personalizar').style.display = "none"
document.getElementById('fecha').innerHTML = moment().format('dddd Do MMMM YYYY');
document.getElementById('saludo').innerHTML = localStorage.getItem('mifrase')
if(document.getElementById('saludo').innerHTML == ""){
document.getElementById('saludo').innerHTML = "Hola Amigo."
}
document.getElementById('mifrase').value = localStorage.getItem('mifrase')
imagen = document.getElementById('imagen')
fecha = document.getElementById('fecha')
setInterval(imagenRandom, 5000)
setInterval(()=>document.getElementById('reloj').innerHTML = moment().format('h:mm:ss a'), 1000)
function imagenRandom(){
fetch('https://picsum.photos/800/600?grayscale')
.then(function(response){
imagen.src= response.url
})
.catch(function(err){
console.log(err)
})
}
function consejoDelDia(){
fetch('https://api.adviceslip.com/advice')
.then((response)=>response.json())
.then(function(res){
document.getElementById('consejo').innerHTML = res.slip.advice
})
.catch(function(error){
console.log(error)
})
}
function paraInformaticos(){
fetch('https://geek-jokes.sameerkumar.website/api')
.then((response)=>response.json())
.then(function(resp){
document.getElementById('frase').innerHTML = resp
})
.catch(function(error){
console.log(error)
})
}
function mostrarOcultar(){
personalizar = document.getElementById('personalizar')
if(personalizar.style.display == 'none'){
personalizar.style.display = 'block'
}else {
personalizar.style.display = 'none'
}
}
function actualizar(){
mifrase = document.getElementById('mifrase')
localStorage.setItem('mifrase', mifrase.value);
saludo.innerHTML = localStorage.getItem('mifrase')
personalizar.style.display = 'none'
}
window.onload = function(){
consejoDelDia();
paraInformaticos();
}
</script>
</body>
</html>