update init state

This commit is contained in:
solehudin5699
2022-02-27 23:24:05 +07:00
parent 8f6c0f1219
commit 9242e6d133
+14 -7
View File
@@ -190,6 +190,7 @@
<script> <script>
const formSubmit = document.getElementById('form-submit'); const formSubmit = document.getElementById('form-submit');
const btnBrowse = document.getElementById('btn-browse'); const btnBrowse = document.getElementById('btn-browse');
const btnSubmit = document.getElementById('btn-submit');
const inputFile = document.getElementById('input-file'); const inputFile = document.getElementById('input-file');
const anchorDonwload = document.getElementById('anchor-donwload'); const anchorDonwload = document.getElementById('anchor-donwload');
const inputQuality = document.getElementById('quality-input'); const inputQuality = document.getElementById('quality-input');
@@ -198,13 +199,17 @@
const inputHeight = document.getElementById('height-input'); const inputHeight = document.getElementById('height-input');
const checkboxOriSize = document.getElementById('original-size-input'); const checkboxOriSize = document.getElementById('original-size-input');
if (checkboxOriSize.checked) { const setInitialState = (() => {
inputHeight.setAttribute('disabled', true); if (checkboxOriSize.checked) {
inputWidth.setAttribute('disabled', true); inputHeight.setAttribute('disabled', true);
} else { inputWidth.setAttribute('disabled', true);
inputHeight.removeAttribute('disabled'); } else {
inputWidth.removeAttribute('disabled'); inputHeight.removeAttribute('disabled');
} inputWidth.removeAttribute('disabled');
}
valueQuality.innerHTML = inputQuality.value;
btnSubmit.setAttribute('disabled', true);
})();
btnBrowse.addEventListener('click', (e) => { btnBrowse.addEventListener('click', (e) => {
inputFile.click(); inputFile.click();
@@ -227,6 +232,8 @@
btnBrowse.innerHTML = 'Change Image'; btnBrowse.innerHTML = 'Change Image';
}; };
imageFile.src = URL.createObjectURL(file); imageFile.src = URL.createObjectURL(file);
btnSubmit.removeAttribute('disabled');
}); });
inputQuality.addEventListener('change', (e) => { inputQuality.addEventListener('change', (e) => {