Added function to parse the URL query string to set config parameters.
This commit is contained in:
parent
271caf6f20
commit
a73450ac92
Notes:
subgit
2018-03-07 17:58:52 +01:00
r637 www/trunk
26
www/misc.js
26
www/misc.js
@ -71,6 +71,17 @@ $( window ).resize(function() {
|
|||||||
setInfoHeight();
|
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 */
|
/* create global vars */
|
||||||
var map;
|
var map;
|
||||||
var openMarkerID;
|
var openMarkerID;
|
||||||
@ -111,6 +122,21 @@ var config = {
|
|||||||
* document ready *
|
* document ready *
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
$(document).ready(function() {
|
$(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
|
// AJAX setup
|
||||||
$.ajaxSetup({timeout: config['ajax']['timeout']});
|
$.ajaxSetup({timeout: config['ajax']['timeout']});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user