-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
291 lines (263 loc) · 10.2 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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
<!DOCTYPE html>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script type="text/javascript" src="js/jquery-3.3.1.min.js"> </script><!Jquery >
<script type="text/javascript" src="js/bootstrap.min.js"> </script><!bootstrap 4 >
<link rel="stylesheet" type="text/css" href="css/bootstrap.css">
<style>
body{
background-color: black;
// background: linear-gradient(to bottom, #7d7e7d 0%,#0e0e0e 100%);
}
div.BotonCalc {
COLOR: White;
border-radius: 20px;
//border: 1px solid White;
padding: 10px;
font-size:7vw;
}
div.Igual {
COLOR: White;
border-radius: 25px;
border: 1px solid White;
padding: 15px;
font-size:8vw;
font-weight: bold;
}
.navbar-toggler{
animation-name: Apaga;
animation-duration: 2s;
}
@keyframes Apaga {
from {background-color:white;}
to {background-color: black;}
}
textarea.form-control {
background : black;
COLOR: White;
border-radius: 20px;
//border: 1px solid White;
//padding: 10px;
font-size:5vw;
text-align: right;
}
.form-control[readonly].no-gray {
background-color : black;
}
.btn-link{
background-color : black;
background : black;
COLOR: White;
text-decoration: none;//para quitar el azul de liga visitada
}
div.card{
background-color : black;
background : black;
COLOR: White;
}
.btn:focus, .btn-success:focus{
COLOR: White;
}
</style>
<html>
<head>
<title>Yakkalc la calculadora que siempre quise</title>
</head>
<body>
<nav class="navbar navbar-dark bg-black">
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarNav" aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<span class="navbar-brand mb-0 h1">Yakkalc</span>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav">
<li class="nav-item active">
<a class="nav-link" href="index.html">Calculadora<span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="convert.html">Conversiones</a>
</li>
<li class="nav-item">
<a class="nav-link" href="porcentajes.html">Porcentajes</a>
</li>
<li class="nav-item">
<a class="nav-link " href="reglade3.html">Regla de tres</a>
</li>
<li class="nav-item">
<a class="nav-link " href="notas.html">Notas</a>
</li>
<li class="nav-item">
<a class="nav-link " href="acercade.html">Acerca de ...</a>
</li>
</ul>
</div>
</nav>
<!**************************Historial********************************>
<style>
#Historial{
background:green;
transition:background 2s ease;
}
</style>
<div class="accordion" id="Historial">
<div class="card">
<div class="card-header" id="headingOne">
<h5 class="mb-0">
<button class="btn btn-link" type="button" data-toggle="collapse" data-target="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
Historial
</button>
</h5>
<div id="collapseOne" class="collapse show" aria-labelledby="headingOne" data-parent="#Historial">
<div class="card-body" id = "Historia">
</div>
</div>
</div>
</div>
</div>
<div class="container-fluid h-100" >
<!****************Resultado**********************>
<div class="form-group">
<textarea class="form-control no-gray" id="Result" rows = "3" readonly>0</textarea>
</div>
<!****************SQRT X**N X2 CE *********************>
<div class="row container-fluid h-100" align="center" >
<div onclick = "Calculadora('RC')" class="col-3 h-100 BotonCalc">√</div><!Raiz cuadrada >
<div onclick = "Calculadora('X2')" class="col-3 h-100 BotonCalc">x^2</div>
<div onclick = "Calculadora('Rev')"class="col-3 h-100 BotonCalc">⇐ </div><!borrar ultimo caracter>
<div onclick = "Calculadora('CE')" class="col-3 h-100 BotonCalc">C</div>
</div>
<!****************N! % PI 10x *********************>
<div class="row container-fluid h-100" align="center" >
<div onclick = "Calculadora('M1')" class="col-3 h-100 BotonCalc">M1</div>
<div onclick = "Calculadora('%')" class=" col-3 h-100 BotonCalc">%</div>
<div onclick = "Calculadora('PI')" class="col-3 h-100 BotonCalc">∏ </div><!PI 3.1416>
<div onclick = "Calculadora('/')" class=" col-3 h-100 BotonCalc">➗ </div>
</div>
<!****************7 8 9 * **********************>
<div class="row container-fluid h-100" align="center" >
<div onclick = "Calculadora('7')" class="col-3 h-100 BotonCalc">7</div>
<div onclick = "Calculadora('8')" class="col-3 h-100 BotonCalc">8</div>
<div onclick = "Calculadora('9')" class="col-3 h-100 BotonCalc">9</div>
<div onclick = "Calculadora('*')" class="col-3 h-100 BotonCalc">X</div>
</div>
<!****************4 5 6 - **********************>
<div class="row container-fluid h-100" align="center" >
<div onclick = "Calculadora('4')" class="col-3 h-100 BotonCalc">4</div>
<div onclick = "Calculadora('5')" class="col-3 h-100 BotonCalc">5</div>
<div onclick = "Calculadora('6')" class="col-3 h-100 BotonCalc">6</div>
<div onclick = "Calculadora('-')" class="col-3 h-100 BotonCalc">-</div>
</div>
<!****************1 2 3 + **********************>
<div class="row container-fluid h-100" align="center" >
<div onclick = "Calculadora('1')" class="col-3 h-100 BotonCalc">1</div>
<div onclick = "Calculadora('2')" class="col-3 h-100 BotonCalc">2</div>
<div onclick = "Calculadora('3')" class="col-3 h-100 BotonCalc">3</div>
<div onclick = "Calculadora('+')" class="col-3 h-100 BotonCalc">+</div>
</div>
<!**************** ( ) 0 . **********************>
<div class="row container-fluid h-100" align="center" >
<div onclick = "Calculadora('(')" class="col-3 h-100 BotonCalc">(</div>
<div onclick = "Calculadora(')')" class="col-3 h-100 BotonCalc">)</div>
<div onclick = "Calculadora('0')" class="col-3 h-100 BotonCalc">0</div>
<div onclick = "Calculadora('.')" class="col-3 h-100 BotonCalc">.</div>
</div>
<!****************=**********************>
<div class="row container-fluid h-100" align="center">
<div onclick = "Calculadora('=')" class="col-12 h-100 Igual">=</div>
</div>
</div> <! del container >
</body>
<footer>
</footer>
</html>
<script>
m1 = 0;//inicializamos la variable m1 con 0
//colapsamos el historial que viene abierto por default
$('#collapseOne').collapse({
toggle: true
})
function Historia(res){
hist = document.getElementById("Historia").innerHTML ;
hist = hist + res;
document.getElementById("Historia").innerHTML = hist;
}
function Calculadora(p){
var res = document.getElementById("Result").innerHTML;
if (res == '0'){ res = ''};
switch(p){
case '+':// Suma
// res = eval(res);//Evaluamos antes de operar
break;
case '-':// Resta
//res = eval(res);//Evaluamos antes de operar
break;
case '*':// Multiplicación
//res = eval(res);//Evaluamos antes de operar
break;
case '/':// División
//res = eval(res);//Evaluamos antes de operar
break;
case 'CE'://Cero borrar
res = '0';
p = '';
Historia( "Borrado = 0" + "<br>" );
break;
case '=':// Evaluar Resultado
try{
Historia( res );
res = eval(res);
Historia( "=" + res + "<br>" );
}catch(e){
alert('Error de Expresión');
res='';
}
p='';
break;
case 'RC'://Raiz Cuadrada
res = eval(res);
Historia( "Raiz de " + res + "=" );
p = Math.sqrt(res);
if ( isNaN( p ) == true ) {
alert ('No se puede Obtener la Raiz de '+ res);
p = '';
}
Historia( p + "<BR>" );
res='';
break;
case 'PI'://PI
p = '3.141592653';
break;
case 'X2'://X Cuadrada
res = eval(res);
Historia( res + "Al cuadrado = " );
p = res * res;
Historia( p + "<BR>" );
res = '';
break;
case 'Rev'://Borra último caracter
res = res.substring(0, res.length-1);
if (res=='' ) res = '0';
p= '';
break;
case '%'://Porcentajes
res = eval(res);
res = res / 10;
p= '';
break;
case 'M1'://sube y baja de memoria
if (m1 != 0){ //si hay algo en la memoria
p = m1;
alert('Se recuperó el valor '+ m1 + ' la memoria se encuentra ahora vacía');
m1 = 0;
}else {// si no hay ya nada en la memoria
res = eval(res);
m1 = res;
alert('Se guarda en la memoria el valor '+ m1);
p = '';
}
break;
}
res += p;
document.getElementById("Result").innerHTML = res;
}//del function calculadora
</script>