javascript - Stop Progress Bar After 10 seconds | CPU % 80 -


i have progress bar , increase value 0 100% in 10 seconds. want stop every process after 10 seconds. when uncomment below code cpu going 80% - 90%. think after 100% still works.

var start = new date();     var maxtime = 10000;     var maxtimesec = 10;     var timeoutval = math.floor( maxtime/100 );     animateupdate();      function updateprogress(percentage, second) {         $('#timerprogress').css("width", percentage + "%");         $('#timercountdown').text(percentage + "%" + second + "sec");     }      function islogined(){         userid = $("#userinfo").attr("data-user") ;         userid = parseint(userid);         var logined = false;         if(userid > 0){             logined = true;         }         return logined;     }      function animateupdate() {         var      = new date();         var timediff = now.gettime() - start.gettime();          var sec      = maxtimesec - math.round( (timediff/maxtime) * maxtimesec );         var perc     = math.round( (timediff/maxtime)*100);         //console.log(perc);         if (perc <= 100) {             updateprogress(perc, sec);             settimeout(animateupdate, timeoutval);         }         else{              var bottomdiv = $('#bottomdiv');             bottomdiv.show();             if( islogined() ){                 bottomdiv.text("congratulations. you're lucky read article. we've updated score.");              }else{                 bottomdiv.text("congratulations. you're lucky read article. if want count score must login :)");             }              return true;         }     } 

is there bug in code?

could not reproduce:

https://jsfiddle.net/7jgllvfz/

chrome cpu profile shows 96% idle, no heavy cpu load. need more information.

var = "manditory codeblock jsfiddle can linked" 

Comments

Popular posts from this blog

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -