//https://developer.mozilla.org/fr/docs/Web/API/setTimeout console.log('scripts loaded'); document.onreadystatechange = function(event) { if (document.readyState === "complete") { if(oProgress = document.getElementById('pourcent-reveil')) { console.log("progress bar exists"); setcurrentprogress(oProgress,10); updateprogress(oProgress); } } } function setcurrentprogress(obj,value) { obj.setAttribute("value",value); obj.setAttribute("aria-valuenow",value); } function updateprogress(obj,step=5) { currentprogress = parseInt(obj.getAttribute("value")) + step; console.log("updating progressbar to "+currentprogress); if(currentprogress > 100) { console.log("terminé"); setcurrentprogress(obj,100); document.getElementById('finished').removeAttribute("style"); return; } setcurrentprogress(obj,currentprogress); setTimeout(updateprogress,500, obj); }