examples: Use iframe to show example

Fixes #475
This commit is contained in:
Hajime Hoshi 2018-01-08 03:08:19 +09:00
parent d8c0d88960
commit 8b2dfdb3e7
2 changed files with 33 additions and 5 deletions

22
examples/example.html Normal file
View File

@ -0,0 +1,22 @@
<!DOCTYPE html>
<!--
Copyright 2015 Hajime Hoshi
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<script>
var msg = 'If an inconsistent behavior is found, please try to clear $GOPATH/pkg/*_js directory.' +
' See also https://github.com/gopherjs/gopherjs/issues/440.';
console.warn(msg);
</script>
<script src="main.js"></script>

View File

@ -1,6 +1,6 @@
<!DOCTYPE html> <!DOCTYPE html>
<!-- <!--
Copyright 2015 Hajime Hoshi Copyright 2018 The Ebiten Authors
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
@ -14,9 +14,15 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and See the License for the specific language governing permissions and
limitations under the License. limitations under the License.
--> -->
<title></title>
<p><a href="..">Index</a></p>
<h1></h1>
<iframe id="example" width="640" height="480"></iframe>
<script> <script>
var msg = 'If an inconsistent behavior is found, please try to clear $GOPATH/pkg/*_js directory.' + window.addEventListener('load', () => {
' See also https://github.com/gopherjs/gopherjs/issues/440.'; let name = location.search.substring(1);
console.warn(msg); document.getElementById('example').src = `example.html?${name}`;
document.getElementsByTagName('title')[0].textContent = `Ebiten Example - ${name}`;
document.getElementsByTagName('h1')[0].textContent = `Ebiten Example - ${name}`;
});
</script> </script>
<script src="main.js"></script>