Simplified component-creation, dropping IE8 compatibility.
This commit is contained in:
parent
6eface57ae
commit
6622db1b2c
5 changed files with 173 additions and 192 deletions
|
|
@ -7,39 +7,35 @@ $.ajax({
|
|||
});
|
||||
|
||||
componentconstructors['chat'] = function(dynmap, configuration) {
|
||||
return {
|
||||
dynmap: dynmap,
|
||||
initialize: function() {
|
||||
// Provides 'chat'-events by monitoring the world-updates.
|
||||
$(dynmap).bind('worldupdate', function(event, update) {
|
||||
swtch(update.type, {
|
||||
chat: function() {
|
||||
$(dynmap).trigger('chat', [{source: 'player', name: update.playerName, text: update.message}]);
|
||||
},
|
||||
webchat: function() {
|
||||
$(dynmap).trigger('chat', [{source: 'web', name: update.playerName, text: update.message}]);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
if (dynmap.options.allowwebchat) {
|
||||
// Accepts 'sendchat'-events to send chat messages to the server.
|
||||
$(dynmap).bind('sendchat', function(event, message) {
|
||||
var data = '{"name":"'+ip+'","message":"'+message+'"}';
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: 'up/sendmessage',
|
||||
data: data,
|
||||
dataType: 'json',
|
||||
success: function(response) {
|
||||
//handle response
|
||||
if(response) {
|
||||
$(dynmap).trigger('chat', [{source: 'me', name: ip, text: message}]);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
var me = this;
|
||||
// Provides 'chat'-events by monitoring the world-updates.
|
||||
$(dynmap).bind('worldupdate', function(event, update) {
|
||||
swtch(update.type, {
|
||||
chat: function() {
|
||||
$(dynmap).trigger('chat', [{source: 'player', name: update.playerName, text: update.message}]);
|
||||
},
|
||||
webchat: function() {
|
||||
$(dynmap).trigger('chat', [{source: 'web', name: update.playerName, text: update.message}]);
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
});
|
||||
|
||||
if (dynmap.options.allowwebchat) {
|
||||
// Accepts 'sendchat'-events to send chat messages to the server.
|
||||
$(dynmap).bind('sendchat', function(event, message) {
|
||||
var data = '{"name":"'+ip+'","message":"'+message+'"}';
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: 'up/sendmessage',
|
||||
data: data,
|
||||
dataType: 'json',
|
||||
success: function(response) {
|
||||
//handle response
|
||||
if(response) {
|
||||
$(dynmap).trigger('chat', [{source: 'me', name: ip, text: message}]);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue