Spaces:
Running
Running
Download script.js from Shaikhsarib/blog: direct link, hf CLI and curl.
- Browser
- Download file 1.05 kB
-
https://huggingface.co/spaces/Shaikhsarib/blog/resolve/main/script.js
- Command line
-
hf download hf://spaces/Shaikhsarib/blog/script.js
-
curl -L -o script.js https://huggingface.co/spaces/Shaikhsarib/blog/resolve/main/script.js
1.05 kB
| // Image preview functionality for create/edit forms | |
| document.addEventListener('DOMContentLoaded', function() { | |
| // Image upload preview | |
| const imageInput = document.getElementById('image'); | |
| if (imageInput) { | |
| imageInput.addEventListener('change', function(e) { | |
| const file = e.target.files[0]; | |
| if (file) { | |
| const reader = new FileReader(); | |
| reader.onload = function(event) { | |
| document.getElementById('image-preview').src = event.target.result; | |
| }; | |
| reader.readAsDataURL(file); | |
| } | |
| }); | |
| } | |
| // Form submission handling | |
| const forms = document.querySelectorAll('form'); | |
| forms.forEach(form => { | |
| form.addEventListener('submit', function(e) { | |
| e.preventDefault(); | |
| // In a real app, this would submit to Django backend | |
| alert('Form submitted! In a real app, this would save to the database.'); | |
| window.location.href = '/blog'; | |
| }); | |
| }); | |
| }); |