| CODENOTIFIER | HelpYou are not signed inSign in |
Project: Lingr tools
Revision: 40
Author: dburkes
Date: 22 May 2007 14:25:43
Changes:added say capability
Files:| ... | ...@@ -112,6 +112,12 @@ | |
| 112 | 112 | |
| 113 | 113 | start: function() { |
| 114 | var s = new Lingr.Session(this); | |
| 115 | s.start(); | |
| 114 | this.session = new Lingr.Session(this); | |
| 115 | this.session.start(); | |
| 116 | }, | |
| 117 | ||
| 118 | say: function(message, occupantId) { | |
| 119 | if (this.session && this.session.room) { | |
| 120 | this.session.room.say(message, occupantId); | |
| 121 | } | |
| 116 | 122 | } |
| 117 | 123 | } |
| ... | ...@@ -169,6 +175,6 @@ | |
| 169 | 175 | |
| 170 | 176 | enterRoom: function() { |
| 171 | var r = new Lingr.Room(this, this.lingr.options.roomId, this.lingr.options.nickname) | |
| 172 | r.enter(); | |
| 177 | this.room = new Lingr.Room(this, this.lingr.options.roomId, this.lingr.options.nickname); | |
| 178 | this.room.enter(); | |
| 173 | 179 | }, |
| 174 | 180 | |
| ... | ...@@ -309,4 +315,25 @@ | |
| 309 | 315 | }, |
| 310 | 316 | |
| 317 | say: function(message, occupantId) { | |
| 318 | params = { | |
| 319 | session: this.session.session, | |
| 320 | ticket: this.ticket, | |
| 321 | message: message | |
| 322 | }; | |
| 323 | ||
| 324 | if (occupantId) { | |
| 325 | params.occupant_id = occupant_id; | |
| 326 | } | |
| 327 | ||
| 328 | this.session.lingr.request('post', '/room/say', params, { | |
| 329 | onSuccess: function(json) { | |
| 330 | this.session.lingr.dispatchEvent('Said', json); | |
| 331 | }.bind(this), | |
| 332 | onFailure: function(json) { | |
| 333 | this.session.lingr.dispatchEvent('ApiFailure', json); | |
| 334 | }.bind(this) | |
| 335 | }); | |
| 336 | }, | |
| 337 | ||
| 311 | 338 | leave: function() { |
| 312 | 339 | if (this.ticket) { |
| ... | ...@@ -8,4 +8,8 @@ | |
| 8 | 8 | <body> |
| 9 | 9 | <h1 id="roomName">Entering room...</h1> |
| 10 | <form onsubmit="lingr.say($F('message')); $('message').value = ''; return false;"> | |
| 11 | <input id="message" type="text"> | |
| 12 | <input type="submit" value="Say it!"> | |
| 13 | </form> | |
| 10 | 14 | <h2>Who's Here</h2> |
| 11 | 15 | <ul id="roster"> |
| ... | ...@@ -56,4 +60,5 @@ | |
| 56 | 60 | |
| 57 | 61 | Event.observe(window, 'load', setTimeout(lingr.start.bind(lingr), 100)); |
| 62 | Field.activate('message'); | |
| 58 | 63 | </script> |
| 59 | 64 | </body> |