-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtempCodeRunnerFile.js
More file actions
42 lines (41 loc) · 1.52 KB
/
tempCodeRunnerFile.js
File metadata and controls
42 lines (41 loc) · 1.52 KB
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
document.addEventListener('DOMContentLoaded', () => {
fetch('/webapp/projects/internalapi/project/new/set/', { method: 'POST' })
.then(r => r.text())
.then(id => {
console.log('New project id:', id);
projectId = id;
const flashvars = {
autostart: 'false',
project_id: id,
project_title: "Untitled",
project_isPrivate: true,
project_isNew: true,
project_creator: "ScratchUser206826",
urlOverrides: encodeURIComponent(JSON.stringify({
sitePrefix: 'http://127.0.0.1:5500/webapp/',
siteCdnPrefix: 'http://127.0.0.1:5500/webapp/cdn/',
assetPrefix: 'http://127.0.0.1:5500/webapp/assets/',
assetCdnPrefix: 'http://127.0.0.1:5500/webapp/cdn.assets/',
projectPrefix: 'http://127.0.0.1:5500/webapp/projects/',
projectCdnPrefix: 'http://127.0.0.1:5500/webapp/cdn.projects/',
internalAPI: 'internalapi/',
siteAPI: 'site-api/'
}))
};
const params = {
allowscriptaccess: 'always',
allowfullscreen: 'true',
wmode: 'direct',
menu: 'false',
flashvars: Object.keys(flashvars).map(k => `${k}=${flashvars[k]}`).join('&')
};
const attributes = {
data: 'http://127.0.0.1:5500/build/11.6/Scratch.swf',
width: '100%',
height: '100%',
id: 'scratch'
};
const swfEl = swfobject.createSWF(attributes, params, 'scratch');
Scratch2API.attach(swfEl || document.getElementById('scratch'));
});
});