This repository has been archived by the owner on Jul 21, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
snap-multi-world.html
101 lines (100 loc) · 3.71 KB
/
snap-multi-world.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<html>
<head>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Snap! Build Your Own Blocks</title>
<link rel="shortcut icon" href="favicon.ico">
<script type="text/javascript" src="snap/morphic.js"></script>
<script type="text/javascript" src="snap/widgets.js"></script>
<script type="text/javascript" src="snap/blocks.js"></script>
<script type="text/javascript" src="snap/threads.js"></script>
<script type="text/javascript" src="snap/objects.js"></script>
<script type="text/javascript" src="snap/gui.js"></script>
<script type="text/javascript" src="snap/paint.js"></script>
<script type="text/javascript" src="snap/lists.js"></script>
<script type="text/javascript" src="snap/byob.js"></script>
<script type="text/javascript" src="snap/tables.js"></script>
<script type="text/javascript" src="snap/symbols.js"></script>
<script type="text/javascript" src="snap/xml.js"></script>
<script type="text/javascript" src="snap/store.js"></script>
<script type="text/javascript" src="snap/locale.js"></script>
<script type="text/javascript" src="snap/cloud.js"></script>
<script type="text/javascript" src="snap/sha512.js"></script>
<script type="text/javascript" src="snap/FileSaver.min.js"></script>
<script type="text/javascript">
var worlds;
window.onload = function () {
var world_canvases = document.getElementsByClassName("snap-world");
worlds = Array.prototype.map.call(world_canvases,
function (world_canvas) {
return new WorldMorph(world_canvas);
});
// world_1.worldCanvas.focus();
// world_2.worldCanvas.focus();
var ide_morphs = worlds.map(function (world) {
var ide_morph = new IDE_Morph();
ide_morph.openIn(world);
return ide_morph;
});
Array.prototype.forEach.call(world_canvases,
function (world_canvas, index) {
var project_path = world_canvas.getAttribute('project_path');
if (project_path) {
fetch(project_path).then(function (response) {
response.text().then(function (project_text) {
ide_morphs[index].rawOpenProjectString(project_text);
});
}).catch(function (error) {
console.error("Error fetching " + project_path + ": " + error.message);
});
}
});
loop();
};
function loop() {
requestAnimationFrame(loop);
worlds.forEach(function (world) {
world.doOneCycle();
});
}
</script>
<style>
.snap-world-container {
border: 1px solid rgb(201, 0, 1);
overflow: hidden;
margin: 15px auto;
width: 700px;
height: 170px;
}
.snap-world-clipped {
border: 0px none;
margin-left: -450px;
margin-top: -240px;
/* width: 1300px;
height: 800px; */
width: 1600px;
height: 1200px;
/* -ms-transform: scale(.75);
-moz-transform: scale(.75);
-o-transform: scale(.75);
-webkit-transform: scale(.75);
transform: scale(.75); */
}
.snap_world {
width: 3072px;
height: 756px;
}
</style>
</head>
<body>
<p>Some text</p>
<div class="snap-world-container">
<div class="snap-world-clipped">
<canvas id="world_1" class="snap-world" project_path="projects/single-speak-block.xml" width=3072 height=756></canvas></div></div>
<p>And some more.</p>
<div class="snap-world-container">
<div class="snap-world-clipped">
<canvas id="world_2" class="snap-world" project_path="projects/single doorbell fix.xml" width=3072 height=756></canvas></div></div>
<p>Final text</p>
</body>
</html>