2018-08-25 05:55:03 +02:00
|
|
|
const $ = document.querySelector.bind(document)
|
2019-07-24 17:57:23 +02:00
|
|
|
const $$ = document.querySelectorAll.bind(document)
|
2018-08-25 05:55:03 +02:00
|
|
|
|
|
|
|
export function setupButtons (start) {
|
2019-07-24 17:57:23 +02:00
|
|
|
// Sections
|
|
|
|
$('a#start').addEventListener('click', () => setVisibleSection('start'))
|
|
|
|
$('a#floppy').addEventListener('click', () => setVisibleSection('floppy'))
|
|
|
|
$('a#state').addEventListener('click', () => setVisibleSection('state'))
|
2019-08-04 17:45:18 +02:00
|
|
|
$('a#disk').addEventListener('click', () => setVisibleSection('disk'))
|
2018-08-25 05:55:03 +02:00
|
|
|
|
2019-08-04 17:45:18 +02:00
|
|
|
// Start
|
|
|
|
$('.btn-start').addEventListener('click', start)
|
2018-08-25 05:55:18 +02:00
|
|
|
|
2019-08-04 17:45:18 +02:00
|
|
|
// Disk Image
|
|
|
|
$('#disk-image-show').addEventListener('click', () => windows95.showDiskImage())
|
2018-08-25 05:55:03 +02:00
|
|
|
|
2019-08-04 17:45:18 +02:00
|
|
|
// Reset
|
|
|
|
$('#reset').addEventListener('click', () => windows95.resetState())
|
2018-08-25 05:55:03 +02:00
|
|
|
|
2019-08-04 17:45:18 +02:00
|
|
|
$('#discard-state').addEventListener('click', () => {
|
|
|
|
window.appState.bootFresh = true
|
2018-08-25 05:55:03 +02:00
|
|
|
|
2019-08-04 17:45:18 +02:00
|
|
|
start()
|
|
|
|
})
|
2019-07-24 17:57:23 +02:00
|
|
|
|
2019-08-04 17:45:18 +02:00
|
|
|
// Floppy
|
|
|
|
$('#floppy-select').addEventListener('click', () => {
|
|
|
|
$('#floppy-input').click()
|
|
|
|
})
|
2018-08-25 05:55:03 +02:00
|
|
|
|
|
|
|
// Floppy (Hidden Input)
|
2019-08-04 17:45:18 +02:00
|
|
|
$('#floppy-input').addEventListener('change', (event) => {
|
2018-08-25 05:55:03 +02:00
|
|
|
window.appState.floppyFile = event.target.files && event.target.files.length > 0
|
|
|
|
? event.target.files[0]
|
|
|
|
: null
|
|
|
|
|
|
|
|
if (window.appState.floppyFile) {
|
|
|
|
$('#floppy-path').innerHTML = `Inserted Floppy Disk: ${window.appState.floppyFile.path}`
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2019-08-04 17:45:18 +02:00
|
|
|
export function toggleSetup (forceTo) {
|
|
|
|
const buttonElements = $('#setup')
|
2018-08-25 05:55:03 +02:00
|
|
|
|
|
|
|
if (buttonElements.style.display !== 'none' || forceTo === false) {
|
|
|
|
buttonElements.style.display = 'none'
|
|
|
|
} else {
|
|
|
|
buttonElements.style.display = undefined
|
|
|
|
}
|
|
|
|
}
|
2019-07-24 17:57:23 +02:00
|
|
|
|
|
|
|
function setVisibleSection(id = '') {
|
|
|
|
$$(`section`).forEach((s) => s.classList.remove('visible'))
|
|
|
|
$(`section#section-${id}`).classList.add('visible')
|
|
|
|
}
|