OLD | NEW |
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 | 8 |
9 Set numberKeyPresses; | 9 Set numberKeyPresses; |
10 Set operatorKeyPresses; | 10 Set operatorKeyPresses; |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 tape.addToTape(Tape.OP_NOOP, currentRegister); | 249 tape.addToTape(Tape.OP_NOOP, currentRegister); |
250 } | 250 } |
251 } | 251 } |
252 } | 252 } |
253 | 253 |
254 void processNumber(int code, Element key) { | 254 void processNumber(int code, Element key) { |
255 String char = new String.fromCharCodes([code]); | 255 String char = new String.fromCharCodes([code]); |
256 | 256 |
257 // TODO(terry): Need to fix this in Dart library. | 257 // TODO(terry): Need to fix this in Dart library. |
258 // If there's already a . in our current register don't allow a second period. | 258 // If there's already a . in our current register don't allow a second period. |
259 // Math.parseDouble validates that 2.2.3.4.5 is okay and returns 2.2 | |
260 if (char == '.' && currentRegister.indexOf('.') != -1) { | 259 if (char == '.' && currentRegister.indexOf('.') != -1) { |
261 // Signal dot is valid more than once for a number. | 260 // Signal dot is valid more than once for a number. |
262 flickerKey(padUI.keyDot, '-error'); | 261 flickerKey(padUI.keyDot, '-error'); |
263 return; | 262 return; |
264 } else { | 263 } else { |
265 currentRegister = "${currentRegister}${char}"; | 264 currentRegister = "${currentRegister}${char}"; |
266 } | 265 } |
267 | 266 |
268 flickerKey(key); | 267 flickerKey(key); |
269 tape.addToTape(Tape.OP_NOOP, currentRegister); | 268 tape.addToTape(Tape.OP_NOOP, currentRegister); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
362 renderPad(element); | 361 renderPad(element); |
363 | 362 |
364 // Render the UI. | 363 // Render the UI. |
365 document.body.children.add(element); | 364 document.body.children.add(element); |
366 | 365 |
367 currentRegister = ""; | 366 currentRegister = ""; |
368 total = 0.0; | 367 total = 0.0; |
369 | 368 |
370 setupEvents(); | 369 setupEvents(); |
371 } | 370 } |
OLD | NEW |