"use strict"; //if (!console) console = { log: function() {} }; var maptypes = {}; var clocks = {}; function splitArgs(s) { var r = s.split(' '); delete arguments[0]; var obj = {}; var index = 0; $.each(arguments, function(argumentIndex, argument) { if (!argumentIndex) return; var value = r[argumentIndex-1]; obj[argument] = value; }); return obj; } function swtch(value, options, defaultOption) { return (options[value] || defaultOption)(value); } function DynMapType() { } DynMapType.prototype = { onTileUpdated: function(tile, tileName) { var src = this.dynmap.getTileUrl(tileName); tile.attr('src', src); tile.show(); }, updateTileSize: function(zoom) {} }; function DynMap(options) { var me = this; me.options = options; $.getJSON(me.options.updateUrl + 'configuration', function(configuration) { me.configure(configuration); me.initialize(); }) } DynMap.prototype = { worlds: {}, registeredTiles: new Array(), markers: new Array(), chatPopups: new Array(), lasttimestamp: '0', followingPlayer: '', configure: function(configuration) { var me = this; $.extend(me.options, configuration); $.each(me.options.worlds, function(index, worldentry) { var world = me.worlds[worldentry.name] = $.extend({}, worldentry, { maps: {} }); $.each(worldentry.maps, function(index, mapentry) { var map = $.extend({}, mapentry, { world: world, dynmap: me }); map = world.maps[mapentry.name] = maptypes[mapentry.type](map); world.defaultmap = world.defaultmap || map; }); me.defaultworld = me.defaultworld || world; }); }, initialize: function() { var me = this; var container = $(me.options.container); container.addClass('dynmap'); var mapContainer; (mapContainer = $('
')) .addClass('map') .appendTo(container); var map = this.map = new google.maps.Map(mapContainer.get(0), { zoom: 1, center: new google.maps.LatLng(0, 1), navigationControl: true, navigationControlOptions: { style: google.maps.NavigationControlStyle.DEFAULT }, scaleControl: false, mapTypeControl: false, streetViewControl: false, backgroundColor: 'none' }); map.zoom_changed = function() { me.maptype.updateTileSize(me.map.zoom); }; google.maps.event.addListener(map, 'dragstart', function(mEvent) { me.followPlayer(''); }); // TODO: Enable hash-links. /*google.maps.event.addListener(map, 'zoom_changed', function() { me.updateLink(); }); google.maps.event.addListener(map, 'center_changed', function() { me.updateLink(); });*/ // Sidebar var sidebar = me.sidebar = $('
') .addClass('sidebar') .appendTo(container); var panel = $('
') .addClass('panel') .appendTo(sidebar); // Pin button. var pinbutton = $('
') .addClass('pin') .click(function() { sidebar.toggleClass('pinned'); }) .appendTo(panel); // Worlds var worldlist; $('
') .append($('').text('Map Types')) .append(me.worldlist = worldlist = $('