OLD | NEW |
| (Empty) |
1 // XXX: This file isn't used right now | |
2 | |
3 import 'dart:html'; | |
4 | |
5 final List<String> osList = const <String>['macos', 'windows', 'linux']; // all
supported OSs | |
6 String osName = 'linux'; // the currently displayed platform | |
7 | |
8 /** Initializes osName and selects the corresponding radio button. */ | |
9 void detectPlatform() { | |
10 // osName is initially 'linux', since linux strings are unpredictable. | |
11 if (window.navigator.appVersion.contains('Win')) { | |
12 osName = 'windows'; | |
13 } else if (window.navigator.appVersion.contains('Mac')) { | |
14 osName = 'macos'; | |
15 } | |
16 document.querySelector('#$osName').attributes['checked'] = 'true'; | |
17 } | |
18 | |
19 /** Shows the text for the chosen platform (and no other). */ | |
20 void filterPlatformText() { | |
21 // Get all the platform-specific elements. | |
22 osList.forEach((os) { | |
23 bool shouldShow = (os == osName); | |
24 document.querySelectorAll('.$os').forEach((el) { | |
25 el.hidden = !shouldShow; // Show or hide each element. | |
26 }); | |
27 }); | |
28 } | |
29 | |
30 /** Allows the user to choose the OS. */ | |
31 void registerHandlers() { | |
32 osList.forEach((os) { | |
33 document.querySelector('#$os').onClick.listen((e) { | |
34 osName = os; | |
35 filterPlatformText(); | |
36 }); | |
37 }); | |
38 } | |
39 | |
40 /** Ready, set, go! */ | |
41 void main() { | |
42 detectPlatform(); | |
43 filterPlatformText(); | |
44 registerHandlers(); | |
45 } | |
OLD | NEW |