forked from trumank/phosphorus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.html
127 lines (107 loc) · 3.62 KB
/
app.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
<!doctype html>
<meta charset=utf-8>
<meta name=viewport content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<meta name=apple-mobile-web-app-capable content=yes>
<meta name=apple-mobile-web-app-status-bar-style content=black>
<title>sulfurous</title>
<link rel=icon type="image/png" href="favicon.ico">
<link rel=stylesheet href=app.css>
<div class=player></div>
<div class=splash>
<div>
<h1>sulfurous</h1>
<div class=progress><div class=progress-bar></div></div>
</div>
</div>
<div class=error>
<div>
<h1>sulfurous</h1>
<p>An error has occurred. <a id=bug-link href=https://github.com/mittagskogel/sulfurous/issues/new>Click here</a> to file a bug report on GitHub.</p>
</div>
</div>
<script src=fonts.js></script>
<script src=//cdnjs.cloudflare.com/ajax/libs/jszip/2.4.0/jszip.js></script>
<script src=phosphorus.js></script>
<script>
(function () {
'use strict';
if (location.protocol === 'https:') {
location.replace(('' + location).replace(/^https:/, 'http:'));
}
var stage;
var projectId = 17088932;
var projectTitle = '';
var turbo = false;
var fullScreen = true;
var resolution = 480;
var params = location.search.substr(1).split('&');
params.forEach(function(p) {
var parts = p.split('=');
if (parts.length > 1) {
switch (parts[0]) {
case 'id':
projectId = Number(parts[1]);
break;
case 'turbo':
turbo = parts[1] !== 'false';
break;
case 'full-screen':
fullScreen = parts[1] !== 'false';
break;
case 'resolution-x':
resolution = Number(parts[1]);
break;
default:
console.log('Skipping unknown option: ' + parts[0] + '=' + parts[1]);
}
}
});
P.resolution = resolution;
var splash = document.querySelector('.splash');
var progressBar = document.querySelector('.progress-bar');
var error = document.querySelector('.error');
var bugLink = document.querySelector('#bug-link');
var player = document.querySelector('.player');
var stage;
function layout() {
if (!stage) return;
var w = Math.min(window.innerWidth, window.innerHeight / .75);
if (!fullScreen) w = resolution;
var h = w * .75;
player.style.left = (window.innerWidth - w) / 2 + 'px';
player.style.top = (window.innerHeight - h) / 2 + 'px';
stage.setZoom(w / 480);
stage.draw();
}
function showError(e) {
error.style.display = 'table';
bugLink.href = 'https://github.com/mittagskogel/sulfurous/issues/new?title=' + encodeURIComponent(projectTitle || '') + '&body=' + encodeURIComponent('\n\n\nhttp://scratch.mit.edu/projects/' + projectId + '\nhttp://phosphorus.github.io/#' + projectId + (e.stack ? '\n\n```\n' + e.stack + '\n```' : ''));
console.error(e.stack);
}
window.addEventListener('resize', layout);
if (P.hasTouchEvents) {
document.addEventListener('touchmove', function(e) {
e.preventDefault();
});
}
var request = P.IO.loadScratchr2Project(projectId);
request.onload = function (s) {
splash.style.display = 'none';
stage = s;
layout();
s.isTurbo = turbo;
s.start();
s.triggerGreenFlag();
player.appendChild(s.root);
s.focus();
s.handleError = showError;
};
request.onerror = showError;
request.onprogress = function (e) {
progressBar.style.width = (10 + e.loaded / e.total * 90) + '%';
};
P.IO.loadScratchr2ProjectTitle(projectId, function(title) {
document.title = projectTitle = title;
});
}());
</script>