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

Side by Side Diff: src/site/js/Switcher.dart

Issue 1394993002: Doing some cleanup. (Closed) Base URL: https://github.com/dart-lang/www.dartlang.org.git@master
Patch Set: Created 5 years, 2 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
« no previous file with comments | « no previous file | src/tests/site/code/Switcher.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 }
OLDNEW
« no previous file with comments | « no previous file | src/tests/site/code/Switcher.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698