Created
October 10, 2020 13:48
-
-
Save donrestarone/90bb1886e805db07a9b9cbf50d23c386 to your computer and use it in GitHub Desktop.
javascript file for image_detectr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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