-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathtm-iframe.html
55 lines (45 loc) · 1.49 KB
/
tm-iframe.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>tmlib.js Examples</title>
<!-- My custom components -->
<script type="text/javascript" src="./../build/tmlib.js"></script>
<style>
html, body {
height: 200px;
}
</style>
<script type="text/javascript">
function loadInlineExample(code, options, callback) {
try {
console.log(code, options, callback);
document.body.innerHTML = '';
runDisplayExample(code);
callback && callback(true);
} catch (e) {
document.body.innerHTML = e;
callback && callback(false, e);
}
};
var runDisplayExample = function(code) {
var canvas = document.createElement('canvas');
canvas.setAttribute("id", "world");
document.body.appendChild(canvas);
var app = tm.app.CanvasApp(canvas);
tm.define("MainScene", {
superClass: "tm.app.Scene",
init: function() {
this.superInit();
eval(code);
}
});
app.replaceScene(MainScene());
app.run();
};
</script>
</head>
<body>
<canvas></canvas>
</body>
</html>