Simplified component-creation, dropping IE8 compatibility.
This commit is contained in:
parent
4390581901
commit
d926770096
5 changed files with 173 additions and 192 deletions
|
|
@ -7,9 +7,7 @@ $.ajax({
|
||||||
});
|
});
|
||||||
|
|
||||||
componentconstructors['chat'] = function(dynmap, configuration) {
|
componentconstructors['chat'] = function(dynmap, configuration) {
|
||||||
return {
|
var me = this;
|
||||||
dynmap: dynmap,
|
|
||||||
initialize: function() {
|
|
||||||
// Provides 'chat'-events by monitoring the world-updates.
|
// Provides 'chat'-events by monitoring the world-updates.
|
||||||
$(dynmap).bind('worldupdate', function(event, update) {
|
$(dynmap).bind('worldupdate', function(event, update) {
|
||||||
swtch(update.type, {
|
swtch(update.type, {
|
||||||
|
|
@ -40,6 +38,4 @@ componentconstructors['chat'] = function(dynmap, configuration) {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,6 @@
|
||||||
componentconstructors['chatballoon'] = function(dynmap, configuration) {
|
componentconstructors['chatballoon'] = function(dynmap, configuration) {
|
||||||
return {
|
|
||||||
dynmap: dynmap,
|
|
||||||
options: configuration,
|
|
||||||
chatpopups: {},
|
|
||||||
initialize: function() {
|
|
||||||
var me = this;
|
var me = this;
|
||||||
|
me.chatpopups = {};
|
||||||
$(dynmap).bind('chat', function(event, message) {
|
$(dynmap).bind('chat', function(event, message) {
|
||||||
if (message.source != 'player') {
|
if (message.source != 'player') {
|
||||||
return;
|
return;
|
||||||
|
|
@ -48,6 +44,4 @@ componentconstructors['chatballoon'] = function(dynmap, configuration) {
|
||||||
delete me.chatpopups[message.name];
|
delete me.chatpopups[message.name];
|
||||||
}, 8000);
|
}, 8000);
|
||||||
});
|
});
|
||||||
}
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
componentconstructors['chatbox'] = function(dynmap, configuration) {
|
componentconstructors['chatbox'] = function(dynmap, configuration) {
|
||||||
return {
|
var me = this;
|
||||||
dynmap: dynmap,
|
|
||||||
initialize: function() {
|
|
||||||
var chat = $('<div/>')
|
var chat = $('<div/>')
|
||||||
.addClass('chat')
|
.addClass('chat')
|
||||||
.appendTo(dynmap.options.container);
|
.appendTo(dynmap.options.container);
|
||||||
|
|
@ -69,6 +67,4 @@ componentconstructors['chatbox'] = function(dynmap, configuration) {
|
||||||
//var scrollHeight = jQuery(me.messagelist).attr('scrollHeight');
|
//var scrollHeight = jQuery(me.messagelist).attr('scrollHeight');
|
||||||
messagelist.scrollTop(messagelist.scrollHeight());
|
messagelist.scrollTop(messagelist.scrollHeight());
|
||||||
});
|
});
|
||||||
}
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
@ -280,10 +280,8 @@ DynMap.prototype = {
|
||||||
me.selectMap(me.defaultworld.defaultmap);
|
me.selectMap(me.defaultworld.defaultmap);
|
||||||
|
|
||||||
$.each(me.options.components, function(index, configuration) {
|
$.each(me.options.components, function(index, configuration) {
|
||||||
me.components.push(componentconstructors[configuration.type](me, configuration));
|
var componentconstructor = componentconstructors[configuration.type];
|
||||||
});
|
me.components.push(new componentconstructor(me, configuration));
|
||||||
$.each(me.components, function(index, component) {
|
|
||||||
component.initialize();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
setTimeout(function() { me.update(); }, me.options.updaterate);
|
setTimeout(function() { me.update(); }, me.options.updaterate);
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
componentconstructors['playermarkers'] = function(dynmap, configuration) {
|
componentconstructors['playermarkers'] = function(dynmap, configuration) {
|
||||||
return {
|
var me = this;
|
||||||
initialize: function() {
|
|
||||||
$(dynmap).bind('playeradded', function(event, player) {
|
$(dynmap).bind('playeradded', function(event, player) {
|
||||||
// Create the player-marker.
|
// Create the player-marker.
|
||||||
var markerPosition = dynmap.map.getProjection().fromWorldToLatLng(player.location.x, player.location.y, player.location.z);
|
var markerPosition = dynmap.map.getProjection().fromWorldToLatLng(player.location.x, player.location.y, player.location.z);
|
||||||
|
|
@ -35,6 +34,4 @@ componentconstructors['playermarkers'] = function(dynmap, configuration) {
|
||||||
player.marker.toggle(dynmap.world === player.location.world);
|
player.marker.toggle(dynmap.world === player.location.world);
|
||||||
player.marker.setPosition(markerPosition);
|
player.marker.setPosition(markerPosition);
|
||||||
});
|
});
|
||||||
}
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
Loading…
Add table
Add a link
Reference in a new issue