| CODENOTIFIER | HelpYou are not signed inSign in |
Project: Lingr tools
Revision: 42
Author: dburkes
Date: 29 Aug 2007 16:50:11
Changes:Patches from gimite to support his Lingr Google Gadget
Files:| ... | ...@@ -40,5 +40,6 @@ | |
| 40 | 40 | request: function(method, path, params, options) { |
| 41 | 41 | options = options || {}; |
| 42 | ||
| 42 | var head = document.getElementsByTagName('head')[0]; | |
| 43 | var script; | |
| 43 | 44 | if (this.options.useDsr) { |
| 44 | 45 | |
| ... | ...@@ -49,4 +50,5 @@ | |
| 49 | 50 | (options.onFailure || this.emptyFunction)(json) |
| 50 | 51 | } |
| 52 | head.removeChild(script); | |
| 51 | 53 | }.bind(this); |
| 52 | 54 | |
| ... | ...@@ -56,9 +58,9 @@ | |
| 56 | 58 | |
| 57 | 59 | try { |
| 58 | var script = document.createElement('script'); | |
| 60 | script = document.createElement('script'); | |
| 59 | 61 | script.type = 'text/javascript'; |
| 60 | 62 | script.charset = 'UTF-8'; |
| 61 | 63 | script.src = this.url(path) + '?' + this.formatParams(params); |
| 62 | document.getElementsByTagName('head')[0].appendChild(script); | |
| 64 | head.appendChild(script); | |
| 63 | 65 | this.timeout = setTimeout(params.callback, options.timeout || this.options.dsrTimeout); |
| 64 | 66 | } catch(e) { |
| ... | ...@@ -120,4 +122,18 @@ | |
| 120 | 122 | this.session.room.say(message, occupantId); |
| 121 | 123 | } |
| 124 | }, | |
| 125 | ||
| 126 | getNickname: function() { | |
| 127 | if (this.session && this.session.room) { | |
| 128 | return this.session.room.nickname; | |
| 129 | } else { | |
| 130 | return null; | |
| 131 | } | |
| 132 | }, | |
| 133 | ||
| 134 | setNickname: function(nickname) { | |
| 135 | if (this.session && this.session.room) { | |
| 136 | this.session.room.setNickname(nickname); | |
| 137 | } | |
| 122 | 138 | } |
| 123 | 139 | } |
| ... | ...@@ -148,6 +164,16 @@ | |
| 148 | 164 | } |
| 149 | 165 | else { |
| 150 | this.lingr.setCookie(this.session); | |
| 151 | this.enterRoom(); | |
| 166 | this.lingr.request('post', '/session/verify', { | |
| 167 | session: this.session | |
| 168 | }, { | |
| 169 | onSuccess: function(json) { | |
| 170 | this.lingr.setCookie(this.session); | |
| 171 | this.enterRoom(); | |
| 172 | }.bind(this), | |
| 173 | onFailure: function(json) { | |
| 174 | this.session = null; | |
| 175 | this.start(); | |
| 176 | }.bind(this) | |
| 177 | }) | |
| 152 | 178 | } |
| 153 | 179 | }, |
| ... | ...@@ -259,4 +285,22 @@ | |
| 259 | 285 | } |
| 260 | 286 | }, |
| 287 | ||
| 288 | setNickname: function(nickname) { | |
| 289 | this.nickname = nickname; | |
| 290 | if (!this.ticket) return; | |
| 291 | var params = { | |
| 292 | session: this.session.session, | |
| 293 | ticket: this.ticket, | |
| 294 | nickname: this.nickname | |
| 295 | }; | |
| 296 | this.session.lingr.request('post', '/room/set_nickname', params, { | |
| 297 | onSuccess: function(json) { | |
| 298 | this.session.lingr.dispatchEvent('NicknameChanged', json); | |
| 299 | }.bind(this), | |
| 300 | onFailure: function(json) { | |
| 301 | this.session.lingr.dispatchEvent('ApiFailure', json); | |
| 302 | }.bind(this) | |
| 303 | }) | |
| 304 | }, | |
| 261 | 305 | |
| 262 | 306 | getContext: function() { |