Skip to content

Commit 59fb1f2

Browse files
committed
Updating Demos
1 parent 98b309e commit 59fb1f2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+10316
-4953
lines changed

demos/common.dart

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import "dart:html";
2-
import "dart:async" show Timer;
32

43
void init(String script, {void onReady()}) {
54
var stopwatch = new Stopwatch();
@@ -16,14 +15,33 @@ void init(String script, {void onReady()}) {
1615

1716
document.querySelector("#view-source").onClick.listen((_) {
1817
var popup = window.open("view_source.html", "View Source");
19-
20-
HttpRequest.getString(script).then((code) {
21-
new Timer(new Duration(seconds: 1), () {
18+
19+
var fetched = false;
20+
var ready = false;
21+
22+
String code;
23+
24+
window.addEventListener("message", (event) {
25+
if (event.data['command'] == "ready") {
26+
ready = true;
27+
if (fetched) {
28+
popup.postMessage({
29+
"command": "code",
30+
"code": code
31+
}, window.location.href);
32+
}
33+
}
34+
});
35+
36+
HttpRequest.getString(script).then((c) {
37+
code = c;
38+
fetched = true;
39+
if (ready) {
2240
popup.postMessage({
2341
"command": "code",
2442
"code": code
2543
}, window.location.href);
26-
});
44+
}
2745
});
2846
});
2947
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy