Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(262)

Side by Side Diff: samples/chat/dart_client/chat.dart

Issue 11783009: Big merge from experimental to bleeding edge. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « samples/chat/chat_stress_client.dart ('k') | samples/clock/balls.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library chat; 5 library chat;
6 import 'dart:html'; 6 import 'dart:html';
7 import 'dart:json'; 7 import 'dart:json' as jsonlib;
8 8
9 void main() { 9 void main() {
10 new Chat().start(); 10 new Chat().start();
11 } 11 }
12 12
13 class Chat { 13 class Chat {
14 void start() { 14 void start() {
15 Document doc = window.document; 15 Document doc = window.document;
16 _joinButton = doc.query("#joinButton"); 16 _joinButton = doc.query("#joinButton");
17 _leaveButton = doc.query("#leaveButton"); 17 _leaveButton = doc.query("#leaveButton");
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 void onPollFailed() { 156 void onPollFailed() {
157 showStatus("Failed to receive messages. Please try again later."); 157 showStatus("Failed to receive messages. Please try again later.");
158 uiJoin(); 158 uiJoin();
159 } 159 }
160 160
161 HttpRequest sendRequest(String url, Map json, var onSuccess, var onError) { 161 HttpRequest sendRequest(String url, Map json, var onSuccess, var onError) {
162 HttpRequest request = new HttpRequest(); 162 HttpRequest request = new HttpRequest();
163 request.on.readyStateChange.add((Event event) { 163 request.on.readyStateChange.add((Event event) {
164 if (request.readyState != 4) return; 164 if (request.readyState != 4) return;
165 if (request.status == 200) { 165 if (request.status == 200) {
166 onSuccess(JSON.parse(request.responseText)); 166 onSuccess(jsonlib.parse(request.responseText));
167 } else { 167 } else {
168 onError(); 168 onError();
169 } 169 }
170 }); 170 });
171 request.open("POST", url, true); 171 request.open("POST", url, true);
172 request.setRequestHeader("Content-Type", "text/plain;charset=UTF-8"); 172 request.setRequestHeader("Content-Type", "text/plain;charset=UTF-8");
173 request.send(JSON.stringify(json)); 173 request.send(jsonlib.stringify(json));
174 return request; 174 return request;
175 } 175 }
176 176
177 void uiJoin() { 177 void uiJoin() {
178 enableButton(_joinButton); 178 enableButton(_joinButton);
179 showElement(_joinSection); 179 showElement(_joinSection);
180 hideElement(_chatSection); 180 hideElement(_chatSection);
181 _nextMessage = 0; 181 _nextMessage = 0;
182 _messages.children.clear(); 182 _messages.children.clear();
183 showStatus("Welcome to dart chat sample. " 183 showStatus("Welcome to dart chat sample. "
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 Element _chatSection; 306 Element _chatSection;
307 InputElement _messageInput; 307 InputElement _messageInput;
308 Element _messages; 308 Element _messages;
309 Element _statusText; 309 Element _statusText;
310 310
311 String _session = null; 311 String _session = null;
312 int _nextMessage = 0; 312 int _nextMessage = 0;
313 HttpRequest _pollRequest = null; 313 HttpRequest _pollRequest = null;
314 314
315 } 315 }
OLDNEW
« no previous file with comments | « samples/chat/chat_stress_client.dart ('k') | samples/clock/balls.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698