5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-24 17:16:22 +00:00
panel/app/javascript/etc/image_preview.js

12 lines
368 B
JavaScript
Raw Normal View History

2020-11-20 00:23:23 +00:00
document.addEventListener('turbolinks:load', () => {
document.querySelectorAll('input[type=file]').forEach(file => {
if (!file.dataset.preview) return
2019-08-22 01:09:29 +00:00
2020-11-20 00:23:23 +00:00
file.addEventListener('change', event => {
if (file.files.length === 0) return
2019-08-22 01:09:29 +00:00
2020-11-20 00:23:23 +00:00
document.querySelector('#' + file.dataset.preview).src = window.URL.createObjectURL(file.files[0])
})
})
})