-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
37 lines (33 loc) · 1.62 KB
/
Copy pathscript.js
File metadata and controls
37 lines (33 loc) · 1.62 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
import { GenArtPlatform } from "./genps-platform.js";
initGenArtPlatform(document.getElementById("project-1"));
initGenArtPlatform(document.getElementById("project-2"));
function initGenArtPlatform(containerElement) {
const projectIframe = containerElement.querySelector(".project-iframe");
const logElement = containerElement.querySelector(".log");
const downloadContainer = containerElement.querySelector(".download-container");
const genArtPlatform = new GenArtPlatform(projectIframe, {
onInit: (version, signals) => {
logElement.innerHTML += `<div><b>[EVENT FIRED]</b> onInit, <i>project version: ${version}</i>, supported signals:</div>`;
logElement.innerHTML += `<pre>${JSON.stringify(signals, undefined, 4)}</pre>`;
genArtPlatform.downloadSignals.forEach((signal) => {
const btn = document.createElement("button");
btn.innerText = signal.text;
btn.disabled = true;
btn.addEventListener("click", () => {
genArtPlatform.triggerDownload(signal.key);
});
downloadContainer.appendChild(btn);
});
},
onLoadingComplete: () => {
logElement.innerHTML += `<div><b>[EVENT FIRED]</b> onLoadingComplete</div>`;
},
onCapturePreview: () => {
logElement.innerHTML += `<div><b>[EVENT FIRED]</b> onCapturePreview</div>`;
const downloadButtons = downloadContainer.querySelectorAll("button");
downloadButtons.forEach((btn) => {
btn.disabled = false;
});
}
});
}