Browse Source

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

master
rayburgemeestre 6 years ago
parent
commit
5e38768659
3 changed files with 17 additions and 7 deletions
  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 View File

//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 View File

</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 View File

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

Loading…
Cancel
Save