Pen Settings

HTML

CSS

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

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

Behavior

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

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.

HTML

              
                <div class="top">

<img class="twitch-logo" src="https://s17.postimg.org/65dvyos4f/Twitch_White_RGB.png">
<div class="buttons">
<button type="button" class="btn btn-primary" id="on">Online</button>
<button type="button" class="btn btn-primary" id="off">Offline</button>
<button type="button" id="all" class="btn btn-primary all">All</button>
  </div>
</div>

<div id='streamers'>
</div>
              
            
!

CSS

              
                
body{
  text-align: center;
  background: rgba(82, 51, 136, .6);
}
.twitch-logo{
  margin: 40px;
  width: 300px;
}
.btn{
  background: #6441A4;
  border: none;
  cusor: pointer;
}
.btn:hover{
  background: #301D56;
}
#streamers{
  margin: 20px;
  
}
.channel-card{
  background-color: #fff;
  border: 1px solid #888;
  color: #ecf0f1;
  box-shadow: 0 8px 17px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
  
  margin: 5px;
  padding: 10px 10px 0;
  width: 275px;
  min-height: 230px;
  overflow: hidden;
  white-space: nowrap;
  text-decoration: none;
  
}
.card{
  border: 1px solid #888;
  color: #ecf0f1;
  box-shadow: 0 8px 17px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
  display: inline-block;
  margin: 5px;
  width: 275px;
  min-height: 230px;
  overflow: hidden;
  white-space: nowrap;
  text-decoration: none;
} 
.card-header{
  background: #6441A4;
  color: white;
  width: 100%;
}  
 
  
 
.block img{
  border-radius: 50%;
  width: 100px;
  margin: 15px;
}

.online{
  background: white;
  color: black;
}
.online h4{
  font-size: 12px;
}
.offline{
  background: #B9A0E8;
  
}
              
            
!

JS

              
                
  
const channels = ["comster404", "cretetion", "freecodecamp", "habathcx", "ESL_SC2", "brunofin", "noobs2ninjas", "RobotCaleb", "riotgames", "omgitsfirefoxx" ,"missesmae","nl_kripp","trumpsc", "disguisedtoasths","pokimane", "scarra"];


Promise.all(channels.map(channel=>Promise.all([
  fetch("https://wind-bow.glitch.me/twitch-api/channels/"+channel).then(res=>res.json()),
  
  fetch("https://wind-bow.glitch.me/twitch-api/streams/"+channel).then(res=>res.json())
  
]))).then(data=> data.forEach(showStreamer)).catch(console.error);

                                    
function showStreamer(res){
 
  const logo=res[0].logo 
  const name=res[0].display_name || res[1]._links.channel.split("/").pop() ;
  const url=res[0].url;
   streamers.innerHTML += 
     
     `<a target="_blank"  href="${url}" >
<div class='card ${res[1].stream != null? "online": "offline"}'>
      
        <div class='card-header'>${name}</div>
        <div class="block">
        <img src=${logo}></img>
        <h4>${res[1].stream != null ? res[0].game : res[0].error ? "Closed Account" : "Offline"}</h4>
        </div>
        
      </div
</a>`
   
}
let onButton=document.getElementById("on");
let offButton=document.getElementById("off");
let allButton=document.getElementById("all");

const offlineCards=document.querySelectorAll(".offline");
// Online button to show online accounts
onButton.addEventListener("click",hideOff);
function hideOff(){
  let offlineCards=document.querySelectorAll(".offline");
  offlineCards.forEach(elem=>elem.style.display="none");
  
  let onlineCards=document.querySelectorAll(".online");
  onlineCards.forEach(elem=>elem.style.display="inline-block");
}

//Offline button to show offline accounts
offButton.addEventListener("click",hideOn);
function hideOn(){
  let onlineCards=document.querySelectorAll(".online");
  onlineCards.forEach(elem=>elem.style.display="none");
  
  let offlineCards=document.querySelectorAll(".offline");
  offlineCards.forEach(elem=>elem.style.display="inline-block");
}


// All button to show all accounts
allButton.addEventListener("click",showAll);
function showAll(){
  let allCards=document.querySelectorAll(".online, .offline");
  allCards.forEach(el=>el.style.display="inline-block");
  
} 

/* 
jquery

$("#off").click(function(){
  $(".online").hide();
  $(".offline").show();
});


$("#on").click(function(){
  $(".offline").hide();
  $(".online").show();
});

$(".all").click(function(){
  $(".offline").show();
  $(".online").show();
}); */

/* [onButton, offButton, allButton].forEach(el => {
  el.addEventListener("click",function() {
    if(el.id.includes('off')) buttonFilter('.online');
    if(el.id.includes('on')) buttonFilter('.offline');
    if(el.id.includes('all')) buttonFilter();
  })
});

function buttonFilter(className) {
  document.querySelectorAll('.online, .offline').forEach(el => el.style.display = "inline-block");
  document.querySelectorAll(className).forEach(el => el.style.display = "none");
  
  have a function that takes a class name as an argument
for each button, add a click event listener
if the button id has the word "off" in it, hide the online classes
if the button id has the word "on" in it, hide the offline classes
otherwise, just show everything
} */
              
            
!
999px

Console