Created
          April 19, 2015 22:13 
        
      - 
      
 - 
        
Save loadletter/986fdea4d17abda6753d to your computer and use it in GitHub Desktop.  
    Progress bar
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | <!DOCTYPE html> | |
| <head> | |
| <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> | |
| <script src="script.js"></script> | |
| <link rel="stylesheet" type="text/css" href="style.css"/> | |
| <title>Slider example</title> | |
| </head> | |
| <body onload="drawProgressBar('P0', 50); barsExample();"> | |
| <div style="width:200px; padding:50px;"> | |
| <div class="ProgressBar" id='P0'> | |
| <div class="bar"> | |
| </div> | |
| <div class="text"> | |
| </div> | |
| </div> | |
| </div> | |
| <script type="text/javascript"> | |
| var p1 = 0; | |
| var p2 = 0; | |
| var interval; | |
| function barsStep() | |
| { | |
| drawProgressBar('P1', p1); | |
| drawProgressBar('P2', p2); | |
| p1 += 1; | |
| if (p1 > 100) { | |
| p1 = 0; | |
| p2 += 1; | |
| if (p2 > 100) { | |
| clearInterval(interval); | |
| } | |
| } | |
| } | |
| function barsExample() | |
| { | |
| interval = setInterval(barsStep, 50); | |
| } | |
| </script> | |
| <div style="width:200px; padding:50px;"> | |
| <div class="ProgressBar" id='P1'> | |
| <div class="bar"> | |
| </div> | |
| <div class="text"> | |
| </div> | |
| </div> | |
| </div> | |
| <div style="width:200px; padding:50px;"> | |
| <div class="ProgressBar" id='P2'> | |
| <div class="bar"> | |
| </div> | |
| <div class="text"> | |
| </div> | |
| </div> | |
| </div> | |
| </body> | |
| </html> | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | function drawProgressBar(barid, completion) | |
| { | |
| document.querySelector('#' + barid + ' > .bar').style.width=completion+'%'; | |
| document.querySelector('#' + barid + ' > .text').innerHTML=completion+'%'; | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | .ProgressBar { | |
| width:100%; | |
| height:15px; | |
| border:1px solid #000; | |
| overflow:hidden; | |
| } | |
| .ProgressBar > .bar { | |
| width:37%; | |
| height:15px; | |
| background: #d65946; | |
| } | |
| .ProgressBar > .text { | |
| color: #000000; | |
| font-size: 15px; | |
| text-align: center; | |
| position: relative; | |
| top: -16px; | |
| } | |
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment