added option to disable webchat input

This commit is contained in:
Arthur Mayer 2011-03-07 07:07:48 +01:00
parent 689df03b78
commit 32fdf9da86
3 changed files with 30 additions and 24 deletions

1
configuration.txt Executable file → Normal file
View File

@ -69,6 +69,7 @@ web:
# showchat: modal/balloons
showchat: modal
allowchat: true
messagettl: 15000
showplayerfacesonmap: true

View File

@ -132,15 +132,18 @@ public class DynmapPlugin extends JavaPlugin {
webServer.handlers.put("/up/configuration", new ClientConfigurationHandler((Map<?, ?>) configuration.getProperty("web")));
SendMessageHandler messageHandler = new SendMessageHandler();
messageHandler.onMessageReceived.addListener(new Listener<SendMessageHandler.Message>() {
@Override
public void triggered(Message t) {
mapManager.pushUpdate(new Client.WebChatMessage(t.name, t.message));
log.info("[WEB]" + t.name + ": " + t.message);
getServer().broadcastMessage("[WEB]" + t.name + ": " + t.message);
}
});
webServer.handlers.put("/up/sendmessage", messageHandler);
boolean allowchat = configuration.getBoolean("allowchat", true);
if (allowchat == true) {
messageHandler.onMessageReceived.addListener(new Listener<SendMessageHandler.Message>() {
@Override
public void triggered(Message t) {
mapManager.pushUpdate(new Client.WebChatMessage(t.name, t.message));
log.info("[WEB]" + t.name + ": " + t.message);
getServer().broadcastMessage("[WEB]" + t.name + ": " + t.message);
}
});
webServer.handlers.put("/up/sendmessage", messageHandler);
}
try {
webServer.startServer();

View File

@ -202,21 +202,23 @@ DynMap.prototype = {
var messagelist = me.messagelist = $('<div/>')
.addClass('messagelist')
.appendTo(chat);
var chatinput = me.chatinput = $('<input/>')
.addClass('chatinput')
.attr({
id: 'chatinput',
type: 'text',
value: ''
})
.keydown(function(event) {
if (event.keyCode == '13') {
event.preventDefault();
sendChat(chatinput.val());
chatinput.val('');
}
})
.appendTo(chat);
if (me.options.allowchat === 'true') {
var chatinput = me.chatinput = $('<input/>')
.addClass('chatinput')
.attr({
id: 'chatinput',
type: 'text',
value: ''
})
.keydown(function(event) {
if (event.keyCode == '13') {
event.preventDefault();
sendChat(chatinput.val());
chatinput.val('');
}
})
.appendTo(chat);
}
}
// TODO: Enable hash-links.