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

Side by Side Diff: samples/calculator/calculator.dart

Issue 12258020: Reverting setTimeout removal. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 10 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 | « no previous file | samples/dartcombat/setup.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 import 'dart:html'; 5 import 'dart:html';
6 import 'dart:math' as Math; 6 import 'dart:math' as Math;
7 import 'calcui.dart'; 7 import 'calcui.dart';
8 import 'dart:async';
9 8
10 Set numberKeyPresses; 9 Set numberKeyPresses;
11 Set operatorKeyPresses; 10 Set operatorKeyPresses;
12 Set equalKeyPresses; 11 Set equalKeyPresses;
13 Set clearKeyPresses; 12 Set clearKeyPresses;
14 Set dotKeyPresses; 13 Set dotKeyPresses;
15 Set backspacePresses; 14 Set backspacePresses;
16 List eventSubscriptions = []; 15 List eventSubscriptions = [];
17 16
18 void setupEvents() { 17 void setupEvents() {
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 // Only Change classes with 1 hyphen that's the main class for an element 317 // Only Change classes with 1 hyphen that's the main class for an element
319 // to handle hover and active. 318 // to handle hover and active.
320 String theClass; 319 String theClass;
321 for (final String cls in key.classes) { 320 for (final String cls in key.classes) {
322 if (cls.split('-').length == 2) { 321 if (cls.split('-').length == 2) {
323 theClass = cls; 322 theClass = cls;
324 } 323 }
325 } 324 }
326 key.classes.add('${theClass}${postfix}'); 325 key.classes.add('${theClass}${postfix}');
327 final String nextPostfix = (postfix == '-error') ? '-error' : '-press'; 326 final String nextPostfix = (postfix == '-error') ? '-error' : '-press';
328 new Timer(const Duration(milliseconds: 80), 327 window.setTimeout(() => resetKey(key, '${theClass}${postfix}',
329 () => resetKey(key, '${theClass}${postfix}', 328 '${theClass}${nextPostfix}'), 80);
330 '${theClass}${nextPostfix}'));
331 } 329 }
332 330
333 void resetKey(Element key, String classToRemove, [String classToAdd = ""]) { 331 void resetKey(Element key, String classToRemove, [String classToAdd = ""]) {
334 if (key != null) { 332 if (key != null) {
335 key.classes.remove(classToRemove); 333 key.classes.remove(classToRemove);
336 if (classToAdd.length > 0) { 334 if (classToAdd.length > 0) {
337 key.classes.add(classToAdd); 335 key.classes.add(classToAdd);
338 new Timer(const Duration(milliseconds: 80), 336 window.setTimeout(() => resetKey(key, classToAdd), 80);
339 () => resetKey(key, classToAdd));
340 } 337 }
341 } 338 }
342 } 339 }
343 340
344 void main() { 341 void main() {
345 final Element element = new Element.tag('div'); 342 final Element element = new Element.tag('div');
346 343
347 // Create our Tape UI. 344 // Create our Tape UI.
348 tapeUI = new TapeUI(); 345 tapeUI = new TapeUI();
349 element.children.add(tapeUI.root); // Render the UI 346 element.children.add(tapeUI.root); // Render the UI
350 347
351 // Create our tape controller. 348 // Create our tape controller.
352 tape = new Tape(); 349 tape = new Tape();
353 350
354 renderPad(element); 351 renderPad(element);
355 352
356 // Render the UI. 353 // Render the UI.
357 document.body.children.add(element); 354 document.body.children.add(element);
358 355
359 currentRegister = ""; 356 currentRegister = "";
360 total = 0.0; 357 total = 0.0;
361 358
362 setupEvents(); 359 setupEvents();
363 } 360 }
OLDNEW
« no previous file with comments | « no previous file | samples/dartcombat/setup.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698