diff --git a/web/config.js b/web/config.js index 0b6ab591..a54b37a3 100644 --- a/web/config.js +++ b/web/config.js @@ -1,9 +1,33 @@ var config = { + // For internal server or proxying webserver. + url: { + configuration: 'up/configuration', + update: 'up/world/{world}/{timestamp}', + sendmessage: 'up/sendmessage' + }, + + // For proxying webserver through php. + //url: { + // configuration: 'up.php?path=configuration', + // update: 'up.php?path=world/{world}/?{timestamp}', + // sendmessage: 'up.php?path=sendmessage' + //}, + + // For proxying webserver through aspx. + //url: { + // configuration: 'up.aspx?path=configuration', + // update: 'up.aspx?path=world/{world}/?{timestamp}', + // sendmessage: 'up.aspx?path=sendmessage' + //}, + + // For standalone (jsonfile) webserver. + //url: { + // configuration: 'standalone/dynmap_config.json', + // update: 'standalone/dynmap_{world}.json', + // sendmessage: 'standalone/sendmessage.php' + //}, + tileUrl: 'tiles/', - updateUrl: 'up/', // For Apache and lighttpd -// updateUrl: 'up.php?path=', // For Apache and lighttpd without ability to natively proxy -// updateUrl: 'up.aspx?path=', // For IIS -// configurationUrl: 'standalone/dynmap_config.json', // For some standalone setups. - tileWidth: 128, - tileHeight: 128 + tileWidth: 128, + tileHeight: 128 }; \ No newline at end of file diff --git a/web/js/map.js b/web/js/map.js index 4114f525..539b80be 100644 --- a/web/js/map.js +++ b/web/js/map.js @@ -78,7 +78,7 @@ function Location(world, x, y, z) { function DynMap(options) { var me = this; me.options = options; - $.getJSON(me.options.configurationUrl || (me.options.updateUrl + 'configuration'), function(configuration) { + $.getJSON(me.options.url.configuration, function(configuration) { me.configure(configuration); me.initialize(); }, function(status, statusMessage) { @@ -92,6 +92,13 @@ DynMap.prototype = { players: {}, lasttimestamp: '0', followingPlayer: '', + formatUrl: function(name, options) { + var url = this.options.url[name]; + $.each(options, function(n,v) { + url = url.replace("{" + n + "}", v); + }); + return url; + }, configure: function(configuration) { var me = this; $.extend(me.options, configuration); @@ -352,7 +359,7 @@ DynMap.prototype = { var me = this; $(me).trigger('worldupdating'); - $.getJSON(me.options.updateUrl + "world/" + me.world.name + "/" + me.lasttimestamp, function(update) { + $.getJSON(me.formatUrl('update', { world: me.world.name, timestamp: me.lasttimestamp }), function(update) { if (!update) { setTimeout(function() { me.update(); }, me.options.updaterate); return;