浏览代码

Make customizable where to inject javascript, it might be different for various examples

master
rayburgemeestre 6 年前
父节点
当前提交
5e38768659
共有 3 个文件被更改,包括 17 次插入7 次删除
  1. +15
    -7
      src/App.vue
  2. +1
    -0
      src/examples/dom_example
  3. +1
    -0
      src/examples/pong_example

+ 15
- 7
src/App.vue 查看文件

//const iframe = findIframeByName(name); //const iframe = findIframeByName(name);
const iframe = document.getElementsByTagName('iframe')[0]; const iframe = document.getElementsByTagName('iframe')[0];
//iframe.document.body.innerHTML = '' //iframe.document.body.innerHTML = ''
var head = this.html_code.indexOf("<head>");
var marker = '<!-- MARKER: Include javascript here. -->';
var m = this.html_code.indexOf(marker);
var s = ""; var s = "";
if (head != -1) {
s += this.html_code.substr(0, head + 6 /* len(<head>) */);
}
else {
s += this.html_code;
if (m != -1) {
s += this.html_code.substr(0, m);
} else {
var head = this.html_code.indexOf("<head>");
if (head != -1) {
s += this.html_code.substr(0, head + 6 /* len(<head>) */);
}
else {
s += this.html_code;
}
} }


s += "<script>"; s += "<script>";
s += this.js_code; s += this.js_code;
s += "<\/script>"; s += "<\/script>";


if (head != -1) {
if (m != -1) {
s += this.html_code.substr(m);
} else if (head != -1) {
s += this.html_code.substr(head + 6 /* len(<head>) */ + 1); s += this.html_code.substr(head + 6 /* len(<head>) */ + 1);
} }



+ 1
- 0
src/examples/dom_example 查看文件

</head> </head>
<body> <body>
<h1 id="pagetitle">Boring static text</h1> <h1 id="pagetitle">Boring static text</h1>
<!-- MARKER: Include javascript here. -->
</body> </body>
</html>`.trim(); </html>`.trim();



+ 1
- 0
src/examples/pong_example 查看文件

</head> </head>
<body> <body>
<canvas id="pongcanvas"></canvas> <canvas id="pongcanvas"></canvas>
<!-- MARKER: Include javascript here. -->
</body> </body>
</html> </html>
`.trim(); `.trim();

正在加载...
取消
保存