123

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <body background="">
  
  <div class="row">

    <div class="col-sm-3">
    </div>

    <div class="col-sm-6 header">
      <div class="overall">
        <p id="heading">Twitch Streamers</p>
        <button class="btn-primary allsli slideout-menu">All
          <div class="dot" style="background: rgb(0, 0, 255)">
          </div>
        </button>

        <button class="btn-primary onsli slideout-menu">Online
          <div class="dot" style="background: rgb(0,255, 0)">
          </div>
        </button>

        <button class="btn-primary offsli slideout-menu">Offline
          <div class="dot"style="background: rgb(255,0,0">
          </div>
        </button>
        
        <div class="results">
            <div class="online">
            </div>
            <div class="offline">
            </div>
            <div class="closed">
            </div>
        </div>
        <div class="col-sm-3">
        </div>
      </div>
   </div>
<div class="row">
  <div class="col-sm-12 footer">
    <p>Coded by <a href="https://codepen.io/bowenrd40">Richard Bowen</a></p>                      
  </div>
</div>
</body>
            
          
!
            
              body{
background: url(http://www.pokermediapro.com/wp-content/uploads/2015/03/twitch-tv-2.jpg);
background-size:100%;
background-repeat: no-repeat;
}

.glyphicon{
  right:400px;
  top:65px;
  font-size:50px;
  margin:-150px;
}
.glyphicon img{
  height:60px;
  margin-top:-35px;
  margin-left:-60px
}
.header p{
  margin-top: 30px;
  font-size: 50px;
  color:white;
}
ul{
  list-style:none;
}
.closed, .online, .offline{
  margin:10px;
}
.results{
  margin-top:-50px;
}
.header{
  text-align:center;
}
.slideout-menu {
  margin-top:-78px;
  margin-left:600px;
  padding-bottom:5px;
  width: 100px;
  height: 25px;
  font-family: Arial, sans-serif;
  font-weight: bold;
  line-height: 1;
  color: #999;
  text-decoration: none;
  vertical-align:top; 
}
.dot {
  margin-top:-10px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  color:white;
}
.online ul{
 border-radius:5px;
 height:60px;
 background-color:rgb(150,255,100);
}
.offline ul{
 border-radius:5px;
 height:60px;
 background-color:rgb(255,200,150);
}
.offline p{
  color:red;
}
.closed ul{
 height:60px;
 background-color:black;
}
.closed p{
  color:white;
}
.user{
  left:-250px;
  font-weight:bold;
  font-size: 25px;
  position:relative;
  top:20px;
  }
.game{
  position:relative;
  top:-60px;
  left:100px;
}
.game p{
  font-size:40px
}
.overall{
  
  border-radius:5px;
}
.footer p,.footer a{
  font-size:20px;
}
.footer{
  left: 43%;
  
}
            
          
!
            
              $(document).ready(function() {

var sugstrs = ["ESL_SC2", "OgamingSC2", "cretetion", "freecodecamp", "storbeck", "habathcx", "RobotCaleb", "noobs2ninjas","comster404","brunofin"]
var wiki=""
//initialise variables

for(var i=0;i<sugstrs.length;i++) //call get_twitches function with an interation over the sugstrs array 
  {
    get_twitches(sugstrs[i]);
  }
  
function get_twitches (twitches) //function recieves each item of array and writes to results div
  {
 $.getJSON('https://api.twitch.tv/kraken/users/44322889?client_id=' + twitches + '?callback=?', function(data) //get JSON data
      {
        //Buld up base wiki string which is common to online, offline and closed  
        wiki='<div>';
        wiki+='<span class="glyphicon glyphicon-user"></span>';
        wiki+= '<ul><li class="user"><a href="https://www.twitch.tv/';
        wiki+= twitches;
        wiki+='" target="_blank">';
        wiki+= twitches;
        wiki+='</a></li><li class="game"><p>';
     
   
        if(data.status===422) //if account closed add further info to wiki
        {
              wiki='<div>';
              wiki+='<span class="glyphicon glyphicon-user"></span>';
              wiki+= '<ul><li class="user"><a href="https://www.twitch.tv/';
              wiki+= twitches;
              wiki+='" target="_blank">';
              wiki+= twitches;
              wiki+='</a></li><li class="game"><p>';wiki+='Account closed</p></li></ul></div>';
              $(".closed").append(wiki); 
               //add all account closed to closed div
        }
        else if(data.stream === null) //add more info into wiki
        {
              wiki='<div>';
              wiki+='<span class="glyphicon glyphicon-user"></span>';
              wiki+= '<ul><li class="user"><a href="https://www.twitch.tv/';
              wiki+= twitches;
              wiki+='" target="_blank">';
              wiki+= twitches;
              wiki+='</a></li><li class="game"><p>';
              wiki+='Offline</p></li></ul></div>';
              $(".offline").append(wiki); 
        }
        else if (data.stream&&data.stream.channel.logo)
          {
          wiki='<div>';
          wiki+='<span class="glyphicon glyphicon-user"><img src="'
          wiki+= data.stream.channel.logo;
          wiki+='"></img></span>';
          wiki+= '<ul><li class="user"><a href="https://www.twitch.tv/';
          wiki+= twitches;
          wiki+='" target="_blank">';
          wiki+= twitches;
          wiki+='</a></li><li class="game"><p>';wiki+= data.stream.channel.game
          wiki+= '</p></li></ul></div>';
          $(".online").append(wiki);
          }
        else
        {
          wiki='<div>';
          wiki+='<span class="glyphicon glyphicon-user"></span>';
          wiki+= '<ul><li class="user"><a href="https://www.twitch.tv/';
          wiki+= twitches;
          wiki+='" target="_blank">';
          wiki+= twitches;
          wiki+='</a></li><li class="game"><p>';wiki+= data.stream.channel.game
          wiki+= '</p></li></ul></div>';
          $(".online").append(wiki); 
        }
      
      });
 };
$(".allsli").on("click",function() //actions to perform when all button is clicked
 {
  $(".online").show();
  $(".offline").show();
  $(".closed").show();
});  

$(".onsli").on("click",function() //actions to perform when onsli button is clicked
 {
  $(".online").show();
  $(".offline").hide();
  $(".closed").hide();
});  

  $(".offsli").on("click",function() //actions to perform when offsli button is clicked
 {
  $(".online").hide();
  $(".offline").show();
  $(".closed").hide();
});  
}); 
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.

Console