Skip to content
Snippets Groups Projects
Commit cd2d2909 authored by Anton Sarukhanov's avatar Anton Sarukhanov
Browse files

Fixed infinite loop on invalid modal request, and implemented modal contents caching

parent 1c2b42bb
No related branches found
No related tags found
1 merge request!1Implemented Embed-code generator interface
...@@ -15,6 +15,7 @@ BusMap.Map = function(opts) { ...@@ -15,6 +15,7 @@ BusMap.Map = function(opts) {
this.opts = opts; this.opts = opts;
var stops = {}; var stops = {};
var routes = {}; var routes = {};
var modal_cache = {};
var that = this; var that = this;
window._busmap = this; window._busmap = this;
...@@ -399,10 +400,18 @@ BusMap.Map = function(opts) { ...@@ -399,10 +400,18 @@ BusMap.Map = function(opts) {
query: "modal", query: "modal",
modal_name: name, modal_name: name,
}; };
$.get("ajax", params).done(function(contents) { if (modal_cache[name]) {
modal.append(contents); modal.append(modal_cache[name]);
}); setUrlFromView();
setUrlFromView(); } else {
$.get("ajax", params).done(function(contents) {
modal_cache[name] = contents;
modal.append(contents);
setUrlFromView();
}).fail(function() {
modal.append("Please refresh the page and try again.");
});
}
} }
// Scaling: update what is displayed based on zoom level // Scaling: update what is displayed based on zoom level
...@@ -428,7 +437,7 @@ BusMap.Map = function(opts) { ...@@ -428,7 +437,7 @@ BusMap.Map = function(opts) {
return; return;
} }
var hash = window.location.hash.substring(1); var hash = window.location.hash.substring(1);
if (hash == "") return false; if (hash == "") return;
var parts = hash.split(";"); var parts = hash.split(";");
// First part: view string (lat,lon,zoom; vehicle; or stop) // First part: view string (lat,lon,zoom; vehicle; or stop)
applyViewString(parts[0]); applyViewString(parts[0]);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment