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

Side by Side Diff: src/tests/site/gists/homepage_jw_html/web/main.dart

Issue 1319523005: Embed DartPad in the top part of homepage (Closed) Base URL: https://github.com/dart-lang/www.dartlang.org.git@master
Patch Set: remove 2nd dartpad Created 5 years, 3 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
OLDNEW
(Empty)
1 import 'dart:html';
2
3 main() async {
4 const findMe = 'jabberwock';
5
6 // Find an element with the ID "jw".
7 var displayer = querySelector('#jw');
8
9 // Get the text to display, and display it.
10 var lines = await getLines(findMe);
11 lines?.forEach((line) {
12 print(line);
13 displayer?.text += line + '\n';
14 });
15
16 // Find all elements with the class "searchString".
17 querySelectorAll('.searchString').forEach((el) {
18 // Set each one's text and highlight it.
19 el..text = findMe
20 ..classes.add('highlighted');
21 });
22 }
23
24 // Reads a file, returning its lines.
25 getLines(String withString) async {
26 var jabber = await HttpRequest.getString(
27 'https://www.dartlang.org/samples-files/jabberwocky.txt');
28 var lines = jabber.split('\n');
29 lines.retainWhere((line) =>
30 line.toLowerCase().contains(withString));
31 return lines;
32 }
OLDNEW
« no previous file with comments | « src/tests/site/gists/homepage_jw_html/web/index.html ('k') | src/tests/site/gists/homepage_jw_html/web/styles.css » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698