Advertisement
vitareinforce

progress bar by time

Jun 24th, 2025
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. HTML
  2.  
  3. <div id="loading" class="col-sm-12" style="text-align: center; margin-bottom: 20px; height: 50px !important;" v-if="identifier == true">
  4.     <span id="" style="font-size: 32px; color: black;">Loading, please wait...</span><img id="" style="height: 100%" src="/img/loading_input_manual.gif" alt="Loading" />
  5.     <div class="progress">
  6.         <div class="progress-bar" role="progressbar" style="width: 0%" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100"></div>
  7.     </div>
  8. </div>
  9.  
  10. JS
  11.  
  12. function simpanUbah(){
  13.     $('#loading').css('display', 'block');
  14.  
  15.     startProgressBar();
  16.    
  17.     const interval = 1000;
  18.     let progress = 0;
  19.     const maxProgress = 100;
  20.     const increment = 1;
  21.    
  22.     const progressInterval = setInterval(function() {
  23.         progressBarFunction(progress, maxProgress, increment);
  24.         progress += increment;
  25.         if (progress >= maxProgress) {
  26.             clearInterval(progressInterval);
  27.         }
  28.     }, interval);
  29. }
  30. function startProgressBar() {
  31.     const progressBar = $('.progress-bar');
  32.     progressBar.css('width', '0%');
  33.     progressBar.attr('aria-valuenow', 0);
  34. }
  35. function progressBarFunction(progress, maxProgress, increment) {
  36.     const progressBar = $('.progress-bar');
  37.     progressBar.css('width', progress + '%');
  38.     progressBar.attr('aria-valuenow', progress);
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement