mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2024-12-27 14:29:39 +00:00
fixed embed with machine/ platforms
This commit is contained in:
parent
91e9ba1e93
commit
551c6fb340
@ -90,7 +90,7 @@ function findPrimaryCanvas() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function recordVideo(intervalMsec, maxFrames, callback) {
|
function recordVideo(intervalMsec, maxFrames, callback) {
|
||||||
loadScript("gif.js/dist/gif.js", () => {
|
loadScript("gif.js/dist/gif.js").then( () => {
|
||||||
var canvas = findPrimaryCanvas()[0] as HTMLCanvasElement;
|
var canvas = findPrimaryCanvas()[0] as HTMLCanvasElement;
|
||||||
if (!canvas) {
|
if (!canvas) {
|
||||||
alert("Could not find canvas element to record video!");
|
alert("Could not find canvas element to record video!");
|
||||||
@ -168,18 +168,27 @@ function loadPlatform(qs) {
|
|||||||
if (qs.data) qs = qs.data;
|
if (qs.data) qs = qs.data;
|
||||||
platform_id = qs['p'];
|
platform_id = qs['p'];
|
||||||
if (!platform_id) throw('No platform variable!');
|
if (!platform_id) throw('No platform variable!');
|
||||||
var scriptfn = 'gen/platform/' + platform_id.split(/[.-]/)[0] + '.js';
|
var platformfn = 'gen/platform/' + platform_id.split(/[.-]/)[0] + '.js'; // required file
|
||||||
loadScript(scriptfn, () => {
|
var machinefn = platformfn.replace('/platform/', '/machine/'); // optional file
|
||||||
console.log("loaded platform", platform_id);
|
loadScript(platformfn).then( () => {
|
||||||
|
return loadScript(machinefn).catch(() => { console.log('skipped',machinefn); }); // optional file skipped
|
||||||
|
}).then( () => {
|
||||||
|
console.log("starting platform", platform_id); // loaded required <platform_id>.js file
|
||||||
startPlatform(qs);
|
startPlatform(qs);
|
||||||
|
}).catch( (e) => {
|
||||||
|
console.log(e);
|
||||||
|
alert('Platform "' + platform_id + '" not supported.');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadScript(scriptfn, onload) {
|
export function loadScript(scriptfn:string) : Promise<Event> {
|
||||||
|
return new Promise( (resolve, reject) => {
|
||||||
var script = document.createElement('script');
|
var script = document.createElement('script');
|
||||||
script.onload = onload;
|
script.onload = resolve;
|
||||||
|
script.onerror = reject;
|
||||||
script.src = scriptfn;
|
script.src = scriptfn;
|
||||||
document.getElementsByTagName('head')[0].appendChild(script);
|
document.getElementsByTagName('head')[0].appendChild(script);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// start
|
// start
|
||||||
|
Loading…
Reference in New Issue
Block a user