/** * Created by Lukas on 28.07.2016. */ $(document).ready(function() { var $racelist = $("#racelist"), timer = 0, perc = -1, timeTotal = 30, timeCount = 1000; function updateProgress(percentage) { var x = (percentage/timeTotal)*100; $('#pbar_innerdiv').css("width", x + "%"); $('#pbar_innertext').text(timeTotal-percentage); } function animateUpdate() { if(perc < timeTotal) { perc++; updateProgress(perc); timer = setTimeout(animateUpdate, timeCount); } else { $.ajax({ url: "readout.php?dir=hiscdm_21&noc=0", method: "GET", dataType: "html" }).done(function( msg ) { var IDs = []; $racelist.find((".ui-collapsible:not(.ui-collapsible-collapsed)")).each(function(){ IDs.push(this.id); }); $racelist.html(msg); // $("[data-role=collapsible]").collapsible(); $racelist.trigger("create"); $.each(IDs, function (index, val) { $("#"+val+" > h3 > a").trigger("click"); }); }).always(function () { perc = -1; timer = setTimeout(animateUpdate, timeCount); }); } } animateUpdate(); });