diff --git a/img/blue-bus-180-hi.png b/img/blue-bus-180-hi.png new file mode 100644 index 0000000..24abfec Binary files /dev/null and b/img/blue-bus-180-hi.png differ diff --git a/img/relojRojo.png b/img/relojRojo.png new file mode 100644 index 0000000..3f58103 Binary files /dev/null and b/img/relojRojo.png differ diff --git a/js/index.js b/js/index.js index 1b16c78..816d867 100644 --- a/js/index.js +++ b/js/index.js @@ -4769,8 +4769,8 @@ function imgConverter(url) { trueUrl = 'https://www.emtusahuelva.com/' + url } } else { - if (url.indexOf('http://www.emtusahuelva') != 1) { - trueUrl = url.replace('http', 'https') + if (url.indexOf('http://www.emtusahuelva') == 0) { + trueUrl = url.replace('http://', 'https://') } else { trueUrl = url } diff --git a/slick/index.js b/slick/index.js deleted file mode 100644 index 1b16c78..0000000 --- a/slick/index.js +++ /dev/null @@ -1,6227 +0,0 @@ -//Variables -var urlDatos = 'https://datos.emtusahuelva.es/' -var urlMapas = 'https://osm.tecnosis.net/' -var urlRutas = 'https://osrm.tecnosis.net/' -var urlNomin = 'https://nominatim.tecnosis.net/' -var urlSrch = 'https://katon.tecnosis.net/api?' -var version = parseFloat(0.35).toFixed(2); -var tiempoRecargaMilis = 15000; -var servidor = 's=0'; -var storage; -var online = true; -var plataforma = "web"; -var lineaSelecionada; -var codParadaMasCercana = null; var codParadaMasCercana2 = null; -String.prototype.toHHorMMorSS = function () { - var time; - var sec_num = parseInt(this, 10); - var hours = Math.floor(sec_num / 3600); - var minutes = Math.floor((sec_num - (hours * 3600)) / 60); - var seconds = sec_num - (hours * 3600) - (minutes * 60); - - hours = hours - minutes = ("0" + minutes).slice(-2); - seconds = ("0" + seconds).slice(-2); - - if (hours > 00) { - if (hours == 1) { - time = '1 hora ' - } else { - time = hours + ' horas ' - } - time += minutes + ' min.'; - } else if (minutes != "00") { - time = minutes + ' min.'; - } else if (parseInt(seconds) > 0) { - //time = 'Llegando…'; - time = "Próxima Llegada" - } else { - time = 'En Parada';// + '(' + seconds + 'seg)' - } - return time; -} -String.prototype.toHHMMorMMSS = function () { - var time; - var sec_num = parseInt(this, 10); - var hours = Math.floor(sec_num / 3600); - var minutes = Math.floor((sec_num - (hours * 3600)) / 60); - var seconds = sec_num - (hours * 3600) - (minutes * 60); - - hours = ("0" + hours).slice(-2); - minutes = ("0" + minutes).slice(-2); - seconds = ("0" + seconds).slice(-2); - - if (hours == "00") { - time = minutes + 'm ' + seconds + "s"; - } else { - time = hours + 'h ' + minutes + 'm '; - } - return time; -} -String.prototype.toHHMMSS = function () { - var sec_num = parseInt(this, 10); - var hours = Math.floor(sec_num / 3600); - var minutes = Math.floor((sec_num - (hours * 3600)) / 60); - var seconds = sec_num - (hours * 3600) - (minutes * 60); - - if (hours < 10) { - hours = "0" + hours; - } - if (minutes < 10) { - minutes = "0" + minutes; - } - if (seconds < 10) { - seconds = "0" + seconds; - } - var time = hours + ':' + minutes + ':' + seconds; - return time; -} -Array.prototype.unique = function (a) {//array sin repetidos - return function () { return this.filter(a) } -}(function (a, b, c) { return c.indexOf(a, b + 1) < 0 }); -(function ($) { - $.each(['show', 'hide'], function (i, ev) { - var el = $.fn[ev]; - $.fn[ev] = function () { - this.trigger(ev); - return el.apply(this, arguments); - }; - }); -})(jQuery); -function toRadians(a) { - return (a * Math.PI / 180.0) -} -function pad(num, size) { - var s = num + ""; - while (s.length < size) s = "0" + s; - return s; -} -function getSeconds(horaA, horaB) { - var arrA = replaceAll(replaceAll(horaA, "/", " "), ":", " ").split(" ") - var arrB = replaceAll(replaceAll(horaB, "/", " "), ":", " ").split(" ") - var fechaA = new Date(arrA[2], parseInt(arrA[1]) - 1, arrA[0], arrA[3], arrA[4], arrA[5], 0) - var fechaB = new Date(arrB[2], parseInt(arrB[1]) - 1, arrB[0], arrB[3], arrB[4], arrB[5], 0) - var cambio = false; - if (fechaA.getTime() > fechaB.getTime()) { - var fechacop = fechaA - fechaA = fechaB - fechaB = fechacop - cambio = true; - } - calculo = (fechaB.getTime() - fechaA.getTime()) / 1000 - - return calculo -} -function replaceAll(text, busca, reemplaza) { - while (text.toString().indexOf(busca) != -1) { - text = text.toString().replace(busca, reemplaza); - } - return text; -} -function distanciaMetros(lat1, lon1, lat2, lon2) { - var R = 6371e3; // metres - var φ1 = toRadians(lat1); - var φ2 = toRadians(lat2); - var Δφ = toRadians((lat2 - lat1)); - var Δλ = toRadians((lon2 - lon1)); - - var a = Math.sin(Δφ / 2) * Math.sin(Δφ / 2) + - Math.cos(φ1) * Math.cos(φ2) * - Math.sin(Δλ / 2) * Math.sin(Δλ / 2); - var c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a)); - - var d = R * c; - return d -} -function CalculartiempoNormal(distancia, velocidad) { - var distmetros = 1; - var velocidadKilometros = 0.277777777777777777777777777777777777; - // calculamos tiempo en segundos - segundos = (distancia * distmetros) / (velocidad * velocidadKilometros); - // convert to hours, minutes, seconds - return segundos; -} -//////////////////////////////////////////////////////////////////////////FUNCIONES GENERALES//////////////////////////////////////////////////// -//#region general -function CheckPlataforma() { - if (typeof cordova != 'undefined') { - plataforma="cordova" - } -} -function SinConexion(restrictivo) { - //TODO: - if (restrictivo) { - LanzarSwalBasico("Sin Conexion", "Esta aplicación requiere conexión a internet para obtener datos importantes. Por favor active Wi-Fi o datos móviles e inténtelo de nuevo.") - $("#loadText").text("Esperando acceso a Internet") - $(".spinner") - } else { - $("#sinInternet").removeClass("conectado") - } -} -function ProblemaConexion(tipo, visible, texto) { - //TODO:Mejorar esta zona, porfa no uses if, pon un switch - if (tipo == 'CRASH') { - LanzarSwalBasico("Poblema al Conectar", "Ha ocurrido un problema al recibir datos del servidor, es posible que se encuentre en mantenimiento, vuelva a intentarlo más tarde y perdone las molestias ocasionadas") - $("#loadText").text("Por favor intentelo más tarde") - } else if (tipo == 'TIMEOUT') { - LanzarSwalBasico("Servidor Ocupado", "El servidor esta tardando demasiado en responder, puede encontrarse saturado debido a gran demanda por los usuarios, vuelva a intentarlo más tarde") - $("#loadText").text("Servidor ocupado, reintenteló más tarde") - } else if (tipo == 'DATOSCORRUPTOS') { - LanzarSwalBasico("Problema de compilación", texto) - } else { - LanzarSwalBasico("Error Inesperado", "Ha ocurrido un error, disculpe las molestias") - } -} -function AbrirMenu() { - $('#panelMenu').trigger('create'); - $('#' + $.mobile.activePage.attr('data-url')).append($('#panelMenu')); - $('#panelMenu').panel().panel("open"); -} -function AbrirPanel(idPanel) { - $('#' + idPanel).panel().panel('open'); -} -function CerrarPanel(idPanel) { - $('#' + idPanel).panel().panel('close'); -} -function ColorLuminance(hex, lum) { - if (hex.indexOf("rgb") > -1) { - var hex_rgb = hex.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/); - function hexa(x) { return ("0" + parseInt(x).toString(16)).slice(-2); } - if (hex_rgb) { - hex = "#" + hexa(hex_rgb[1]) + hexa(hex_rgb[2]) + hexa(hex_rgb[3]); - } - } - // validate hex string - hex = String(hex).replace(/[^0-9a-f]/gi, ''); - if (hex.length < 6) { - hex = hex[0] + hex[0] + hex[1] + hex[1] + hex[2] + hex[2]; - } - lum = lum || 0; - - // convert to decimal and change luminosity - var rgb = "#", c, i; - for (i = 0; i < 3; i++) { - c = parseInt(hex.substr(i * 2, 2), 16); - c = Math.round(Math.min(Math.max(0, c + (c * lum)), 255)).toString(16); - rgb += ("00" + c).substr(c.length); - } - - return rgb; -} -function ObtenerAbreviaturaMargen(codigo, backColor, foreColor) { - return '' + codigo + '' -} -function GetSeconds(horaA, horaB) { - var arrA = ReplaceAll(ReplaceAll(horaA, "/", " "), ":", " ").split(" ") - var arrB = ReplaceAll(ReplaceAll(horaB, "/", " "), ":", " ").split(" ") - var fechaA = new Date(arrA[2], parseInt(arrA[1]) - 1, arrA[0], arrA[3], arrA[4], arrA[5], 0) - var fechaB = new Date(arrB[2], parseInt(arrB[1]) - 1, arrB[0], arrB[3], arrB[4], arrB[5], 0) - var cambio = false; - if (fechaA.getTime() > fechaB.getTime()) { - var fechacop = fechaA - fechaA = fechaB - fechaB = fechacop - cambio = true; - } - calculo = (fechaB.getTime() - fechaA.getTime()) / 1000 - - return calculo -} -function tiempoNormal(seconds, permitir) { - var returnTiempo = "" - seconds = seconds.toString() - if (verHoraLlegada || permitir) { - returnTiempo = seconds.toHHMMorMMSS() - var tiempo = seconds.toHHMMSS().split(":") - var horaActual = new Date() - horaActual.setSeconds(horaActual.getSeconds() + parseInt(tiempo[2])); - horaActual.setMinutes(horaActual.getMinutes() + parseInt(tiempo[1])); - horaActual.setHours(horaActual.getHours() + parseInt(tiempo[0])); - - returnTiempo = " (" + pad(horaActual.getHours(), 2) + ":" + pad(horaActual.getMinutes(), 2) + ")" - } - return returnTiempo -} -function ReplaceAll(text, busca, reemplaza) { - text = text.toString() - while (text.indexOf(busca) != -1) { - text = text.replace(busca, reemplaza); - } - return text; -} -function BlinkElement() { - return window.setInterval(function () { - $('.blink').fadeTo('slow', 0.1).fadeTo('slow', 1.0); - }, 1000); -} -function LanzarSwalBasico(titulo, texto) { - Swal.fire({ - title: titulo, - text: texto, - allowOutsideClick: false, - }); -} -//#endregion general -///////////////////////////////////////////////////////////////////FUNCIONES DE CARGA E INICIALIZACION DE WEB/////////////////////////////////// -function WebCargada() { - //setTimeout(function () { - console.log("cargada") - $('body').toggleClass('loaded'); - //}, 3000); - //pruebas - //SinConexion(true) -} -CheckPlataforma() -if (plataforma == "web") { - $(document).ready(function () { - CargarApp() - }); -} else { - (function () { - "use strict"; - - document.addEventListener('deviceready', onDeviceReady.bind(this), false); - - function onDeviceReady() { - // Controlar la pausa de Cordova y reanudar eventos - document.addEventListener('pause', onPause.bind(this), false); - document.addEventListener('resume', onResume.bind(this), false); - //document.addEventListener('chcp_updateIsReadyToInstall', onUpdateReady(this), false); - //document.addEventListener('chcp_nothingToUpdate', nothingToUpdate(this), false); - // TODO: Cordova se ha cargado. Haga aquí las inicializaciones que necesiten Cordova. - var parentElement = document.getElementById('deviceready'); - codePush.sync(); - CargarApp() - - }; - - function onPause() { - // TODO: esta aplicación se ha suspendido. Guarde el estado de la aplicación aquí. - }; - - function onResume() { - // TODO: esta aplicación se ha reactivado. Restaure el estado de la aplicación aquí. - codePush.sync(); - }; - - function finalizarApp() { - - } - - //function onUpdateReady(){ - // console.log("La actualización está lista para instalar") - //} - //function nothingToUpdate() { - // console.log("Nada que actualizar, la aplicacion está actualizada") - //} - - })(); -} - -function CargarApp() { - //$("#popup").popup();//instanciamos el popup - - InicializarLocalStorage() - LimpiarLocalStorage() - LSMenuLineas = storage.get('MEN') - LSLineas = storage.get('ITI') - LSParadas = storage.get('PAR') - LSTrayectos = (storage.isSet('TRY')) ? storage.get('TRY').Tray : null - LSVerTodasLineas = storage.get('verTodasLineas') - LSReferenciadas = storage.get("Referenciadas") - LSUltLocalizacion = storage.get("lstLoc") - LSVerCercanas = (storage.isSet('LSVC')) ? storage.get('LSVC') : true - LSFecNot = storage.get("ultFN") - LSFavoritos = storage.get("FV") - if (storage.isSet("AB")) { - AlarmaBajadaActiva = true - AlarmaBajada = storage.get("AB") - } - layersSeleccionados = (storage.isSet('LS')) ? storage.get('LS') : []; - mostrarBus = (storage.isSet('MB')) ? storage.get('MB') : true; - verCorrespondencia = (storage.isSet('VC')) ? storage.get('VC') : true; - verHoraLlegada = (storage.isSet('VHL')) ? storage.get('VHL') : true; - favoritosInicio = (storage.isSet('FI')) ? storage.get('FI') : false; - vibracion = (storage.isSet('VB')) ? storage.get('VB') : true; - sonido = (storage.isSet('SN')) ? storage.get('SN') : true; - ComprobarVersion() - - //Para saber que version y plataforma estamos usando - if (storage.isSet("server")) { - servidor = storage.get("server") - } - if (storage.isSet("url")) { - urlDatos = storage.get("url") - } - InicializarListenersEventos() - ComprobarHashApp() - ObtenerNumeroNoticiasNuevas() -} -function InicializarListenersEventos() { - //TODO: Restricciones - //#region PAGESHOW - $(document).on("pageshow", "#pageInicio", function () { - //if (storage.isSet("PreguntarNoticias")) { - // if ((Date.parse(new Date()) - Date.parse(storage.get("PreguntarNoticias"))) >= 300000) { - // storage.set("PreguntarNoticias", new Date()) - // ObtenerNumeroNoticiasNuevas() - // console.log('Vuelta cuenta noticia') - // } - //} else { - // console.log('Primer cuenta noticia') - // storage.set("PreguntarNoticias", new Date()) - // ObtenerNumeroNoticiasNuevas() - //} - }); - $(document).on("pageshow", "#pageLinea", function () { - //if (!EstaRestringido(2)) { - if (storage.isSet('ITI')) { - MostrarLineasDisponibles() - } else { - LineasInexistententes() - } - //} else { - // AccesoRestringido(2) - //} - }); - $(document).on("pageshow", "#pageLineaVer", function () { - //if (!EstaRestringido(2)) { - if (storage.isSet('LineaVer')) { - DibujarLineaEsquema(); - } else { - $.mobile.changePage("#pageInicio"); - } - //} else { - // AccesoRestringido(2) - //} - }); - $(document).on("pageshow", "#pageMapa", function () { - //if (!EstaRestringido(3)) { - if (online) { - //TODO: mostrar mensajes? - //if (!storage.isSet('popMap') && !iraloc && !storage.isSet('LineaPpal')) { - // swal({ - // title: "Modo Mapa", - // text: 'Consulte lineas seleccionandolas a través del menu "Líneas" o marque su ubicación mediante el botón "Gestión"' - // }); - // storage.set('popMap', true) - //} - //TODO: haremos que el botón de localizarte parpadee cuando se sigue en tiempo real - //if (storage.isSet('popPanLoc')) { - // $("#headMapa span").removeClass('blink') - //} - try { - setTimeout(function () { - InicializarMapa(); - DibujarLineasSeleccionadas() - PedirAutobusesMapa() - }, 10);//200 - MostrarLineasMapaDisponibles() - } catch (err) { alert(err.message) }; - //setTimeout(function () { CargarSelectRutas(); }, 0); - //setTimeout(function () { CargarListaPuntosInteres() }, 10); - //setTimeout(function () { CargarListaPuntosInteresUsuario() }, 10); - //if (navigator.userAgent.match(/Trident/) || navigator.userAgent.match(/Windows Phone/i) || navigator.userAgent.match(/edge/i) || indexModo == "cordova") { - // $('#footerMapa').addClass("footerFix"); - //} - } else { - mapaCargado = false; - $("#mapCanvas").empty() - $("#mapCanvas").html('
aaaaaaa
' + -//'' + linea.NumP + ' Paradas. ' + comentario + '
' + - 'Pulse sobre las líneas para visualizarlas en el mapa
' - html += "
'
- } else {
- htmlGeo = '';
- }
- //comprobamos si hay bus o no, si no hay monstramos "sin información"
- if (!autobus) {
- htmlbus = '';
- } else {
- busPintados.push(autobus)
- if (autobus.tiempo < 179) {
- classBlink = 'blink ';
- blink = true
- } else {
- classBlink = '';
- }
-
- var partHora = [autobus.tiempo.toHHorMMorSS()]
- if (autobus.tiempo.toHHorMMorSS() != 'En Parada' && autobus.tiempo.toHHorMMorSS() != 'Próxima Llegada') {
- partHora = autobus.tiempo.toHHorMMorSS().split(' ');//autobus.tiempo
- }
- if (partHora.length >= 4) {
- time = '' + partHora[0] + ' ' + partHora[1] + ' ' + partHora[2] + ' ' + partHora[3]
- } else if (partHora.length == 1) {
- time = '' + partHora[0] + ''
- } else {
- time = '' + partHora[0] + ' ' + partHora[1]
- }
- htmlbus = ''
- + htmlGeo
- + '
'
- + '' + data.Abr + ''
- + time
- + tiempoNormal(autobus.tiempo) + '';//' + htmlOtrasLineas + '
-
- $(".btnMapa" + parada.CP + " label").html(htmlbus)
- }
- var itiyuse = AdquirirtiempoProximoItinerarios(parada, data.CL, data.CI)
- var itinerariosHermanos = itiyuse.hermanas
- $(".btnMapa" + parada.CP + " label.hermana").remove()
- if (document.getElementById("corresp" + parada.CP) != null) {
- $(itinerariosHermanos).insertBefore("#corresp" + parada.CP)
- } else {
- $(".btnMapa" + parada.CP).append(itinerariosHermanos)
- }
- }
- }
- horaActual = Date.now();
- window.clearInterval(idBlink)
- $('.blink').fadeTo('slow', 0.1).fadeTo('slow', 1.0);
- idBlink = BlinkElement();
- ActivarAutobuses(data.Cla,data.PC)
- if ($("#cambiarTimeout").text() == "Iniciar" && storage.get('modoPrueba')) {
-
- } else {
- window.clearInterval(idLineas);
-
- if (timeout == null) {
- //console.log('timeout normal')
- idLineas = TimeoutRecargarLineaAutomaticamente();
- } else {
- //console.log("mini timeout"+ timeout)
- idLineas = TimeoutRecargarLineaAutomaticamente(timeout);
- }
- }
-}
-function ObtenerAutobusTrayecto(bus, busesActivos) {
- var buses =null
- for (var d = 0; d < busesActivos.length; d++) {
- if(busesActivos[d].Coc == bus.codigo) {
- buses = busesActivos[d]
- break;
- }
- }
- return buses
-}
-function ObtenerBotonEsquema(parada, tipo, linea, contadorParada, trayecto, p, data, i) {
- var busRaro = false;//para controlar si el bus tiene algo inusual
- var primera = true;
- var classLlegada = "";
- var htmlTotal = "";
- var htmlOtrasLineas = "", htmlGeo = "", htmlbus = ""
- //Obtenemos el sentido, en caso de ser la primera parada de idavuelta, obtiene el sentido contrario, porque "llegan a su posición"
-
- //Para pintar de verde si es primera o regulación
- var cssClass = '';
- var classAlubia = ''
- if (p == 0) {
- cssClass = ' paradaRegulacion';
- classAlubia = 'ppal'
- }
- //buscamos el mismo coche para la parada anterior (aunque sea la última del otro sentido) y la siguiente (aunque sea la primera del otro sentido) para luego dibujar el coche a la derecha
- var autobus = null, autobusAnt = null, autobusSig = null;
- $.each(parada.EB, function (b, coche) {
- //NOTAS:En teoria tratamos esto como ida/vuelta/ida+vuelta ya veremos que pasa despues
- if (coche.itinerario == data.CI && coche.codigoLinea == data.CL) {
- //console.log('El primer bus de ' + parada.Nombre + ' tiene el codigo ' + coche.codigo);
- autobus = coche;
- return false;
- }
- });
- //Ponemos el icono del muñeco corriendo si es parada + cercana
- if (parada.CP == codParadaMasCercana || parada.CP == codParadaMasCercana2) {
- htmlGeo = '
'
- } else {
- htmlGeo = '';
- }
- //comprobamos si hay bus o no, si no hay monstramos "sin información"
- if (!autobus) {
- htmlbus = '';
- } else {
- //console.log(i+". cod:" + autobus.codigo + "-> " + autobusSig.tiempo + ' > ' + autobus.tiempo + ' && ' + autobusAnt.tiempo + ' > ' + autobus.tiempo)
- if (autobus.trayecto == trayecto) {
- console.log(contadorParada + ")" + autobus.trayecto + "-" + autobus.posEnTrayecto + " tp:" + autobus.tiempo.toHHorMMorSS())
- busPintados.push(autobus)
- } else {
- classLlegada = '';
- classBlink = '';
- }
- if (autobus.tiempo < 179) {
- classBlink = 'blink ';
- blink = true
- } else {
- classBlink = '';
- }
-
- var partHora = [autobus.tiempo.toHHorMMorSS()]
- if (autobus.tiempo.toHHorMMorSS() != 'En Parada' && autobus.tiempo.toHHorMMorSS() != 'Próxima Llegada') {
- partHora = autobus.tiempo.toHHorMMorSS().split(' ');//autobus.tiempo
- }
- if (partHora.length >= 4) {
- time = '' + partHora[0] + ' ' + partHora[1] + ' ' + partHora[2] + ' ' + partHora[3]
- } else if (partHora.length == 1) {
- time = '' + partHora[0] + ''
- } else {
- time = '' + partHora[0] + ' ' + partHora[1]
- }
- htmlbus = '';
- }
- var itiyuse = AdquirirtiempoProximoItinerarios(parada, data.CL, data.CI)
- var itinerariosHermanos = itiyuse.hermanas
-
- if (verCorrespondencia == true) {
- if (parada.Iti.length > 1) {//TODO: && storage.get("verTransbordos") == true
- htmlOtrasLineas = 'Corresp. : '
- //recorremos las lineas
- var limite = 8
- var sobremas = false;
- for (index = 0; index < parada.Iti.length; index++) {
- if (itiyuse.usadas.indexOf(parada.Iti[index]) == -1) {
- if (limite > 0) {
- if (parada.Iti[index] != lineaActual) {
- limite = limite - 1;
- lineaInfo = ObtenerItinerario(parada.Iti[index]);
- idLineaSize = parada.Iti[index]
- padding = ''
- htmlOtrasLineas += '' + lineaInfo.Abr + '';
- }
- } else {
- sobremas = true
- }
- }
- }
- if (sobremas) {
- htmlOtrasLineas += '...';
- }
- htmlOtrasLineas += ""
- if (htmlOtrasLineas == 'Corresp. : ') {
- htmlOtrasLineas = ""
- }
- }
- }
-
- htmlTotal = 'Cómo Llegar a Píe
' + - 'Ver en Mapa
' + - 'Street View
' + - 'Crear Alerta
' + - 'L-' + miLinea.Abr + ': ' + miLinea.Nom + '
'; - var iwContenido2 = 'regulación
'; - var iwDireccion = ""; - var iwDistancia = ""; - var iwMenu = '![]()
Distancia: ' + parseInt(distancia).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ".") + ' metros.
SentidoVTA - ' + nomParPrimera + '
' - } else { - var nombreRegulacion = miLinea.Sen[0].Par[miLinea.Sen[0].Par.length - 1].Nom - if (miLinea.Sen.length > 1) { - nombreRegulacion = miLinea.Sen[1].Par[0].Nom - } - iwDireccion = 'SentidoIDA - ' + nombreRegulacion + '
' - } - primerBus = null - iwContenidoTotal += iwDireccion; - iwContenidoTotal += iwDistancia; - iwContenidoTotal += '
Próximos Autobuses
Sin información
'; - var otroiti = "" - var otraslin = "" - if (par.Iti.length > 1) { - otroiti += '
Otros itinerarios:
Otras líneas:
' + ObtenerAbreviaturaMargen(miLineaB.Abr, miLineaB.BC, miLineaB.FC) + 'Sin información.
Otros itinerarios:
Otras líneas:
' + pos + '.
' + tiempo + '
•' + avi + '
' - } - }) - maxMostrar = maxMostrar - 1; - pos += 1; - } - } else { - bOtrasLineas = true; - } - }); - if (maxMostrar == 2) { - iwContenidoTotal += 'Sin información
' - } - if (bOtrasLineas) { - var listaPrimeraLinea = [] - $.each(data.EB, function (i, coche) { - $.each(LSLineas, function (i, x) { - var claCo = coche.Lin + "." + coche.Iti - if (x.Cla == claCo) { - if (listaPrimeraLinea[x.Cla] == null) { - listaPrimeraLinea[x.Cla] = coche - } - } - }); - }); - - var otroiti = "" - var otraslin = "" - if (data.Iti.length > 1) { - otroiti += '
Otros itinerarios:
Otras líneas:
' + ObtenerAbreviaturaMargen(miLineaB.Abr, miLineaB.BC, miLineaB.FC);//
- itinerarioyhorario += '
- if (coche != null) {
- classBlink = '';
- if (coche.TP < 179) {
- classBlink = 'blink ';
- }
- iwCoches.push(coche);
- reloj = "img/reloj.png"
- if (data.Ref != null) {
- if (data.Ref.indexOf(idlin) > -1) {
- reloj = "img/relojRojo.png"
- }
- }
- itinerarioyhorario += ' ' + coche.TP.toHHorMMorSS() + tiempoNormal(coche.TP);//+ ' ('+ coche.distancia + ' metros)';
- var lineaclavecoche = coche.Lin + "." + coche.Iti
- if (coche.sen == 0) {
- ultParada = miLinea.Sen[0].Par[miLinea.Sen[0].Par.length - 1].Nom
- if (miLinea.Sen.length > 1) {
- miLinea.Sen[1].Par[0].Nom
- }
- itinerarioyhorario += ' ' + ultParada + '
' + 'Sin información.
Otros itinerarios:
Otras líneas:
' + ObtenerAbreviaturaMargen(miLineaB.Definicion.Abreviatura, miLineaB.Apariencia.BackColor.substring(2), miLineaB.Apariencia.ForeColor.substring(2)); - // htmlOtras += 'Sin información.
Otras líneas:
indican que su poste no es el mismo que el de la parada consultada.'
- }
- iwContenidoTotal = iwContenidoTotal + 'Última actualización: ' + new Date().getHours() + ":" + pad(new Date().getMinutes(), 2) + ":" + pad(new Date().getSeconds(), 2) + ""; - if ($.mobile.activePage.attr('data-url') == 'pageLineaVer' && storage.isSet("log")) { - if (storage.get("log")) { - iwContenidoTotal += dudea + '' + primerBus.codigo + ' - ' + primerBus.tiempo.toMMSS() + '' + dudeb - } - } - //TODO: btn Reproducir audio - //iwContenidoTotal += '
' - } - return iwContenidoTotal -} -function SolicitarHTMLInformacionParadaCombi(data) { - var iwContenidoTotal = ''; - - if (data != null) { - var par = data - //obtenemos el itinerario en lugar de infolinea para el tratamiento de paradas - //miLinea = ObtenerItinerario(idLinea) - - //var paradaPrimera = miLinea.Sen[0].Par[0].CP - //var paradaRegulacion = null - //if (miLinea.Sen.length > 1) { - // paradaRegulacion = miLinea.Sen[1].Par[0].CP - //} - - - var iwCoches = [] - - abierto = "display:none;" - //TODO: InfodotAbierto (al pulsar en 3 puntos), se debe cerrar cuando cierre el popup (que no cuando salga otro encima de este) - if (infodotAbierto) { - abierto = "display:block;" - } - var iwContenido1 = 'Cómo Llegar a Píe
' + - //'Ver en Mapa
' + - //'Street View
' + - //'Crear Alerta
' + - //'regulación
'; - var iwDireccion = ""; - var iwDistancia = ""; - var iwMenu = '![]()
Distancia: ' + parseInt(distancia).toString().replace(/\B(?=(\d{3})+(?!\d))/g, ".") + ' metros.
L-' + miLinea.Abr + ': ' + miLinea.Nom + '
'; - iwContenidoTotal += iwLinea; - ////si es regulacion la cambiamos a verde - //if (primeraParada == par.CP || ultimaParada == par.CP) { // La primera parada y la definida como regulación. - // iwContenidoTotal = iwContenidoTotal.replace("h4Blue", "h4Green"); - //}// else { - //// iwContenidoTotal += 'SentidoVTA - ' + nomParPrimera + '
' - } else { - var nombreRegulacion = miLinea.Sen[0].Par[miLinea.Sen[0].Par.length - 1].Nom - if (miLinea.Sen.length > 1) { - nombreRegulacion = miLinea.Sen[1].Par[0].Nom - } - iwDireccion = 'SentidoIDA - ' + nombreRegulacion + '
' - } - primerBus = null - iwContenidoTotal += iwDireccion; - iwContenidoTotal += iwDistancia; - iwContenidoTotal += '
Próximos Autobuses
Sin información
'; - var otroiti = "" - var otraslin = "" - if (par.Iti.length > 1) { - otroiti += '
Otros itinerarios:
Otras líneas:
' + ObtenerAbreviaturaMargen(miLineaB.Abr, miLineaB.BC, miLineaB.FC) + 'Sin información.
Otros itinerarios:
Otras líneas:
' + pos + '.
' + tiempo + '
•' + avi + '
' - } - }) - maxMostrar = maxMostrar - 1; - pos += 1; - } - } else { - bOtrasLineas = true; - } - }); - if (maxMostrar == 2) { - iwContenidoTotal += 'Sin información
' - } - - } - iwContenidoTotal += "Última actualización: ' + new Date().getHours() + ":" + pad(new Date().getMinutes(), 2) + ":" + pad(new Date().getSeconds(), 2) + ""; - if ($.mobile.activePage.attr('data-url') == 'pageLineaVer' && storage.isSet("log")) { - if (storage.get("log")) { - iwContenidoTotal += dudea + '' + primerBus.codigo + ' - ' + primerBus.tiempo.toMMSS() + '' + dudeb - } - } - //TODO: btn Reproducir audio - //iwContenidoTotal += '
' - } - return iwContenidoTotal -} -function AbrirInfoDot() { - $(".popupDotMenu").show() - infodotAbierto = true; -} -function CerrarInfoDot() { - $(".popupDotMenu").hide() - infodotAbierto = false; -} -function ObtenerHtmlInformacionBus(coche, codLinea) { - //infoCoche = ObtenerInfoCoche(codBus) - var rampa = 'Sí' - if (coche.CB < 130) { - rampa = 'No disponible' - } - html = 'Información del Autobús
' - //+'' - //+'' - //+'Street View
' - //+'L-' + linea.Abr + ': ' + linea.Nom + '
' - + 'Código del autobús: ' + coche.CB + '
' - + 'Próxima parada:
' + parada.Nom + '
' - + 'Tiempo:
' + coche.TPS.toHHorMMorSS() + '
' - + 'Rampa de Accesibilidad:
' + rampa + '
Última actualización: ' + new Date().getHours() + ":" + pad(new Date().getMinutes(), 2) + ":" + pad(new Date().getSeconds(), 2) + '
' - + '' - - return html -} -function ObtenerBusEsquema(codigo, clave) { - window.clearInterval(idLineas) - tiempo = Date.now() - ultFechaBusMapa; - if (tiempo <= (tiempoRecargaMilis - 500) && storage.isSet("BSE" + codigo)) { - MostrarAutobusEsquema(storage.get("BSE" + codigo), clave) - - } else { - JSZipUtils.getBinaryContent(urlDatos + 'api/JQ/JSONQRYZIP/ESTGRAL|' + clave + '?i=' + Math.random() + '&' + servidor + '&p=' + plataforma + '&v=' + version, function (err, data) { - var elt = document.getElementById('jszip_utils'); - if (err) { - ErrorServidor('noRespuesta', 'PUGR01', '') - return; - } else { - try { - JSZip.loadAsync(data) - .then(function (zip) { - return zip.file("datos.json").async("string") - }) - .then(function success(text) { - try { - data = JSON.parse(text.substring(1)) - ultFechaBusMapa = Date.now() - $.each(data.EL[0].EC, function (ec, bus) { - bus.TPS = getSeconds(data.FH, bus.TPS).toString() - bus.TPF = getSeconds(data.FH, bus.TPF).toString() - if (bus.CB == codigo) { - storage.set("BSE" + bus.CB, bus) - MostrarAutobusEsquema(bus, clave) - return false - } - }) - } catch (ex) { - console.log(ex + "" + text.toString()) - } - }, function error(e) { - ErrorServidor('errorZip', 'PUGR01', 'ocurrencia baja') - }); - } catch (e) { - ErrorServidor('errorDesconocido', 'PUGR01', e) - } - } - }); - } -} -function MostrarAutobusEsquema(data, clave) { - htmlTexto = ObtenerHtmlInformacionBus(data, clave) - Swal.fire({ - html: htmlTexto, - showConfirmButton: false, - customClass: 'SwalInformacionAutobus', - animation: !Swal.isVisible() - //showCloseButton:true - }).then((result) => { - console.log("Me han cerrado :(") - CerrarInfoDot() - window.clearInterval(idLineas) - if (storage.isSet('UTH' + storage.get('LineaVer'))) { - tiempo = tiempoRecargaMilis - (Date.now() - storage.get('UTH' + storage.get('LineaVer'))); - console.log("tiempo para refresco:" + tiempo) - if (tiempo > 0) { - idLineas = TimeoutRecargarLineaAutomaticamente(tiempo); - } else { - idLineas = TimeoutRecargarLineaAutomaticamente(0); - } - } else { - idLineas = TimeoutRecargarLineaAutomaticamente(0); - } - }) - idLineas = TimeoutRecargarBusEsquemaAutomaticamente(data.CB, clave) -} -function TimeoutRecargarBusEsquemaAutomaticamente(codigo, clave) { - tiempo = tiempoRecargaMilis - return window.setInterval(function () { - ObtenerBusEsquema(codigo, clave); - }, tiempo); -} -//TODO: popup offline -function AbrirParadaOffline(codParada, codLinea, posicion) { - paradaActual = codParada; - listaLineasFavoritos = null - storage.set('CodUltParadaPulsada', codParada); - lineaActual = codLinea; - paradaABuscar = ObtenerParada(codParada); - Swal.fire({ - html: SolicitarHTMLInformacionOffline(paradaABuscar, lineaActual), - showConfirmButton: false, - customClass: 'SwalInformacionParada' - //showCloseButton:true - }).then((result) => { - console.log("Me han cerrado :(") - CerrarInfoDot() - window.clearInterval(idLineas) - }) -} -function SolicitarHTMLInformacionOffline(parada, idLinea) { - var html = "" - var data = parada; - codParada = parada.CP - miLinea = ObtenerItinerario(idLinea) - var iwContenido1 = 'L-' + miLinea.Abr + ': ' + miLinea.Nom + '
'; - var iwContenidoRegulacion = 'regulación
'; - var iwDireccion = ""; - var iwDistancia = ""; - var iwMenu = 'Sin conexión de red, conecta tu dispositivo a una red para obtener mayor información
' - return html + 'Última actualización: ' + new Date().getHours() + ":" + pad(new Date().getMinutes(), 2) + ":" + pad(new Date().getSeconds(), 2) + ""; - -} -function SeleccionarParada(idBoton) { - if (ultimaSeleccionada != "") { - $("#" + ultimaSeleccionada).removeClass("btnEsquemaPulsado") - } - ultimaSeleccionada = idBoton; - $("#" + ultimaSeleccionada).addClass("btnEsquemaPulsado"); -} -function TimeoutRecargarLineaAutomaticamente(timeout) { - tiempo = tiempoRecargaMilis - if (timeout != null && timeout >= 0) { - tiempo = timeout - } - return window.setInterval(function () { - RecargarModoLineasAutomaticamente(); - }, tiempo); -} -function TimeoutRecargarParadaAutomaticamente(codigo, linea, posicion, sentido) { - tiempo = tiempoRecargaMilis - return window.setInterval(function () { - RecargarParadaMostradaAutomaticamente(codigo, linea, posicion, sentido); - }, tiempo); -} -function RecargarModoLineasAutomaticamente() { - //SolicitarDatosLineaPageLineas($("#selectLineaPageRutas").children(":selected").val()); - value = storage.get('LineaVer') - window.clearInterval(idLineas) - if (online) { - ObtenerLineaConParada(value, 'recargar lineaVer'); - } else { - verLineaOffline() - } -} -function RecargarParadaMostradaAutomaticamente(codigo, linea, posicion, sentido) { - value = storage.get('LineaVer') - window.clearInterval(idParadas) - if (online) { - LineaParadaPulsada(codigo, linea, posicion, sentido) - } else { - AbrirParadaOffline() - } -} -/////////////////////////////////////////////////////////////////////////////MAPA/////////////////////////////////////////////////////////////// -//#region MAPA -var mapa = null, initLat = 37.2667696, initLng = -6.9401195; LSUltLocalizacion = null; LSVerCercanas = true; idMapa = null, idMapaParada = null; ultFechaBusMapa = null; autobusesActuales = null; -var layerGPS = null; var layersItinerarios = []; var layersSeleccionados = [] -var ballgeo = L.icon({ - iconUrl: 'img/gpsloc_azul.png', - iconSize: [20, 20], // size of the icon - iconAnchor: [10, 10], // point of the icon which will correspond to marker's location - popupAnchor: [0, 0] // point from which the popup should open relative to the iconAnchor -}); -var wave = L.icon({ - iconUrl: 'img/wave.gif', - iconSize: [60, 60], // size of the icon - iconAnchor: [30, 30], // point of the icon which will correspond to marker's location - popupAnchor: [0, 30] // point from which the popup should open relative to the iconAnchor -}); -var balldestino = L.icon({ - iconUrl: 'img/gpsloc_rojo.png', - iconSize: [20, 20], // size of the icon - iconAnchor: [10, 10], // point of the icon which will correspond to marker's location - popupAnchor: [0, 10] // point from which the popup should open relative to the iconAnchor -}); -var simpleMarker = L.icon({ - iconUrl: 'img/bus64.png', - iconSize: [22, 32], // size of the icon - iconAnchor: [11, 32], // point of the icon which will correspond to marker's location - popupAnchor: [0, -32] // point from which the popup should open relative to the iconAnchor -}); -var refMarker = L.icon({ - iconUrl: 'img/busr64.png', - iconSize: [22, 32], // size of the icon - iconAnchor: [11, 32], // point of the icon which will correspond to marker's location - popupAnchor: [0, -32] // point from which the popup should open relative to the iconAnchor -}); - -function InicializarMapa() { - if (mapa == null) { - mapa = L.map('mapCanvas').setView([initLat, initLng], 14); - layerGPS = L.layerGroup().addTo(mapa); - //L.tileLayer('https://tile.tecnosis.net/hot/{z}/{x}/{y}.png', { - // attribution: 'Map data © OpenStreetMap contributors, CC-BY-SA', - // id: 'mapa.map' - //}).addTo(mapa); - L.tileLayer(urlMapas + 'osm_tiles/{z}/{x}/{y}.png', { - attribution: 'Map data © OpenStreetMap contributors, CC-BY-SA', - id: 'mapa.map' - }).addTo(mapa); - if (LSUltLocalizacion != null) { - var latlng = new L.LatLng(LSUltLocalizacion[0], LSUltLocalizacion[1]); - var marker = L.marker(latlng, { icon: ballgeo, draggable: true }).addTo(layerGPS); - AñadirEventosGeo(marker) - ObtenerCercanas() - } - mapa.on('zoomend', function () { - ZoomCambiado(mapa.getZoom()); - }); - mapa.on('contextmenu', function (e) {//longpress - console.log("trigger") - layerGPS.clearLayers() - var latlng = e.latlng - var marker = L.marker(latlng, { icon: ballgeo, draggable: true }).addTo(layerGPS); - AñadirEventosGeo(marker) - LSUltLocalizacion = [latlng.lat, latlng.lng]; - storage.set("lstLoc", [latlng.lat, latlng.lng]); - ObtenerCercanas() - }); - $("#txtBuscarParada").on("paste keyup", function () { - var valor = this.value - //if (valor.length % 3 == 0) { - if (valor.length >= 3) { - BuscarOrigenMapa(valor) - } - }); - $("#txtBuscarParada").autocomplete({ - source: arraySugerenciasMapa//.concat(paradasSugeridas) - }); - DibujarCuadrosLineasSeleccionadas() - } -} -var arraySugerenciasMapa = [] -var arrayUbicacionesMapa = [] -function BuscarOrigenMapa(texto) { - arrayUbicaciones = [] - arraySugerencias = [] - urlGeo = urlSrch + 'q=' + texto + '&lon=-6.941150856&lat=37.2635917&limit=20' - $.getJSON(urlGeo, function (data) { - data = data.features - console.log('------------------------------------') - for (var bo = 0; bo < data.length; bo++) { - //console.log(data[bo].display_name) - var dt = data[bo] - if (dt.properties.city == "Huelva") { - arrayUbicaciones.push(dt) - if (dt.properties.street == null) { - arraySugerencias.push(dt.properties.name) - } else { - arraySugerencias.push(dt.properties.name + ", " + dt.properties.street) - } - } - } - arraySugerencias = arraySugerencias.concat(SugerirParada(texto)) - if (arrayUbicaciones.length != 0) { - arraySugerenciasMapa = arraySugerencias - arrayUbicacionesMapa = arrayUbicaciones - $('#txtBuscarParada').autocomplete("option", { - source: SearchMatch, - select: function (event, ui) { - console.log(ui.item.label) - if (ui.item.label.indexOf(" - ") == -1) {//normal - - for (var suo = 0; suo < arrayUbicacionesMapa.length; suo++) { - if (arrayUbicacionesMapa[suo].properties.name == ui.item.label || arrayUbicacionesMapa[suo].properties.name + ", " + arrayUbicacionesMapa[suo].properties.street) { - $('#txtBuscarParada').val(ui.item.label) - - layerGPS.clearLayers() - var latlng = new L.LatLng(arrayUbicacionesMapa[suo].geometry.coordinates[1], arrayUbicacionesMapa[suo].geometry.coordinates[0]) - var marker = L.marker(latlng, { icon: ballgeo, draggable: true }).addTo(layerGPS); - AñadirEventosGeo(marker) - LSUltLocalizacion = [latlng.lat, latlng.lng]; - storage.set("lstLoc", [latlng.lat, latlng.lng]); - ObtenerCercanas() - } - } - } else {//Paradas - cpar = ui.item.label.split(" - ")[1] - par = ObtenerParada(cpar) - $('#txtBuscarParada').val(ui.item.label) - - layerGPS.clearLayers() - var latlng = new L.LatLng(par.XY[1], par.XY[0]); - var marker = L.marker(latlng, { icon: ballgeo, draggable: true }).addTo(layerGPS.clearLayers()); - AñadirEventosGeo(marker) - LSUltLocalizacion = [latlng.lat, latlng.lng]; - storage.set("lstLoc", [latlng.lat, latlng.lng]); - ObtenerCercanas() - } - return false; - } - }); - } - }); -} - -function GetLocation() { - navigator.geolocation.getCurrentPosition(function (location) { - var latlng = new L.LatLng(location.coords.latitude, location.coords.longitude); - layerGPS.clearLayers() - var marker = L.marker(latlng, { icon: ballgeo, draggable: true }).addTo(layerGPS); - AñadirEventosGeo(marker) - mapa.setView(latlng, mapa.getZoom()); - LSUltLocalizacion = [location.coords.latitude, location.coords.longitude]; - storage.set("lstLoc", [location.coords.latitude, location.coords.longitude]); - ObtenerCercanas() - }); -} -var layersParadasCercanas = [] -function ObtenerCercanas() { - var arrayCordenadas = []; - var arrayCodigos = [] - OcultarRutasParadasCercanas() - layersParadasCercanas = [] - Origen = LSUltLocalizacion[1] + "," + LSUltLocalizacion[0] - for (var i = 0; i < LSParadas.length; i++) { - var par = LSParadas[i] - if (par.Iti.length > 0) { - arrayCodigos.push(par) - arrayCordenadas.push(par.XY[0] + "," + par.XY[1]) - } - } - arrayCodigos = JSON.parse(JSON.stringify(arrayCodigos)) - var output = arrayCordenadas.join(";"); - - urlhtmlOri = urlRutas + 'table/v1/foot/' + Origen + ";" + output + '?destinations=0' - ObtenerDistanciasAPunto(urlhtmlOri, "origen") - - for (var i = 0; i < arrayCodigos.length; i++) { - //(arrayCodigos(CoorAOrigen - arrayCodigos[i].duracionOrigen = CoorAOrigen.durations[i + 1][0] - } - - parCercOrigen = arrayCodigos.slice(0).sort((a, b) => (a.duracionOrigen > b.duracionOrigen) ? 1 : -1) - - LineasParadasCercanas = [] - - for (var i = 0; i < LSLineas.length; i++) { - iti = LSLineas[i] - lin = { linea: iti, paradasOrigen: [] } - for (var t = 0; t < parCercOrigen.length; t++) { - if (parCercOrigen[t].Iti.includes(lin.linea.Cla)) { - parCercOrigen[t].PosOrigen = ObtenerPosicionParada(iti, parCercOrigen[t].CP) - lin.paradasOrigen.push(JSON.parse(JSON.stringify(parCercOrigen[t]))) - } - - if (lin.paradasOrigen.length == 4) { break; } - } - LineasParadasCercanas.push(lin) - } - //Ahora vamos a crear la información de paradas más cercanas - for (var i = 0; i < LineasParadasCercanas.length; i++) { - var iti = LineasParadasCercanas[i].linea - var paradas = LineasParadasCercanas[i].paradasOrigen - layer = L.layerGroup() - var latslngs = [] - for (var t = 0; t < 2; t++) { - var latlng = new L.LatLng(paradas[t].XY[1], paradas[t].XY[0]); - latslngs.push(paradas[t].XY[0] + "," + paradas[t].XY[1]) - var marker = L.marker(latlng, { icon: wave, Cla: iti.Cla, Pos: pos, Sen: (i + 1), zIndexOffset: 0 }).addTo(layer) - } - layersParadasCercanas.push({ Clave: iti.Cla, Marcadores: layer, Rutas: null, LatLng: latslngs, Color: iti.BC, Paradas: paradas.slice(0, 2) }) - } - if (LSVerCercanas == true) { - MostrarRutasParadasCercanas() - } -} -function MostrarRutasParadasCercanas() { - for (var i = 0; i < layersSeleccionados.length; i++) { - for (var i2 = 0; i2 < layersParadasCercanas.length; i2++) { - if (layersSeleccionados[i] == layersParadasCercanas[i2].Clave) { - layersParadasCercanas[i2].Marcadores.addTo(mapa) - if (layersParadasCercanas[i2].Rutas == null) { - dat1 = ObtenerRutaCercana(LSUltLocalizacion[1] + "," + LSUltLocalizacion[0], layersParadasCercanas[i2].LatLng[0]) - dat2 = ObtenerRutaCercana(LSUltLocalizacion[1] + "," + LSUltLocalizacion[0], layersParadasCercanas[i2].LatLng[1]) - - layerRutaParada1 = L.layerGroup().addTo(mapa); - layerRutaMarcadores1 = L.layerGroup(); - layerRutaParada2 = L.layerGroup().addTo(mapa); - layerRutaMarcadores2 = L.layerGroup(); - - DibujarRutaPolilinea(dat1, layerRutaParada1, layerRutaMarcadores1, layersParadasCercanas[i2].Color) - DibujarRutaPolilinea(dat2, layerRutaParada2, layerRutaMarcadores2, layersParadasCercanas[i2].Color) - - layersParadasCercanas[i2].Rutas = [] - layersParadasCercanas[i2].Rutas.push(layerRutaParada1) - layersParadasCercanas[i2].Rutas.push(layerRutaParada2) - - layersParadasCercanas[i2].Duraciones = [] - layersParadasCercanas[i2].Duraciones.push(dat1.routes[0].duration) - layersParadasCercanas[i2].Duraciones.push(dat2.routes[0].duration) - - layersParadasCercanas[i2].Distancia = [] - layersParadasCercanas[i2].Distancia.push(dat1.routes[0].distance) - layersParadasCercanas[i2].Distancia.push(dat2.routes[0].distance) - } else { - layersParadasCercanas[i2].Rutas[0].addTo(mapa) - layersParadasCercanas[i2].Rutas[1].addTo(mapa) - } - break; - } - } - } -} -function OcultarRutasParadasCercanas() { - for (var i2 = 0; i2 < layersParadasCercanas.length; i2++) { - mapa.removeLayer(layersParadasCercanas[i2].Marcadores) - if (layersParadasCercanas[i2].Rutas != null) { - mapa.removeLayer(layersParadasCercanas[i2].Rutas[0]) - mapa.removeLayer(layersParadasCercanas[i2].Rutas[1]) - } - } -} -function ObtenerRutaCercana(LatLngOr, LatLngDes) { - var dt = null; - $.ajax({ - type: 'GET', - url: urlRutas + 'route/v1/footer/' + LatLngOr + ";" + LatLngDes + '?steps=true&alternatives=true&geometries=geojson', - dataType: "json", - timeout: tiempoRecargaMilis, - success: function (data) { - dt = data - }, - error: function (xmlhttprequest, textstatus, message) { - //TODO: Esto deberia dar un error tipo "toast" en lugar de esto, ya paso que la app daba error de conexión aqui y aprecia que la app estaba rota, pero solo eran las noticias - }, - async: false - }); - return dt -} -function LineaMapaPulsada(idLinea) { - var layerExistente = ObtenerLayer(idLinea) - - if (layerExistente == null) { - layersItinerarios.push(CrearLayer(idLinea, mapa)) - $('#linMapa-' + idLinea.toString().replace(".", "-")).addClass('LinSelected') - layersSeleccionados.push(idLinea) - storage.set('LS', layersSeleccionados) - ZoomCambiado(mapa.getZoom()) - } else if (!mapa.hasLayer(layerExistente)) { - MostrarLayer(idLinea) - } else { - OcultarAutobuses(idLinea) - OcultarLayer(idLinea) - DibujarCuadrosLineasSeleccionadas() - } - if (LSVerCercanas) { - OcultarRutasParadasCercanas() - MostrarRutasParadasCercanas() - } -} -function DibujarCuadrosLineasSeleccionadas() { - var html = "" - var layersOrdenados = JSON.parse(JSON.stringify(layersSeleccionados)).sort((a, b) => (a > b) ? 1 : -1) - for (var ls = 0; ls < layersOrdenados.length; ls++) { - var iti = ObtenerItinerario(layersOrdenados[ls]) - html += ' ' + iti.Abr + '' - } - $('.lineasMostradas').empty() - $('.lineasMostradas').append(html) - altura = window.innerHeight - 255 - alturaCuadro = 40 * layersSeleccionados.length - if (altura < alturaCuadro) { - $('.lineasMostradas').css('height', window.innerHeight - 255 + "px") - } else { - $('.lineasMostradas').css("height", ""); - } -} -function ObtenerLayer(idLinea) { - for (var r = 0; r < layersItinerarios.length; r++) { - if (layersItinerarios[r].id == idLinea) { - return layersItinerarios[r].layer; - } - } - return null -} -function CrearLayer(idLinea, objetoMapa) { - //Esta función se encarga de crear los layes y almacenarlos, luego podrán quitarse y añadirse a voluntad - layerCreado = L.layerGroup().addTo(objetoMapa); - layerZoom1 = L.layerGroup().addTo(objetoMapa); - layerZoom2 = L.layerGroup().addTo(objetoMapa); - layerZoom3 = L.layerGroup().addTo(objetoMapa); - layerMarcadores = L.layerGroup().addTo(objetoMapa); - latlngs = [] - var it = ObtenerItinerario(idLinea) - var pos = 0 - for (var i = 0; i < it.Sen.length; i++) { - for (var i2 = 0; i2 < it.Sen[i].Tray.length; i2++) { - var icon = simpleMarker - if (i2 == 0) { icon = refMarker } - parada = it.Sen[i].Par[i2] - AñadirMarkerMapa(parada, layerZoom1, layerZoom2, layerZoom3, layerMarcadores, icon, it, i, i2, pos) - pos = pos + 1 - } - latlngs = latlngs.concat(it.Sen[i].XY) - - if (it.Sen.length == 1) { - parada = it.Sen[0].Par[it.Sen[0].Par.length - 1] - AñadirMarkerMapa(parada, layerZoom1, layerZoom2, layerZoom3, layerMarcadores, refMarker, it, 0, it.Sen[0].Par.length - 1, pos) - } - else if (it.Sen.length == 2 && i == 1) { - paradaInicio = it.Sen[0].Par[0] - paradaFin = it.Sen[1].Par[it.Sen[1].Par.length - 1] - if (paradaInicio.CP != paradaFin.CP) { - AñadirMarkerMapa(paradaFin, layerZoom1, layerZoom2, layerZoom3, layerMarcadores, refMarker, it, 1, it.Sen[1].Par.length - 1, pos) - } - } - else if (it.Sen.length == 2 && i == 0) { - paradaFinIda = it.Sen[0].Par[it.Sen[0].Par.length - 1] - paradaInicioVuelta = it.Sen[1].Par[0] - if (paradaFinIda.CP != paradaInicioVuelta.CP) { - AñadirMarkerMapa(paradaFinIda, layerZoom1, layerZoom2, layerZoom3, layerMarcadores, refMarker, it, 1, it.Sen[1].Par.length - 1, pos) - } - } - } - var polyline = L.polyline(latlngs, { stroke: true, color: "#" + it.BC, opacity: 0.7, className: "pruebaclase" }).addTo(layerCreado); - return { id: idLinea, layer: layerCreado, markers: layerMarcadores, zoom1: layerZoom1, zoom2: layerZoom2, zoom3: layerZoom3, bounds: polyline.getBounds() } -} -function AñadirMarkerMapa(parada, layerZoom1, layerZoom2, layerZoom3, layerMarcadores, icon, it, i, i2, pos) { - var latlng = new L.LatLng(parada.XY[1], parada.XY[0]); - var marker = L.marker(latlng, { icon: icon, Cla: it.Cla, CP: it.Sen[i].Par[i2].CP, Pos: pos, Sen: (i + 1), zIndexOffset: 0 }).addTo(layerMarcadores).on('click', function (e) { VerParadaMarker(e.target.options.Cla, e.target.options.CP, e.target.options.Pos, e.target.options.Sen, e) }); - marker.setZIndexOffset(666) - var testoMarker = L.marker(latlng, { - icon: new L.DivIcon({ - className: 'my-div-iconj', - html: '
' + (pos + 1) + ' - ' + parada.Nom + '
' +
- '' + iti.Abr + '' + 'L-' + it.Abr + ': ' + it.Nom + '
' - html += "| ' + Math.floor(par.duracionOrigen / 60) + ' min | (' + par.CP + ') | ' + par.Nom + ' |
' + Math.floor(rut.OrigenElegido.duracionOrigen / 60) + '->' + ObtenerAbreviaturaMargen(l.Abr, l.BC, l.FC) + Math.floor(rut.Duracion / 60) + '->
' + Math.floor(rut.DestinoElegido.duracionDestino / 60) + '
' + numParadas + ' Paradas.
' + - '
Ruta a pie
' + (rutaPie.routes[0].distance / 1000).toFixed(1) + ' Kilómetros
' + - '' + (pos + 1) + ' - ' + parada.Nom + '
' + nombre + '
' + nombre + '
arrow_upward' + nombre + '
' + categoria + '
' + - //'' + $('title', child).text() + '
' +
- //'' + pagina + "." + (e + 1) + '' +
- '' + fecha[0] + ':' + fecha[1] + '' +
- '' + categoria.slice(0, -1) + '' +
- '
' + favorito.Nom + ' ' + linea.Abr + ' - ' + parada.Nom + '
' + - '' + - 'Obteniendo...' + - //'
1. 5 min
2. 12 min'+
- '' +
- '' +
- '' +
- 'edit' +
- 'delete' +
- '' +
- '
' + contador + '. ' + bus.TP.toHHorMMorSS() + 'No se encuentran datos para un autobús con este código, compruebe que el código está disponible e inténtelo de nuevo
' + - '' - $("#AlarmaFinalizada").empty() - $("#AlarmaFinalizada").append(html) - break - case 'Finalizado': - var audio = new Audio('./sounds/alarmclock.mp3'); - audio.play(); - texto=AlarmaBajada.TP+" "+AlarmaBajada.MD - if (AlarmaBajada.MD=="tiempo") { - texto = AlarmaBajada.TP + " minuto" - } - if (AlarmaBajada.TP > 1) { - texto+='s' - } - - html = 'El autobús va a llegar a su destino en ' + texto + '
' + - '' - $("#AlarmaFinalizada").empty() - $("#AlarmaFinalizada").append(html) - break; - case 'Cancelar': - html = 'Se ha Cancelado la alarma por parte del usuario
' + - '' - $("#AlarmaFinalizada").empty() - $("#AlarmaFinalizada").append(html) - } -} -function ObtenerBusAlarmaBajada() { - JSZipUtils.getBinaryContent(urlDatos + 'api/JQ/JSONQRYZIP/ESTGRAL|' + AlarmaBajada.CL + '?i=' + Math.random() + '&' + servidor + '&p=' + plataforma + '&v=' + version, function (err, data) { - var elt = document.getElementById('jszip_utils'); - if (err) { - ErrorServidor('noRespuesta', 'PUGR01', '') - return; - } else { - try { - JSZip.loadAsync(data) - .then(function (zip) { - return zip.file("datos.json").async("string") - }) - .then(function success(text) { - try { - data = JSON.parse(text.substring(1)) - var busSeguimiento = null - - $.each(data.EL[0].EC, function (ec, bus) { - if (bus.CB == AlarmaBajada.CB && bus.Iti == AlarmaBajada.CL.split(".")[1]) { - bus.TPS = getSeconds(data.FH, bus.TPS).toString() - bus.TPF = getSeconds(data.FH, bus.TPF).toString() - busSeguimiento = bus - } - }); - if (layerAlarma.autobuses != null) { - mapaAlarma.removeLayer(layerAlarma.autobuses) - } - - if (busSeguimiento != null) { - var paradasEnMedio = CalcularParadasEnMedio(AlarmaBajada.CL, busSeguimiento.CPS, AlarmaBajada.CP) - paradasEnMedio = paradasEnMedio - AlarmaBajada.TP - if (paradasEnMedio >= AlarmaBajada.TP) { - var layerBus = L.layerGroup().addTo(mapaAlarma); - angulo = busSeguimiento.OB + 90; - lat = busSeguimiento.XY[1] - lng = busSeguimiento.XY[0] - iti = ObtenerItinerario(AlarmaBajada.CL) - var latlng = new L.LatLng(lat, lng); - var markerbus = L.marker(latlng, { - zIndexOffset: 1000, - icon: new L.DivIcon({ - className: 'my-div-iconj', - html: '
' +
- '' + iti.Abr + '' + '" + parada.Codigo + ", " + parada.Nombre + "
"; - var onclick = 'VerParadaCombi(' + parada.CP + ')' - var nom = parada.Nom - var cod = parada.CP - if (texto != "") { - var indexBusq = normalize(parada.Nom).toLowerCase().indexOf(normalize(texto)) - if (indexBusq > -1) { - split = normalize(nom.toLowerCase()).split(normalize(texto)) - aLength = split[0].length - bLength = aLength + texto.length - mitadA = parada.Nom.substring(0, aLength) - trozo = parada.Nom.substring(aLength, bLength) - mitadB = parada.Nom.substring(bLength) - nom = mitadA + '' + trozo + '' + mitadB - } - var indexBusq = parada.CP.toString().indexOf(texto) - if (indexBusq > -1) { - split = parada.CP.toString().split(texto) - - cod = split[0] + '' + texto + '' + split[1] - } - } - - - htmlBusqueda += '' + cod + ': ' + nom + '
' - codlineas = parada.Iti; - htmlBusqueda += '| ' + ObtenerAbreviaturaMargen(miLinea.Abr, miLinea.BC, miLinea.FC) + ' | ' - //htmlBusqueda += htmlLineas[c] - if (sentido == 1) {//IDA - var nombreRegulacion = miLinea.Sen[0].Par[miLinea.Sen[0].Par.length - 1].Nom - if (miLinea.Sen.length > 1) { - nombreRegulacion = miLinea.Sen[1].Par[0].Nom - } - htmlBusqueda += 'IDA - ' + nombreRegulacion + ' | '
- } else {//VTA
- var nomParPrimera = miLinea.Sen[0].Par[0].Nom
- htmlBusqueda += 'VTA - ' + nomParPrimera + ' | '
- }
- htmlBusqueda += '