Skip to content

Commit

Permalink
Update index.html
Browse files Browse the repository at this point in the history
  • Loading branch information
kisahklasik authored Aug 3, 2024
1 parent 5704519 commit 1c47731
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,46 @@ <h1>Example Domain</h1>
domain in literature without prior coordination or asking for permission.</p>
<p><a href="https://www.iana.org/domains/example">More information...</a></p>
</main>
<script>
const slider = document.getElementById('slider');
const baseImageInput = document.getElementById('base-image-input');
const overlayImageInput = document.getElementById('overlay-image-input');
const baseImage = document.querySelector('.base-image');
const overlayImage = document.querySelector('.overlay-image');
const baseImageButton = document.getElementById('base-image-button');
const overlayImageButton = document.getElementById('overlay-image-button');

function loadImage(input, imgElement) {
if (input.files && input.files[0]) {
const reader = new FileReader();
reader.onload = (e) => {
imgElement.src = e.target.result;
};
reader.readAsDataURL(input.files[0]);
}
}

slider.addEventListener('input', () => {
let opacity = slider.value / 100;
overlayImage.style.opacity = opacity;
});

baseImageInput.addEventListener('change', () => {
loadImage(baseImageInput, baseImage);
});

overlayImageInput.addEventListener('change', () => {
loadImage(overlayImageInput, overlayImage);
});

baseImageButton.addEventListener('click', () => {
baseImageInput.click();
});

overlayImageButton.addEventListener('click', () => {
overlayImageInput.click();
});

</script>
</body>
</html>

0 comments on commit 1c47731

Please sign in to comment.