Se modifican funciones para manejar los datos
parent
0d9d568786
commit
2f8c4a0ebb
|
@ -58,12 +58,13 @@
|
||||||
|
|
||||||
// Función para obtener un color aleatorio de la lista
|
// Función para obtener un color aleatorio de la lista
|
||||||
function getColorAleatorio(index) {
|
function getColorAleatorio(index) {
|
||||||
return colores[index];
|
return colores[index%6];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Función para calcular la diferencia en minutos entre la hora actual y la hora planificada
|
// Función para calcular la diferencia en minutos entre la hora actual y la hora planificada
|
||||||
function calcularDiferenciaMinutos(horaPlanificada) {
|
function calcularDiferenciaMinutos(horaPlanificada) {
|
||||||
const horaActual = new Date();
|
const horaActual = new Date();
|
||||||
|
|
||||||
const horaPlanificadaArray = horaPlanificada.split(':');
|
const horaPlanificadaArray = horaPlanificada.split(':');
|
||||||
const horaPlanificadaDate = new Date(
|
const horaPlanificadaDate = new Date(
|
||||||
horaActual.getFullYear(),
|
horaActual.getFullYear(),
|
||||||
|
@ -74,7 +75,8 @@
|
||||||
);
|
);
|
||||||
|
|
||||||
const diferenciaMilisegundos = horaPlanificadaDate.getTime() - horaActual.getTime();
|
const diferenciaMilisegundos = horaPlanificadaDate.getTime() - horaActual.getTime();
|
||||||
const diferenciaMinutos = Math.floor(diferenciaMilisegundos / (1000 * 60));
|
const diferenciaMinutos = Math.abs(Math.floor(diferenciaMilisegundos / (1000 * 60)));
|
||||||
|
console.log(diferenciaMinutos)
|
||||||
|
|
||||||
return diferenciaMinutos;
|
return diferenciaMinutos;
|
||||||
}
|
}
|
||||||
|
@ -93,6 +95,37 @@
|
||||||
return "Más de 10 minutos";
|
return "Más de 10 minutos";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
function LetraoNumeroMicro(cadena, flag) {
|
||||||
|
if (!cadena || (flag !== 0 && flag !== 1)) {
|
||||||
|
return "Error: Entrada no válida";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Extraer el número y la letra
|
||||||
|
let numero = "";
|
||||||
|
let letra = "";
|
||||||
|
let i = 0;
|
||||||
|
|
||||||
|
// Obtener el número
|
||||||
|
while (i < cadena.length && !isNaN(parseInt(cadena[i]))) {
|
||||||
|
numero += cadena[i];
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Obtener la letra (si hay)
|
||||||
|
while (i < cadena.length) {
|
||||||
|
letra += cadena[i];
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flag === 0) {
|
||||||
|
return numero ? parseInt(numero) : "Error: No se encontró un número";
|
||||||
|
} else if (flag === 1) {
|
||||||
|
return letra ? letra : "Error: No se encontró una letra";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
@ -226,7 +259,7 @@
|
||||||
<div class="cuadricula">
|
<div class="cuadricula">
|
||||||
{#if paraderoData}
|
{#if paraderoData}
|
||||||
|
|
||||||
|
<!--
|
||||||
{#each paraderoData.DetalleLineas as linea}
|
{#each paraderoData.DetalleLineas as linea}
|
||||||
{#each linea.Llegadas as llegada,index}
|
{#each linea.Llegadas as llegada,index}
|
||||||
<div class="rectangulo-pequeno" >
|
<div class="rectangulo-pequeno" >
|
||||||
|
@ -236,6 +269,14 @@
|
||||||
</div>
|
</div>
|
||||||
{/each}
|
{/each}
|
||||||
{/each}
|
{/each}
|
||||||
|
-->
|
||||||
|
{#each paraderoData.DetalleLineas as linea,index}
|
||||||
|
<div class="rectangulo-pequeno" >
|
||||||
|
<div class="numero-micro">{LetraoNumeroMicro(linea.Descripcion,0)}</div>
|
||||||
|
<div class="circulo-letra" style="background-color: {getColorAleatorio(index)}">{LetraoNumeroMicro(linea.Descripcion,1)}</div>
|
||||||
|
<div class="hora" style="background-color: {getColorAleatorio(index)}">{obtenerTextoHora(linea.Llegadas[0].EstimadaGPS)} </div>
|
||||||
|
</div>
|
||||||
|
{/each}
|
||||||
|
|
||||||
{:else}
|
{:else}
|
||||||
<p>Cargando datos...</p>
|
<p>Cargando datos...</p>
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
import { base,getToken } from './config'
|
import { base,getToken } from './config'
|
||||||
|
|
||||||
export async function getAplicacion(id) {
|
export async function getAplicacion(id) {
|
||||||
const res = await fetch(`${base}/paradero_info/?id=${id}/`, {
|
const res = await fetch(`${base}/paradero_info/?id=${id}`, {
|
||||||
headers: { "Authorization": `Bearer ${getToken()}`, "Content-Type": "application/json" }
|
headers: { "Authorization": `Bearer ${getToken()}`, "Content-Type": "application/json" }
|
||||||
})
|
})
|
||||||
if (!res.ok) throw await res.json()
|
if (!res.ok) throw await res.json()
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
// vite.config.js
|
||||||
|
import { defineConfig } from "file:///app/node_modules/vite/dist/node/index.js";
|
||||||
|
import { svelte } from "file:///app/node_modules/@sveltejs/vite-plugin-svelte/src/index.js";
|
||||||
|
var vite_config_default = defineConfig({
|
||||||
|
plugins: [svelte()]
|
||||||
|
});
|
||||||
|
export {
|
||||||
|
vite_config_default as default
|
||||||
|
};
|
||||||
|
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsidml0ZS5jb25maWcuanMiXSwKICAic291cmNlc0NvbnRlbnQiOiBbImNvbnN0IF9fdml0ZV9pbmplY3RlZF9vcmlnaW5hbF9kaXJuYW1lID0gXCIvYXBwXCI7Y29uc3QgX192aXRlX2luamVjdGVkX29yaWdpbmFsX2ZpbGVuYW1lID0gXCIvYXBwL3ZpdGUuY29uZmlnLmpzXCI7Y29uc3QgX192aXRlX2luamVjdGVkX29yaWdpbmFsX2ltcG9ydF9tZXRhX3VybCA9IFwiZmlsZTovLy9hcHAvdml0ZS5jb25maWcuanNcIjtpbXBvcnQgeyBkZWZpbmVDb25maWcgfSBmcm9tICd2aXRlJ1xuaW1wb3J0IHsgc3ZlbHRlIH0gZnJvbSAnQHN2ZWx0ZWpzL3ZpdGUtcGx1Z2luLXN2ZWx0ZSdcblxuLy8gaHR0cHM6Ly92aXRlanMuZGV2L2NvbmZpZy9cbmV4cG9ydCBkZWZhdWx0IGRlZmluZUNvbmZpZyh7XG4gIHBsdWdpbnM6IFtzdmVsdGUoKV0sXG59KVxuIl0sCiAgIm1hcHBpbmdzIjogIjtBQUE4TCxTQUFTLG9CQUFvQjtBQUMzTixTQUFTLGNBQWM7QUFHdkIsSUFBTyxzQkFBUSxhQUFhO0FBQUEsRUFDMUIsU0FBUyxDQUFDLE9BQU8sQ0FBQztBQUNwQixDQUFDOyIsCiAgIm5hbWVzIjogW10KfQo=
|
|
@ -0,0 +1,10 @@
|
||||||
|
// vite.config.js
|
||||||
|
import { defineConfig } from "file:///app/node_modules/vite/dist/node/index.js";
|
||||||
|
import { svelte } from "file:///app/node_modules/@sveltejs/vite-plugin-svelte/src/index.js";
|
||||||
|
var vite_config_default = defineConfig({
|
||||||
|
plugins: [svelte()]
|
||||||
|
});
|
||||||
|
export {
|
||||||
|
vite_config_default as default
|
||||||
|
};
|
||||||
|
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsidml0ZS5jb25maWcuanMiXSwKICAic291cmNlc0NvbnRlbnQiOiBbImNvbnN0IF9fdml0ZV9pbmplY3RlZF9vcmlnaW5hbF9kaXJuYW1lID0gXCIvYXBwXCI7Y29uc3QgX192aXRlX2luamVjdGVkX29yaWdpbmFsX2ZpbGVuYW1lID0gXCIvYXBwL3ZpdGUuY29uZmlnLmpzXCI7Y29uc3QgX192aXRlX2luamVjdGVkX29yaWdpbmFsX2ltcG9ydF9tZXRhX3VybCA9IFwiZmlsZTovLy9hcHAvdml0ZS5jb25maWcuanNcIjtpbXBvcnQgeyBkZWZpbmVDb25maWcgfSBmcm9tICd2aXRlJ1xuaW1wb3J0IHsgc3ZlbHRlIH0gZnJvbSAnQHN2ZWx0ZWpzL3ZpdGUtcGx1Z2luLXN2ZWx0ZSdcblxuLy8gaHR0cHM6Ly92aXRlanMuZGV2L2NvbmZpZy9cbmV4cG9ydCBkZWZhdWx0IGRlZmluZUNvbmZpZyh7XG4gIHBsdWdpbnM6IFtzdmVsdGUoKV0sXG59KVxuIl0sCiAgIm1hcHBpbmdzIjogIjtBQUE4TCxTQUFTLG9CQUFvQjtBQUMzTixTQUFTLGNBQWM7QUFHdkIsSUFBTyxzQkFBUSxhQUFhO0FBQUEsRUFDMUIsU0FBUyxDQUFDLE9BQU8sQ0FBQztBQUNwQixDQUFDOyIsCiAgIm5hbWVzIjogW10KfQo=
|
Loading…
Reference in New Issue