| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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("Total"); | 5 #library("Total"); |
| 6 #import("dart:html"); | 6 #import("dart:html"); |
| 7 #import("TotalLib.dart"); | 7 #import("TotalLib.dart"); |
| 8 | 8 |
| 9 class Total { | |
| 10 static final int DEFAULT_VISIBLE_COLUMNS = 10; | |
| 11 static final int DEFAULT_VISIBLE_ROWS = 25; | |
| 12 | |
| 13 Spreadsheet _spreadsheet; | |
| 14 SpreadsheetPresenter _presenter; | |
| 15 | |
| 16 Total() { | |
| 17 Element recalcButton = document.query("#recalcButton"); | |
| 18 recalcButton.innerHTML = "Recalculate"; | |
| 19 recalcButton.on.click.add((Event e) { | |
| 20 _presenter.recalculateAll(); | |
| 21 }); | |
| 22 } | |
| 23 | |
| 24 void run() { | |
| 25 _spreadsheet = new Spreadsheet(); | |
| 26 SYLKReader reader = new SYLKReader(); | |
| 27 reader.request("mortgage", (String data) { | |
| 28 reader.loadFromString(_spreadsheet, data); | |
| 29 _presenter = new SpreadsheetPresenter(_spreadsheet, window, | |
| 30 0, 0, DEFAULT_VISIBLE_ROWS, DEFAULT_VISIBLE_COLUMNS); | |
| 31 _spreadsheet.setListener(_presenter); | |
| 32 _presenter.recalculateViewport(); | |
| 33 }); | |
| 34 } | |
| 35 } | |
| 36 | |
| 37 void main() { | 9 void main() { |
| 38 // Instantiate the app | 10 // Instantiate the app |
| 39 new Total().run(); | 11 new Total().run(); |
| 40 | 12 |
| 41 document.on.keyDown.add((KeyboardEvent event) { | 13 document.on.keyDown.add((KeyboardEvent event) { |
| 42 // TODO: Browsers need to fix the keyCode/keyIdentifier situation. | 14 // TODO: Browsers need to fix the keyCode/keyIdentifier situation. |
| 43 if (event.ctrlKey && event.keyCode == 68 /* d */) { | 15 if (event.ctrlKey && event.keyCode == 68 /* d */) { |
| 44 Element db = document.query('#debugbar'); | 16 Element db = document.query('#debugbar'); |
| 45 if (db.classes.contains('on')) { | 17 if (db.classes.contains('on')) { |
| 46 db.classes.remove('on'); | 18 db.classes.remove('on'); |
| 47 } else { | 19 } else { |
| 48 db.classes.add('on'); | 20 db.classes.add('on'); |
| 49 } | 21 } |
| 50 } | 22 } |
| 51 }, false); | 23 }, false); |
| 52 } | 24 } |
| OLD | NEW |