mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-17 05:46:23 +00:00
11 lines
368 B
JavaScript
11 lines
368 B
JavaScript
document.addEventListener('turbolinks:load', () => {
|
|
document.querySelectorAll('input[type=file]').forEach(file => {
|
|
if (!file.dataset.preview) return
|
|
|
|
file.addEventListener('change', event => {
|
|
if (file.files.length === 0) return
|
|
|
|
document.querySelector('#' + file.dataset.preview).src = window.URL.createObjectURL(file.files[0])
|
|
})
|
|
})
|
|
})
|