Skip to content

Instantly share code, notes, and snippets.

@donrestarone
Created October 10, 2020 13:48
Show Gist options
  • Save donrestarone/90bb1886e805db07a9b9cbf50d23c386 to your computer and use it in GitHub Desktop.
Save donrestarone/90bb1886e805db07a9b9cbf50d23c386 to your computer and use it in GitHub Desktop.
javascript file for image_detectr
window.addEventListener('DOMContentLoaded', (event) => {
const analyzeButton = document.querySelector('#start-analysis');
const loadingButton = document.querySelector('#started-analysis');
console.log(analyzeButton)
$("#new_image").submit(function() {
analyzeButton.classList.add('d-none')
loadingButton.classList.remove('d-none')
})
// for previewing the image that is attached
function readURL(input) {
if (input.files && input.files[0]) {
const reader = new FileReader();
reader.onload = function(e) {
$('#uploaded-image-preview').attr('src', e.target.result);
}
reader.readAsDataURL(input.files[0]); // convert to base64 string
}
}
$("#uploaded-image").change(function() {
readURL(this);
const errorMessage = document.querySelector('#error-message');
if (errorMessage) {
errorMessage.classList.add('d-none')
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment