css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

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.

            
              <h1 class="title is-1 container has-text-centered">Twitch<span>.</span>TV <a href="https://www.twitch.tv" target="_blank"><i class="fa fa-twitch" aria-hidden="true"></i></a></h1>

<div class="searchBox">
<input type="search" class="input" placeholder="Search streamers..." autofocus id="filterInput">
</div>

<main id="output" class="container box">
</main>

<footer class="footer has-text-centered is-paddingless">
  <a href='https://www.linkedin.com/in/simongjetaj' target='_blank'> <span>By Simon</span></a> <i class="fa fa-copyright" aria-hidden="true"></i> 2017
</footer>
            
          
!
            
              body, html {
  background: linear-gradient(to top, #ffffff, #abbaab);
  background-attachment: fixed;
  background-repeat: no-repeat;
}

.container {
  max-width: 94%;
  margin: auto;
}

div.searchBox {
  max-width: 300px;
  margin: 0 auto;
}

div input[type="search"] {
  max-width: 350px;
  margin-bottom: 4rem;
}

input[type="search"]::placeholder {
  text-align: center;  
}

h1.title, footer {
  font-family: 'Fredoka One', cursive;
}

h1.title {
  margin-top: 1rem;
  letter-spacing: 0.06rem;
}

h1.title.is-1 span{
  color: #6441a5;
  margin-right: -0.67rem;
}

img {
  border-radius: 50%;
}

main#output strong a {
  text-decoration: none;
}

main div.columns strong:hover {
  font-style: italic;
  text-decoration: underline;
}

main#output {
  margin-top: -2.9rem;
}

div.columns {
  display: flex;
  transition: all 0.2s ease;
}

div.columns:hover { 
  transform: scale(1.015);
  background-color: rgba(100, 65, 165, 0.25);
}

.fa-ban {
  color: #FFB300; 
}

.fa-check {
  color: #64DD17;  
}

.fa-twitch {
  color: #6441a5;
  font-size: 2.2rem;
}

footer.footer {
  background-color: rgba(171, 186, 171, 0.02);
}

footer span {
  color: #000;
}

footer span:hover { 
  color: #6441a5;
}

.fa-copyright {
    font-size: 1.2rem;
 }

@media (max-width: 425px) {
  h1.title.is-1 {
    font-size: 2.4rem;
  }
  main p {
    font-size: 0.85em;
  }
  
  input::placeholder {
    font-size: 0.93rem;
  }
  
  img {
    width: 40px;
    height: 40px;
  }
  .fa-twitch {
  font-size: 1.5rem;
  }
  .fa-copyright {
    font-size: 0.9rem;
 }
  footer.footer {
    font-size: 0.9rem;
  }
}
            
          
!
            
              let users = ["simongjetaj", "ESL_SC2", "OgamingSC2", "cretetion", "freecodecamp", "storbeck", "habathcx", "RobotCaleb", "noobs2ninjas"
];
const clientId = "9c1zh48p6w4gvq0tejahra4q2fp934";
let obj = {};
let output = "";

// getting the name and the logo for each user
// adding the necessary properties to the object for each user
users.forEach(user => {
  let streamersApi = `https://api.twitch.tv/kraken/users/${user}?client_id=${clientId}`;
  fetch(streamersApi)
    .then(response => response.json())
    .then(userData => {
      obj.name = userData.display_name;
      obj.logo = userData.logo;

      // is a user streaming or not?
      let isStreaming = `https://api.twitch.tv/kraken/streams/${user}?client_id=${clientId}`;
      fetch(isStreaming)
        .then(response => response.json())
        .then(streamData => {
          obj.name = userData.display_name;
          obj.logo = userData.logo || "https://dummyimage.com/50/fff/000";
          if (streamData.stream === null) {
            obj.online = false;
            obj.status = "";
            obj.text = " is currently offline";
            obj.icon = "fa-ban";
          } else {
            obj.online = true;
            obj.status = streamData.stream.channel.status;
            obj.text = " is currently streaming ";
            obj.icon = "fa-check";
          }

          output += `
                  <div class="columns">
                    <div class="column">
                        <a href="https://www.twitch.tv/${obj.name}" target="_blank">
                          <img width="50" height="50" src="${obj.logo}">
                        </a>
                    </div>
                    <div class="column is-8 has-text-centered">
                      <p>
                        <a class="${obj.online}" href="https://www.twitch.tv/${user}" target="_blank">
                          <strong>${obj.name}</strong>
                        </a>
                        ${obj.text}${obj.status}.
                      </p>
                      </div>
                      <div class="column">
                        <span><i class="fa ${obj.icon} is-pulled-right" aria-hidden="true"></i></span>
                      </div>
                    </div>
                `;
          document.getElementById("output").innerHTML = output;
        })
        .catch(err => console.log(err));
    });
});

// filtering the streamers by their names
let filterInput = document.getElementById("filterInput");
filterInput.addEventListener("keyup", filterUsers);
function filterUsers() {
  filterValue = filterInput.value.toUpperCase();
  let divs = document.querySelectorAll("#output div.columns");

  divs.forEach(a => {
    let names = a.getElementsByTagName("strong")[0];
    // If matched
    if (names.innerHTML.toUpperCase().indexOf(filterValue) != -1) {
      a.style.display = "";
    } else {
      a.style.display = "none";
    }
  });
}

            
          
!
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.
Loading ..................

Console