-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathoriginal.html
314 lines (278 loc) · 14.3 KB
/
original.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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
<!doctype html>
<meta charset=utf-8>
<meta name=viewport content="width=device-width, initial-scale=1.0">
<title>sulfurous</title>
<link rel=icon type="image/png" href="favicon.ico">
<link rel=stylesheet href=player.css>
<link rel=stylesheet href=index.css>
<div class=area id=title-area>
<h1 class=title>sulfurous</h1>
<p>sulfurous, just like phosphorus, runs your Scratch projects really fast by compiling them to JavaScript. Try it out by pasting a URL or project ID into the field below or <a class=dropdown>choosing an example<select id=examples>
<option value>
<option value=11397100>3D Remix by DadOfMrLog
<option value=15945630>O by DCPU-16
<option value=10128407>Paper Minecraft by griffpatch
<option value=16207935>Alone in the depths by sticku
<option value=16205373>3D Framework by DadOfMrLog
<option value=31903442>gb.sb2 [Dr. Mario] by DCPU-16
<option value=34791164>gb.sb2 [Mario Land 2] by DCPU-16
<option value=21554369>Epic Ninja by griffpatch
<option value=15832807>Pretty by blob8108
</select></a>. You can also drag a local .sb2 project onto this page.</p>
</div>
<div class=area id=player-area>
<div class=controls>
<span class=stop></span>
<span class=pause></span>
<span class=flag title="Shift+click to enable turbo mode."></span>
<div class=turbo>Turbo Mode</div>
<span class=full-screen></span>
</div>
<div class=player></div>
<div class=internal-error>
An internal error occurred. <a id=error-bug-link target=_blank href=https://github.com/mittagskogel/sulfurous/issues/new>Click here</a> to file a bug report.
</div>
</div>
<div class=title>
<div class=progress-bar></div>
<input class=url value=https://scratch.mit.edu/projects/>
<a target=_blank class=project-link title="View project on Scratch"></a>
</div>
<div class=area id=project-area>
<section class=package>
<h1>Package this project</h1>
<p>Get a link to a web page that automatically runs your project.</p>
<p>
<a href=# target=_blank id=package-link>Package</a>
<input type=checkbox id=package-turbo>
<label for=package-turbo>Turbo mode</label>
<input type=radio id=package-full-screen name=custom-resolution>
<label for=package-full-screen>Full screen</label>
<br />
<input type=radio id=package-standard-resolution checked name=custom-resolution>
<label for=package-standard-resolution>480x360</label>
<input type=radio id=package-double-resolution name=custom-resolution>
<label for=package-double-resolution>960x720</label>
<input type=radio id=package-custom-resolution name=custom-resolution>
<label for=package-custom-resolution>Custom width:</label>
<input type=number id=package-custom-resolution-value min=0 max=16000>
</p>
</section>
<section class=package>
<h1>Embed this project</h1>
<p>Include the sulfurous player in your web site.</p>
<p>
<input readonly id=embed-code>
<input type=checkbox id=embed-auto-start checked>
<label for=embed-auto-start>Start automatically</label>
<input type=checkbox id=embed-light-content>
<label for=embed-light-content>Light controls</label>
<input type=checkbox id=embed-hide-controls>
<label for=embed-hide-controls>Hide UI</label>
<input type=radio id=embed-standard-resolution name=e-custom-resolution>
<label for=embed-standard-resolution>480x360</label>
<input type=radio id=embed-double-resolution name=e-custom-resolution>
<label for=embed-double-resolution>960x720</label>
<input type=radio id=embed-custom-resolution name=e-custom-resolution>
<label for=embed-custom-resolution>Custom width:</label>
<input type=number id=embed-custom-resolution-value min=0 max=16000>
</p>
</section>
<section>
<h1>Report a problem</h1>
<p>sulfurous is still in development. <a id=bug-link target=_blank href=https://github.com/mittagskogel/sulfurous/issues/new>Click here</a> to report a problem with this project.</p>
</section>
</div>
<section>
<h1>Credits</h1>
<p>Sulfurous was created by <a href=https://github.com/mittagskogel>Mittagskogel</a> and is based off Phosphorus, which was created by <a href=https://github.com/nathan>Nathan Dinsmore</a>. Its CPS-style compilation and overall design was inspired by <a href=https://github.com/RHY3756547>Rhys Simpson</a>'s <a href=https://code.google.com/p/sb2-js/>sb2.js</a>. It would have more bugs if not for <a href=https://github.com/trumank>Truman Kilen</a>. It uses the <a href=https://stuk.github.io/jszip/>JSZip</a> library, created by <a href=https://github.com/stuk>Stuart Knightley</a>, <a href=https://github.com/dduponchel>David Duponchel</a>, Franz Buchinger, and <a href=https://github.com/aadsm>António Afonso</a>, to read <code>.sb2</code> files and compressed projects, and the <a href=https://code.google.com/p/canvg/>canvg</a> library, created by <a href=https://code.google.com/u/[email protected]/>Gabe Lerner</a>, to render SVGs in <code><canvas></code> elements.
<h1>Code</h1>
<p>The source code for sulfurous is available <a href=https://github.com/mittagskogel/sulfurous>on GitHub</a>. See <a href=https://github.com/nathan/phosphorus>Phosphorus</a> for the original version.</p>
</section>
<script src=fonts.js></script>
<script src=https://cdnjs.cloudflare.com/ajax/libs/jszip/2.4.0/jszip.js></script>
<script src=phosphorus.js></script>
<script src=player.js></script>
<script>
(function() {
'use strict';
var prefix = 'https://scratch.mit.edu/projects/';
var initialId = location.hash.substr(1);
if (initialId === 'zip') initialId = '';
var titleArea = document.querySelector('#title-area');
var playerArea = document.querySelector('#player-area');
var projectArea = document.querySelector('#project-area');
playerArea.style.height = projectArea.style.height = 'auto';
var titleAreaHeight = titleArea.offsetHeight;
var playerAreaHeight = playerArea.offsetHeight;
var projectAreaHeight = projectArea.offsetHeight;
playerArea.style.height = projectArea.style.height = 0;
var examples = document.querySelector('#examples');
var urlInput = document.querySelector('.url');
urlInput.value = prefix + initialId;
var progressBar = document.querySelector('.progress-bar');
var player = document.querySelector('.player');
var projectLink = document.querySelector('.project-link');
var bugLink = document.querySelector('#bug-link');
var packageLink = document.querySelector('#package-link');
var packageTurbo = document.querySelector('#package-turbo');
var packageFullScreen = document.querySelector('#package-full-screen');
var packageStandardResolution = document.querySelector('#package-standard-resolution');
var packageDoubleResolution = document.querySelector('#package-double-resolution');
var packageCustomResolution = document.querySelector('#package-custom-resolution');
var packageCustomResolutionValue = document.querySelector('#package-custom-resolution-value');
var embedCode = document.querySelector('#embed-code');
var embedAutoStart = document.querySelector('#embed-auto-start');
var embedLightContent = document.querySelector('#embed-light-content');
var embedHideControls = document.querySelector('#embed-hide-controls');
var embedStandardResolution = document.querySelector('#embed-standard-resolution');
var embedDoubleResolution = document.querySelector('#embed-double-resolution');
var embedCustomResolution = document.querySelector('#embed-custom-resolution');
var embedCustomResolutionValue = document.querySelector('#embed-custom-resolution-value');
var timeout;
urlInput.addEventListener('input', function() {
var ss = urlInput.selectionStart;
var se = urlInput.selectionEnd;
var url = urlInput.value;
var id = url.match(/\d+/g) || [''];
while (id.length > 1 && id.indexOf(P.player.projectId) > -1) {
id.splice(id.indexOf(P.player.projectId), 1);
}
id = id[0];
urlInput.value = url = prefix + id;
urlInput.selectionStart = urlInput.selectionEnd = Math.max(prefix.length, ss);
clearTimeout(timeout);
if (P.player.projectId !== id) {
timeout = setTimeout(function() {
location.hash = '#' + id;
}, 300);
}
});
urlInput.addEventListener('focus', function() {
setTimeout(function() {
if (/\d/.test(urlInput.value)) {
urlInput.select();
}
});
});
examples.addEventListener('change', function() {
if (examples.value) {
location.hash = '#' + examples.value;
examples.selectedIndex = 0;
}
});
window.addEventListener('hashchange', function() {
var id = location.hash.substr(1);
if (id !== 'zip') {
if (+id !== +id) id = '';
urlInput.value = prefix + id;
}
load(id);
});
function show(id) {
titleArea.style.height = id ? 0 : titleAreaHeight + 'px';
playerArea.style.height = id ? playerAreaHeight + 'px' : 0
projectArea.style.height = id ? projectAreaHeight + 'px' : 0;
if (!id) urlInput.focus();
}
function load(id) {
if (id !== 'zip') {
show(id);
} else {
id = '';
}
document.title = 'sulfurous';
P.player.load(id, function(stage) {
stage.triggerGreenFlag();
}, function(title) {
document.title = title ? title + ' \xb7 sulfurous' : 'sulfurous';
updateBugLink();
});
projectLink.href = P.player.projectURL;
updateBugLink();
updatePackageLink();
updateEmbedCode();
}
function updateBugLink() {
bugLink.href = P.player.projectId ? 'https://github.com/mittagskogel/sulfurous/issues/new?title=' + encodeURIComponent(P.player.projectTitle || P.player.projectURL) + '&body=' + encodeURIComponent('\n\n\n' + P.player.projectURL + '\nhttps://newton.nes.aau.at/~sulfurous/#' + P.player.projectId + '\n' + navigator.userAgent) : 'https://github.com/mittagskogel/sulfurous/issues/new?body=' + encodeURIComponent('\n\n\n' + navigator.userAgent);
}
function updatePackageLink() {
if(packageFullScreen.checked) packageCustomResolutionValue.value = null;
if(packageStandardResolution.checked) packageCustomResolutionValue.value = 480;
if(packageDoubleResolution.checked) packageCustomResolutionValue.value = 960;
//remember to change the URL back to /app.html when putting this back online...
//packageLink.href = P.player.projectId ? 'file:///D:/Mittagskogel/Sulfurous/app.html?id=' + P.player.projectId + '&turbo=' + packageTurbo.checked + '&full-screen=' + packageFullScreen.checked + '&resolution-x=' + packageCustomResolutionValue.value: 'about:blank';
packageLink.href = P.player.projectId ? 'https://sulfurous.aau.at/~sulfurous/app.html?id=' + P.player.projectId + '&turbo=' + packageTurbo.checked + '&full-screen=' + packageFullScreen.checked + '&resolution-x=' + packageCustomResolutionValue.value: 'about:blank';
packageCustomResolutionValue.disabled = !packageCustomResolution.checked;
}
packageTurbo.addEventListener('change', updatePackageLink);
packageFullScreen.addEventListener('change', updatePackageLink);
packageStandardResolution.addEventListener('change', updatePackageLink);
packageDoubleResolution.addEventListener('change', updatePackageLink);
packageCustomResolution.addEventListener('change', updatePackageLink);
packageCustomResolutionValue.addEventListener('change', updatePackageLink);
function updateEmbedCode(e) {
if(embedStandardResolution.checked) embedCustomResolutionValue.value = 480;
if(embedDoubleResolution.checked) embedCustomResolutionValue.value = 960;
//remember to change the URL back to 'https://' + location.host when putting this back online...
//embedCode.value = P.player.projectId ? '<script src=file:///D:/Mittagskogel/Sulfurous' + '/embed.js?id=' + P.player.projectId + '&resolution-x=' + embedCustomResolutionValue.value + (embedHideControls.checked ? '&ui=false' : '&auto-start=' + embedAutoStart.checked + '&light-content=' + embedLightContent.checked) + '></' + 'script>' : '';
embedCode.value = P.player.projectId ? '<script src=https://sulfurous.aau.at/~sulfurous' + '/embed.js?id=' + P.player.projectId + '&resolution-x=' + embedCustomResolutionValue.value + (embedHideControls.checked ? '&ui=false' : '&auto-start=' + embedAutoStart.checked + '&light-content=' + embedLightContent.checked) + '></' + 'script>' : '';
embedCustomResolutionValue.disabled = !embedCustomResolution.checked;
embedAutoStart.disabled =
embedLightContent.disabled = embedHideControls.checked;
if (embedHideControls.checked) embedAutoStart.checked = true;
if (e) embedCode.focus();
}
function selectEmbedCode() {
setTimeout(function() {
embedCode.select();
});
}
embedCode.addEventListener('focus', selectEmbedCode);
embedCode.addEventListener('click', selectEmbedCode);
embedHideControls.addEventListener('change', updateEmbedCode);
embedAutoStart.addEventListener('change', updateEmbedCode);
embedLightContent.addEventListener('change', updateEmbedCode);
embedStandardResolution.addEventListener('change', updateEmbedCode);
embedDoubleResolution.addEventListener('change', updateEmbedCode);
embedCustomResolution.addEventListener('change', updateEmbedCode);
embedCustomResolutionValue.addEventListener('change', updateEmbedCode);
load(initialId);
setTimeout(function() {
function setTransition(el) {
el.style.WebkitTransition =
el.style.MozTransition =
el.style.OTransition =
el.style.transition = 'height 0.2s';
}
setTransition(titleArea);
setTransition(playerArea);
setTransition(projectArea);
});
function cancel(e) {
e.preventDefault();
e.dataTransfer.dropEffect = 'copy';
}
document.body.addEventListener('dragover', cancel);
document.body.addEventListener('dragenter', cancel);
document.body.addEventListener('drop', function(e) {
e.preventDefault();
var f = e.dataTransfer.files[0];
if (f) {
location.hash = '#zip';
show('zip');
var ext = f.name.split('.').pop();
if (ext === 'sb2' || ext === 'zip') {
var request = P.IO.loadSB2File(f);
} else if (ext === 'json') {
request = P.IO.loadJSONFile(f);
}
if (request) {
P.player.showProgress(request, function(stage) {
stage.triggerGreenFlag();
});
}
}
});
}());
</script>