Created
          June 5, 2017 04:48 
        
      - 
      
- 
        Save stephenhmarsh/5dc13193e617b2895db0eb9290777183 to your computer and use it in GitHub Desktop. 
    Exported from Popcode. Click to import: https://popcode.org/?gist=5dc13193e617b2895db0eb9290777183
  
        
  
    
      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> | |
| <html> | |
| <head> | |
| <title>RaffleBot</title> | |
| </head> | |
| <body> | |
| <div class="centered"> | |
| <h1>RaffleBot</h1> | |
| <button id="raffle" class="alert">Raffle Time!!!</button> | |
| </div> | |
| <div class="container"> | |
| <div class="row"> | |
| <div class="col-3"> | |
| <p>Tickets remaining: <span id="count"></span></p> | |
| <p>Winners:</p> | |
| <ul id="winners"> | |
| </ul> | |
| </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
    
  
  
    
  | {"enabledLibraries":["jquery","bootstrap","mustache"],"hiddenUIComponents":["editor.css","editor.javascript"]} | 
  
    
      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
    
  
  
    
  | var students = { | |
| "Eri" : 60, | |
| "Jyraya" : 58, | |
| "Jennifer" : 57, | |
| "Jytia " : 55, | |
| "Sanai" : 30, | |
| "Dante" : 22, | |
| "Lissete" : 19, | |
| "Xavier" : 17, | |
| "Layla" : 12, | |
| "Jaevon" : 11, | |
| "Maya" : 7, | |
| "Aletha" : 1, | |
| "Jhonny" : 0 | |
| }; | |
| var bowlOfTickets = []; | |
| for (var studentName in students) { | |
| var points = students[studentName]; | |
| while(points > 0) { | |
| bowlOfTickets.push(studentName); | |
| points--; | |
| } | |
| } | |
| function raffle(){ | |
| var winner = bowlOfTickets.splice(random(), 1); | |
| alert(winner); | |
| updateStats(winner); | |
| } | |
| function random(){ | |
| return Math.floor(Math.random() * bowlOfTickets.length); | |
| } | |
| function updateStats(winner){ | |
| $('#count').html(bowlOfTickets.length); | |
| if (!!winner) { | |
| $('#winners').append('<li>' + winner + '</li>'); | |
| } | |
| } | |
| $('#raffle').click(raffle); | |
| updateStats(); | 
  
    
      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
    
  
  
    
  | body { | |
| width: 100%; | |
| height: 100%; | |
| } | |
| .centered { | |
| text-align: center; | |
| } | |
| #raffle { | |
| margin-top: 10px; | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment