diff options
author | fmoga <fmoga@13f79535-47bb-0310-9956-ffa450edef68> | 2011-05-26 09:15:35 +0000 |
---|---|---|
committer | fmoga <fmoga@13f79535-47bb-0310-9956-ffa450edef68> | 2011-05-26 09:15:35 +0000 |
commit | b10e115b9241a2a123c9bdba0a8d082954788c3c (patch) | |
tree | 7fceb1a09de4bb9a964c97f02aa762eba7a99695 /sca-java-2.x | |
parent | 8a4608d1921af2bdb8f05120eca074c2d9cbd934 (diff) |
Add focuses and Enter key shortcut for the chat sample.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1127839 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
-rw-r--r-- | sca-java-2.x/contrib/samples/learning-more/binding-comet/chat-webapp/src/main/webapp/index.html | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/sca-java-2.x/contrib/samples/learning-more/binding-comet/chat-webapp/src/main/webapp/index.html b/sca-java-2.x/contrib/samples/learning-more/binding-comet/chat-webapp/src/main/webapp/index.html index 059388b216..7e17397877 100644 --- a/sca-java-2.x/contrib/samples/learning-more/binding-comet/chat-webapp/src/main/webapp/index.html +++ b/sca-java-2.x/contrib/samples/learning-more/binding-comet/chat-webapp/src/main/webapp/index.html @@ -28,22 +28,45 @@ $(document).ready(function() { $("#chat").hide(); + $("#username").focus(); // Tuscany Comet specific API SCA.TuscanyComet.connect(); $("#register").click(function() { - SCA.CometComponentContext.ChatService.register(messageCallback); + register(messageCallback); + }); + + $("#username").keyup(function(e) { + if(e.keyCode == 13) { + register(messageCallback); + } + }); + + function register(callback) { + SCA.CometComponentContext.ChatService.register(callback); user = $("#username").val(); $("#login").hide(); $("#chat").show(); - }); + $("#message").focus(); + } $("#send").click(function() { - SCA.CometComponentContext.ChatService.postMessage(user, $("#message").val(), postCallback); - $("#message").val(""); + postMessage(user, $("#message").val(), postCallback); + }); + + $("#message").keyup(function(e) { + if(e.keyCode == 13) { + postMessage(user, $("#message").val(), postCallback); + } }); + function postMessage(user, message, callback) { + SCA.CometComponentContext.ChatService.postMessage(user, message, callback); + $("#message").val(""); + $("#message").focus(); + } + }); // this method is invoked on new messages because the CometCallback object is saved |