Initial commit
This commit is contained in:
47
Creative/dynmap/web/js/chat.js
Normal file
47
Creative/dynmap/web/js/chat.js
Normal file
@@ -0,0 +1,47 @@
|
||||
|
||||
componentconstructors['chat'] = function(dynmap, configuration) {
|
||||
var me = this;
|
||||
|
||||
if(dynmap.getBoolParameterByName("hidechat"))
|
||||
return;
|
||||
|
||||
// Provides 'chat'-events by monitoring the world-updates.
|
||||
$(dynmap).bind('worldupdate', function(event, update) {
|
||||
swtch(update.type, {
|
||||
chat: function() {
|
||||
$(dynmap).trigger('chat', [{source: update.source, name: update.playerName, text: update.message, account: update.account,
|
||||
channel: update.channel}]);
|
||||
}
|
||||
});
|
||||
});
|
||||
var pname = null;
|
||||
if(configuration.allowurlname) {
|
||||
pname = dynmap.getParameterByName("chatname");
|
||||
if(pname == "") pname = null;
|
||||
}
|
||||
|
||||
if (dynmap.options.allowwebchat) {
|
||||
// Accepts 'sendchat'-events to send chat messages to the server.
|
||||
$(dynmap).bind('sendchat', function(event, message) {
|
||||
var data = '{"name":'+JSON.stringify(pname?pname:"")+',"message":'+JSON.stringify(message)+'}';
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
contentType: "application/json; charset=utf-8",
|
||||
url: config.url.sendmessage,
|
||||
data: data,
|
||||
dataType: 'json',
|
||||
success: function(response) {
|
||||
if(response.error != "none") {
|
||||
var msg = dynmap.options['msg-chatnotallowed'];
|
||||
$(dynmap).trigger('chat', [{source: 'me', name: 'Error', text: msg }]);
|
||||
}
|
||||
},
|
||||
error: function(xhr) {
|
||||
if (xhr.status === 403) {
|
||||
$(dynmap).trigger('chat', [{source: 'me', name: 'Error', text: dynmap.options.spammessage.replace('%interval%', dynmap.options['webchat-interval'])}]);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
69
Creative/dynmap/web/js/chatballoon.js
Normal file
69
Creative/dynmap/web/js/chatballoon.js
Normal file
@@ -0,0 +1,69 @@
|
||||
componentconstructors['chatballoon'] = function(dynmap, configuration) {
|
||||
var me = this;
|
||||
|
||||
if(dynmap.getBoolParameterByName("hidechat"))
|
||||
return;
|
||||
|
||||
me.chatpopups = {};
|
||||
$(dynmap).bind('playerupdated', function(event, player) {
|
||||
var popup = me.chatpopups[player.account];
|
||||
if (popup) {
|
||||
var markerPosition = dynmap.getProjection().fromLocationToLatLng(player.location);
|
||||
popup.layer.setLatLng(markerPosition);
|
||||
}
|
||||
});
|
||||
$(dynmap).bind('worldchanged', function() {
|
||||
$.each(me.chatpopups, function(name, popup) {
|
||||
popup.close();
|
||||
});
|
||||
});
|
||||
$(dynmap).bind('chat', function(event, message) {
|
||||
if (message.source != 'player') {
|
||||
return;
|
||||
}
|
||||
var player = dynmap.players[message.account];
|
||||
if (!player)
|
||||
return;
|
||||
if (dynmap.world !== player.location.world) {
|
||||
return;
|
||||
}
|
||||
var popupPosition = dynmap.getProjection().fromLocationToLatLng(player.location);
|
||||
var popup = me.chatpopups[message.account];
|
||||
if (!popup) {
|
||||
me.chatpopups[message.account] = popup = {
|
||||
layer: new L.Popup({autoPan: configuration.focuschatballoons, closeButton: false}),
|
||||
content: $('<div/>').addClass('balloonmessages')[0]
|
||||
};
|
||||
popup.layer.setContent($(popup.content).html());
|
||||
|
||||
popup.close = function() {
|
||||
if (popup.timeout) { window.clearTimeout(popup.timeout); }
|
||||
dynmap.map.removeLayer(popup.layer);
|
||||
delete me.chatpopups[message.account];
|
||||
};
|
||||
|
||||
popup.layer.setLatLng(popupPosition);
|
||||
dynmap.map.addLayer(popup.layer);
|
||||
}
|
||||
|
||||
// Add line to balloon.
|
||||
$('<div/>').addClass('balloonmessage').text(chat_encoder(message)).appendTo(popup.content);
|
||||
|
||||
// Remove older lines when too many messages are shown.
|
||||
var children = $(popup.content).children();
|
||||
if (children.length > 5) {
|
||||
$(children[0]).remove();
|
||||
}
|
||||
|
||||
popup.layer.setContent($(popup.content).html());
|
||||
|
||||
if (popup.timeout) { window.clearTimeout(popup.timeout); }
|
||||
popup.timeout = window.setTimeout(function() {
|
||||
popup.close();
|
||||
}, 8000);
|
||||
|
||||
if (configuration.focuschatballoons) {
|
||||
dynmap.panToLatLng(popupPosition);
|
||||
}
|
||||
});
|
||||
};
|
153
Creative/dynmap/web/js/chatbox.js
Normal file
153
Creative/dynmap/web/js/chatbox.js
Normal file
@@ -0,0 +1,153 @@
|
||||
componentconstructors['chatbox'] = function(dynmap, configuration) {
|
||||
var me = this;
|
||||
|
||||
if(dynmap.getBoolParameterByName("hidechat"))
|
||||
return;
|
||||
var chat = $('<div/>')
|
||||
.addClass('chat')
|
||||
.appendTo(dynmap.options.container);
|
||||
var messagelist = $('<div/>')
|
||||
.addClass('messagelist')
|
||||
.appendTo(chat);
|
||||
|
||||
if (configuration.visiblelines) {
|
||||
messagelist.css('max-height', configuration.visiblelines + 'em');
|
||||
}
|
||||
else {
|
||||
messagelist.css('max-height', '6em');
|
||||
}
|
||||
|
||||
if (configuration.scrollback) {
|
||||
messagelist.addClass('scrollback')
|
||||
.click( function() { $(this).hide(); } );
|
||||
}
|
||||
|
||||
if (dynmap.options.allowwebchat) {
|
||||
if(dynmap.options.loggedin || !dynmap.options['webchat-requires-login']) {
|
||||
var chatinput = $('<input/>')
|
||||
.addClass('chatinput')
|
||||
.attr({
|
||||
id: 'chatinput',
|
||||
type: 'text',
|
||||
value: '',
|
||||
maxlength: dynmap.options.chatlengthlimit
|
||||
})
|
||||
.keydown(function(event) {
|
||||
if (event.keyCode == '13') {
|
||||
event.preventDefault();
|
||||
if(chatinput.val() != '') {
|
||||
$(dynmap).trigger('sendchat', [chatinput.val()]);
|
||||
chatinput.val('');
|
||||
}
|
||||
}
|
||||
});
|
||||
if(configuration.sendbutton) {
|
||||
var chatbutton = $('<button/>').addClass('chatsendbutton').click(function(event) {
|
||||
if(chatinput.val() != '') {
|
||||
$(dynmap).trigger('sendchat', [chatinput.val()]);
|
||||
chatinput.val('');
|
||||
}
|
||||
}).text("+").appendTo(chat);
|
||||
}
|
||||
chatinput.appendTo(chat);
|
||||
if (configuration.scrollback) {
|
||||
chatinput.click(function(){
|
||||
var m = $('.messagelist');
|
||||
m.show().scrollTop(m.scrollHeight());
|
||||
});
|
||||
}
|
||||
}
|
||||
else {
|
||||
var login = $('<button/>').addClass('loginbutton').click(function(event) {
|
||||
window.location = 'login.html';
|
||||
}).text(dynmap.options['msg-chatrequireslogin']).appendTo(chat);
|
||||
}
|
||||
}
|
||||
|
||||
var addrow = function(row) {
|
||||
if (configuration.scrollback) {
|
||||
var c = messagelist.children();
|
||||
c.slice(0, Math.max(0, c.length-configuration.scrollback)).each(function(index, elem){ $(elem).remove(); });
|
||||
} else {
|
||||
setTimeout(function() { row.remove(); }, (configuration.messagettl * 1000));
|
||||
}
|
||||
messagelist.append(row);
|
||||
messagelist.show();
|
||||
messagelist.scrollTop(messagelist.scrollHeight());
|
||||
};
|
||||
|
||||
$(dynmap).bind('playerjoin', function(event, playername) {
|
||||
if ((dynmap.options.joinmessage.length > 0) && (playername.length > 0)) {
|
||||
addrow($('<div/>')
|
||||
.addClass('messagerow')
|
||||
.append(dynmap.options.joinmessage.replace('%playername%', playername))
|
||||
);
|
||||
}
|
||||
else if ((dynmap.options['msg-hiddennamejoin'].length > 0) && (playername.length == 0)) {
|
||||
addrow($('<div/>')
|
||||
.addClass('messagerow')
|
||||
.append(dynmap.options['msg-hiddennamejoin'])
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
$(dynmap).bind('playerquit', function(event, playername) {
|
||||
if ((dynmap.options.quitmessage.length > 0) && (playername.length > 0)) {
|
||||
addrow($('<div/>')
|
||||
.addClass('messagerow')
|
||||
.append(dynmap.options.quitmessage.replace('%playername%', playername))
|
||||
);
|
||||
}
|
||||
else if ((dynmap.options['msg-hiddennamequit'].length > 0) && (playername.length == 0)) {
|
||||
addrow($('<div/>')
|
||||
.addClass('messagerow')
|
||||
.append(dynmap.options['msg-hiddennamequit'])
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
$(dynmap).bind('chat', function(event, message) {
|
||||
var playerName = message.name;
|
||||
var playerAccount = message.account;
|
||||
var messageRow = $('<div/>')
|
||||
.addClass('messagerow');
|
||||
|
||||
var playerIconContainer = $('<span/>')
|
||||
.addClass('messageicon');
|
||||
|
||||
if (message.source === 'player' && configuration.showplayerfaces &&
|
||||
playerAccount) {
|
||||
getMinecraftHead(playerAccount, 16, function(head) {
|
||||
messageRow.icon = $(head)
|
||||
.addClass('playerMessageIcon')
|
||||
.appendTo(playerIconContainer);
|
||||
});
|
||||
}
|
||||
|
||||
var playerChannelContainer = '';
|
||||
if (message.channel) {
|
||||
playerChannelContainer = $('<span/>').addClass('messagetext')
|
||||
.text('[' + message.channel + '] ')
|
||||
.appendTo(messageRow);
|
||||
}
|
||||
|
||||
if (message.source === 'player' && configuration.showworld && playerAccount) {
|
||||
var playerWorldContainer = $('<span/>')
|
||||
.addClass('messagetext')
|
||||
.text('['+dynmap.players[playerAccount].location.world.name+']')
|
||||
.appendTo(messageRow);
|
||||
}
|
||||
|
||||
var playerNameContainer = '';
|
||||
if(message.name) {
|
||||
playerNameContainer = $('<span/>').addClass('messagetext').append(' '+message.name+': ');
|
||||
}
|
||||
|
||||
var playerMessageContainer = $('<span/>')
|
||||
.addClass('messagetext')
|
||||
.text(chat_encoder(message));
|
||||
|
||||
messageRow.append(playerIconContainer,playerChannelContainer,playerNameContainer,playerMessageContainer);
|
||||
addrow(messageRow);
|
||||
});
|
||||
};
|
67
Creative/dynmap/web/js/coord.js
Normal file
67
Creative/dynmap/web/js/coord.js
Normal file
@@ -0,0 +1,67 @@
|
||||
componentconstructors['coord'] = function(dynmap, configuration) {
|
||||
|
||||
var Coord = L.Control.extend({
|
||||
valfield: $('<span/>'),
|
||||
mcrfield: $('<span/>'),
|
||||
chunkfield: $('<span/>'),
|
||||
|
||||
onAdd: function(map) {
|
||||
if(configuration.hidey)
|
||||
this._container = L.DomUtil.create('div', 'coord-control coord-control-noy');
|
||||
else
|
||||
this._container = L.DomUtil.create('div', 'coord-control');
|
||||
this._map = map;
|
||||
$('<span/>').addClass('coord-control-label').text((configuration.label || 'x,y,z') + ': ').appendTo(this._container);
|
||||
$('<br/>').appendTo(this._container);
|
||||
this.valfield.addClass('coord-control-value').text(configuration.hidey ? '---,---' : '---,---,---').appendTo(this._container);
|
||||
if(configuration['show-mcr']) {
|
||||
$('<br/>').appendTo(this._container);
|
||||
this.mcrfield.addClass('coord-control-value').text('--------').appendTo(this._container);
|
||||
}
|
||||
if(configuration['show-chunk']) {
|
||||
$('<br/>').appendTo(this._container);
|
||||
this.chunkfield.addClass('coord-control-value').text('Chunk: ---,---').appendTo(this._container);
|
||||
}
|
||||
this._update();
|
||||
return this.getContainer();
|
||||
},
|
||||
|
||||
getPosition: function() {
|
||||
return 'topleft';
|
||||
},
|
||||
|
||||
getContainer: function() {
|
||||
return this._container;
|
||||
},
|
||||
|
||||
_update: function() {
|
||||
if (!this._map) return;
|
||||
}
|
||||
});
|
||||
|
||||
var coord = new Coord();
|
||||
dynmap.map.addControl(coord);
|
||||
dynmap.map.on('mousemove', function(mevent) {
|
||||
if(!dynmap.map) return;
|
||||
var loc = dynmap.getProjection().fromLatLngToLocation(mevent.latlng, dynmap.world.sealevel+1);
|
||||
if(configuration.hidey)
|
||||
coord.valfield.text(Math.round(loc.x) + ',' + Math.round(loc.z));
|
||||
else
|
||||
coord.valfield.text(Math.round(loc.x) + ',' + loc.y + ',' + Math.round(loc.z));
|
||||
if(configuration['show-mcr'])
|
||||
coord.mcrfield.text('r.' + Math.floor(loc.x/512) + '.' + Math.floor(loc.z/512) + '.mca');
|
||||
if(configuration['show-chunk'])
|
||||
coord.chunkfield.text('Chunk: ' + Math.floor(loc.x/16) + ',' + Math.floor(loc.z/16));
|
||||
});
|
||||
dynmap.map.on('mouseout', function(mevent) {
|
||||
if(!dynmap.map) return;
|
||||
if(configuration.hidey)
|
||||
coord.valfield.text('---,---');
|
||||
else
|
||||
coord.valfield.text('---,---,---');
|
||||
if(configuration['show-mcr'])
|
||||
coord.mcrfield.text('--------');
|
||||
if(configuration['show-chunk'])
|
||||
coord.chunkfield.text('Chunk: ---,---');
|
||||
});
|
||||
};
|
146
Creative/dynmap/web/js/custommarker.js
Normal file
146
Creative/dynmap/web/js/custommarker.js
Normal file
@@ -0,0 +1,146 @@
|
||||
L.CustomMarker = L.Class.extend({
|
||||
|
||||
includes: L.Mixin.Events,
|
||||
|
||||
options: {
|
||||
contentCreator: undefined,
|
||||
shadowCreator: undefined,
|
||||
clickable: true,
|
||||
draggable: false
|
||||
},
|
||||
|
||||
initialize: function(latlng, options) {
|
||||
L.Util.setOptions(this, options);
|
||||
this._latlng = latlng;
|
||||
},
|
||||
|
||||
onAdd: function(map) {
|
||||
this._map = map;
|
||||
|
||||
if (!this._element && this.options.elementCreator) {
|
||||
this._element = this.options.elementCreator();
|
||||
|
||||
this._element.className += ' leaflet-marker-icon';
|
||||
|
||||
this._initInteraction();
|
||||
}
|
||||
if (!this._shadow && this.options.shadowCreator) {
|
||||
this._shadow = this.options.shadowCreator();
|
||||
}
|
||||
|
||||
if (this._element) {
|
||||
map._panes.markerPane.appendChild(this._element);
|
||||
}
|
||||
if (this._shadow) {
|
||||
map._panes.shadowPane.appendChild(this._shadow);
|
||||
}
|
||||
|
||||
map.on('viewreset', this._reset, this);
|
||||
this._reset();
|
||||
if (map.options.zoomAnimation && map.options.markerZoomAnimation) {
|
||||
map.on('zoomanim', this._animateZoom, this);
|
||||
}
|
||||
},
|
||||
|
||||
onRemove: function(map) {
|
||||
if (this._element) {
|
||||
map._panes.markerPane.removeChild(this._element);
|
||||
}
|
||||
if (this._shadow) {
|
||||
map._panes.shadowPane.removeChild(this._elementShadow);
|
||||
}
|
||||
|
||||
map.off('viewreset', this._reset, this);
|
||||
|
||||
map = null;
|
||||
},
|
||||
|
||||
getLatLng: function() {
|
||||
return this._latlng;
|
||||
},
|
||||
|
||||
setLatLng: function(latlng) {
|
||||
this._latlng = latlng;
|
||||
this._reset();
|
||||
},
|
||||
|
||||
_animateZoom: function (opt) {
|
||||
var pos = this._map._latLngToNewLayerPoint(this._latlng, opt.zoom, opt.center);
|
||||
L.DomUtil.setPosition(this._element, pos);
|
||||
this._element.style.zIndex = pos.y;
|
||||
},
|
||||
|
||||
_reset: function() {
|
||||
if(this._map == null)
|
||||
return;
|
||||
var pos = this._map.latLngToLayerPoint(this._latlng);
|
||||
|
||||
if (this._element) {
|
||||
L.DomUtil.setPosition(this._element, pos);
|
||||
}
|
||||
if (this._shadow) {
|
||||
L.DomUtil.setPosition(this._shadow, pos);
|
||||
}
|
||||
|
||||
if (this._element) {
|
||||
this._element.style.zIndex = pos.y;
|
||||
}
|
||||
},
|
||||
|
||||
_initInteraction: function() {
|
||||
if (this._element && this.options.clickable) {
|
||||
this._element.className += ' leaflet-clickable';
|
||||
|
||||
L.DomEvent.addListener(this._element, 'click', this._onMouseClick, this);
|
||||
|
||||
var events = ['dblclick', 'mousedown', 'mouseover', 'mouseout'];
|
||||
for (var i = 0; i < events.length; i++) {
|
||||
L.DomEvent.addListener(this._element, events[i], this._fireMouseEvent, this);
|
||||
}
|
||||
}
|
||||
|
||||
if (this._element && L.Handler.MarkerDrag) {
|
||||
this.dragging = new L.Handler.MarkerDrag(this);
|
||||
|
||||
if (this.options.draggable) {
|
||||
this.dragging.enable();
|
||||
}
|
||||
}
|
||||
var animation = (map.options.zoomAnimation && map.options.markerZoomAnimation);
|
||||
if (this._element)
|
||||
this._element.className += animation ? ' leaflet-zoom-animated' : ' leaflet-zoom-hide';
|
||||
},
|
||||
|
||||
_onMouseClick: function(e) {
|
||||
L.DomEvent.stopPropagation(e);
|
||||
if (this.dragging && this.dragging.moved()) { return; }
|
||||
this.fire(e.type);
|
||||
},
|
||||
|
||||
_fireMouseEvent: function(e) {
|
||||
this.fire(e.type);
|
||||
L.DomEvent.stopPropagation(e);
|
||||
},
|
||||
|
||||
openPopup: function() {
|
||||
this._popup.setLatLng(this._latlng);
|
||||
this._map.openPopup(this._popup);
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
closePopup: function() {
|
||||
if (this._popup) {
|
||||
this._popup._close();
|
||||
}
|
||||
},
|
||||
|
||||
bindPopup: function(content, options) {
|
||||
this._popup = new L.Popup(options);
|
||||
this._popup.setContent(content);
|
||||
this.on('click', this.openPopup, this);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
});
|
49
Creative/dynmap/web/js/digitalclock.js
Normal file
49
Creative/dynmap/web/js/digitalclock.js
Normal file
@@ -0,0 +1,49 @@
|
||||
componentconstructors['digitalclock'] = function(dynmap, configuration) {
|
||||
var element = $('<div/>')
|
||||
.addClass('digitalclock')
|
||||
.addClass('largeclock')
|
||||
.appendTo(dynmap.options.container);
|
||||
|
||||
var timeout = null;
|
||||
|
||||
var 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);
|
||||
};
|
||||
|
||||
var setTime = function(servertime) {
|
||||
if (timeout != null) {
|
||||
window.clearTimeout(timeout);
|
||||
timeout = null;
|
||||
}
|
||||
var time = null;
|
||||
if(servertime >= 0) {
|
||||
time = getMinecraftTime(servertime);
|
||||
element
|
||||
.addClass(time.day ? 'day' : 'night')
|
||||
.removeClass(time.night ? 'day' : 'night')
|
||||
.text(formatTime(time));
|
||||
}
|
||||
else {
|
||||
element
|
||||
.removeClass('day night')
|
||||
.text('');
|
||||
}
|
||||
if ((timeout == null) && (time != null)) {
|
||||
timeout = window.setTimeout(function() {
|
||||
timeout = null;
|
||||
setTime(time.servertime+(1000/60));
|
||||
}, 700);
|
||||
}
|
||||
};
|
||||
|
||||
$(dynmap).bind('worldupdated', function(event, update) {
|
||||
setTime(update.servertime);
|
||||
});
|
||||
};
|
450
Creative/dynmap/web/js/dynmaputils.js
Normal file
450
Creative/dynmap/web/js/dynmaputils.js
Normal file
@@ -0,0 +1,450 @@
|
||||
var DynmapProjection = L.Class.extend({
|
||||
initialize: function(options) {
|
||||
L.Util.setOptions(this, options);
|
||||
},
|
||||
fromLocationToLatLng: function(location) {
|
||||
throw "fromLocationToLatLng not implemented";
|
||||
},
|
||||
fromLatLngToLocation: function(location) {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
if (!Array.prototype.indexOf) { // polyfill for IE < 9
|
||||
Array.prototype.indexOf = function (searchElement /*, fromIndex */ ) {
|
||||
"use strict";
|
||||
if (this === void 0 || this === null) {
|
||||
throw new TypeError();
|
||||
}
|
||||
var t = Object(this);
|
||||
var len = t.length >>> 0;
|
||||
if (len === 0) {
|
||||
return -1;
|
||||
}
|
||||
var n = 0;
|
||||
if (arguments.length > 0) {
|
||||
n = Number(arguments[1]);
|
||||
if (n !== n) { // shortcut for verifying if it's NaN
|
||||
n = 0;
|
||||
} else if (n !== 0 && n !== (1 / 0) && n !== -(1 / 0)) {
|
||||
n = (n > 0 || -1) * Math.floor(Math.abs(n));
|
||||
}
|
||||
}
|
||||
if (n >= len) {
|
||||
return -1;
|
||||
}
|
||||
var k = n >= 0 ? n : Math.max(len - Math.abs(n), 0);
|
||||
for (; k < len; k++) {
|
||||
if (k in t && t[k] === searchElement) {
|
||||
return k;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
var DynmapLayerControl = L.Control.Layers.extend({
|
||||
getPosition: function() {
|
||||
return 'topleft';
|
||||
},
|
||||
|
||||
// Function override to include pos
|
||||
addOverlay: function(layer, name, pos) {
|
||||
this._addLayer(layer, name, true, pos);
|
||||
this._update();
|
||||
return this;
|
||||
},
|
||||
|
||||
// Function override to order layers by pos
|
||||
_addLayer: function (layer, name, overlay, pos) {
|
||||
var id = L.stamp(layer);
|
||||
|
||||
this._layers[pos] = {
|
||||
layer: layer,
|
||||
name: name,
|
||||
overlay: overlay,
|
||||
id: id
|
||||
};
|
||||
|
||||
if (this.options.autoZIndex && layer.setZIndex) {
|
||||
this._lastZIndex++;
|
||||
layer.setZIndex(this._lastZIndex);
|
||||
}
|
||||
},
|
||||
|
||||
// Function override to convert the position-based ordering into the id-based ordering
|
||||
_onInputClick: function () {
|
||||
var i, input, obj,
|
||||
inputs = this._form.getElementsByTagName('input'),
|
||||
inputsLen = inputs.length,
|
||||
baseLayer;
|
||||
|
||||
this._handlingClick = true;
|
||||
|
||||
// Convert ID to pos
|
||||
var id2pos = {};
|
||||
for (i in this._layers) {
|
||||
id2pos[this._layers[i].id] = i;
|
||||
}
|
||||
|
||||
for (i = 0; i < inputsLen; i++) {
|
||||
input = inputs[i];
|
||||
obj = this._layers[id2pos[input.layerId]];
|
||||
|
||||
if (input.checked && !this._map.hasLayer(obj.layer)) {
|
||||
this._map.addLayer(obj.layer);
|
||||
if (!obj.overlay) {
|
||||
baseLayer = obj.layer;
|
||||
}
|
||||
} else if (!input.checked && this._map.hasLayer(obj.layer)) {
|
||||
this._map.removeLayer(obj.layer);
|
||||
}
|
||||
}
|
||||
|
||||
if (baseLayer) {
|
||||
this._map.setZoom(this._map.getZoom());
|
||||
this._map.fire('baselayerchange', {layer: baseLayer});
|
||||
}
|
||||
|
||||
this._handlingClick = false;
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
var DynmapTileLayer = L.TileLayer.extend({
|
||||
_currentzoom: undefined,
|
||||
getProjection: function() {
|
||||
return this.projection;
|
||||
},
|
||||
onTileUpdated: function(tile, tileName) {
|
||||
var src = this.dynmap.getTileUrl(tileName);
|
||||
tile.attr('src', src);
|
||||
tile.show();
|
||||
},
|
||||
|
||||
getTileName: function(tilePoint, zoom) {
|
||||
throw "getTileName not implemented";
|
||||
},
|
||||
|
||||
getTileUrl: function(tilePoint, zoom) {
|
||||
var tileName = this.getTileName(tilePoint, zoom);
|
||||
var url = this._cachedTileUrls[tileName];
|
||||
if (!url) {
|
||||
this._cachedTileUrls[tileName] = url = this.options.dynmap.getTileUrl(tileName);
|
||||
}
|
||||
return url;
|
||||
},
|
||||
|
||||
updateNamedTile: function(name) {
|
||||
var tile = this._namedTiles[name];
|
||||
delete this._cachedTileUrls[name];
|
||||
if (tile) {
|
||||
this.updateTile(tile);
|
||||
}
|
||||
},
|
||||
|
||||
updateTile: function(tile) {
|
||||
this._loadTile(tile, tile.tilePoint, this._map.getZoom());
|
||||
},
|
||||
// Override to fix loads completing after layer removed
|
||||
_addTilesFromCenterOut: function(bounds) {
|
||||
if(this._container == null) // Ignore if we've stopped being active layer
|
||||
return;
|
||||
var queue = [],
|
||||
center = bounds.getCenter();
|
||||
|
||||
for (var j = bounds.min.y; j <= bounds.max.y; j++) {
|
||||
for (var i = bounds.min.x; i <= bounds.max.x; i++) {
|
||||
if ((i + ':' + j) in this._tiles) { continue; }
|
||||
queue.push(new L.Point(i, j));
|
||||
}
|
||||
}
|
||||
|
||||
// load tiles in order of their distance to center
|
||||
queue.sort(function(a, b) {
|
||||
return a.distanceTo(center) - b.distanceTo(center);
|
||||
});
|
||||
|
||||
var fragment = document.createDocumentFragment();
|
||||
|
||||
this._tilesToLoad = queue.length;
|
||||
for (var k = 0, len = this._tilesToLoad; k < len; k++) {
|
||||
this._addTile(queue[k], fragment);
|
||||
}
|
||||
|
||||
this._container.appendChild(fragment);
|
||||
},
|
||||
//Copy and mod of Leaflet method - marked changes with Dynmap: to simplify reintegration
|
||||
_addTile: function(tilePoint, container) {
|
||||
var tilePos = this._getTilePos(tilePoint),
|
||||
zoom = this._map.getZoom(),
|
||||
key = tilePoint.x + ':' + tilePoint.y,
|
||||
name = this.getTileName(tilePoint, zoom), //Dynmap
|
||||
tileLimit = (1 << zoom);
|
||||
|
||||
// wrap tile coordinates
|
||||
if (!this.options.continuousWorld) {
|
||||
if (!this.options.noWrap) {
|
||||
tilePoint.x = ((tilePoint.x % tileLimit) + tileLimit) % tileLimit;
|
||||
} else if (tilePoint.x < 0 || tilePoint.x >= tileLimit) {
|
||||
this._tilesToLoad--;
|
||||
return;
|
||||
}
|
||||
|
||||
if (tilePoint.y < 0 || tilePoint.y >= tileLimit) {
|
||||
this._tilesToLoad--;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// create tile
|
||||
var tile = this._createTile();
|
||||
tile.tileName = name; //Dynmap
|
||||
tile.tilePoint = tilePoint; //Dynmap
|
||||
L.DomUtil.setPosition(tile, tilePos);
|
||||
|
||||
this._tiles[key] = tile;
|
||||
this._namedTiles[name] = tile; //Dynmap
|
||||
|
||||
if (this.options.scheme == 'tms') {
|
||||
tilePoint.y = tileLimit - tilePoint.y - 1;
|
||||
}
|
||||
|
||||
this._loadTile(tile, tilePoint, zoom);
|
||||
|
||||
container.appendChild(tile);
|
||||
},
|
||||
_loadTile: function(tile, tilePoint, zoom) {
|
||||
var me = this;
|
||||
tile._layer = this;
|
||||
function done() {
|
||||
me._loadingTiles.splice(me._loadingTiles.indexOf(tile), 1);
|
||||
me._nextLoadTile();
|
||||
}
|
||||
tile.onload = function(e) {
|
||||
me._tileOnLoad.apply(this, [e]);
|
||||
done();
|
||||
}
|
||||
tile.onerror = function() {
|
||||
me._tileOnError.apply(this);
|
||||
done();
|
||||
}
|
||||
tile.loadSrc = function() {
|
||||
me._loadingTiles.push(tile);
|
||||
tile.src = me.getTileUrl(tilePoint, zoom);
|
||||
};
|
||||
this._loadQueue.push(tile);
|
||||
this._nextLoadTile();
|
||||
},
|
||||
_nextLoadTile: function() {
|
||||
if (this._loadingTiles.length > 4) { return; }
|
||||
var next = this._loadQueue.shift();
|
||||
if (!next) { return; }
|
||||
|
||||
next.loadSrc();
|
||||
},
|
||||
|
||||
_removeOtherTiles: function(bounds) {
|
||||
var kArr, x, y, key;
|
||||
|
||||
for (key in this._tiles) {
|
||||
if (this._tiles.hasOwnProperty(key)) {
|
||||
kArr = key.split(':');
|
||||
x = parseInt(kArr[0], 10);
|
||||
y = parseInt(kArr[1], 10);
|
||||
|
||||
// remove tile if it's out of bounds
|
||||
if (x < bounds.min.x || x > bounds.max.x || y < bounds.min.y || y > bounds.max.y) {
|
||||
var tile = this._tiles[key];
|
||||
if (tile.parentNode === this._container) {
|
||||
this._container.removeChild(this._tiles[key]);
|
||||
}
|
||||
delete this._namedTiles[tile.tileName];
|
||||
delete this._tiles[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
_updateTileSize: function() {
|
||||
var newzoom = this._map.getZoom();
|
||||
if (this._currentzoom !== newzoom) {
|
||||
var newTileSize = this.calculateTileSize(newzoom);
|
||||
this._currentzoom = newzoom;
|
||||
if (newTileSize !== this.options.tileSize) {
|
||||
this.setTileSize(newTileSize);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
_reset: function() {
|
||||
this._updateTileSize();
|
||||
this._tiles = {};
|
||||
this._namedTiles = {};
|
||||
this._loadQueue = [];
|
||||
this._loadingTiles = [];
|
||||
this._cachedTileUrls = {};
|
||||
this._initContainer();
|
||||
this._container.innerHTML = '';
|
||||
},
|
||||
|
||||
_update: function() {
|
||||
this._updateTileSize();
|
||||
var bounds = this._map.getPixelBounds(),
|
||||
tileSize = this.options.tileSize;
|
||||
|
||||
var nwTilePoint = new L.Point(
|
||||
Math.floor(bounds.min.x / tileSize),
|
||||
Math.floor(bounds.min.y / tileSize)),
|
||||
seTilePoint = new L.Point(
|
||||
Math.floor(bounds.max.x / tileSize),
|
||||
Math.floor(bounds.max.y / tileSize)),
|
||||
tileBounds = new L.Bounds(nwTilePoint, seTilePoint);
|
||||
|
||||
this._addTilesFromCenterOut(tileBounds);
|
||||
|
||||
if (this.options.unloadInvisibleTiles) {
|
||||
this._removeOtherTiles(tileBounds);
|
||||
}
|
||||
},
|
||||
/*calculateTileSize: function(zoom) {
|
||||
return this.options.tileSize;
|
||||
},*/
|
||||
calculateTileSize: function(zoom) {
|
||||
// zoomoutlevel: 0 when izoom > mapzoomin, else mapzoomin - izoom (which ranges from 0 till mapzoomin)
|
||||
var izoom = this.options.maxZoom - zoom;
|
||||
var zoominlevel = Math.max(0, this.options.mapzoomin - izoom);
|
||||
return 128 << zoominlevel;
|
||||
},
|
||||
setTileSize: function(tileSize) {
|
||||
this.options.tileSize = tileSize;
|
||||
this._tiles = {};
|
||||
this._createTileProto();
|
||||
},
|
||||
updateTileSize: function(zoom) {},
|
||||
|
||||
// Some helper functions.
|
||||
zoomprefix: function(amount) {
|
||||
return 'zzzzzzzzzzzzzzzzzzzzzz'.substr(0, amount);
|
||||
},
|
||||
getTileInfo: function(tilePoint, zoom) {
|
||||
// zoom: max zoomed in = this.options.maxZoom, max zoomed out = 0
|
||||
// izoom: max zoomed in = 0, max zoomed out = this.options.maxZoom
|
||||
// zoomoutlevel: izoom < mapzoomin -> 0, else -> izoom - mapzoomin (which ranges from 0 till mapzoomout)
|
||||
var izoom = this.options.maxZoom - zoom;
|
||||
var zoomoutlevel = Math.max(0, izoom - this.options.mapzoomin);
|
||||
var scale = 1 << zoomoutlevel;
|
||||
var x = scale*tilePoint.x;
|
||||
var y = scale*tilePoint.y;
|
||||
return {
|
||||
prefix: this.options.prefix,
|
||||
nightday: (this.options.nightandday && this.options.dynmap.serverday) ? '_day' : '',
|
||||
scaledx: x >> 5,
|
||||
scaledy: y >> 5,
|
||||
zoom: this.zoomprefix(zoomoutlevel),
|
||||
zoomprefix: (zoomoutlevel==0)?"":(this.zoomprefix(zoomoutlevel)+"_"),
|
||||
x: x,
|
||||
y: y,
|
||||
fmt: this.options['image-format'] || 'png'
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
function loadjs(url, completed) {
|
||||
var script = document.createElement('script');
|
||||
script.setAttribute('src', url);
|
||||
script.setAttribute('type', 'text/javascript');
|
||||
var isloaded = false;
|
||||
script.onload = function() {
|
||||
if (isloaded) { return; }
|
||||
isloaded = true;
|
||||
completed();
|
||||
};
|
||||
|
||||
// Hack for IE, don't know whether this still applies to IE9.
|
||||
script.onreadystatechange = function() {
|
||||
if (script.readyState == 'loaded' || script.readyState == 'complete')
|
||||
script.onload();
|
||||
};
|
||||
(document.head || document.getElementsByTagName('head')[0]).appendChild(script);
|
||||
}
|
||||
|
||||
function loadcss(url, completed) {
|
||||
var link = document.createElement('link');
|
||||
link.setAttribute('href', url);
|
||||
link.setAttribute('rel', 'stylesheet');
|
||||
var isloaded = false;
|
||||
if (completed) {
|
||||
link.onload = function() {
|
||||
if (isloaded) { return; }
|
||||
isloaded = true;
|
||||
completed();
|
||||
};
|
||||
|
||||
// Hack for IE, don't know whether this still applies to IE9.
|
||||
link.onreadystatechange = function() {
|
||||
link.onload();
|
||||
};
|
||||
}
|
||||
|
||||
(document.head || document.getElementsByTagName('head')[0]).appendChild(link);
|
||||
}
|
||||
|
||||
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 || function(){})(value);
|
||||
}
|
||||
(function( $ ){
|
||||
$.fn.scrollHeight = function(height) {
|
||||
return this[0].scrollHeight;
|
||||
};
|
||||
})($);
|
||||
|
||||
function Location(world, x, y, z) {
|
||||
this.world = world;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
function namedReplace(str, obj)
|
||||
{
|
||||
var startIndex = 0;
|
||||
var result = '';
|
||||
while(true) {
|
||||
var variableBegin = str.indexOf('{', startIndex);
|
||||
var variableEnd = str.indexOf('}', variableBegin+1);
|
||||
if (variableBegin < 0 || variableEnd < 0) {
|
||||
result += str.substr(startIndex);
|
||||
break;
|
||||
}
|
||||
if (variableBegin < variableEnd) {
|
||||
var variableName = str.substring(variableBegin+1, variableEnd);
|
||||
result += str.substring(startIndex, variableBegin);
|
||||
result += obj[variableName];
|
||||
} else /* found '{}' */ {
|
||||
result += str.substring(startIndex, variableBegin-1);
|
||||
result += '';
|
||||
}
|
||||
startIndex = variableEnd+1;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
function concatURL(base, addition) {
|
||||
if(base.indexOf('?') >= 0)
|
||||
return base + escape(addition);
|
||||
|
||||
return base + addition;
|
||||
}
|
50
Creative/dynmap/web/js/hdmap.js
Normal file
50
Creative/dynmap/web/js/hdmap.js
Normal file
@@ -0,0 +1,50 @@
|
||||
var HDProjection = DynmapProjection.extend({
|
||||
fromLocationToLatLng: function(location) {
|
||||
var wtp = this.options.worldtomap;
|
||||
var xx = wtp[0]*location.x + wtp[1]*location.y + wtp[2]*location.z;
|
||||
var yy = wtp[3]*location.x + wtp[4]*location.y + wtp[5]*location.z;
|
||||
return new L.LatLng(
|
||||
xx / (1 << this.options.mapzoomout)
|
||||
, (128-yy) / (1 << this.options.mapzoomout)
|
||||
, true);
|
||||
},
|
||||
fromLatLngToLocation: function(latlon, y) {
|
||||
var ptw = this.options.maptoworld;
|
||||
var lat = latlon.lat * (1 << this.options.mapzoomout);
|
||||
var lon = 128 - latlon.lng * (1 << this.options.mapzoomout);
|
||||
var x = ptw[0]*lat + ptw[1]*lon + ptw[2]*y;
|
||||
var z = ptw[6]*lat + ptw[7]*lon + ptw[8]*y;
|
||||
return { x: x, y: y, z: z };
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
var HDMapType = DynmapTileLayer.extend({
|
||||
projection: undefined,
|
||||
options: {
|
||||
minZoom: 0,
|
||||
maxZoom: 0,
|
||||
errorTileUrl: 'images/blank.png',
|
||||
continuousWorld: true
|
||||
},
|
||||
initialize: function(options) {
|
||||
options.maxZoom = options.mapzoomin + options.mapzoomout;
|
||||
L.Util.setOptions(this, options);
|
||||
this.projection = new HDProjection($.extend({map: this}, options));
|
||||
},
|
||||
getTileName: function(tilePoint, zoom) {
|
||||
var info = this.getTileInfo(tilePoint, zoom);
|
||||
// Y is inverted for HD-map.
|
||||
info.y = -info.y;
|
||||
info.scaledy = info.y >> 5;
|
||||
return namedReplace('{prefix}{nightday}/{scaledx}_{scaledy}/{zoom}{x}_{y}.{fmt}', info);
|
||||
},
|
||||
zoomprefix: function(amount) {
|
||||
// amount == 0 -> ''
|
||||
// amount == 1 -> 'z_'
|
||||
// amount == 2 -> 'zz_'
|
||||
return 'zzzzzzzzzzzzzzzzzzzzzz'.substr(0, amount) + (amount === 0 ? '' : '_');
|
||||
}
|
||||
});
|
||||
|
||||
maptypes.HDMapType = function(options) { return new HDMapType(options); };
|
21
Creative/dynmap/web/js/inactive.js
Normal file
21
Creative/dynmap/web/js/inactive.js
Normal file
@@ -0,0 +1,21 @@
|
||||
componentconstructors['inactive'] = function(dynmap, configuration) {
|
||||
var me = this;
|
||||
var inactivetimer = null;
|
||||
$(document)
|
||||
.ready(onactivity)
|
||||
.mousemove(onactivity)
|
||||
.mouseup(onactivity)
|
||||
.keypress(onactivity);
|
||||
function onactivity() {
|
||||
clearTimeout(inactivetimer);
|
||||
inactivetimer = setTimeout(oninactive, (configuration.timeout || 1800)*1000);
|
||||
}
|
||||
function oninactive() {
|
||||
if (configuration.showmessage) {
|
||||
alert(configuration.showmessage);
|
||||
}
|
||||
if (configuration.redirecturl) {
|
||||
window.location = configuration.redirecturl;
|
||||
}
|
||||
}
|
||||
};
|
10872
Creative/dynmap/web/js/jquery-3.5.1.js
vendored
Normal file
10872
Creative/dynmap/web/js/jquery-3.5.1.js
vendored
Normal file
File diff suppressed because it is too large
Load Diff
88
Creative/dynmap/web/js/jquery.json.js
Normal file
88
Creative/dynmap/web/js/jquery.json.js
Normal file
@@ -0,0 +1,88 @@
|
||||
if(!this.JSON){this.JSON={};}(function(){function f(n){return n<10?'0'+n:n;}if(typeof Date.prototype.toJSON!=='function'){Date.prototype.toJSON=function(key){return isFinite(this.valueOf())?this.getUTCFullYear()+'-'+f(this.getUTCMonth()+1)+'-'+f(this.getUTCDate())+'T'+f(this.getUTCHours())+':'+f(this.getUTCMinutes())+':'+f(this.getUTCSeconds())+'Z':null;};String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(key){return this.valueOf();};}var cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,escapable=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,gap,indent,meta={'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','"':'\\"','\\':'\\\\'},rep;function quote(string){escapable.lastIndex=0;return escapable.test(string)?'"'+string.replace(escapable,function(a){var c=meta[a];return typeof c==='string'?c:'\\u'+('0000'+a.charCodeAt(0).toString(16)).slice(-4);})+'"':'"'+string+'"';}function str(key,holder){var i,k,v,length,mind=gap,partial,value=holder[key];if(value&&typeof value==='object'&&typeof value.toJSON==='function'){value=value.toJSON(key);}if(typeof rep==='function'){value=rep.call(holder,key,value);}switch(typeof value){case'string':return quote(value);case'number':return isFinite(value)?String(value):'null';case'boolean':case'null':return String(value);case'object':if(!value){return'null';}gap+=indent;partial=[];if(Object.prototype.toString.apply(value)==='[object Array]'){length=value.length;for(i=0;i<length;i+=1){partial[i]=str(i,value)||'null';}v=partial.length===0?'[]':gap?'[\n'+gap+partial.join(',\n'+gap)+'\n'+mind+']':'['+partial.join(',')+']';gap=mind;return v;}if(rep&&typeof rep==='object'){length=rep.length;for(i=0;i<length;i+=1){k=rep[i];if(typeof k==='string'){v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v);}}}}else{for(k in value){if(Object.hasOwnProperty.call(value,k)){v=str(k,value);if(v){partial.push(quote(k)+(gap?': ':':')+v);}}}}v=partial.length===0?'{}':gap?'{\n'+gap+partial.join(',\n'+gap)+'\n'+mind+'}':'{'+partial.join(',')+'}';gap=mind;return v;}}if(typeof JSON.stringify!=='function'){JSON.stringify=function(value,replacer,space){var i;gap='';indent='';if(typeof space==='number'){for(i=0;i<space;i+=1){indent+=' ';}}else if(typeof space==='string'){indent=space;}rep=replacer;if(replacer&&typeof replacer!=='function'&&(typeof replacer!=='object'||typeof replacer.length!=='number')){throw new Error('JSON.stringify');}return str('',{'':value});};}if(typeof JSON.parse!=='function'){JSON.parse=function(text,reviver){var j;function walk(holder,key){var k,v,value=holder[key];if(value&&typeof value==='object'){for(k in value){if(Object.hasOwnProperty.call(value,k)){v=walk(value,k);if(v!==undefined){value[k]=v;}else{delete value[k];}}}}return reviver.call(holder,key,value);}text=String(text);cx.lastIndex=0;if(cx.test(text)){text=text.replace(cx,function(a){return'\\u'+('0000'+a.charCodeAt(0).toString(16)).slice(-4);});}if(/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,'@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,']').replace(/(?:^|:|,)(?:\s*\[)+/g,''))){j=eval('('+text+')');return typeof reviver==='function'?walk({'':j},''):j;}throw new SyntaxError('JSON.parse');};}}());
|
||||
|
||||
jQuery.parseJSON = function(str) {
|
||||
try {
|
||||
return JSON.parse(str);
|
||||
} catch(e) {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
jQuery.stringifyJSON = function(obj) {
|
||||
return JSON.stringify(obj);
|
||||
};
|
||||
|
||||
function fixedAjax(obj) {
|
||||
var mysuccess = obj.success;
|
||||
obj.success = function(data, status, request) {
|
||||
if (request.status == 200) {
|
||||
if (mysuccess) mysuccess(data, status, request);
|
||||
} else {
|
||||
obj.error(request, request.status, null);
|
||||
}
|
||||
};
|
||||
$.ajax(obj);
|
||||
}
|
||||
|
||||
jQuery.deleteJSON = function(url, success, error) {
|
||||
fixedAjax({
|
||||
type: 'DELETE',
|
||||
dataType: 'text',
|
||||
url: url,
|
||||
success: function(data, status, request) {
|
||||
if (success) success(request);
|
||||
},
|
||||
error: function(request, status, errorThrown) {
|
||||
if (error) error(request.status, request.statusText, request);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
jQuery.postJSON = function(obj, url, success, error) {
|
||||
fixedAjax({
|
||||
type: 'POST',
|
||||
contentType: 'application/json',
|
||||
dataType: 'text',
|
||||
url: url,
|
||||
data: $.stringifyJSON(obj),
|
||||
success: function(data, status, request) {
|
||||
if (success) success(data ? $.parseJSON(data) : null, request);
|
||||
},
|
||||
error: function(request, status, errorThrown) {
|
||||
if (error) error(request.status, request.statusText, request);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
jQuery.putJSON = function(obj, url, success, error) {
|
||||
fixedAjax({
|
||||
type: 'PUT',
|
||||
contentType: 'application/json',
|
||||
dataType: 'text',
|
||||
url: url,
|
||||
data: $.stringifyJSON(obj),
|
||||
success: function(data, status, request) {
|
||||
if (success) success(request);
|
||||
},
|
||||
error: function(request, status, errorThrown) {
|
||||
if (error) error(request.status, request.statusText, request);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
jQuery.getJSON = function(url, success, error) {
|
||||
fixedAjax({
|
||||
type: 'GET',
|
||||
dataType: 'text',
|
||||
url: url,
|
||||
beforeSend: function(request) {
|
||||
request.setRequestHeader('Accept', 'application/json');
|
||||
},
|
||||
success: function(data, status, request) {
|
||||
if (success) success(data ? $.parseJSON(data) : null, request);
|
||||
},
|
||||
error: function(request, status, errorThrown) {
|
||||
if (error) error(request.status, request.statusText, request);
|
||||
}
|
||||
});
|
||||
};
|
221
Creative/dynmap/web/js/jquery.mousewheel.js
Normal file
221
Creative/dynmap/web/js/jquery.mousewheel.js
Normal file
@@ -0,0 +1,221 @@
|
||||
/*!
|
||||
* jQuery Mousewheel 3.1.13
|
||||
*
|
||||
* Copyright jQuery Foundation and other contributors
|
||||
* Released under the MIT license
|
||||
* http://jquery.org/license
|
||||
*/
|
||||
|
||||
(function (factory) {
|
||||
if ( typeof define === 'function' && define.amd ) {
|
||||
// AMD. Register as an anonymous module.
|
||||
define(['jquery'], factory);
|
||||
} else if (typeof exports === 'object') {
|
||||
// Node/CommonJS style for Browserify
|
||||
module.exports = factory;
|
||||
} else {
|
||||
// Browser globals
|
||||
factory(jQuery);
|
||||
}
|
||||
}(function ($) {
|
||||
|
||||
var toFix = ['wheel', 'mousewheel', 'DOMMouseScroll', 'MozMousePixelScroll'],
|
||||
toBind = ( 'onwheel' in document || document.documentMode >= 9 ) ?
|
||||
['wheel'] : ['mousewheel', 'DomMouseScroll', 'MozMousePixelScroll'],
|
||||
slice = Array.prototype.slice,
|
||||
nullLowestDeltaTimeout, lowestDelta;
|
||||
|
||||
if ( $.event.fixHooks ) {
|
||||
for ( var i = toFix.length; i; ) {
|
||||
$.event.fixHooks[ toFix[--i] ] = $.event.mouseHooks;
|
||||
}
|
||||
}
|
||||
|
||||
var special = $.event.special.mousewheel = {
|
||||
version: '3.1.12',
|
||||
|
||||
setup: function() {
|
||||
if ( this.addEventListener ) {
|
||||
for ( var i = toBind.length; i; ) {
|
||||
this.addEventListener( toBind[--i], handler, false );
|
||||
}
|
||||
} else {
|
||||
this.onmousewheel = handler;
|
||||
}
|
||||
// Store the line height and page height for this particular element
|
||||
$.data(this, 'mousewheel-line-height', special.getLineHeight(this));
|
||||
$.data(this, 'mousewheel-page-height', special.getPageHeight(this));
|
||||
},
|
||||
|
||||
teardown: function() {
|
||||
if ( this.removeEventListener ) {
|
||||
for ( var i = toBind.length; i; ) {
|
||||
this.removeEventListener( toBind[--i], handler, false );
|
||||
}
|
||||
} else {
|
||||
this.onmousewheel = null;
|
||||
}
|
||||
// Clean up the data we added to the element
|
||||
$.removeData(this, 'mousewheel-line-height');
|
||||
$.removeData(this, 'mousewheel-page-height');
|
||||
},
|
||||
|
||||
getLineHeight: function(elem) {
|
||||
var $elem = $(elem),
|
||||
$parent = $elem['offsetParent' in $.fn ? 'offsetParent' : 'parent']();
|
||||
if (!$parent.length) {
|
||||
$parent = $('body');
|
||||
}
|
||||
return parseInt($parent.css('fontSize'), 10) || parseInt($elem.css('fontSize'), 10) || 16;
|
||||
},
|
||||
|
||||
getPageHeight: function(elem) {
|
||||
return $(elem).height();
|
||||
},
|
||||
|
||||
settings: {
|
||||
adjustOldDeltas: true, // see shouldAdjustOldDeltas() below
|
||||
normalizeOffset: true // calls getBoundingClientRect for each event
|
||||
}
|
||||
};
|
||||
|
||||
$.fn.extend({
|
||||
mousewheel: function(fn) {
|
||||
return fn ? this.bind('mousewheel', fn) : this.trigger('mousewheel');
|
||||
},
|
||||
|
||||
unmousewheel: function(fn) {
|
||||
return this.unbind('mousewheel', fn);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
function handler(event) {
|
||||
var orgEvent = event || window.event,
|
||||
args = slice.call(arguments, 1),
|
||||
delta = 0,
|
||||
deltaX = 0,
|
||||
deltaY = 0,
|
||||
absDelta = 0,
|
||||
offsetX = 0,
|
||||
offsetY = 0;
|
||||
event = $.event.fix(orgEvent);
|
||||
event.type = 'mousewheel';
|
||||
|
||||
// Old school scrollwheel delta
|
||||
if ( 'detail' in orgEvent ) { deltaY = orgEvent.detail * -1; }
|
||||
if ( 'wheelDelta' in orgEvent ) { deltaY = orgEvent.wheelDelta; }
|
||||
if ( 'wheelDeltaY' in orgEvent ) { deltaY = orgEvent.wheelDeltaY; }
|
||||
if ( 'wheelDeltaX' in orgEvent ) { deltaX = orgEvent.wheelDeltaX * -1; }
|
||||
|
||||
// Firefox < 17 horizontal scrolling related to DOMMouseScroll event
|
||||
if ( 'axis' in orgEvent && orgEvent.axis === orgEvent.HORIZONTAL_AXIS ) {
|
||||
deltaX = deltaY * -1;
|
||||
deltaY = 0;
|
||||
}
|
||||
|
||||
// Set delta to be deltaY or deltaX if deltaY is 0 for backwards compatabilitiy
|
||||
delta = deltaY === 0 ? deltaX : deltaY;
|
||||
|
||||
// New school wheel delta (wheel event)
|
||||
if ( 'deltaY' in orgEvent ) {
|
||||
deltaY = orgEvent.deltaY * -1;
|
||||
delta = deltaY;
|
||||
}
|
||||
if ( 'deltaX' in orgEvent ) {
|
||||
deltaX = orgEvent.deltaX;
|
||||
if ( deltaY === 0 ) { delta = deltaX * -1; }
|
||||
}
|
||||
|
||||
// No change actually happened, no reason to go any further
|
||||
if ( deltaY === 0 && deltaX === 0 ) { return; }
|
||||
|
||||
// Need to convert lines and pages to pixels if we aren't already in pixels
|
||||
// There are three delta modes:
|
||||
// * deltaMode 0 is by pixels, nothing to do
|
||||
// * deltaMode 1 is by lines
|
||||
// * deltaMode 2 is by pages
|
||||
if ( orgEvent.deltaMode === 1 ) {
|
||||
var lineHeight = $.data(this, 'mousewheel-line-height');
|
||||
delta *= lineHeight;
|
||||
deltaY *= lineHeight;
|
||||
deltaX *= lineHeight;
|
||||
} else if ( orgEvent.deltaMode === 2 ) {
|
||||
var pageHeight = $.data(this, 'mousewheel-page-height');
|
||||
delta *= pageHeight;
|
||||
deltaY *= pageHeight;
|
||||
deltaX *= pageHeight;
|
||||
}
|
||||
|
||||
// Store lowest absolute delta to normalize the delta values
|
||||
absDelta = Math.max( Math.abs(deltaY), Math.abs(deltaX) );
|
||||
|
||||
if ( !lowestDelta || absDelta < lowestDelta ) {
|
||||
lowestDelta = absDelta;
|
||||
|
||||
// Adjust older deltas if necessary
|
||||
if ( shouldAdjustOldDeltas(orgEvent, absDelta) ) {
|
||||
lowestDelta /= 40;
|
||||
}
|
||||
}
|
||||
|
||||
// Adjust older deltas if necessary
|
||||
if ( shouldAdjustOldDeltas(orgEvent, absDelta) ) {
|
||||
// Divide all the things by 40!
|
||||
delta /= 40;
|
||||
deltaX /= 40;
|
||||
deltaY /= 40;
|
||||
}
|
||||
|
||||
// Get a whole, normalized value for the deltas
|
||||
delta = Math[ delta >= 1 ? 'floor' : 'ceil' ](delta / lowestDelta);
|
||||
deltaX = Math[ deltaX >= 1 ? 'floor' : 'ceil' ](deltaX / lowestDelta);
|
||||
deltaY = Math[ deltaY >= 1 ? 'floor' : 'ceil' ](deltaY / lowestDelta);
|
||||
|
||||
// Normalise offsetX and offsetY properties
|
||||
if ( special.settings.normalizeOffset && this.getBoundingClientRect ) {
|
||||
var boundingRect = this.getBoundingClientRect();
|
||||
offsetX = event.clientX - boundingRect.left;
|
||||
offsetY = event.clientY - boundingRect.top;
|
||||
}
|
||||
|
||||
// Add information to the event object
|
||||
event.deltaX = deltaX;
|
||||
event.deltaY = deltaY;
|
||||
event.deltaFactor = lowestDelta;
|
||||
event.offsetX = offsetX;
|
||||
event.offsetY = offsetY;
|
||||
// Go ahead and set deltaMode to 0 since we converted to pixels
|
||||
// Although this is a little odd since we overwrite the deltaX/Y
|
||||
// properties with normalized deltas.
|
||||
event.deltaMode = 0;
|
||||
|
||||
// Add event and delta to the front of the arguments
|
||||
args.unshift(event, delta, deltaX, deltaY);
|
||||
|
||||
// Clearout lowestDelta after sometime to better
|
||||
// handle multiple device types that give different
|
||||
// a different lowestDelta
|
||||
// Ex: trackpad = 3 and mouse wheel = 120
|
||||
if (nullLowestDeltaTimeout) { clearTimeout(nullLowestDeltaTimeout); }
|
||||
nullLowestDeltaTimeout = setTimeout(nullLowestDelta, 200);
|
||||
|
||||
return ($.event.dispatch || $.event.handle).apply(this, args);
|
||||
}
|
||||
|
||||
function nullLowestDelta() {
|
||||
lowestDelta = null;
|
||||
}
|
||||
|
||||
function shouldAdjustOldDeltas(orgEvent, absDelta) {
|
||||
// If this is an older event and the delta is divisable by 120,
|
||||
// then we are assuming that the browser is treating this as an
|
||||
// older mouse wheel event and that we should divide the deltas
|
||||
// by 40 to try and get a more usable deltaFactor.
|
||||
// Side note, this actually impacts the reported scroll distance
|
||||
// in older browsers and can cause scrolling to be slower than native.
|
||||
// Turn this off by setting $.event.special.mousewheel.settings.adjustOldDeltas to false.
|
||||
return special.settings.adjustOldDeltas && orgEvent.type === 'mousewheel' && absDelta % 120 === 0;
|
||||
}
|
||||
|
||||
}));
|
8339
Creative/dynmap/web/js/leaflet.js
Normal file
8339
Creative/dynmap/web/js/leaflet.js
Normal file
File diff suppressed because it is too large
Load Diff
49
Creative/dynmap/web/js/link.js
Normal file
49
Creative/dynmap/web/js/link.js
Normal file
@@ -0,0 +1,49 @@
|
||||
componentconstructors['link'] = function(dynmap, configuration) {
|
||||
|
||||
var dynmapLink = L.Control.extend({
|
||||
options: { position: 'bottomleft' },
|
||||
|
||||
onAdd: function(map) {
|
||||
this._map = map;
|
||||
this._container = L.DomUtil.create('div', 'dynmap-link');
|
||||
|
||||
this._linkButton = this._createButton(
|
||||
'Link', 'dynmap-link-button', this._follow, this);
|
||||
|
||||
this._container.appendChild(this._linkButton);
|
||||
return this._container;
|
||||
},
|
||||
|
||||
getContainer: function() {
|
||||
return this._container;
|
||||
},
|
||||
|
||||
getPosition: function() {
|
||||
return this.options.position;
|
||||
},
|
||||
|
||||
_createButton: function(title, className, fn, context) {
|
||||
var link = document.createElement('a');
|
||||
link.href = '#';
|
||||
link.title = title;
|
||||
link.className = className;
|
||||
link.onmouseover = function() {
|
||||
link.href = dynmap.getLink();
|
||||
};
|
||||
|
||||
L.DomEvent.disableClickPropagation(link);
|
||||
L.DomEvent.addListener(link, 'click', L.DomEvent.preventDefault);
|
||||
L.DomEvent.addListener(link, 'click', fn, context);
|
||||
|
||||
return link;
|
||||
},
|
||||
|
||||
_follow: function() {
|
||||
var url = dynmap.getLink();
|
||||
window.location = url;
|
||||
}
|
||||
});
|
||||
|
||||
var link = new dynmapLink();
|
||||
dynmap.map.addControl(link);
|
||||
};
|
47
Creative/dynmap/web/js/logo.js
Normal file
47
Creative/dynmap/web/js/logo.js
Normal file
@@ -0,0 +1,47 @@
|
||||
componentconstructors['logo'] = function(dynmap, configuration) {
|
||||
|
||||
var Logo = L.Control.extend({
|
||||
onAdd: function(map) {
|
||||
this._container = L.DomUtil.create('div', 'leaflet-control-attribution');
|
||||
this._map = map;
|
||||
this._update();
|
||||
return this._container;
|
||||
},
|
||||
|
||||
getPosition: function() {
|
||||
if(configuration.position == 'top-left')
|
||||
return 'topleft';
|
||||
else if(configuration.position == 'top-right')
|
||||
return 'topright';
|
||||
else if(configuration.position == 'bottom-left')
|
||||
return 'bottomleft';
|
||||
else
|
||||
return 'bottomright';
|
||||
},
|
||||
|
||||
getContainer: function() {
|
||||
return this._container;
|
||||
},
|
||||
|
||||
_update: function() {
|
||||
if (!this._map) return;
|
||||
var c = this._container;
|
||||
if (configuration.linkurl) {
|
||||
c = $('<a/>').attr('href', configuration.linkurl).appendTo(c)[0];
|
||||
}
|
||||
if (configuration.logourl) {
|
||||
$(c).append($('<img/>').attr('src', configuration.logourl).attr('alt', configuration.text).appendTo(c)[0]);
|
||||
} else {
|
||||
$(c).text(configuration.text);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
dynmap.map.options.attributionControl = false;
|
||||
if (dynmap.map.attributionControl) {
|
||||
dynmap.map.removeControl(dynmap.map.attributionControl);
|
||||
dynmap.map.attributionControl = null;
|
||||
}
|
||||
var l = new Logo();
|
||||
dynmap.map.addControl(l);
|
||||
};
|
1075
Creative/dynmap/web/js/map.js
Normal file
1075
Creative/dynmap/web/js/map.js
Normal file
File diff suppressed because it is too large
Load Diff
529
Creative/dynmap/web/js/markers.js
Normal file
529
Creative/dynmap/web/js/markers.js
Normal file
@@ -0,0 +1,529 @@
|
||||
|
||||
var dynmapmarkersets = {};
|
||||
|
||||
componentconstructors['markers'] = function(dynmap, configuration) {
|
||||
var me = this;
|
||||
|
||||
function removeAllMarkers() {
|
||||
$.each(dynmapmarkersets, function(setname, set) {
|
||||
$.each(set.markers, function(mname, marker) {
|
||||
deleteMarker(set, marker);
|
||||
});
|
||||
set.markers = {};
|
||||
$.each(set.areas, function(aname, area) {
|
||||
deleteMarker(set, area);
|
||||
});
|
||||
set.areas = {};
|
||||
$.each(set.lines, function(lname, line) {
|
||||
deleteMarker(set, line);
|
||||
});
|
||||
set.lines = {};
|
||||
$.each(set.circles, function(cname, circle) {
|
||||
deleteMarker(set, circle);
|
||||
});
|
||||
set.circles = {};
|
||||
});
|
||||
}
|
||||
|
||||
function loadmarkers(world) {
|
||||
removeAllMarkers();
|
||||
var url = concatURL(dynmap.options.url.markers, '_markers_/marker_'+world+'.json');
|
||||
|
||||
$.getJSON(url, function(data) {
|
||||
var ts = data.timestamp;
|
||||
$.each(data.sets, function(name, markerset) {
|
||||
if(markerset.showlabels == undefined) markerset.showlabels = configuration.showlabel;
|
||||
var ms = dynmapmarkersets[name];
|
||||
if(!ms) {
|
||||
ms = { id: name, label: markerset.label, hide: markerset.hide, layerprio: markerset.layerprio, minzoom: markerset.minzoom || -1, maxzoom: markerset.maxzoom || -1,
|
||||
showlabels: markerset.showlabels, markers: {}, areas: {}, lines: {}, circles: {} } ;
|
||||
createMarkerSet(ms, ts);
|
||||
}
|
||||
else {
|
||||
if(ms.label != markerset.label) {
|
||||
ms.label = markerset.label;
|
||||
dynmap.addToLayerSelector(ms.layergroup, ms.label, ms.layerprio || 0);
|
||||
}
|
||||
ms.markers = {};
|
||||
ms.areas = {};
|
||||
ms.lines = {};
|
||||
ms.circles = {};
|
||||
ms.hide = markerset.hide;
|
||||
ms.showlabels = markerset.showlabels;
|
||||
ms.timestamp = ts;
|
||||
}
|
||||
dynmapmarkersets[name] = ms;
|
||||
$.each(markerset.markers, function(mname, marker) {
|
||||
ms.markers[mname] = { label: marker.label, markup: marker.markup, x: marker.x, y: marker.y, z:marker.z,
|
||||
icon: marker.icon, desc: marker.desc, dim: marker.dim, minzoom: marker.minzoom || -1, maxzoom: marker.maxzoom || -1 };
|
||||
createMarker(ms, ms.markers[mname], ts);
|
||||
});
|
||||
$.each(markerset.areas, function(aname, area) {
|
||||
ms.areas[aname] = { label: area.label, markup: area.markup, desc: area.desc, x: area.x, z: area.z,
|
||||
ytop: area.ytop, ybottom: area.ybottom, color: area.color, weight: area.weight, opacity: area.opacity,
|
||||
fillcolor: area.fillcolor, fillopacity: area.fillopacity, minzoom: area.minzoom || -1, maxzoom: area.maxzoom || -1 };
|
||||
createArea(ms, ms.areas[aname], ts);
|
||||
});
|
||||
$.each(markerset.lines, function(lname, line) {
|
||||
ms.lines[lname] = { label: line.label, markup: line.markup, desc: line.desc, x: line.x, y: line.y, z: line.z,
|
||||
color: line.color, weight: line.weight, opacity: line.opacity, minzoom: line.minzoom || -1, maxzoom: line.maxzoom || -1 };
|
||||
createLine(ms, ms.lines[lname], ts);
|
||||
});
|
||||
$.each(markerset.circles, function(cname, circle) {
|
||||
ms.circles[cname] = { label: circle.label, markup: circle.markup, desc: circle.desc, x: circle.x, y: circle.y, z: circle.z,
|
||||
xr: circle.xr, zr: circle.zr, color: circle.color, weight: circle.weight, opacity: circle.opacity,
|
||||
fillcolor: circle.fillcolor, fillopacity: circle.fillopacity, minzoom: circle.minzoom || -1, maxzoom: circle.maxzoom || -1 };
|
||||
createCircle(ms, ms.circles[cname], ts);
|
||||
});
|
||||
});
|
||||
|
||||
$(dynmap).trigger('markersupdated', [dynmapmarkersets]);
|
||||
});
|
||||
}
|
||||
|
||||
function getPosition(marker) {
|
||||
return dynmap.getProjection().fromLocationToLatLng({ x: marker.x, y: marker.y, z: marker.z });
|
||||
}
|
||||
|
||||
function createMarker(set, marker, ts) {
|
||||
|
||||
if(marker.our_layer) {
|
||||
set.layergroup.removeLayer(marker.our_layer);
|
||||
delete marker.our_layer;
|
||||
marker.our_layer = null;
|
||||
}
|
||||
|
||||
var markerPosition = getPosition(marker);
|
||||
marker.our_layer = new L.CustomMarker(markerPosition, { elementCreator: function() {
|
||||
var div = document.createElement('div');
|
||||
|
||||
var markerPosition = getPosition(marker);
|
||||
marker.our_layer.setLatLng(markerPosition);
|
||||
var url = concatURL(dynmap.options.url.markers, '_markers_/'+marker.icon+'.png');
|
||||
|
||||
$(div)
|
||||
.addClass('Marker')
|
||||
.addClass('mapMarker')
|
||||
.append($('<img/>').addClass('markerIcon'+marker.dim).attr({ src: url }));
|
||||
if(marker.markup) {
|
||||
$(div).append($('<span/>')
|
||||
.addClass(set.showlabels?'markerName-show':'markerName')
|
||||
.addClass('markerName_' + set.id)
|
||||
.addClass('markerName' + marker.dim)
|
||||
.append(marker.label));
|
||||
}
|
||||
else if(marker.label != "")
|
||||
$(div).append($('<span/>')
|
||||
.addClass(set.showlabels?'markerName-show':'markerName')
|
||||
.addClass('markerName_' + set.id)
|
||||
.addClass('markerName' + marker.dim)
|
||||
.text(marker.label));
|
||||
return div;
|
||||
}});
|
||||
marker.timestamp = ts;
|
||||
if(marker.desc) {
|
||||
var popup = document.createElement('div');
|
||||
$(popup).addClass('MarkerPopup').append(marker.desc);
|
||||
marker.our_layer.bindPopup(popup, {});
|
||||
}
|
||||
|
||||
updateMarker(set, marker, dynmap.map.getZoom());
|
||||
}
|
||||
|
||||
function updateMarker(set, marker, mapzoom) {
|
||||
if (set && marker && marker.our_layer) {
|
||||
// marker specific zoom supercedes set specific zoom
|
||||
var minzoom = (marker.minzoom >= 0) ? marker.minzoom : set.minzoom;
|
||||
var maxzoom = (marker.maxzoom >= 0) ? marker.maxzoom : set.maxzoom;
|
||||
if (maxzoom < 0) maxzoom = 100;
|
||||
set.layergroup.removeLayer(marker.our_layer);
|
||||
if ((mapzoom >= minzoom) && (mapzoom <= maxzoom)) {
|
||||
set.layergroup.addLayer(marker.our_layer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function deleteMarker(set, marker) {
|
||||
if(marker && marker.our_layer) {
|
||||
set.layergroup.removeLayer(marker.our_layer);
|
||||
delete marker.our_layer;
|
||||
}
|
||||
}
|
||||
|
||||
function createMarkerSet(set, ts) {
|
||||
set.layergroup = new L.LayerGroup();
|
||||
set.timestamp = ts;
|
||||
if(!set.hide)
|
||||
dynmap.map.addLayer(set.layergroup);
|
||||
// dynmap.layercontrol.addOverlay(set.layergroup, set.label);
|
||||
dynmap.addToLayerSelector(set.layergroup, set.label, set.layerprio || 0);
|
||||
|
||||
}
|
||||
|
||||
function createArea(set, area, ts) {
|
||||
var style = { color: area.color, opacity: area.opacity, weight: area.weight, fillOpacity: area.fillopacity, fillColor: area.fillcolor, smoothFactor: 0.0 };
|
||||
|
||||
if(area.our_layer) {
|
||||
set.layergroup.removeLayer(area.our_layer);
|
||||
delete area.our_layer;
|
||||
area.our_layer = null;
|
||||
}
|
||||
|
||||
if(area.x.length == 2) { /* Only 2 points */
|
||||
if(area.ytop == area.ybottom) {
|
||||
area.our_layer = create2DBoxLayer(area.x[0], area.x[1], area.ytop, area.ybottom, area.z[0], area.z[1], style);
|
||||
}
|
||||
else {
|
||||
area.our_layer = create3DBoxLayer(area.x[0], area.x[1], area.ytop, area.ybottom, area.z[0], area.z[1], style);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if(area.ytop == area.ybottom) {
|
||||
area.our_layer = create2DOutlineLayer(area.x, area.ytop, area.ybottom, area.z, style);
|
||||
}
|
||||
else {
|
||||
area.our_layer = create3DOutlineLayer(area.x, area.ytop, area.ybottom, area.z, style);
|
||||
}
|
||||
}
|
||||
area.timestamp = ts;
|
||||
if(area.label != "") {
|
||||
var popup = document.createElement('span');
|
||||
if(area.desc) {
|
||||
$(popup).addClass('AreaPopup').append(area.desc);
|
||||
}
|
||||
else if(area.markup) {
|
||||
$(popup).addClass('AreaPopup').append(area.label);
|
||||
}
|
||||
else {
|
||||
$(popup).text(area.label);
|
||||
}
|
||||
area.our_layer.bindPopup($(popup).html(), {});
|
||||
}
|
||||
|
||||
updateMarker(set, area, dynmap.map.getZoom());
|
||||
}
|
||||
|
||||
function createLine(set, line, ts) {
|
||||
var style = { color: line.color, opacity: line.opacity, weight: line.weight, smoothFactor: 0.0 };
|
||||
|
||||
if(line.our_layer) {
|
||||
set.layergroup.removeLayer(line.our_layer);
|
||||
delete line.our_layer;
|
||||
line.our_layer = null;
|
||||
}
|
||||
|
||||
var llist = [];
|
||||
var i;
|
||||
for(i = 0; i < line.x.length; i++) {
|
||||
llist[i] = latlng(line.x[i], line.y[i], line.z[i]);
|
||||
}
|
||||
line.our_layer = new L.Polyline(llist, style);
|
||||
line.timestamp = ts;
|
||||
if(line.label != "") {
|
||||
var popup = document.createElement('span');
|
||||
if(line.desc) {
|
||||
$(popup).addClass('LinePopup').append(line.desc);
|
||||
}
|
||||
else if(line.markup) {
|
||||
$(popup).addClass('LinePopup').append(line.label);
|
||||
}
|
||||
else {
|
||||
$(popup).text(line.label);
|
||||
}
|
||||
line.our_layer.bindPopup($(popup).html(), {});
|
||||
}
|
||||
|
||||
updateMarker(set, line, dynmap.map.getZoom());
|
||||
}
|
||||
|
||||
function createCircle(set, circle, ts) {
|
||||
var style = { color: circle.color, opacity: circle.opacity, weight: circle.weight, fillOpacity: circle.fillopacity, fillColor: circle.fillcolor };
|
||||
|
||||
if(circle.our_layer) {
|
||||
set.layergroup.removeLayer(circle.our_layer);
|
||||
delete circle.our_layer;
|
||||
circle.our_layer = null;
|
||||
}
|
||||
var x = [];
|
||||
var z = [];
|
||||
var i;
|
||||
for(i = 0; i < 360; i++) {
|
||||
var rad = i * Math.PI / 180.0;
|
||||
x[i] = circle.xr * Math.sin(rad) + circle.x;
|
||||
z[i] = circle.zr * Math.cos(rad) + circle.z;
|
||||
}
|
||||
circle.our_layer = create2DOutlineLayer(x, circle.y, circle.y, z, style);
|
||||
circle.timestamp = ts;
|
||||
if(circle.label != "") {
|
||||
var popup = document.createElement('span');
|
||||
if(circle.desc) {
|
||||
$(popup).addClass('CirclePopup').append(circle.desc);
|
||||
}
|
||||
else if(circle.markup) {
|
||||
$(popup).addClass('CirclePopup').append(circle.label);
|
||||
}
|
||||
else {
|
||||
$(popup).text(circle.label);
|
||||
}
|
||||
circle.our_layer.bindPopup($(popup).html(), {});
|
||||
}
|
||||
|
||||
updateMarker(set, circle, dynmap.map.getZoom());
|
||||
}
|
||||
|
||||
// Helper functions
|
||||
latlng = function(x, y, z) {
|
||||
return dynmap.getProjection().fromLocationToLatLng(new Location(undefined, x,y,z));
|
||||
}
|
||||
|
||||
function create3DBoxLayer(maxx, minx, maxy, miny, maxz, minz, style) {
|
||||
return new L.MultiPolygon([
|
||||
[
|
||||
latlng(minx,miny,minz),
|
||||
latlng(maxx,miny,minz),
|
||||
latlng(maxx,miny,maxz),
|
||||
latlng(minx,miny,maxz)
|
||||
],[
|
||||
latlng(minx,maxy,minz),
|
||||
latlng(maxx,maxy,minz),
|
||||
latlng(maxx,maxy,maxz),
|
||||
latlng(minx,maxy,maxz)
|
||||
],[
|
||||
latlng(minx,miny,minz),
|
||||
latlng(minx,maxy,minz),
|
||||
latlng(maxx,maxy,minz),
|
||||
latlng(maxx,miny,minz)
|
||||
],[
|
||||
latlng(maxx,miny,minz),
|
||||
latlng(maxx,maxy,minz),
|
||||
latlng(maxx,maxy,maxz),
|
||||
latlng(maxx,miny,maxz)
|
||||
],[
|
||||
latlng(minx,miny,maxz),
|
||||
latlng(minx,maxy,maxz),
|
||||
latlng(maxx,maxy,maxz),
|
||||
latlng(maxx,miny,maxz)
|
||||
],[
|
||||
latlng(minx,miny,minz),
|
||||
latlng(minx,maxy,minz),
|
||||
latlng(minx,maxy,maxz),
|
||||
latlng(minx,miny,maxz)
|
||||
]], style);
|
||||
}
|
||||
|
||||
function create2DBoxLayer(maxx, minx, maxy, miny, maxz, minz, style) {
|
||||
if(style.fillOpacity <= 0.0)
|
||||
return new L.Polyline([
|
||||
latlng(minx,miny,minz),
|
||||
latlng(maxx,miny,minz),
|
||||
latlng(maxx,miny,maxz),
|
||||
latlng(minx,miny,maxz),
|
||||
latlng(minx,miny,minz)
|
||||
], style);
|
||||
else
|
||||
return new L.Polygon([
|
||||
latlng(minx,miny,minz),
|
||||
latlng(maxx,miny,minz),
|
||||
latlng(maxx,miny,maxz),
|
||||
latlng(minx,miny,maxz)
|
||||
], style);
|
||||
}
|
||||
|
||||
function create3DOutlineLayer(xarray, maxy, miny, zarray, style) {
|
||||
var toplist = [];
|
||||
var botlist = [];
|
||||
var i;
|
||||
var polylist = [];
|
||||
for(i = 0; i < xarray.length; i++) {
|
||||
toplist[i] = latlng(xarray[i], maxy, zarray[i]);
|
||||
botlist[i] = latlng(xarray[i], miny, zarray[i]);
|
||||
}
|
||||
for(i = 0; i < xarray.length; i++) {
|
||||
var sidelist = [];
|
||||
sidelist[0] = toplist[i];
|
||||
sidelist[1] = botlist[i];
|
||||
sidelist[2] = botlist[(i+1)%xarray.length];
|
||||
sidelist[3] = toplist[(i+1)%xarray.length];
|
||||
polylist[i] = sidelist;
|
||||
}
|
||||
polylist[xarray.length] = botlist;
|
||||
polylist[xarray.length+1] = toplist;
|
||||
|
||||
return new L.MultiPolygon(polylist, style);
|
||||
}
|
||||
|
||||
function create2DOutlineLayer(xarray, maxy, miny, zarray, style) {
|
||||
var llist = [];
|
||||
var i;
|
||||
for(i = 0; i < xarray.length; i++) {
|
||||
llist[i] = latlng(xarray[i], miny, zarray[i]);
|
||||
}
|
||||
if(style.fillOpacity <= 0.0) {
|
||||
llist.push(llist[0]);
|
||||
return new L.Polyline(llist, style);
|
||||
}
|
||||
else
|
||||
return new L.Polygon(llist, style);
|
||||
}
|
||||
|
||||
$(dynmap).bind('component.markers', function(event, msg) {
|
||||
if(msg.msg == 'markerupdated') {
|
||||
var set = dynmapmarkersets[msg.set];
|
||||
if (!set) return;
|
||||
deleteMarker(set, set.markers[msg.id]);
|
||||
|
||||
var marker = { x: msg.x, y: msg.y, z: msg.z, icon: msg.icon, label: msg.label, markup: msg.markup, desc: msg.desc, dim: msg.dim || '16x16', minzoom: msg.minzoom || -1, maxzoom: msg.maxzoom };
|
||||
set.markers[msg.id] = marker;
|
||||
createMarker(set, marker, msg.timestamp);
|
||||
}
|
||||
else if(msg.msg == 'markerdeleted') {
|
||||
var set = dynmapmarkersets[msg.set];
|
||||
if (!set) return;
|
||||
deleteMarker(set, set.markers[msg.id]);
|
||||
delete set.markers[msg.id];
|
||||
}
|
||||
else if(msg.msg == 'setupdated') {
|
||||
if(msg.showlabels == undefined) msg.showlabels = configuration.showlabel;
|
||||
if(!dynmapmarkersets[msg.id]) {
|
||||
dynmapmarkersets[msg.id] = { id: msg.id, label: msg.label, layerprio: msg.layerprio, minzoom: msg.minzoom, maxzoom: msg.maxzoom,
|
||||
showlabels: msg.showlabels, markers:{} };
|
||||
createMarkerSet(dynmapmarkersets[msg.id]);
|
||||
}
|
||||
else {
|
||||
if((dynmapmarkersets[msg.id].label != msg.label) || (dynmapmarkersets[msg.id].layerprio != msg.layerprio) ||
|
||||
(dynmapmarkersets[msg.id].showlabels != msg.showlabels)) {
|
||||
dynmapmarkersets[msg.id].label = msg.label;
|
||||
dynmapmarkersets[msg.id].layerprio = msg.layerprio;
|
||||
dynmapmarkersets[msg.id].showlabels = msg.showlabels;
|
||||
//dynmap.layercontrol.removeLayer(dynmapmarkersets[msg.id].layergroup);
|
||||
//dynmap.layercontrol.addOverlay(dynmapmarkersets[msg.id].layergroup, dynmapmarkersets[msg.id].label);
|
||||
dynmap.addToLayerSelector(dynmapmarkersets[msg.id].layergroup, dynmapmarkersets[msg.id].label,
|
||||
dynmapmarkersets[msg.id].layerprio || 0);
|
||||
}
|
||||
if(dynmapmarkersets[msg.id].minzoom != msg.minzoom) {
|
||||
dynmapmarkersets[msg.id].minzoom = msg.minzoom;
|
||||
}
|
||||
if(dynmapmarkersets[msg.id].maxzoom != msg.maxzoom) {
|
||||
dynmapmarkersets[msg.id].maxzoom = msg.maxzoom;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(msg.msg == 'setdeleted') {
|
||||
if(dynmapmarkersets[msg.id]) {
|
||||
dynmap.removeFromLayerSelector(dynmapmarkersets[msg.id].layergroup);
|
||||
delete dynmapmarkersets[msg.id].layergroup;
|
||||
delete dynmapmarkersets[msg.id];
|
||||
}
|
||||
}
|
||||
else if(msg.msg == 'areaupdated') {
|
||||
var set = dynmapmarkersets[msg.set];
|
||||
if (!set) return;
|
||||
deleteMarker(set, set.areas[msg.id]);
|
||||
|
||||
var area = { x: msg.x, ytop: msg.ytop, ybottom: msg.ybottom, z: msg.z, label: msg.label, markup: msg.markup, desc: msg.desc,
|
||||
color: msg.color, weight: msg.weight, opacity: msg.opacity, fillcolor: msg.fillcolor, fillopacity: msg.fillopacity, minzoom: msg.minzoom || -1, maxzoom: msg.maxzoom || -1 };
|
||||
set.areas[msg.id] = area;
|
||||
createArea(set, area, msg.timestamp);
|
||||
}
|
||||
else if(msg.msg == 'areadeleted') {
|
||||
var set = dynmapmarkersets[msg.set];
|
||||
if (!set) return;
|
||||
deleteMarker(set, set.areas[msg.id]);
|
||||
delete set.areas[msg.id];
|
||||
}
|
||||
else if(msg.msg == 'lineupdated') {
|
||||
var set = dynmapmarkersets[msg.set];
|
||||
if (!set) return;
|
||||
deleteMarker(set, set.lines[msg.id]);
|
||||
|
||||
var line = { x: msg.x, y: msg.y, z: msg.z, label: msg.label, markup: msg.markup, desc: msg.desc,
|
||||
color: msg.color, weight: msg.weight, opacity: msg.opacity, minzoom: msg.minzoom || -1, maxzoom: msg.maxzoom || -1 };
|
||||
set.lines[msg.id] = line;
|
||||
createLine(set, line, msg.timestamp);
|
||||
}
|
||||
else if(msg.msg == 'linedeleted') {
|
||||
var set = dynmapmarkersets[msg.set];
|
||||
if (!set) return;
|
||||
deleteMarker(set, set.lines[msg.id]);
|
||||
delete set.lines[msg.id];
|
||||
}
|
||||
else if(msg.msg == 'circleupdated') {
|
||||
var set = dynmapmarkersets[msg.set];
|
||||
if (!set) return;
|
||||
deleteMarker(set, set.circles[msg.id]);
|
||||
|
||||
var circle = { x: msg.x, y: msg.y, z: msg.z, xr: msg.xr, zr: msg.zr, label: msg.label, markup: msg.markup, desc: msg.desc,
|
||||
color: msg.color, weight: msg.weight, opacity: msg.opacity, fillcolor: msg.fillcolor, fillopacity: msg.fillopacity, minzoom: msg.minzoom || -1, maxzoom: msg.maxzoom || -1 };
|
||||
set.circles[msg.id] = circle;
|
||||
createCircle(set, circle, msg.timestamp);
|
||||
}
|
||||
else if(msg.msg == 'circledeleted') {
|
||||
var set = dynmapmarkersets[msg.set];
|
||||
if (!set) return;
|
||||
deleteMarker(set, set.circles[msg.id]);
|
||||
delete set.circles[msg.id];
|
||||
}
|
||||
|
||||
$(dynmap).trigger('markersupdated', [dynmapmarkersets]);
|
||||
});
|
||||
|
||||
// Remove markers on start of map change
|
||||
$(dynmap).bind('mapchanging', function(event) {
|
||||
$.each(dynmapmarkersets, function(setname, set) {
|
||||
$.each(set.markers, function(mname, marker) {
|
||||
deleteMarker(set, marker);
|
||||
});
|
||||
$.each(set.areas, function(aname, area) {
|
||||
deleteMarker(set, area);
|
||||
});
|
||||
$.each(set.lines, function(lname, line) {
|
||||
deleteMarker(set, line);
|
||||
});
|
||||
$.each(set.circles, function(cname, circle) {
|
||||
deleteMarker(set, circle);
|
||||
});
|
||||
});
|
||||
});
|
||||
// Recreate markers after map change
|
||||
$(dynmap).bind('mapchanged', function(event) {
|
||||
var zoom = dynmap.map.getZoom();
|
||||
$.each(dynmapmarkersets, function(setname, set) {
|
||||
$.each(set.markers, function(mname, marker) {
|
||||
createMarker(set, marker, marker.timestamp);
|
||||
});
|
||||
$.each(set.areas, function(aname, area) {
|
||||
createArea(set, area, area.timestamp);
|
||||
});
|
||||
$.each(set.lines, function(lname, line) {
|
||||
createLine(set, line, line.timestamp);
|
||||
});
|
||||
$.each(set.circles, function(cname, circle) {
|
||||
createCircle(set, circle, circle.timestamp);
|
||||
});
|
||||
});
|
||||
});
|
||||
$(dynmap).bind('zoomchanged', function(event) {
|
||||
var zoom = dynmap.map.getZoom();
|
||||
$.each(dynmapmarkersets, function(setname, set) {
|
||||
$.each(set.markers, function(mname, marker) {
|
||||
updateMarker(set, marker, zoom);
|
||||
});
|
||||
$.each(set.areas, function(aname, area) {
|
||||
updateMarker(set, area, zoom);
|
||||
});
|
||||
$.each(set.lines, function(lname, line) {
|
||||
updateMarker(set, line, zoom);
|
||||
});
|
||||
$.each(set.circles, function(cname, circle) {
|
||||
updateMarker(set, circle, zoom);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// Load markers for new world
|
||||
$(dynmap).bind('worldchanged', function(event) {
|
||||
loadmarkers(this.world.name);
|
||||
});
|
||||
|
||||
loadmarkers(dynmap.world.name);
|
||||
};
|
60
Creative/dynmap/web/js/minecraft.js
Normal file
60
Creative/dynmap/web/js/minecraft.js
Normal file
@@ -0,0 +1,60 @@
|
||||
function createMinecraftHead(player,size,completed,failed) {
|
||||
var faceImage = new Image();
|
||||
faceImage.onload = function() {
|
||||
completed(faceImage);
|
||||
};
|
||||
faceImage.onerror = function() {
|
||||
failed();
|
||||
};
|
||||
var faceimg;
|
||||
if(size == 'body')
|
||||
faceimg = 'faces/body/' + player + '.png';
|
||||
else
|
||||
faceimg = 'faces/' + size + 'x' + size + '/' + player + '.png';
|
||||
|
||||
faceImage.src = concatURL(dynmap.options.url.markers, faceimg);
|
||||
}
|
||||
|
||||
function getMinecraftHead(player,size,completed) {
|
||||
createMinecraftHead(player, size, completed, function() {
|
||||
console.error('Failed to retrieve face of "', player, '" with size "', size, '"!')
|
||||
});
|
||||
}
|
||||
|
||||
function getMinecraftTime(servertime) {
|
||||
servertime = parseInt(servertime);
|
||||
var day = servertime >= 0 && servertime < 13700;
|
||||
return {
|
||||
servertime: servertime,
|
||||
days: parseInt((servertime+8000) / 24000),
|
||||
|
||||
// Assuming it is day at 6:00
|
||||
hours: (parseInt(servertime / 1000)+6) % 24,
|
||||
minutes: parseInt(((servertime / 1000) % 1) * 60),
|
||||
seconds: parseInt(((((servertime / 1000) % 1) * 60) % 1) * 60),
|
||||
|
||||
day: day,
|
||||
night: !day
|
||||
};
|
||||
}
|
||||
|
||||
function chat_encoder(message) {
|
||||
if (dynmap.options.cyrillic) {
|
||||
if(message.source === 'player') {
|
||||
var utftext = "";
|
||||
for (var n = 0; n < message.text.length; n++) {
|
||||
var c = message.text.charCodeAt(n);
|
||||
if (c >= 192) {
|
||||
var c = message.text.charCodeAt(n);
|
||||
utftext += String.fromCharCode(c+848);
|
||||
}
|
||||
else if (c == 184) { utftext += String.fromCharCode(1105); }
|
||||
else {
|
||||
utftext += String.fromCharCode(c);
|
||||
}
|
||||
}
|
||||
return utftext
|
||||
}
|
||||
}
|
||||
return message.text;
|
||||
}
|
147
Creative/dynmap/web/js/playermarkers.js
Normal file
147
Creative/dynmap/web/js/playermarkers.js
Normal file
@@ -0,0 +1,147 @@
|
||||
componentconstructors['playermarkers'] = function(dynmap, configuration) {
|
||||
var me = this;
|
||||
$(dynmap).bind('playeradded', function(event, player) {
|
||||
// Create the player-marker.
|
||||
var markerPosition = dynmap.getProjection().fromLocationToLatLng(player.location);
|
||||
player.marker = new L.CustomMarker(markerPosition, { elementCreator: function() {
|
||||
var div = document.createElement('div');
|
||||
var playerImage;
|
||||
|
||||
var markerPosition = dynmap.getProjection().fromLocationToLatLng(player.location);
|
||||
player.marker.setLatLng(markerPosition);
|
||||
|
||||
// Only show player faces if canvas supported
|
||||
if(dynmap.canvassupport == false)
|
||||
configuration.showplayerfaces = false;
|
||||
|
||||
$(div)
|
||||
.addClass('Marker')
|
||||
.addClass('playerMarker')
|
||||
.append(playerImage = $('<img/>').addClass(configuration.smallplayerfaces?'playerIconSm':'playerIcon')
|
||||
.attr({ src: 'images/player.png' }))
|
||||
.append(player.namefield = $('<span/>')
|
||||
.addClass(configuration.smallplayerfaces?'playerNameSm':'playerName')
|
||||
.append(player.name));
|
||||
|
||||
if (configuration.showplayerfaces) {
|
||||
if(configuration.smallplayerfaces) {
|
||||
getMinecraftHead(player.account, 16, function(head) {
|
||||
$(head)
|
||||
.addClass('playerIconSm')
|
||||
.prependTo(div);
|
||||
playerImage.remove();
|
||||
});
|
||||
}
|
||||
else if(configuration.showplayerbody) {
|
||||
getMinecraftHead(player.account, 'body', function(head) {
|
||||
$(head)
|
||||
.addClass('playerIcon')
|
||||
.prependTo(div);
|
||||
playerImage.remove();
|
||||
});
|
||||
}
|
||||
else {
|
||||
getMinecraftHead(player.account, 32, function(head) {
|
||||
$(head)
|
||||
.addClass('playerIcon')
|
||||
.prependTo(div);
|
||||
playerImage.remove();
|
||||
});
|
||||
}
|
||||
}
|
||||
if (configuration.showplayerhealth) {
|
||||
player.healthContainer = $('<div/>')
|
||||
.addClass(configuration.smallplayerfaces?'healthContainerSm':'healthContainer')
|
||||
.appendTo(div);
|
||||
if (player.health !== undefined && player.armor !== undefined) {
|
||||
player.healthBar = $('<div/>')
|
||||
.addClass('playerHealth')
|
||||
.css('width', Math.ceil(player.health*2.5) + 'px');
|
||||
player.armorBar = $('<div/>')
|
||||
.addClass('playerArmor')
|
||||
.css('width', Math.ceil(player.armor*2.5) + 'px');
|
||||
|
||||
$('<div/>')
|
||||
.addClass('playerHealthBackground')
|
||||
.append(player.healthBar)
|
||||
.appendTo(player.healthContainer);
|
||||
$('<div/>')
|
||||
.addClass('playerArmorBackground')
|
||||
.append(player.armorBar)
|
||||
.appendTo(player.healthContainer);
|
||||
} else {
|
||||
player.healthContainer.css('display','none');
|
||||
}
|
||||
}
|
||||
else {
|
||||
player.namefield.addClass('playerNameNoHealth');
|
||||
}
|
||||
|
||||
return div;
|
||||
}});
|
||||
if(dynmap.world === player.location.world)
|
||||
dynmap.playermarkergroup.addLayer(player.marker);
|
||||
});
|
||||
$(dynmap).bind('playerremoved', function(event, player) {
|
||||
// Remove the marker.
|
||||
dynmap.playermarkergroup.removeLayer(player.marker);
|
||||
});
|
||||
$(dynmap).bind('playerupdated', function(event, player) {
|
||||
if(dynmap.world === player.location.world) {
|
||||
// Add if needed
|
||||
dynmap.playermarkergroup.addLayer(player.marker);
|
||||
// Update the marker.
|
||||
var markerPosition = dynmap.getProjection().fromLocationToLatLng(player.location);
|
||||
player.marker.setLatLng(markerPosition);
|
||||
// Update health
|
||||
if (configuration.showplayerhealth) {
|
||||
if (player.health !== undefined && player.armor !== undefined) {
|
||||
player.healthContainer.css('display','block');
|
||||
player.healthBar.css('width', Math.ceil(player.health*2.5) + 'px');
|
||||
player.armorBar.css('width', Math.ceil(player.armor*2.5) + 'px');
|
||||
} else {
|
||||
player.healthContainer.css('display','none');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
dynmap.playermarkergroup.removeLayer(player.marker);
|
||||
}
|
||||
if (player.namefield && (player.namefield.html() != player.name)) {
|
||||
player.namefield.html(player.name);
|
||||
}
|
||||
});
|
||||
// Remove marker on start of map change
|
||||
$(dynmap).bind('mapchanging', function(event) {
|
||||
var name;
|
||||
for(name in dynmap.players) {
|
||||
var player = dynmap.players[name];
|
||||
// Turn off marker - let update turn it back on
|
||||
dynmap.playermarkergroup.removeLayer(player.marker);
|
||||
}
|
||||
});
|
||||
// Remove marker on start of map change
|
||||
$(dynmap).bind('mapchanging', function(event) {
|
||||
var name;
|
||||
for(name in dynmap.players) {
|
||||
var player = dynmap.players[name];
|
||||
dynmap.playermarkergroup.removeLayer(player.marker);
|
||||
}
|
||||
});
|
||||
// Add markers back on end of map change
|
||||
$(dynmap).bind('mapchanged', function(event) {
|
||||
var name;
|
||||
for(name in dynmap.players) {
|
||||
var player = dynmap.players[name];
|
||||
if(dynmap.world === player.location.world) {
|
||||
dynmap.playermarkergroup.addLayer(player.marker);
|
||||
var markerPosition = dynmap.getProjection().fromLocationToLatLng(player.location);
|
||||
player.marker.setLatLng(markerPosition);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
dynmap.playermarkergroup = new L.LayerGroup();
|
||||
if(!configuration.hidebydefault)
|
||||
dynmap.map.addLayer(dynmap.playermarkergroup);
|
||||
dynmap.addToLayerSelector(dynmap.playermarkergroup, configuration.label || 'Players', configuration.layerprio || 0);
|
||||
};
|
31
Creative/dynmap/web/js/projectiontest.js
Normal file
31
Creative/dynmap/web/js/projectiontest.js
Normal file
@@ -0,0 +1,31 @@
|
||||
componentconstructors['projectiontest'] = function(dynmap, configuration) {
|
||||
var me = this;
|
||||
var marker = new L.CustomMarker(new L.LatLng(0,0,true), {
|
||||
elementCreator: function() {
|
||||
var div = document.createElement('div');
|
||||
var textContainer;
|
||||
$(div)
|
||||
.css({margin: '10px 10px 10px 10px'})
|
||||
.append(
|
||||
textContainer = $('<span/>')
|
||||
.css({'white-space': 'pre'})
|
||||
.text('')
|
||||
);
|
||||
marker.setText = function(text) {
|
||||
$(textContainer).text(text);
|
||||
};
|
||||
return div;
|
||||
}
|
||||
});
|
||||
dynmap.map.addLayer(marker);
|
||||
|
||||
dynmap.map.on('mousemove', function(event) {
|
||||
marker.setLatLng(event.latlng);
|
||||
if (marker.setText) {
|
||||
marker.setText('LatLng: (' + event.latlng.lat + ',' + event.latlng.lng + ')\n'+
|
||||
'LayerPoint: (' + event.layerPoint.x + ',' + event.layerPoint.y + ')\n'+
|
||||
'World: (?,?,?)'
|
||||
);
|
||||
}
|
||||
});
|
||||
};
|
3
Creative/dynmap/web/js/regions.js
Normal file
3
Creative/dynmap/web/js/regions.js
Normal file
@@ -0,0 +1,3 @@
|
||||
componentconstructors['regions'] = function(dynmap, configuration) {
|
||||
|
||||
}
|
73
Creative/dynmap/web/js/sidebarmarkers.js
Normal file
73
Creative/dynmap/web/js/sidebarmarkers.js
Normal file
@@ -0,0 +1,73 @@
|
||||
componentconstructors['sidebarmarkers'] = function(dynmap, configuration) {
|
||||
var cfg = $.extend({
|
||||
title: 'Markers (current world)'
|
||||
}, configuration);
|
||||
|
||||
this.markersSection = null;
|
||||
this.markersList = null;
|
||||
|
||||
var me = this;
|
||||
|
||||
$(dynmap).bind('markersupdated', function(event, markersets) {
|
||||
updateMarkers(markersets);
|
||||
});
|
||||
|
||||
if (typeof dynmapmarkersets !== 'undefined' && dynmapmarkersets) {
|
||||
updateMarkers(dynmapmarkersets);
|
||||
}
|
||||
|
||||
function initSection() {
|
||||
me.markersSection = SidebarUtils.createListSection(cfg.title);
|
||||
me.markersList = me.markersSection.content.addClass('markerslist');
|
||||
dynmap.sidebarPanel.find('fieldset:eq(0)').after(me.markersSection.section);
|
||||
dynmap.sidebarSections.push(me.markersSection);
|
||||
}
|
||||
|
||||
function updateMarkers(markersets) {
|
||||
if (me.markersList == null) {
|
||||
initSection();
|
||||
}
|
||||
|
||||
me.markersList.empty();
|
||||
var sets = [];
|
||||
|
||||
$.each(markersets, function (key, set) {
|
||||
if (!set.markers || $.isEmptyObject(set.markers)) {
|
||||
return;
|
||||
}
|
||||
|
||||
var markers = $('<ul/>').addClass('sublist');
|
||||
|
||||
$.each(set.markers, function (key, marker) {
|
||||
var title = marker.label + ' (' + marker.x + ',' + marker.y + ',' + marker.z + ')';
|
||||
var imgURL = concatURL(dynmap.options.url.markers, '_markers_/'+marker.icon+'.png');
|
||||
|
||||
$('<li/>')
|
||||
.addClass('marker item')
|
||||
.append($('<a/>')
|
||||
.attr({ title: title, href: '#' })
|
||||
.css({ backgroundImage: 'url(' + imgURL + ')' })
|
||||
.text(title)
|
||||
)
|
||||
.click(function() {
|
||||
dynmap.panToLocation({
|
||||
world: dynmap.world,
|
||||
x: marker.x,
|
||||
y: marker.y,
|
||||
z: marker.z
|
||||
});
|
||||
})
|
||||
.appendTo(markers);
|
||||
});
|
||||
|
||||
sets.push($('<li/>')
|
||||
.addClass('markerset subsection')
|
||||
.append($('<span/>').text(set.label))
|
||||
.append(markers)
|
||||
);
|
||||
});
|
||||
|
||||
me.markersList.append(sets);
|
||||
dynmap.updateSidebarHeight();
|
||||
}
|
||||
};
|
49
Creative/dynmap/web/js/sidebarutils.js
Normal file
49
Creative/dynmap/web/js/sidebarutils.js
Normal file
@@ -0,0 +1,49 @@
|
||||
var SidebarUtils = {
|
||||
createSection: function (labelText, content) {
|
||||
var legend = $('<legend/>').text(labelText);
|
||||
var upBtn = SidebarUtils.createScrollButton(true, content);
|
||||
var downBtn = SidebarUtils.createScrollButton(false, content);
|
||||
|
||||
var section = $('<fieldset/>')
|
||||
.addClass('section')
|
||||
.append(legend)
|
||||
.append(upBtn)
|
||||
.append(
|
||||
content
|
||||
.addClass('content')
|
||||
.bind('mousewheel', function(event, delta){
|
||||
this.scrollTop -= (delta * 10);
|
||||
event.preventDefault();
|
||||
})
|
||||
)
|
||||
.append(downBtn);
|
||||
|
||||
return {
|
||||
section: section,
|
||||
legend: legend,
|
||||
upBtn: upBtn,
|
||||
content: content,
|
||||
downBtn: downBtn
|
||||
};
|
||||
},
|
||||
|
||||
createListSection: function (labelText) {
|
||||
var content = $('<ul/>').addClass('list');
|
||||
return SidebarUtils.createSection(labelText, content);
|
||||
},
|
||||
|
||||
createScrollButton: function (up, target) {
|
||||
var cls = up ? 'scrollup' : 'scrolldown';
|
||||
var amount = (up ? '-' : '+') + '=300px';
|
||||
|
||||
return $('<div/>')
|
||||
.addClass(cls)
|
||||
.bind('mousedown mouseup touchstart touchend', function (event) {
|
||||
if (event.type == 'mousedown' || event.type == 'touchstart') {
|
||||
target.animate({"scrollTop": amount}, 3000, 'linear');
|
||||
} else {
|
||||
target.stop();
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
125
Creative/dynmap/web/js/timeofdayclock.js
Normal file
125
Creative/dynmap/web/js/timeofdayclock.js
Normal file
@@ -0,0 +1,125 @@
|
||||
componentconstructors['timeofdayclock'] = function(dynmap, configuration) {
|
||||
var me = this;
|
||||
|
||||
var timeout = null;
|
||||
|
||||
var element = $('<div/>')
|
||||
.addClass('largeclock')
|
||||
.addClass('timeofday')
|
||||
.appendTo(dynmap.options.container);
|
||||
|
||||
var sun = $('<div/>')
|
||||
.height(60)
|
||||
.addClass('timeofday')
|
||||
.addClass('sun')
|
||||
.css('background-position', (-150) + 'px ' + (-150) + 'px')
|
||||
.appendTo(element);
|
||||
|
||||
var moon = $('<div/>')
|
||||
.height(60)
|
||||
.addClass('timeofday')
|
||||
.addClass('moon')
|
||||
.css('background-position', (-150) + 'px ' + (-150) + 'px')
|
||||
.appendTo(sun);
|
||||
|
||||
if (configuration.showdigitalclock) {
|
||||
var clock = $('<div/>')
|
||||
.addClass('timeofday')
|
||||
.addClass('digitalclock')
|
||||
.appendTo(element);
|
||||
|
||||
var 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);
|
||||
};
|
||||
|
||||
var setTime = function(servertime) {
|
||||
if (timeout != null) {
|
||||
window.clearTimeout(timeout);
|
||||
timeout = null;
|
||||
}
|
||||
var time = null;
|
||||
if(servertime >= 0) {
|
||||
time = getMinecraftTime(servertime);
|
||||
clock
|
||||
.addClass(time.day ? 'day' : 'night')
|
||||
.removeClass(time.night ? 'day' : 'night')
|
||||
.text(formatTime(time));
|
||||
}
|
||||
else {
|
||||
clock
|
||||
.removeClass('day night')
|
||||
.text('');
|
||||
}
|
||||
if ((timeout == null) && (time != null)) {
|
||||
timeout = window.setTimeout(function() {
|
||||
timeout = null;
|
||||
setTime(time.servertime+(1000/60));
|
||||
}, 700);
|
||||
}
|
||||
};
|
||||
|
||||
$(dynmap).bind('worldupdated', function(event, update) {
|
||||
setTime(update.servertime);
|
||||
});
|
||||
}
|
||||
if(configuration.showweather) {
|
||||
var weather = $('<div/>')
|
||||
.addClass('weather')
|
||||
.appendTo(element);
|
||||
|
||||
var setWeather = function(hasStorm, isThundering, time) {
|
||||
var daynight = (time > 23100 || time < 12900) ? "_day" : "_night";
|
||||
var cls = 'sunny';
|
||||
if (hasStorm) {
|
||||
cls = 'stormy';
|
||||
if (isThundering) {
|
||||
cls = 'thunder';
|
||||
}
|
||||
}
|
||||
weather
|
||||
.removeClass('stormy_day stormy_night sunny_day sunny_night thunder_day thunder_night')
|
||||
.addClass(cls + daynight);
|
||||
};
|
||||
|
||||
$(dynmap).bind('worldupdated', function(event, update) {
|
||||
setWeather(update.hasStorm, update.isThundering, update.servertime);
|
||||
});
|
||||
}
|
||||
$(dynmap).bind('worldupdated', function(event, update) {
|
||||
var sunangle;
|
||||
var time = update.servertime;
|
||||
|
||||
if(time > 23100 || time < 12900) {
|
||||
//day mode
|
||||
var movedtime = time + 900;
|
||||
movedtime = (movedtime >= 24000) ? movedtime - 24000 : movedtime;
|
||||
//Now we have 0 -> 13800 for the day period
|
||||
//Divide by 13800*2=27600 instead of 24000 to compress day
|
||||
sunangle = ((movedtime)/27600 * 2 * Math.PI);
|
||||
} else {
|
||||
//night mode
|
||||
var movedtime = time - 12900;
|
||||
//Now we have 0 -> 10200 for the night period
|
||||
//Divide by 10200*2=20400 instead of 24000 to expand night
|
||||
sunangle = Math.PI + ((movedtime)/20400 * 2 * Math.PI);
|
||||
}
|
||||
|
||||
var moonangle = sunangle + Math.PI;
|
||||
|
||||
if(time >= 0) {
|
||||
sun.css('background-position', (-50 * Math.cos(sunangle)) + 'px ' + (-50 * Math.sin(sunangle)) + 'px');
|
||||
moon.css('background-position', (-50 * Math.cos(moonangle)) + 'px ' + (-50 * Math.sin(moonangle)) + 'px');
|
||||
}
|
||||
else {
|
||||
sun.css('background-position', '-150px -150px');
|
||||
moon.css('background-position', '-150px -150px');
|
||||
}
|
||||
});
|
||||
};
|
Reference in New Issue
Block a user