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

Unified 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, 4 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 side-by-side diff with in-line comments
Download patch
Index: src/tests/site/gists/homepage_jw_html/web/main.dart
diff --git a/src/tests/site/gists/homepage_jw_html/web/main.dart b/src/tests/site/gists/homepage_jw_html/web/main.dart
new file mode 100644
index 0000000000000000000000000000000000000000..31a91f9bca5585cd2ef8f435aae1ad069d82eab7
--- /dev/null
+++ b/src/tests/site/gists/homepage_jw_html/web/main.dart
@@ -0,0 +1,32 @@
+import 'dart:html';
+
+main() async {
+ const findMe = 'jabberwock';
+
+ // Find an element with the ID "jw".
+ var displayer = querySelector('#jw');
+
+ // Get the text to display, and display it.
+ var lines = await getLines(findMe);
+ lines?.forEach((line) {
+ print(line);
+ displayer?.text += line + '\n';
+ });
+
+ // Find all elements with the class "searchString".
+ querySelectorAll('.searchString').forEach((el) {
+ // Set each one's text and highlight it.
+ el..text = findMe
+ ..classes.add('highlighted');
+ });
+}
+
+// Reads a file, returning its lines.
+getLines(String withString) async {
+ var jabber = await HttpRequest.getString(
+ 'https://www.dartlang.org/samples-files/jabberwocky.txt');
+ var lines = jabber.split('\n');
+ lines.retainWhere((line) =>
+ line.toLowerCase().contains(withString));
+ return lines;
+}
« 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