-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
233 lines (188 loc) · 7.43 KB
/
script.js
File metadata and controls
233 lines (188 loc) · 7.43 KB
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
// info date
const dateText = document.getElementById("dateText");
const dateNumber = document.getElementById("dateNumber");
const dateMonth = document.getElementById("dateMonth");
const dateYear = document.getElementById("dateYear");
const tasksContainer = document.getElementById("tasksContainer");
const daysOfWeek = ["Ene", "Feb", "Mar", "Abr", "May", "Jun", "Jul", "Ago", "Sep", "Oct", "Nov", "Dic"]
const date = new Date();
console.log("la variable date es: " + date)
console.log('la funcion "toLocaleString" de date es: ' + date.toLocaleString())
const setDate = () => {
// se usan las variables que usan el document.getElementById("xxxxx") y les setea un valor basado en la fecha actual
dateText.textContent = setWeedDay(date);
dateNumber.textContent = date.getDate();
dateMonth.textContent = daysOfWeek[date.getMonth()];
dateYear.textContent = date.getFullYear();
// ********* Otra manera de hacerlo es así: **********
//dateText.textContent = date.toLocaleString('es', {weekday: 'long'});
//dateNumber.textContent = date.toLocaleString('es', {day: 'numeric'});
//dateMonth.textContent = date.toLocaleString('es', {month: 'short'});
//dateYear.textContent = date.toLocaleString('es', {year: 'numeric'});
}
const setWeedDay = (date) => {
const day = date.getDay();
switch (day) {
case 0:
return "Domingo"
break;
case 1:
return "Lunes"
break;
case 2:
return "Martes"
break;
case 3:
return "Miércoles"
break;
case 4:
return "Jueves"
break;
case 5:
return "Viernes"
break;
case 6:
return "Sábado"
break;
default:
break;
}
}
const addNewTask = (event) => {
event.preventDefault();
const { value } = event.target.taskText;
if (!value) return;
const task = document.createElement('div');
task.classList.add('task', 'roundBorder');
task.addEventListener('click', changeTaskState);
task.textContent = value;
tasksContainer.prepend(task);
event.target.reset();
}
const changeTaskState = event => {
event.target.classList.toggle('done');
}
const order = () => {
const done = [];
const toDo = [];
tasksContainer.childNodes.forEach(el => {
el.classList.contains('done') ? done.push(el) : toDo.push(el);
})
return [...toDo, ...done];
}
const renderOlderedTasks = () => {
order().forEach(el => tasksContainer.appendChild(el))
}
setDate();
const abcarr = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "0", "1", "2", "3", "4", "5", "6", "7", "8", "9"]
const abcDEFarr = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "_", "-", "/", "!", "@", "#", "$", "%", "&", "?", ";", ":", "(", ")", "*", "+" ]
const compArr = abcarr.concat(abcDEFarr)
const abc = () => {
const start = new Date();
let times = 0
for (let a = 0; a < abcarr.length ; a++) {
for (let b = 0; b < abcarr.length; b++) {
for (let c = 0; c < abcarr.length; c++) {
// solo con 3 digitos... si se quiere con 4 se deben eliminar las siguientes 2 lineas y descomentar el siguiente for
console.log(abcarr[a] + abcarr[b] + abcarr[c] + abcarr[d])
times += 1;
// for (let d = 0; d < abcarr.length; d++) {
// console.log(abcarr[a] + abcarr[b] + abcarr[c] + abcarr[d])
// times += 1;
// }
}
}
}
const end = new Date();
console.log("*******************************")
console.log(times)
console.log(start)
console.log(end)
console.log(end.getTime() - start.getTime(), "ms");
}
function hacerCodigoIPV6 () {
function mathr() {
return Math.ceil(Math.random()*35)
}
const ramdomly = () => {
const a = abcarr[mathr()] + abcarr[mathr()] + abcarr[mathr()] + abcarr[mathr()]
return a
}
for (let i = 0; i < 100 ; i++){
console.log(`${ramdomly()}:${ramdomly()}:${ramdomly()}:${ramdomly()}:${ramdomly()}:${ramdomly()}`)
}
}
function generadorClavesGoogle () {
for (let i = 0; i < 100 ; i++){
const ramdomly = () => {
return compArr[Math.ceil(Math.random()*77)]
}
console.log(`${ramdomly()}${ramdomly()}${ramdomly()}${ramdomly()}${ramdomly()}${ramdomly()}${ramdomly()}${ramdomly()}${ramdomly()}${ramdomly()}${ramdomly()}${ramdomly()}${ramdomly()}${ramdomly()}${ramdomly()}`)
}
}
//abc()
//hacerCodigoIPV6();
//generadorClavesGoogle();
const changeColor = document.querySelector("#changeColor")
function random(number) {
return Math.floor(Math.random() * (number+1));
}
/** NO SE REOOMIENTA USAR LA PROPIEDAD .onclick EN UN ELEMENTO, SOLO PERMITE TENER MANEJADOR DE EVENTOS EN DICHO BOTON */
// changeColor.onclick = () => {
// const rndCol = `rgb(${random(255)}, ${random(255)}, ${random(255)})`;
// document.body.style.backgroundColor = rndCol;
// };
/** ES MEJOR USAR addEventListener YA QUE PERMITE TENER VARIOS MANEJADORES PARA UN EVENTO
changeColor.addEventListener("click", () => {
const rndCol = `rgb(${random(255)}, ${random(255)}, ${random(255)})`;
document.body.style.backgroundColor = rndCol;
});
// EN ESTE CASO: 1 Se asignó la funcion de cambiar backgroundColor arriba y en esta se le asigna una nueva fucnion de cambiar color de la fuente
changeColor.addEventListener("click", changeFontColor)
function changeFontColor () {
document.body.style.color = "red";
}
changeColor.addEventListener("click", btnEvent)
// esta funcion recibe como parametro directamente al evento
function btnEvent (e) {
e.preventDefault()
console.log(typeof(e));
console.log(e);
console.log(typeof(e.target.style));
e.target.i = "cambiado"
e.target.value = "p"
e.target.style.width = "300px"
e.target.style.height = "300px"
e.target.style.fontFamily = "impact"
console.dir(e.target);
}
*/
/** JUGANDO CON LOS METODOS DEL OBJETO
*
* const setDate = () => {
const date = new Date();
document.getElementById("dateText").textContent = date.getDay()
console.log("date: ", date)
console.log("date.toDateString: ", date.toDateString())
console.log("date.toJSON: ", date.toJSON())
console.log("getFullYear (año entero): ", date.getFullYear())
console.log("getMonth (mes 0 - 11): ", date.getMonth())
console.log("getHours (Hora 0 - 23): ", date.getHours())
console.log("getDate (dia del mes): ", date.getDate())
console.log("getDay (# dia de la semana): ", date.getDay())
console.log("getUTCHours (Hora 0 - 23): ", date.getUTCHours())
console.log("getMinutes (minutos 0 - 59): ", date.getMinutes())
console.log("getSeconds (segundos 0 - 59): ", date.getSeconds())
console.log("getMilliseconds (milisegundos 0 - 999): ", date.getMilliseconds())
console.log("getTime (valor numerico de la fecha desde 1 Ene 1970): ", date.getTime())
console.log("getTimezoneOffset (diferncia en minutos con UTC): ", date.getTimezoneOffset())
}
setDate()
const newDate = new Date;
newDate.setDate(2);
newDate.setMonth(9);
newDate.setFullYear(1985);
console.log("newDate: " + newDate)
const birthdayWilson = new Date(1985, 9, 2 )
console.log("birthdayWilson: ", birthdayWilson )
*/