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

Unified Diff: dart/site/try/iframe.js

Issue 125123002: try.dartlang.org version 5. (Closed) Base URL: /Users/ahe/Dart/all@master
Patch Set: Created 6 years, 11 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: dart/site/try/iframe.js
diff --git a/dart/site/try/iframe.js b/dart/site/try/iframe.js
new file mode 100644
index 0000000000000000000000000000000000000000..5547e734ca527bdf337ceef5d47cf34ddef66d10
--- /dev/null
+++ b/dart/site/try/iframe.js
@@ -0,0 +1,45 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+function dartPrint(msg) {
+ window.parent.postMessage(String(msg), "*");
+}
+
+window.onerror = function (message, url, lineNumber) {
+ window.parent.postMessage(
+ ["error", {message: message, url: url, lineNumber: lineNumber}], "*");
+};
+
+function onMessageReceived(event) {
+ var data = event.data;
+ if (data instanceof Array) {
+ if (data.length == 2 && data[0] == 'source') {
+ var script = document.createElement('script');
+ script.innerHTML = data[1];
+ script.type = 'application/javascript';
+ document.head.appendChild(script);
+ return;
kasperl 2014/01/07 07:18:43 Do you really need this return?
ahe 2014/01/07 14:06:23 No, but it makes it easier to add new cases.
+ }
+ }
+}
+
+window.addEventListener("message", onMessageReceived, false);
+
+(function () {
+function postScrollHeight() {
+ window.parent.postMessage(["scrollHeight", document.documentElement.scrollHeight], "*");
kasperl 2014/01/07 07:18:43 Long line.
ahe 2014/01/07 14:06:23 Done.
+}
+
+var observer = new (window.MutationObserver||window.WebKitMutationObserver||window.MozMutationObserver)(function(mutations) {
kasperl 2014/01/07 07:18:43 Long line.
ahe 2014/01/07 14:06:23 Done.
+ postScrollHeight()
+ window.setTimeout(postScrollHeight, 500);
+});
+
+observer.observe(
+ document.body,
+ { attributes: true,
+ childList: true,
+ characterData: true,
+ subtree: true });
+})();

Powered by Google App Engine
This is Rietveld 408576698