-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcargaEmergencia.html
More file actions
62 lines (55 loc) · 2.02 KB
/
cargaEmergencia.html
File metadata and controls
62 lines (55 loc) · 2.02 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>CARGA DE EMERGENCIA </title>
<!-- <link rel="icon" type="image/png" href="./IMG/"> -->
<style>
*{
font-size: 1vw;
font-family: Arial, Helvetica, sans-serif;
}
tr:nth-child(odd) {
background-color: #ddd;
}
</style>
</head>
<body>
<div>
<h1>carga</h1>
<button id="cargar" tabindex="-1">Carga Llamadas</button>
<input type="file" id="archivo" style="display:none" tabindex="-1"><br>
</div>
<script>
// Manejador del evento click del botón "Cargar archivo JSON"
document.getElementById("cargar").addEventListener("click", function() {
// Hacer clic en el input file para abrir el selector de archivos
document.getElementById("archivo").click();
});
//RECUPERA EN LOCAL STORAGE LAS LLAMADAS DESDE ARCHVO JSON
document.getElementById("archivo").addEventListener("change", function() {
// Obtener el archivo seleccionado
let archivo = this.files[0];
// Leer el contenido del archivo como texto
var lector = new FileReader();
lector.onload = function() {
debugger
// Parsear el contenido del archivo como un objeto JSON
let listaLLamadas = JSON.parse(lector.result);
//calculo numero de llamadas
let totalLLamadas=listaLLamadas.length
// Almacenar la lista de personas en Local Storage
localStorage.setItem("llamadas", JSON.stringify(listaLLamadas));
// Mostrar un mensaje de éxito
alert("Archivo cargado con éxito, Hay "+totalLLamadas+" Llamadas");
}
lector.readAsText(archivo);
});
// Manejador del evento click del botón "Cargar archivo JSON"
document.getElementById("cargar").addEventListener("click", function() {
// Hacer clic en el input file para abrir el selector de archivos
document.getElementById("archivo").click();
});
</script>
</body>
</html>