//if (!console) console = { log: function() {} }; 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(); } }; function MinecraftClock(element) { this.element = element; } MinecraftClock.prototype = { element: null, timeout: null, time: null, create: function(element) { if (!element) element = $('
'); this.element = element; return element; }, setTime: function(time) { if (this.timeout != null) { window.clearTimeout(this.timeout); this.timeout = null; } this.time = time; this.element .addClass(time.day ? 'day' : 'night') .removeClass(time.night ? 'day' : 'night') .text(this.formatTime(time)); if (this.timeout == null) { var me = this; this.timeout = window.setTimeout(function() { me.timeout = null; me.setTime(getMinecraftTime(me.time.servertime+(1000/60))); }, 700); } }, formatTime: function(time) { var formatDigits = function(n, digits) { var s = n.toString(); while (s.length < digits) { s = '0' + s; } return s; } return formatDigits(time.hours, 2) + ':' + formatDigits(time.minutes, 2); } }; function DynMap(options) { this.options = options; this.initialize(); } DynMap.prototype = { registeredTiles: new Array(), clock: null, markers: new Array(), lasttimestamp: '0', followingPlayer: '', initialize: function() { var me = this; var container = $(me.options.container); 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' }); 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(); });*/ // The sidebar var sidebar = me.sidebar = $('
') .addClass('sidebar') .appendTo(container); // The map list. var maplist = me.maplist = $('
') .addClass('maplist') .appendTo(sidebar); $.each(me.options.maps, function(name, mapType){ mapType.dynmap = me; map.mapTypes.set(name, mapType); var mapButton; $('
') .addClass('maprow') .append(mapButton = $('') .addClass('maptype_' + name) .attr({ type: 'radio', name: 'map', id: 'maptypebutton_' + name }) .attr('checked', me.options.defaultMap == name ? 'checked' : null) ) .append($('