Sfoglia il codice sorgente

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

master
rayburgemeestre 6 anni fa
parent
commit
5e38768659
3 ha cambiato i file con 17 aggiunte e 7 eliminazioni
  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 Vedi File

@@ -243,13 +243,19 @@
//const iframe = findIframeByName(name);
const iframe = document.getElementsByTagName('iframe')[0];
//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 = "";
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>";
@@ -270,7 +276,9 @@
s += this.js_code;
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);
}


+ 1
- 0
src/examples/dom_example Vedi File

@@ -38,6 +38,7 @@ const html_code = `
</head>
<body>
<h1 id="pagetitle">Boring static text</h1>
<!-- MARKER: Include javascript here. -->
</body>
</html>`.trim();


+ 1
- 0
src/examples/pong_example Vedi File

@@ -220,6 +220,7 @@ const html_code = `
</head>
<body>
<canvas id="pongcanvas"></canvas>
<!-- MARKER: Include javascript here. -->
</body>
</html>
`.trim();

Loading…
Annulla
Salva