diff --git a/ouestmonbus.js b/ouestmonbus.js
index 58504f5..6c9ed48 100644
--- a/ouestmonbus.js
+++ b/ouestmonbus.js
@@ -47,7 +47,7 @@ function OuestmonbusApp() {
localStorage.setItem("localStorage", 1);
localStorage.removeItem("localStorage");
this.localstoragePermitted = true;
- } catch (e) {}
+ } catch (e) { }
// Carte Leaflet
this.map = null;
@@ -91,7 +91,7 @@ function OuestmonbusApp() {
this.md = new MobileDetect(window.navigator.userAgent);
}
-OuestmonbusApp.prototype.getLocalStorage = function(key) {
+OuestmonbusApp.prototype.getLocalStorage = function (key) {
if (this.localstoragePermitted) {
return localStorage.getItem(key);
@@ -100,19 +100,19 @@ OuestmonbusApp.prototype.getLocalStorage = function(key) {
}
};
-OuestmonbusApp.prototype.setLocalStorage = function(key, value) {
+OuestmonbusApp.prototype.setLocalStorage = function (key, value) {
if (this.localstoragePermitted) {
try {
localStorage.setItem(key, value);
- } catch (e) {}
+ } catch (e) { }
}
};
/**
* Initialise l'application.
*/
-OuestmonbusApp.prototype.init = function() {
+OuestmonbusApp.prototype.init = function () {
var hpg = 0.5;
if (this.md.phone()) {
@@ -140,11 +140,11 @@ OuestmonbusApp.prototype.init = function() {
this.initPDFLinks();
- window.onload = function() {
+ window.onload = function () {
this.start();
}.bind(this);
- window.onhashchange = function() {
+ window.onhashchange = function () {
this.onHashChange();
}.bind(this);
@@ -155,13 +155,13 @@ OuestmonbusApp.prototype.init = function() {
/**
* Point d'entrée, lorsque la fenêtre est chargé on exécute le programme.
*/
-OuestmonbusApp.prototype.start = function() {
+OuestmonbusApp.prototype.start = function () {
- setTimeout(function() {
+ setTimeout(function () {
this.showHelp();
}.bind(this), 60000);
- var display = function() {
+ var display = function () {
this.getAllTodayStationsData(this.displayAllStations.bind(this));
};
@@ -182,22 +182,22 @@ OuestmonbusApp.prototype.start = function() {
}
};
-OuestmonbusApp.prototype.isMapHere = function(latlng, zoom) {
+OuestmonbusApp.prototype.isMapHere = function (latlng, zoom) {
var res = false;
try {
res = this.map.getCenter().distanceTo(latlng) < this.map.DEFAULT_DISTANCE_RESOLUTION && this.map.getZoom() === zoom;
- } catch (e) {}
+ } catch (e) { }
return res;
};
-OuestmonbusApp.prototype.moveMapTo = function(latlng, zoom, onFinish) {
+OuestmonbusApp.prototype.moveMapTo = function (latlng, zoom, onFinish) {
if (typeof onFinish === "undefined") {
- onFinish = function() {};
+ onFinish = function () { };
}
if (!this.isMapHere(latlng, zoom)) {
- this.map.once("moveend", function() {
+ this.map.once("moveend", function () {
onFinish();
});
this.map.setView(latlng, zoom);
@@ -206,7 +206,7 @@ OuestmonbusApp.prototype.moveMapTo = function(latlng, zoom, onFinish) {
}
};
-OuestmonbusApp.prototype.doOnResize = function() {
+OuestmonbusApp.prototype.doOnResize = function () {
this.placeLegal();
};
@@ -214,7 +214,7 @@ OuestmonbusApp.prototype.doOnResize = function() {
/**
* Appelé quand l'URL change.
*/
-OuestmonbusApp.prototype.onHashChange = function() {
+OuestmonbusApp.prototype.onHashChange = function () {
if (!this.hash_change_from_move) {
var zoomLatLng = this.localisation.urlToZoomLatLng(window.location.hash);
@@ -227,11 +227,11 @@ OuestmonbusApp.prototype.onHashChange = function() {
};
/**
- Ajuste la position des éléments
- Les mentions légal dans div.leaflet-bottom ne sont pas positionné en bas
- sans un ajustement manuel.
+ Ajuste la position des éléments
+ Les mentions légal dans div.leaflet-bottom ne sont pas positionné en bas
+ sans un ajustement manuel.
*/
-OuestmonbusApp.prototype.placeLegal = function() {
+OuestmonbusApp.prototype.placeLegal = function () {
// hauteur des mentions légal
var legal_attribution_height = $("#legal_attribution").height();
@@ -256,9 +256,9 @@ OuestmonbusApp.prototype.placeLegal = function() {
};
/**
- Ajuste la position des éléments
+ Ajuste la position des éléments
*/
-OuestmonbusApp.prototype.addWaitCenterSpinner = function() {
+OuestmonbusApp.prototype.addWaitCenterSpinner = function () {
if (this.waitSpinner !== null && !this.waitSpinnerDisplayed) {
this.waitSpinner.addTo(this.map);
@@ -274,7 +274,7 @@ OuestmonbusApp.prototype.addWaitCenterSpinner = function() {
}
};
-OuestmonbusApp.prototype.removeWaitCenterSpinner = function() {
+OuestmonbusApp.prototype.removeWaitCenterSpinner = function () {
if (this.waitSpinner !== null && this.waitSpinnerDisplayed) {
this.waitSpinner.remove(this.map);
@@ -285,7 +285,7 @@ OuestmonbusApp.prototype.removeWaitCenterSpinner = function() {
/**
* Ajuste la position des dialogues un peu plus en hauteur
*/
-OuestmonbusApp.prototype.updateDialogPosition = function(element_id) {
+OuestmonbusApp.prototype.updateDialogPosition = function (element_id) {
$(element_id).css("top", $(".app-bar").height() + Math.ceil(($(window).height() - $(".app-bar").height()) * 0.05));
};
@@ -293,11 +293,14 @@ OuestmonbusApp.prototype.updateDialogPosition = function(element_id) {
/**
* Initialise les textes
*/
-OuestmonbusApp.prototype.initTexts = function() {
+OuestmonbusApp.prototype.initTexts = function () {
$("#version").html(`Version ${version} (${date_version})`);
$("#app_news").html(marked.parse(`
+**17/06/2024:**
+- Correction suite au changement de format des données GTFS.
+
**03/05/2023:**
- Hébergement: Changement de serveur. Utilisation du serveur de tuile OpenStreetMap France.
@@ -335,7 +338,7 @@ Cette application web existe depuis 2015, c'est un logiciel libre sous [licence
/**
* Affichage de la carte.
*/
-OuestmonbusApp.prototype.initMap = function() {
+OuestmonbusApp.prototype.initMap = function () {
// Création de la carte
var southWest = L.latLng(47.9690, -2.0316);
@@ -353,7 +356,7 @@ OuestmonbusApp.prototype.initMap = function() {
position: "topleft",
noResultLabel: "Pas de résultat",
feedbackEmail: null,
- onSelected: function(feature) {
+ onSelected: function (feature) {
this.map.setView([feature.geometry.coordinates[1], feature.geometry.coordinates[0]], 16);
$(".photon-input").hide();
}.bind(this)
@@ -379,12 +382,12 @@ OuestmonbusApp.prototype.initMap = function() {
// Spinner d'attente de chargement des données
this.waitSpinner = L.control();
- this.waitSpinner.onAdd = function() {
+ this.waitSpinner.onAdd = function () {
this._div = L.DomUtil.create("div", "wait");
this.update();
return this._div;
};
- this.waitSpinner.update = function() {
+ this.waitSpinner.update = function () {
this._div.innerHTML = "
";
};
@@ -414,13 +417,13 @@ OuestmonbusApp.prototype.initMap = function() {
this.resetMapListener();
};
-OuestmonbusApp.prototype.resetMapListener = function() {
+OuestmonbusApp.prototype.resetMapListener = function () {
this.map.on("moveend", this.onMapMoveEnd.bind(this));
this.map.on("zoomend", this.onMapZoomEnd.bind(this));
};
-OuestmonbusApp.prototype.onMapZoomEnd = function() {
+OuestmonbusApp.prototype.onMapZoomEnd = function () {
if (this.stations_on_active_line_layer_group.getLayers().length > 0) {
var currentZoom = this.map.getZoom();
@@ -435,9 +438,9 @@ OuestmonbusApp.prototype.onMapZoomEnd = function() {
var iconSize = [icon_size, icon_size];
var iconAnchor = [icon_anchor, icon_anchor];
- this.stations_on_active_line_layer_group.eachLayer(function(layers) {
+ this.stations_on_active_line_layer_group.eachLayer(function (layers) {
layers.bringToBack();
- layers.eachLayer(function(layer) {
+ layers.eachLayer(function (layer) {
var icon_option = layer.getIcon();
icon_option["options"]["iconSize"] = icon_size;
icon_option["options"]["iconAnchor"] = icon_anchor;
@@ -448,7 +451,7 @@ OuestmonbusApp.prototype.onMapZoomEnd = function() {
};
-OuestmonbusApp.prototype.onMapMoveEnd = function() {
+OuestmonbusApp.prototype.onMapMoveEnd = function () {
this.hideDlg(true);
@@ -464,7 +467,7 @@ OuestmonbusApp.prototype.onMapMoveEnd = function() {
this.setLocalStorage("last_lng", lng);
};
-OuestmonbusApp.prototype.imgPicto = function(ligne) {
+OuestmonbusApp.prototype.imgPicto = function (ligne) {
return `/images/picto_${ligne}.png`;
};
@@ -472,7 +475,7 @@ OuestmonbusApp.prototype.imgPicto = function(ligne) {
/**
* Récupère les liens vers les fiches PDF des lignes
*/
-OuestmonbusApp.prototype.initPDFLinks = function() {
+OuestmonbusApp.prototype.initPDFLinks = function () {
this.allpdflinks = {};
@@ -480,19 +483,19 @@ OuestmonbusApp.prototype.initPDFLinks = function() {
log.debug("call API mkt-information-documents-td");
$.getJSON(url_api,
- function(data) {
+ function (data) {
var url_prefix = "https://data.explore.star.fr/explore/dataset/mkt-information-documents-td/files/"
- _.each(data.records, function(e, i) {
+ _.each(data.records, function (e, i) {
var pdflink_id = e.fields.file.id;
var ligne_id = e.fields.idligne;
this.allpdflinks[ligne_id] = url_prefix + pdflink_id + '/download/';
}.bind(this));
- }.bind(this)).fail(function() {
- this.app.displayAPIError("Impossible de récupérer les url des PDF");
- }.bind(this));
+ }.bind(this)).fail(function () {
+ this.app.displayAPIError("Impossible de récupérer les url des PDF");
+ }.bind(this));
}
-OuestmonbusApp.prototype.showOuestmonbusNewsDlg = function() {
+OuestmonbusApp.prototype.showOuestmonbusNewsDlg = function () {
this.hideDlg(true);
var dialog = $("#ouestmonbus_news_dlg").data("dialog");
@@ -502,7 +505,7 @@ OuestmonbusApp.prototype.showOuestmonbusNewsDlg = function() {
}
-OuestmonbusApp.prototype.hideDlg = function(dlg) {
+OuestmonbusApp.prototype.hideDlg = function (dlg) {
if (dlg) {
if (this.dialogCurrentDisplay) {
@@ -516,10 +519,10 @@ OuestmonbusApp.prototype.hideDlg = function(dlg) {
/**
* Initialise les boutons du menu.
*/
-OuestmonbusApp.prototype.initMenuButtons = function() {
+OuestmonbusApp.prototype.initMenuButtons = function () {
// Bouton News ouestmonbus
- $("#ouestmonbus_btn").click(function() {
+ $("#ouestmonbus_btn").click(function () {
this.showOuestmonbusNewsDlg();
}.bind(this));
if (this.md.mobile()) {
@@ -527,7 +530,7 @@ OuestmonbusApp.prototype.initMenuButtons = function() {
}
// Bouton localisation
- $("#localise_btn").click(function() {
+ $("#localise_btn").click(function () {
this.hideDlg(true);
this.addWaitCenterSpinner();
this.localisation.autoLocate();
@@ -537,7 +540,7 @@ OuestmonbusApp.prototype.initMenuButtons = function() {
}
// photon search
- $("#address_btn").click(function() {
+ $("#address_btn").click(function () {
this.hideDlg(true);
$(".photon-input").show();
$(".photon-input").focus();
@@ -547,7 +550,7 @@ OuestmonbusApp.prototype.initMenuButtons = function() {
}
// Affichage des perturbations
- $("#perturbations_btn").click(function() {
+ $("#perturbations_btn").click(function () {
var h = Math.ceil(($(window).height() - $(".app-bar").height() - $("#progressbar").height() - $("#legal_attribution").height()) * 0.8);
$("#trafic_dlg_content").height(h);
this.hideDlg(true);
@@ -561,7 +564,7 @@ OuestmonbusApp.prototype.initMenuButtons = function() {
}
// Bouton config
- $("#config_btn").click(function() {
+ $("#config_btn").click(function () {
var val = this.getLocalStorage("all_stations_mode") === 'true';
$("#all_stations_checkbox").prop('checked', val);
this.hideDlg(true);
@@ -575,7 +578,7 @@ OuestmonbusApp.prototype.initMenuButtons = function() {
}
// Validation de la config
- $("#config_valid_btn").click(function() {
+ $("#config_valid_btn").click(function () {
var all_stations_mode = $("#all_stations_checkbox").is(":checked");
this.setLocalStorage("all_stations_mode", all_stations_mode);
location.reload();
@@ -585,7 +588,7 @@ OuestmonbusApp.prototype.initMenuButtons = function() {
}
// Bouton aide
- $("#about_btn").click(function() {
+ $("#about_btn").click(function () {
this.hideDlg(true);
var dialog = $("#about_dlg").data("dialog");
this.dialogCurrentDisplay = dialog;
@@ -600,7 +603,7 @@ OuestmonbusApp.prototype.initMenuButtons = function() {
/**
* Affichage de la notice d'aide.
*/
-OuestmonbusApp.prototype.showHelp = function() {
+OuestmonbusApp.prototype.showHelp = function () {
if (this.needHelp) {
$.Notify({
@@ -618,7 +621,7 @@ OuestmonbusApp.prototype.showHelp = function() {
/**
* Affichage de la notification de légende retard.
*/
-OuestmonbusApp.prototype.displayRetardHelp = function() {
+OuestmonbusApp.prototype.displayRetardHelp = function () {
if (this.firstdisplayRetardHelp) {
$.Notify({
@@ -635,7 +638,7 @@ OuestmonbusApp.prototype.displayRetardHelp = function() {
/**
* Affichage de la notification de légende pas de bus.
*/
-OuestmonbusApp.prototype.displayNoBusHelp = function() {
+OuestmonbusApp.prototype.displayNoBusHelp = function () {
if (this.firstdisplayNoBusHelp) {
$.Notify({
@@ -654,7 +657,7 @@ OuestmonbusApp.prototype.displayNoBusHelp = function() {
* @param {moment} now - maintenant
* @return {string} - chemin
*/
-OuestmonbusApp.prototype.getDataStationPath = function(now) {
+OuestmonbusApp.prototype.getDataStationPath = function (now) {
var first = moment(now);
first.hour(5);
@@ -675,7 +678,7 @@ OuestmonbusApp.prototype.getDataStationPath = function(now) {
*
* @param {function} onSucess - fonction à executer après la récupération
*/
-OuestmonbusApp.prototype.getAllTodayStationsData = function(onSuccess) {
+OuestmonbusApp.prototype.getAllTodayStationsData = function (onSuccess) {
var url_data = this.getDataStationPath(moment());
@@ -683,15 +686,15 @@ OuestmonbusApp.prototype.getAllTodayStationsData = function(onSuccess) {
this.addWaitCenterSpinner();
$.getJSON(url_data,
- function(data) {
+ function (data) {
this.allStationsDataCache = data;
this.setLocalStorage("allStationsDataPath", url_data);
this.setLocalStorage("allStationsDataCache", JSON.stringify(data));
onSuccess(data);
- }.bind(this)).fail(function() {
- this.removeWaitCenterSpinner();
- this.displayAPIError("Connexion impossible aux données ouestmonbus");
- }.bind(this));
+ }.bind(this)).fail(function () {
+ this.removeWaitCenterSpinner();
+ this.displayAPIError("Connexion impossible aux données ouestmonbus");
+ }.bind(this));
} else {
onSuccess(this.allStationsDataCache);
}
@@ -703,7 +706,7 @@ OuestmonbusApp.prototype.getAllTodayStationsData = function(onSuccess) {
* @param {array} limits - [premier_passage,dernier_passage]
* @return {boolean} - true si à afficher
*/
-OuestmonbusApp.prototype.stationTimeFilter = function(now, limits) {
+OuestmonbusApp.prototype.stationTimeFilter = function (now, limits) {
// prevent error in GTFS data
if (limits === null || limits[0] === null || limits[1] === null) {
@@ -739,10 +742,13 @@ OuestmonbusApp.prototype.stationTimeFilter = function(now, limits) {
}
};
-OuestmonbusApp.prototype.isMetroLine = function(lines) {
+OuestmonbusApp.prototype.isMetroLine = function (lines) {
- var line_id = Number(lines[0].split(",")[0]);
- var res = _.size(lines) === 1 && (line_id === 1001 || line_id === 1002);
+ var line_id = lines[0].split(",")[0];
+ if (line_id.indexOf('-') > 0) {
+ line_id = line_id.split('-')[1];
+ }
+ var res = _.size(lines) === 1 && (Number(line_id) === 1001 || Number(line_id) === 1002);
return res;
};
@@ -752,7 +758,7 @@ OuestmonbusApp.prototype.isMetroLine = function(lines) {
* Affiche les stations sur la ligne active
*
*/
-OuestmonbusApp.prototype.displayStationsOnActiveLine = function(line, sens) {
+OuestmonbusApp.prototype.displayStationsOnActiveLine = function (line, sens) {
this.deleteAllSelectedStationsOnMap();
@@ -763,13 +769,13 @@ OuestmonbusApp.prototype.displayStationsOnActiveLine = function(line, sens) {
}
// récupère les stations sur la ligne
- var stations = _.filter(this.allStationsDataCache, function(e) {
+ var stations = _.filter(this.allStationsDataCache, function (e) {
return _.contains(e.properties.lines, line + ',' + sens);
});
// Génère un layer pour ces stations
var geoJsonLayer = L.geoJson(stations, {
- pointToLayer: function(feature, latlng) {
+ pointToLayer: function (feature, latlng) {
var stationIcon = L.icon({
iconUrl: iconpath,
@@ -785,7 +791,7 @@ OuestmonbusApp.prototype.displayStationsOnActiveLine = function(line, sens) {
icon: stationIcon
});
},
- onEachFeature: function(feature, marker) {
+ onEachFeature: function (feature, marker) {
marker.idarret = feature.properties.id;
marker.nomarret = feature.properties.name;
marker.lines = feature.properties.lines;
@@ -804,14 +810,14 @@ OuestmonbusApp.prototype.displayStationsOnActiveLine = function(line, sens) {
}
/**
- Callback lors d'un click sur une ligne
+ Callback lors d'un click sur une ligne
*/
-OuestmonbusApp.prototype.displayLine = function(line, sens) {
+OuestmonbusApp.prototype.displayLine = function (line, sens) {
this.displayStationsOnActiveLine(line, sens);
// met toutes les lignes en invisibles
- _.each(this.lines_layers, function(e) {
+ _.each(this.lines_layers, function (e) {
var line_color = e.color;
var invisible = {
opacity: 0,
@@ -821,12 +827,12 @@ OuestmonbusApp.prototype.displayLine = function(line, sens) {
}.bind(this));
// recupère la ligne selectionnée
- var line_layer = _.filter(this.lines_layers, function(e) {
+ var line_layer = _.filter(this.lines_layers, function (e) {
return (e.idligne === line && e.sens == sens);
});
var param = [`${line},${sens}`];
- this.displayLines(param, [], () => {});
+ this.displayLines(param, [], () => { });
};
/**
@@ -834,36 +840,46 @@ OuestmonbusApp.prototype.displayLine = function(line, sens) {
* @param {strings} lines "idligne,sens"
* @param {array[string]} extra_lines "ajoute une ligne qui n'est pas dans les parcours de la station (bus exceptionnel stade,..)"
*/
-OuestmonbusApp.prototype.displayLines = function(lines, extra_lines, fdone) {
+OuestmonbusApp.prototype.displayLines = function (lines, extra_lines, fdone) {
log.debug(`displayLines: ${lines} | ${extra_lines}`);
// Efface les précédentes lignes en cache
this.deleteAllSelectedStationsOnMap();
- _.each(this.lines_layers, function(layer) {
+ _.each(this.lines_layers, function (layer) {
this.map.removeLayer(layer);
}.bind(this));
this.lines_layers = [];
- var parcours_array = _.map(this.markerCurrentDisplay.parcours, function(item) {
+ var parcours_array = _.map(this.markerCurrentDisplay.parcours, function (item) {
return "id=" + item;
});
var q = parcours_array.join(" OR ");
if (extra_lines.length > 0) {
- var extra_lines_array = _.map(extra_lines, function(e) {
- return "idligne=" + e.split(",")[0];
+ var extra_lines_array = _.map(extra_lines, function (e) {
+ var line_id = e.split(",")[0];
+ if (line_id.indexOf('-') > 0) {
+ line_id = line_id.split('-')[1];
+ }
+ return "idligne=" + line_id;
});
q += " OR " + extra_lines_array.join(" OR ");
}
if (lines.length === 1) {
var line = lines[0].split(",")[0];
+ if (line.indexOf('-') > 0) {
+ line = line.split('-')[1];
+ }
q += " OR idligne=" + line;
}
// Ajoute les ligne dans l'ordre pour que la première ligne soit en premier plan.
var first_line = lines[0].split(",")[0];
+ if (first_line.indexOf('-') > 0) {
+ first_line = first_line.split('-')[1];
+ }
var lines_array = _.union(lines, extra_lines);
var args = [first_line, lines_array, fdone];
@@ -877,17 +893,17 @@ OuestmonbusApp.prototype.displayLines = function(lines, extra_lines, fdone) {
}
$.getJSON(url_api,
args,
- function(data) {
+ function (data) {
var first_line = args[0];
var lines_array = args[1];
var fdone = args[2];
- var data_sorted = _.sortBy(data.records, function(i) {
+ var data_sorted = _.sortBy(data.records, function (i) {
return i.fields.idligne === first_line;
});
- _.each(data_sorted, function(trace, index, list) {
+ _.each(data_sorted, function (trace, index, list) {
// Si première ligne on selectionne
if (index == (list.length - 1)) {
@@ -917,7 +933,7 @@ OuestmonbusApp.prototype.displayLines = function(lines, extra_lines, fdone) {
sensstr = "retour";
}
layer.bindPopup(this.generatePopupLineContent(trace.fields.idligne, sensstr, trace.fields.couleurtrace, trace.fields.libellelong, this.allpdflinks[trace.fields.idligne]));
- layer.on("click", function(e) {
+ layer.on("click", function (e) {
$(".line_info").parent().css("margin", 0);
$(".leaflet-popup-tip-container").remove();
e.layer.bringToFront();
@@ -938,7 +954,7 @@ OuestmonbusApp.prototype.displayLines = function(lines, extra_lines, fdone) {
/**
* Génération du contenu de la popup des lignes
*/
-OuestmonbusApp.prototype.generatePopupLineContent = function(idligne, sens, couleur, nom, pdfurl) {
+OuestmonbusApp.prototype.generatePopupLineContent = function (idligne, sens, couleur, nom, pdfurl) {
var img_picto = this.imgPicto(idligne);
var pdf_part = pdfurl ? `
Téléchargement de la fiche horaire` : ``;
@@ -952,12 +968,12 @@ OuestmonbusApp.prototype.generatePopupLineContent = function(idligne, sens, coul
*
* @param {geoJson} geoJsonData - stations du jour
*/
-OuestmonbusApp.prototype.displayAllStations = function(geoJsonData) {
+OuestmonbusApp.prototype.displayAllStations = function (geoJsonData) {
this.removeWaitCenterSpinner();
var geoJsonLayer = L.geoJson(geoJsonData, {
- pointToLayer: function(feature, latlng) {
+ pointToLayer: function (feature, latlng) {
var busIcon = L.icon({
iconUrl: "./images/station.png",
@@ -981,8 +997,12 @@ OuestmonbusApp.prototype.displayAllStations = function(geoJsonData) {
var icon = busIcon;
- var line_id = Number(feature.properties.lines[0].split(",")[0]);
- if (line_id === 1001 || line_id === 1002) {
+ var line_id = feature.properties.lines[0].split(",")[0];
+ if (line_id.indexOf('-') > 0) {
+ line_id = line_id.split('-')[1];
+ }
+
+ if (Number(line_id) === 1001 || Number(line_id) === 1002) {
icon = metroIcon;
}
@@ -990,12 +1010,12 @@ OuestmonbusApp.prototype.displayAllStations = function(geoJsonData) {
icon: icon
});
}.bind(this),
- filter: function(feature) {
+ filter: function (feature) {
var all_stations_mode = this.getLocalStorage("all_stations_mode") === 'true';
var time_ok = this.stationTimeFilter(moment(), feature.properties.limits);
return all_stations_mode || time_ok;
}.bind(this),
- onEachFeature: function(feature, marker) {
+ onEachFeature: function (feature, marker) {
marker.idarret = feature.properties.id;
marker.nomarret = feature.properties.name;
marker.lines = feature.properties.lines;
@@ -1040,7 +1060,7 @@ OuestmonbusApp.prototype.displayAllStations = function(geoJsonData) {
*
* @param {marker}
*/
-OuestmonbusApp.prototype.onEachMakerAdd = function(marker) {
+OuestmonbusApp.prototype.onEachMakerAdd = function (marker) {
var popup = L.popup({
autoPan: true,
@@ -1050,7 +1070,7 @@ OuestmonbusApp.prototype.onEachMakerAdd = function(marker) {
});
popup.setContent("");
marker.bindPopup(popup);
- marker.on("click", function() {
+ marker.on("click", function () {
this.openStation(marker);
}.bind(this));
};
@@ -1061,10 +1081,16 @@ OuestmonbusApp.prototype.onEachMakerAdd = function(marker) {
* @param {string} idarret
* @param {function} onSuccess - callback
*/
-OuestmonbusApp.prototype.getNextDepartures = function(lines, idarret, onSuccess, onFailed) {
+OuestmonbusApp.prototype.getNextDepartures = function (lines, idarret, onSuccess, onFailed) {
log.debug(`getNextDepartures: ${lines} ${idarret}`);
+ if (lines.indexOf('-') > 0) {
+ lines = lines.split('-')[1];
+ }
+ if (idarret.indexOf('-') > 0) {
+ idarret = idarret.split('-')[1];
+ }
if (this.isMetroLine(lines)) {
var url = `https://data.explore.star.fr/api/records/1.0/search?apikey=${apikey}&dataset=tco-metro-circulation-passages-tr&sort=-depart&refine.idarret=${idarret}&timezone=${tz}`;
@@ -1075,7 +1101,7 @@ OuestmonbusApp.prototype.getNextDepartures = function(lines, idarret, onSuccess,
}
$.getJSON(url,
- function(data) {
+ function (data) {
if (data) {
// check server time
@@ -1101,42 +1127,45 @@ OuestmonbusApp.prototype.getNextDepartures = function(lines, idarret, onSuccess,
onFailed();
}
- }.bind(this)).fail(function() {
- this.displayAPIError("échec de connexion au service opendata STAR");
- onFailed();
- }.bind(this));
+ }.bind(this)).fail(function () {
+ this.displayAPIError("échec de connexion au service opendata STAR");
+ onFailed();
+ }.bind(this));
};
-OuestmonbusApp.prototype.deleteAllBusOnMap = function() {
+OuestmonbusApp.prototype.deleteAllBusOnMap = function () {
this.bus_group_layer.clearLayers();
};
-OuestmonbusApp.prototype.deleteAllSelectedStationsOnMap = function() {
+OuestmonbusApp.prototype.deleteAllSelectedStationsOnMap = function () {
this.stations_on_active_line_layer_group.clearLayers();
};
-OuestmonbusApp.prototype.generatePopupBusContent = function(idligne, destination) {
+OuestmonbusApp.prototype.generatePopupBusContent = function (idligne, destination) {
var img_picto = this.imgPicto(idligne);
return `
Direction ${destination} `;
};
-OuestmonbusApp.prototype.getBusPositions = function(data, latlng) {
+OuestmonbusApp.prototype.getBusPositions = function (data, latlng) {
// prepare data
- var all_records = _.reduce(data.records, function(seed, item) {
+ var all_records = _.reduce(data.records, function (seed, item) {
seed.push(item.fields);
return seed;
}, []);
var lignes_selected = _.groupBy(all_records, "idligne");
- lignes_selected = _.map(lignes_selected, function(item) {
+ lignes_selected = _.map(lignes_selected, function (item) {
var first = _.first(item);
return [`${first.idligne},${first.sens}`];
});
lignes_selected = _.flatten(lignes_selected);
- var request = _.map(lignes_selected, function(e) {
+ var request = _.map(lignes_selected, function (e) {
var idligne = e.split(",")[0];
+ if (idligne.indexOf('-') > 0) {
+ idligne = idligne.split('-')[1];
+ }
var sens = e.split(",")[1];
return `idligne=${idligne} AND sens=${sens}`;
});
@@ -1148,38 +1177,38 @@ OuestmonbusApp.prototype.getBusPositions = function(data, latlng) {
log.debug("call API tco-bus-vehicules-position-tr");
$.getJSON(url_api,
- function(data) {
+ function (data) {
if (data) {
// Ajoute la ligne comme clé de dict
- var records = _.groupBy(data.records, function(e) {
+ var records = _.groupBy(data.records, function (e) {
return `${e.fields.idligne},${e.fields.sens}`;
});
// Position de la station
var station_l_latlng = this.normalizeLatLng(latlng);
// Résultat des positions classé par distance de la station et uniquement les ** 4 premiers bus **
- var records_distance_filtred = _.mapObject(records, function(r) {
- return _.first(_.sortBy(r, function(e) {
+ var records_distance_filtred = _.mapObject(records, function (r) {
+ return _.first(_.sortBy(r, function (e) {
return this.normalizeLatLng(e.geometry.coordinates).distanceTo(station_l_latlng);
}.bind(this)), 4);
}.bind(this));
// Ligne avec idlgine comme clé
- var lines_grouped = _.groupBy(this.lines_layers, function(e) {
+ var lines_grouped = _.groupBy(this.lines_layers, function (e) {
return `${e.idligne},${e.sens}`;
});
- var lines = _.mapObject(lines_grouped, function(e) {
- return _.map(e, function(x) {
+ var lines = _.mapObject(lines_grouped, function (e) {
+ return _.map(e, function (x) {
return x.getLayers()[0]._latlngs;
});
});
- _.each(records_distance_filtred, function(value, key) {
+ _.each(records_distance_filtred, function (value, key) {
this.genSegmentsTrajet(key, value, lines[key]);
}.bind(this));
}
}.bind(this)
- ).fail(function() {
+ ).fail(function () {
// TODO add error message
}.bind(this));
return;
@@ -1188,7 +1217,7 @@ OuestmonbusApp.prototype.getBusPositions = function(data, latlng) {
/*
Normalise les coordonnées. L'api peut répondre un array dans les deux sens.
*/
-OuestmonbusApp.prototype.normalizeLatLng = function(a) {
+OuestmonbusApp.prototype.normalizeLatLng = function (a) {
if (a[0] > 47 && a[1] < 0) {
return L.latLng(a[0], a[1]);
@@ -1206,9 +1235,9 @@ OuestmonbusApp.prototype.normalizeLatLng = function(a) {
log.debug(`Error: bad conversion: ${a}`);
}
-OuestmonbusApp.prototype.genSegmentsTrajet = function(ligne_sens, bus_positions, lines) {
+OuestmonbusApp.prototype.genSegmentsTrajet = function (ligne_sens, bus_positions, lines) {
- _.each(bus_positions, function(bus_position) {
+ _.each(bus_positions, function (bus_position) {
var idbus = bus_position.fields.idbus;
var url_api = `https://data.explore.star.fr/api/records/1.0/search?apikey=${apikey}&sort=-depart&dataset=tco-bus-circulation-passages-tr&refine.idbus=${idbus}&timezone=${tz}`;
@@ -1218,10 +1247,10 @@ OuestmonbusApp.prototype.genSegmentsTrajet = function(ligne_sens, bus_positions,
log.debug("call API tco-bus-circulation-passages-tr");
$.getJSON(url_api,
- function(data) {
+ function (data) {
if (data) {
// On ne tient pas compte des stations à moins de 10 secondes
- var records_10s_filtred = _.filter(data.records, function(e) {
+ var records_10s_filtred = _.filter(data.records, function (e) {
var now = moment();
var station_depart = moment(e.fields.depart);
var diff_second = station_depart.diff(now, 'seconds');
@@ -1261,7 +1290,7 @@ Cette fonction prend en paramètre, la position du bus, les 3 prochaine stations
Elle retourne un tableau [0]: un array de L.latLng du déplacement du bus à venir, [1]: le temps estimé que va prendre le bus pour parcourir le trajet.
Le trajet est calculé en utilisant les prochaines station jusqu'à 2 minutes de trajet soit atteint.
*/
-OuestmonbusApp.prototype.getParcoursSegmentsTimes = function(bus_position, first_next_stations, line) {
+OuestmonbusApp.prototype.getParcoursSegmentsTimes = function (bus_position, first_next_stations, line) {
var parcour_points = [];
var parcour_duration = 0;
@@ -1274,19 +1303,19 @@ OuestmonbusApp.prototype.getParcoursSegmentsTimes = function(bus_position, first
return;
}
// index dans la ligne du point de départ du bus
- var first_index = _.findIndex(line, function(e) {
+ var first_index = _.findIndex(line, function (e) {
return e.lat == first_point.lat && e.lon == first_point.lon;
});
var begin_index = first_index;
- _.each(first_next_stations, function(e) {
+ _.each(first_next_stations, function (e) {
if (parcour_duration < STATION_CONTENT_REFRESH) {
var next_station_point = L.GeometryUtil.closest(this.map, line, this.normalizeLatLng(e.fields.coordonnees), true);
if (next_station_point.distance > 250) {
log.debug("Bus hors parcours");
return;
}
- var next_station_index = _.findIndex(line, function(x) {
+ var next_station_index = _.findIndex(line, function (x) {
return x.lat == next_station_point.lat && x.lon == next_station_point.lon;
});
var part_line = line.slice(begin_index, next_station_index);
@@ -1307,18 +1336,18 @@ Prend en paramètre les 3 prochaines stations d'un bus et les parcours connus du
Retourne le parcours le plus proche des 3 prochaines stations.
Si > 2 km on retourn null, on considère que le parcours est inconnu.
*/
-OuestmonbusApp.prototype.getLignesForNextStation = function(first_next_stations, lines) {
+OuestmonbusApp.prototype.getLignesForNextStation = function (first_next_stations, lines) {
// Genere un array des positions des prochaines stations
- var first_next_stations_array = _.map(first_next_stations, function(e) {
+ var first_next_stations_array = _.map(first_next_stations, function (e) {
return e.geometry.coordinates;
});
// pour chaque ligne
- var distances = _.map(lines, function(line_pos) {
+ var distances = _.map(lines, function (line_pos) {
var distance = 0;
// Pour chaque station
- _.each(first_next_stations_array, function(station_pos) {
+ _.each(first_next_stations_array, function (station_pos) {
// On inverse lat et lon car API Star donne dans le sens inverse Leaflet
var pos_station = this.normalizeLatLng(station_pos);
// Le point le plus proche de la station sur tous les points de la ligne
@@ -1329,7 +1358,7 @@ OuestmonbusApp.prototype.getLignesForNextStation = function(first_next_stations,
return [line_pos, distance];
}.bind(this));
- var res = _.first(_.sortBy(distances, function(e) {
+ var res = _.first(_.sortBy(distances, function (e) {
return e[1]
}));
if (_.isUndefined(res)) {
@@ -1344,7 +1373,7 @@ OuestmonbusApp.prototype.getLignesForNextStation = function(first_next_stations,
}
-OuestmonbusApp.prototype.addBusIconOnMap = function(idbus, parcours, durations, idligne, sens, destination) {
+OuestmonbusApp.prototype.addBusIconOnMap = function (idbus, parcours, durations, idligne, sens, destination) {
log.debug(`Ajout de bus sur la carte idligne: ${idligne}`);
@@ -1373,7 +1402,7 @@ OuestmonbusApp.prototype.addBusIconOnMap = function(idbus, parcours, durations,
closeButton: false,
className: "bus_popup"
});
- marker.on("click", function() {
+ marker.on("click", function () {
$(".bus_info").parent().css("margin", 0);
$(".leaflet-popup-tip-container").remove();
@@ -1386,10 +1415,10 @@ OuestmonbusApp.prototype.addBusIconOnMap = function(idbus, parcours, durations,
/*
Enleve l'ancien layer du bus et ajoute le nouveau.
*/
-OuestmonbusApp.prototype.updateBusMarker = function(busMarker) {
+OuestmonbusApp.prototype.updateBusMarker = function (busMarker) {
var bus_already_on_map = false;
- this.bus_group_layer.eachLayer(function(layer) {
+ this.bus_group_layer.eachLayer(function (layer) {
if (layer.idbus === busMarker.idbus) {
this.bus_group_layer.removeLayer(layer);
this.bus_group_layer.addLayer(busMarker);
@@ -1403,10 +1432,10 @@ OuestmonbusApp.prototype.updateBusMarker = function(busMarker) {
};
-OuestmonbusApp.prototype.refreshBusCountHtml = function() {
+OuestmonbusApp.prototype.refreshBusCountHtml = function () {
var bus_count_on_map = 0;
- this.bus_group_layer.eachLayer(function(layer) {
+ this.bus_group_layer.eachLayer(function (layer) {
if (!_.isUndefined(layer.idbus)) {
bus_count_on_map++;
}
@@ -1429,11 +1458,11 @@ OuestmonbusApp.prototype.refreshBusCountHtml = function() {
/*
Callback lors du click sur le bouton ce recentrage de la carte sur les bus.
*/
-OuestmonbusApp.prototype.onBusCountClick = function() {
+OuestmonbusApp.prototype.onBusCountClick = function () {
var bus_map_bounds = [this.markerCurrentDisplay.getLatLng()];
- this.bus_group_layer.eachLayer(function(layer) {
+ this.bus_group_layer.eachLayer(function (layer) {
if (!_.isUndefined(layer.idbus)) {
bus_map_bounds.push(layer.getLatLng());
}
@@ -1449,19 +1478,19 @@ OuestmonbusApp.prototype.onBusCountClick = function() {
*
* @param {L.marker} marker -
*/
-OuestmonbusApp.prototype.openStation = function(marker) {
+OuestmonbusApp.prototype.openStation = function (marker) {
this.needHelp = false;
this.delayRefreshAllStations();
this.markerCurrentDisplay = marker;
- this.getNextDepartures(marker.lines, marker.idarret, function(data) {
+ this.getNextDepartures(marker.lines, marker.idarret, function (data) {
this.setPopupContent(marker, data);
marker.openPopup();
if (Number(data.nhits) > 0) {
this.refreshLinesBus(marker, data);
}
- }.bind(this), function() {
+ }.bind(this), function () {
this.setPopupContent(marker, null);
marker.openPopup();
}.bind(this));
@@ -1470,7 +1499,7 @@ OuestmonbusApp.prototype.openStation = function(marker) {
};
-OuestmonbusApp.prototype.setOrigin = function(marker) {
+OuestmonbusApp.prototype.setOrigin = function (marker) {
this.localisation.deleteMarkerMe.call(this.localisation);
@@ -1481,7 +1510,7 @@ OuestmonbusApp.prototype.setOrigin = function(marker) {
zIndexOffset: -1
});
- this.bus_station_origin.on("click", function(e) {
+ this.bus_station_origin.on("click", function (e) {
this.moveMapTo(e.latlng, this.map.DEFAULT_ZOOM);
}.bind(this));
@@ -1492,7 +1521,7 @@ OuestmonbusApp.prototype.setOrigin = function(marker) {
* Fonction apppellé lorsque l'utilisateur clique sur la station la plus
* proche après une localisation.
*/
-OuestmonbusApp.prototype.followNearestStation = function() {
+OuestmonbusApp.prototype.followNearestStation = function () {
this.moveMapTo(this.localisation.nearestStation.marker.getLatLng(),
this.map.DEFAULT_ZOOM,
@@ -1503,7 +1532,7 @@ OuestmonbusApp.prototype.followNearestStation = function() {
/**
* Mets à jour le contenue d'une popup de station
*/
-OuestmonbusApp.prototype.setPopupContent = function(marker, data) {
+OuestmonbusApp.prototype.setPopupContent = function (marker, data) {
var content = this.generatePopupContent(marker, data);
var popup = marker.getPopup();
@@ -1511,7 +1540,7 @@ OuestmonbusApp.prototype.setPopupContent = function(marker, data) {
//popup.update();
};
-OuestmonbusApp.prototype.getStationUrl = function(marker) {
+OuestmonbusApp.prototype.getStationUrl = function (marker) {
var z = this.map.DEFAULT_ZOOM;
var lat = Number(marker.getLatLng().lat).toFixed(5);
@@ -1521,7 +1550,7 @@ OuestmonbusApp.prototype.getStationUrl = function(marker) {
return station_url;
};
-OuestmonbusApp.prototype.generateImgHtml = function(idligne, sens) {
+OuestmonbusApp.prototype.generateImgHtml = function (idligne, sens) {
var img_picto = this.imgPicto(idligne);
return `
`;
};
@@ -1534,7 +1563,7 @@ OuestmonbusApp.prototype.generateImgHtml = function(idligne, sens) {
*
* @return {string} - code html
*/
-OuestmonbusApp.prototype.generatePopupContent = function(marker, data) {
+OuestmonbusApp.prototype.generatePopupContent = function (marker, data) {
var station_url = this.getStationUrl(marker);
@@ -1543,12 +1572,17 @@ OuestmonbusApp.prototype.generatePopupContent = function(marker, data) {
var lines_array = marker.lines;
- _.each(lines_array, function(item) {
+ _.each(lines_array, function (item) {
var a = item.split(",");
- if (_.indexOf(lines_header, a[0]) === -1) {
- lines_img += this.generateImgHtml(a[0], a[1]);
+ var line_id = a[0];
+ if (line_id.indexOf('-') > 0) {
+ line_id = line_id.split('-')[1];
+ }
+ var sens = a[1];
+ if (_.indexOf(lines_header, line_id) === -1) {
+ lines_img += this.generateImgHtml(line_id, sens);
lines_img += ' ';
- lines_header.push(a[0]);
+ lines_header.push(line_id);
}
}.bind(this));
@@ -1567,7 +1601,7 @@ OuestmonbusApp.prototype.generatePopupContent = function(marker, data) {
if (Number(data.nhits) > 0) {
// prepare data
- var all_records = _.reduce(data.records, function(seed, item) {
+ var all_records = _.reduce(data.records, function (seed, item) {
seed.push(item.fields);
return seed;
}, []);
@@ -1577,9 +1611,9 @@ OuestmonbusApp.prototype.generatePopupContent = function(marker, data) {
var pluriel = all_records.length > 1 ? "s" : "";
full_content += ` ${retard_min_prefix} ${t} min`;
} else
- if (accurate && (retard_min !== 0)) {
- this.displayRetardHelp();
- retard_str = `
${retard_min_prefix} ${t} min`;
- }
+ if (accurate && (retard_min !== 0)) {
+ this.displayRetardHelp();
+ retard_str = `
${retard_min_prefix} ${t} min`;
+ }
var line_h = "";
var wait_str = "";
@@ -1723,7 +1757,7 @@ OuestmonbusApp.prototype.generateLineDeparture = function(localtime, time, accur
/**
* Informe l'utilisateur que l'API STAR est en rade..
*/
-OuestmonbusApp.prototype.displayAPIError = function(err) {
+OuestmonbusApp.prototype.displayAPIError = function (err) {
if (this.markerCurrentDisplay) {
this.markerCurrentDisplay.getPopup().setContent(`
Erreur: ${err}`);
@@ -1739,46 +1773,46 @@ OuestmonbusApp.prototype.displayAPIError = function(err) {
/**
* Annule et relance un timer pour le rafraîchissement des stations.
*/
-OuestmonbusApp.prototype.delayRefreshAllStations = function() {
+OuestmonbusApp.prototype.delayRefreshAllStations = function () {
if (this.refreshAllStationsTimer) {
clearTimeout(this.refreshAllStationsTimer);
}
- this.refreshAllStationsTimer = setTimeout(function() {
+ this.refreshAllStationsTimer = setTimeout(function () {
this.getAllTodayStationsData(this.displayAllStations.bind(this));
}.bind(this), STATION_LIST_REFRESH);
};
-OuestmonbusApp.prototype.refreshLinesBus = function(markerCurrentDisplay, data) {
+OuestmonbusApp.prototype.refreshLinesBus = function (markerCurrentDisplay, data) {
// prepare data
- var all_records = _.reduce(data.records, function(seed, item) {
+ var all_records = _.reduce(data.records, function (seed, item) {
seed.push(item.fields);
return seed;
}, []);
// Affichage des lignes
- var lines_sens = _.map(all_records, function(item) {
+ var lines_sens = _.map(all_records, function (item) {
return item.idligne + "," + item.sens;
});
lines_sens = _.uniq(lines_sens);
// extra lines : lignes annoncées au passage mais qui n'étaient pas prévu par les données GTFS
// cas observé une fois, à vérifier si pertinent de garder le code.
- var extra_lines = _.reject(lines_sens, function(e) {
+ var extra_lines = _.reject(lines_sens, function (e) {
return _.contains(this, e);
}, this.markerCurrentDisplay.lines);
var lignes_selected = _.groupBy(all_records, "idligne");
- lignes_selected = _.map(lignes_selected, function(item) {
+ lignes_selected = _.map(lignes_selected, function (item) {
var first = _.first(item);
return ["" + first.idligne + "," + first.sens];
});
lignes_selected = _.flatten(lignes_selected);
if ((lignes_selected.join() !== this.last_lignes_selected.join()) && markerCurrentDisplay.line_selected == false) {
- this.displayLines(lines_sens, extra_lines, function() {
+ this.displayLines(lines_sens, extra_lines, function () {
this.deleteAllBusOnMap();
this.getBusPositions(data, this.markerCurrentDisplay._latlng);
this.last_lignes_selected = lignes_selected;
@@ -1800,22 +1834,22 @@ OuestmonbusApp.prototype.refreshLinesBus = function(markerCurrentDisplay, data)
/**
* Rafraichie le contenue de la station actuellement ouverte
*/
-OuestmonbusApp.prototype.refreshStation = function() {
+OuestmonbusApp.prototype.refreshStation = function () {
this.startprogressBar();
if (this.refreshStationTimer) {
clearTimeout(this.refreshStationTimer);
}
- this.refreshStationTimer = setTimeout(function() {
+ this.refreshStationTimer = setTimeout(function () {
if (this.markerCurrentDisplay) {
- this.getNextDepartures(this.markerCurrentDisplay.lines, this.markerCurrentDisplay.idarret, function(data) {
+ this.getNextDepartures(this.markerCurrentDisplay.lines, this.markerCurrentDisplay.idarret, function (data) {
// Generation du contenue de la popup
this.setPopupContent(this.markerCurrentDisplay, data);
if (Number(data.nhits) > 0) {
// Update lines and bus
this.refreshLinesBus(this.markerCurrentDisplay, data);
}
- }.bind(this), function() {
+ }.bind(this), function () {
this.setPopupContent(this.markerCurrentDisplay, null);
}.bind(this));
this.refreshStation();
@@ -1823,13 +1857,13 @@ OuestmonbusApp.prototype.refreshStation = function() {
}.bind(this), STATION_CONTENT_REFRESH);
};
-OuestmonbusApp.prototype.startprogressBar = function() {
+OuestmonbusApp.prototype.startprogressBar = function () {
this.stopprogressBar();
this.progressbar.animate(1);
};
-OuestmonbusApp.prototype.stopprogressBar = function() {
+OuestmonbusApp.prototype.stopprogressBar = function () {
this.progressbar.stop();
this.progressbar.set(0);
@@ -1848,7 +1882,7 @@ function InfosTrafics(app) {
}
-InfosTrafics.prototype.fetchLinesAndAlerts = function() {
+InfosTrafics.prototype.fetchLinesAndAlerts = function () {
var isoNow = moment().toISOString(false);
var q = encodeURIComponent(`debutvalidite < ${isoNow} AND finvalidite > ${isoNow}`);
@@ -1859,30 +1893,30 @@ InfosTrafics.prototype.fetchLinesAndAlerts = function() {
log.debug("call API tco-busmetro-trafic-alertes-tr");
$.getJSON(url_api,
- function(data) {
- _.each(data.records, function(info) {
+ function (data) {
+ _.each(data.records, function (info) {
var picto_html = this.getPictoHtml(info.fields.idligne);
var c = this.formatDetail(info.fields.description);
this.html += `
${info.fields.titre}
${picto_html}
${c}
`;
this.count += 1;
}.bind(this));
- }.bind(this)).fail(function() {
- this.app.displayAPIError("Impossible de récupérer les infos trafics (connect)");
- }.bind(this)).done(function() {
- this.html += "
";
- $("#trafic_dlg_content").html(this.html);
- $("#perturbations_btn").attr("data-hint", `Infos trafic| ${this.count} pertubations`);
- }.bind(this));
+ }.bind(this)).fail(function () {
+ this.app.displayAPIError("Impossible de récupérer les infos trafics (connect)");
+ }.bind(this)).done(function () {
+ this.html += "";
+ $("#trafic_dlg_content").html(this.html);
+ $("#perturbations_btn").attr("data-hint", `Infos trafic| ${this.count} pertubations`);
+ }.bind(this));
};
-InfosTrafics.prototype.getPictoHtml = function(ligne) {
+InfosTrafics.prototype.getPictoHtml = function (ligne) {
var img_picto = this.app.imgPicto(ligne);
var html = `
`;
return html;
};
-InfosTrafics.prototype.formatDetail = function(input) {
+InfosTrafics.prototype.formatDetail = function (input) {
return input.replace(/(?:\r\n|\r|\n)/g, "
");
};
@@ -1916,7 +1950,7 @@ function Localization(app, map) {
/**
* Localise l'utilisateur avec le navigateur.
*/
-Localization.prototype.autoLocate = function() {
+Localization.prototype.autoLocate = function () {
this.map.locate({
setView: true,
@@ -1929,13 +1963,13 @@ Localization.prototype.autoLocate = function() {
/**
* Appelé quand la localisation est trouvée.
*/
-Localization.prototype.onLocationFound = function(e) {
+Localization.prototype.onLocationFound = function (e) {
this.app.removeWaitCenterSpinner();
this.showLocation(e.latlng, true, true, Math.round(e.accuracy / 2));
};
-Localization.prototype.deleteMarkerMe = function() {
+Localization.prototype.deleteMarkerMe = function () {
if (this.marker_me && this.map.hasLayer(this.marker_me)) {
this.map.removeLayer(this.marker_me);
@@ -1945,7 +1979,7 @@ Localization.prototype.deleteMarkerMe = function() {
}
};
-Localization.prototype.showLocation = function(latlng, youarehere, show_circle, radius) {
+Localization.prototype.showLocation = function (latlng, youarehere, show_circle, radius) {
if (this.map.getBounds().contains(latlng)) {
@@ -2002,7 +2036,7 @@ Localization.prototype.showLocation = function(latlng, youarehere, show_circle,
$("#localisation_nothere_dlg_close").click({
dlg: dialog
- }, function(e) {
+ }, function (e) {
e.data.dlg.close();
$(".photon-input").show();
$(".photon-input").focus();
@@ -2016,7 +2050,7 @@ Localization.prototype.showLocation = function(latlng, youarehere, show_circle,
};
-Localization.prototype.findNearestStation = function(latlng) {
+Localization.prototype.findNearestStation = function (latlng) {
var nearestStation = {};
var res = L.GeometryUtil.closestLayer(this.map, this.map.cluster_markers.getLayers(), latlng);
@@ -2033,7 +2067,7 @@ Localization.prototype.findNearestStation = function(latlng) {
/**
* Appelé quand la localisation n'est trouvée.
*/
-Localization.prototype.onLocationError = function() {
+Localization.prototype.onLocationError = function () {
this.app.removeWaitCenterSpinner();
var dialog = $("#localisation_failed_dlg").data("dialog");
@@ -2041,7 +2075,7 @@ Localization.prototype.onLocationError = function() {
$("#localisation_failed_dlg_close").click({
dlg: dialog
- }, function(e) {
+ }, function (e) {
e.data.dlg.close();
$(".photon-input").show();
$(".photon-input").focus();
@@ -2056,7 +2090,7 @@ Localization.prototype.onLocationError = function() {
*
* @param {string} url
*/
-Localization.prototype.urlToZoomLatLng = function(url) {
+Localization.prototype.urlToZoomLatLng = function (url) {
var res = null;
try {