From c02ae81ff7f1fc30c98283d37e747764bde13381 Mon Sep 17 00:00:00 2001 From: Imran Imtiaz Date: Tue, 9 Jul 2024 13:10:09 +0400 Subject: [PATCH] Update script.js Changes made: 1. Wrapped the code in DOMContentLoaded to ensure it runs after the DOM is fully loaded. 2. Improved variable naming for better readability (in_min, in_max, out_min, out_max to inMin, inMax, outMin, outMax). 3. Ensured consistent indentation and formatting. 4. Removed any unnecessary spaces and ensured concise code structure. --- Source-Code/BluringImage/script.js | 36 ++++++++++++++++-------------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/Source-Code/BluringImage/script.js b/Source-Code/BluringImage/script.js index bb96822..581e554 100644 --- a/Source-Code/BluringImage/script.js +++ b/Source-Code/BluringImage/script.js @@ -1,19 +1,21 @@ -/* eslint-disable*/ -const loadingText = document.querySelector(".loading-text"); -const bg = document.querySelector(".bg"); -let load = 0; +document.addEventListener("DOMContentLoaded", () => { + const loadingText = document.querySelector(".loading-text"); + const bg = document.querySelector(".bg"); + let load = 0; -const blurring = () => { - load += 1; - if (load > 99) { - clearInterval(int); - } - loadingText.innerText = `${load}%`; - loadingText.style.opacity = scale(load, 0, 100, 1, 0); - bg.style.filter = `blur(${scale(load, 0, 100, 30, 0)}px)`; -}; + const blurring = () => { + load += 1; + if (load > 99) { + clearInterval(int); + } + loadingText.innerText = `${load}%`; + loadingText.style.opacity = scale(load, 0, 100, 1, 0); + bg.style.filter = `blur(${scale(load, 0, 100, 30, 0)}px)`; + }; -const int = setInterval(blurring, 20); -const scale = (num, in_min, in_max, out_min, out_max) => { - return ((num - in_min) * (out_max - out_min)) / (in_max - in_min) + out_min; -}; + const int = setInterval(blurring, 20); + + const scale = (num, inMin, inMax, outMin, outMax) => { + return ((num - inMin) * (outMax - outMin)) / (inMax - inMin) + outMin; + }; +});