OLD | NEW |
| (Empty) |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | |
2 // for details. All rights reserved. Use of this source code is governed by a | |
3 // BSD-style license that can be found in the LICENSE file. | |
4 | |
5 function dartPrint(msg) { | |
6 window.parent.postMessage(String(msg), "*"); | |
7 } | |
8 | |
9 window.onerror = function (message, url, lineNumber) { | |
10 window.parent.postMessage( | |
11 ["error", {message: message, url: url, lineNumber: lineNumber}], "*"); | |
12 }; | |
13 | |
14 function onMessageReceived(event) { | |
15 var data = event.data; | |
16 if (data instanceof Array) { | |
17 if (data.length == 2 && data[0] == 'source') { | |
18 var script = document.createElement('script'); | |
19 script.innerHTML = data[1]; | |
20 script.type = 'application/javascript'; | |
21 document.head.appendChild(script); | |
22 return; | |
23 } | |
24 } | |
25 } | |
26 | |
27 window.addEventListener("message", onMessageReceived, false); | |
28 | |
29 (function () { | |
30 function postScrollHeight() { | |
31 window.parent.postMessage( | |
32 ["scrollHeight", document.documentElement.scrollHeight], "*"); | |
33 } | |
34 | |
35 var mutationObserverConstructor = | |
36 window.MutationObserver || | |
37 window.WebKitMutationObserver || | |
38 window.MozMutationObserver; | |
39 | |
40 var observer = new mutationObserverConstructor(function(mutations) { | |
41 postScrollHeight() | |
42 window.setTimeout(postScrollHeight, 500); | |
43 }); | |
44 | |
45 observer.observe( | |
46 document.body, | |
47 { attributes: true, | |
48 childList: true, | |
49 characterData: true, | |
50 subtree: true }); | |
51 })(); | |
OLD | NEW |