From 10f93c02c1ecbd4e33bc11f7a0459ca06c57877f Mon Sep 17 00:00:00 2001 From: Arthur Mayer Date: Fri, 18 Feb 2011 10:21:55 +0100 Subject: [PATCH] added chatSend() function --- web/chat.js | 21 +++++++++++++++++++++ web/map.js | 6 ++++++ 2 files changed, 27 insertions(+) diff --git a/web/chat.js b/web/chat.js index e69de29b..923fe8cf 100644 --- a/web/chat.js +++ b/web/chat.js @@ -0,0 +1,21 @@ +function sendChat(message) { + var ip; + $.ajax({ + type: "GET", + url: "http://jsonip.appspot.com/?callback=?", + dataType: "jsonp", + success: function(getip) { + var data = { name: getip.ip, message: message }; + $.ajax({ + type: 'POST', + url: '/up/sendmessage', + data: data, + dataType: 'json', + success: function(response) { + //handle response + } + }); + } + }); +} +//curl -d '{"name":"Nickname","message":"Hello"}' http://localhost:8123/up/sendmessage diff --git a/web/map.js b/web/map.js index f40f5090..57ff6a92 100644 --- a/web/map.js +++ b/web/map.js @@ -212,6 +212,12 @@ DynMap.prototype = { type: 'text', value: 'not working yet' }) + .keydown(function(event) { + if (event.keyCode == '13') { + event.preventDefault(); + alert(this.value); + } + }) .appendTo(chat); var chatcursor = me.chatcursor = $('') .attr({ id: 'chatcursor'})