|
5 | 5 | <meta content="text/html;charset=utf-8" http-equiv="Content-Type"> |
6 | 6 | <meta content="utf-8" http-equiv="encoding"> |
7 | 7 | <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
8 | | - <link rel="stylesheet" href="css/style.css"> |
| 8 | + <script src="js/frame.js"></script> |
9 | 9 | </head> |
10 | 10 | <body> |
11 | 11 | <main id="main"></main> |
12 | | -<script type="text/javascript"> |
13 | | - (function() { |
14 | | - function evalPureScript(sources) { |
15 | | - var modules = {}; |
16 | | - function dirname(str) { |
17 | | - var ix = str.lastIndexOf("/"); |
18 | | - return ix < 0 ? "" : str.slice(0, ix); |
19 | | - } |
20 | | - function resolvePath(a, b) { |
21 | | - if (b[0] === "." && b[1] === "/") { |
22 | | - return dirname(a) + b.slice(1); |
23 | | - } |
24 | | - if (b[0] === "." && b[1] === "." && b[2] === "/") { |
25 | | - return dirname(dirname(a)) + b.slice(2); |
26 | | - } |
27 | | - return b; |
28 | | - } |
29 | | - return function load(name) { |
30 | | - if (modules[name]) { |
31 | | - return modules[name].exports; |
32 | | - } |
33 | | - function require(path) { |
34 | | - return load(resolvePath(name, path)); |
35 | | - } |
36 | | - var module = modules[name] = { exports: {} }; |
37 | | - new Function("module", "exports", "require", sources[name])(module, module.exports, require); |
38 | | - return module.exports; |
39 | | - }; |
40 | | - } |
41 | | - |
42 | | - function loadScripts(scripts, cb) { |
43 | | - if (scripts.length === 0) { |
44 | | - return cb(); |
45 | | - } |
46 | | - var script = document.createElement("script"); |
47 | | - script.type = "text/javascript"; |
48 | | - script.src = scripts[0]; |
49 | | - script.addEventListener("load", function() { |
50 | | - loadScripts(scripts.slice(1), cb); |
51 | | - }, { once: true }); |
52 | | - document.head.appendChild(script); |
53 | | - } |
54 | | - |
55 | | - document.addEventListener("DOMContentLoaded", function() { |
56 | | - window.addEventListener("message", function(event) { |
57 | | - loadScripts(event.data.scripts, function() { |
58 | | - var file = evalPureScript(event.data.sources)("<file>"); |
59 | | - if (file.main && typeof file.main === "function") { |
60 | | - file.main(); |
61 | | - } |
62 | | - }); |
63 | | - event.source.postMessage("trypurescript", "*"); |
64 | | - }, { once: true }); |
65 | | - }, { once: true }); |
66 | | - })(); |
67 | | -</script> |
68 | 12 | </body> |
69 | 13 | </html> |
0 commit comments