2020-08-23 11:19:20 +00:00
|
|
|
import init, {load_main, load_additional, merge} from './pkg/mixsy.js';
|
2020-07-03 13:57:07 +00:00
|
|
|
|
|
|
|
async function run() {
|
|
|
|
await init();
|
|
|
|
|
2020-08-23 11:19:20 +00:00
|
|
|
const main = document.getElementById('a');
|
|
|
|
const additional = document.getElementById('b');
|
|
|
|
const output = document.getElementById('c');
|
|
|
|
const merge_button = document.getElementById('merge');
|
|
|
|
|
2020-08-23 15:36:27 +00:00
|
|
|
function handleResult(inputElement, message) {
|
|
|
|
console.log(message);
|
|
|
|
let messageBox = inputElement.nextSibling;
|
|
|
|
messageBox.innerText = message;
|
|
|
|
messageBox.style.display = "block"
|
|
|
|
setTimeout(() => {messageBox.style.display = "none"}, 4000);
|
|
|
|
}
|
|
|
|
|
2020-08-23 11:19:20 +00:00
|
|
|
main.addEventListener('change', () => {
|
2020-08-23 15:36:27 +00:00
|
|
|
if (main.value) {
|
|
|
|
handleResult(main, load_main(main.value));
|
|
|
|
}
|
2020-08-23 11:19:20 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
additional.addEventListener('change', () => {
|
2020-08-23 15:36:27 +00:00
|
|
|
if (additional.value) {
|
|
|
|
handleResult(additional, load_additional(additional.value));
|
|
|
|
}
|
2020-08-23 11:19:20 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
function mix() {
|
|
|
|
output.value = merge();
|
|
|
|
}
|
|
|
|
|
|
|
|
merge_button.addEventListener('click', mix);
|
|
|
|
merge_button.addEventListener('touchend', mix);
|
2020-07-03 13:57:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
run();
|