Added function to parse the URL query string to set config parameters.

This commit is contained in:
Kasper D. Fischer 2014-05-14 05:21:19 +00:00
parent 271caf6f20
commit a73450ac92
Notes: subgit 2018-03-07 17:58:52 +01:00
r637 www/trunk

View File

@ -71,6 +71,17 @@ $( window ).resize(function() {
setInfoHeight();
});
/* parseQueryString */
function parseQueryString() {
var query = (window.location.search || '?').substr(1),
map = {};
query.replace(/([^&=]+)=?([^&]*)(?:&+|$)/g, function(match, key, value) {
key.toLowerCase();
(map[key] = map[key] || []).push(value);
});
return map;
}
/* create global vars */
var map;
var openMarkerID;
@ -111,6 +122,21 @@ var config = {
* document ready *
**********************************************************************/
$(document).ready(function() {
// parse query string
var parameters = parseQueryString();
if ( Number(parameters['minmag']) ) {
config['event']['minMag'] = Number(parameters['minmag']);
};
if ( parameters['markercolor'] ) {
config['event']['markerColor'] = parameters['markercolor'];
};
if ( parameters['markercolorh'] ) {
config['event']['markerColorH'] = parameters['markercolorh'];
};
if ( Number(parameters['timespan']) ) {
config['map']['timespan'] = Number(parameters['timespan']);
};
// AJAX setup
$.ajaxSetup({timeout: config['ajax']['timeout']});