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 includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

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

              
                <div class = "container">
<div class = "header"></div>
  
  <div class = "navigation">
    
      <span class = "col-sm-2 button"><span id = "toggle" class="fa fa-toggle-off" onclick = "clickIt()"></span><p id = "toggleText">All streamer</p></span>
    
<form action = "javascript:search()" id = "form" class = "col-sm-10">
  <input class = "searchBox" placeholder = 'Search streamer' id = "search"></input>
    <button type = "submit" class = "fa fa-search search-icon"></button>
</form>
     
</div>
  
  <div class = "table">
<ul class = "listOn"></ul>
<ul class = "listOff"></ul>
<ul class = "searchResult"></ul>
  </div>

</div>



              
            
!

CSS

              
                body{
  background-image: url("http://gameranx.com/wp-content/uploads/2017/03/Fortnite-1080P-Wallpaper-2.jpg");
  padding-top: 50px;
  margin-bottom: 100px;
}

.error{
  font-size: 1.5em;
}

a:hover{
  cursor: pointer;
}

.picOff:hover{
  cursor: pointer;
}

.container{
  width: 55%;
  background-color: white;
  text-align: center;
  padding-top: 20px;
  padding-bottom: 30px;
}

.header, .navigation{
  text-align: center;
}

.navigation{
  padding-top: 1%;
  margin-bottom: 100px;
}

.header{
  height: 150px;
  margin-bottom: 50px;
  background-image: url("https://rack1.chipmeup.com/assets/twitch/logo-cd148048b88ce417a0c815548e7e4681.png");
  background-repeat: no-repeat;
  background-position: center;
}

.search-icon{
  background-color: transparent;
	font-size: 2em;
  border: none;
}

.fa-toggle-off, .fa-toggle-on{
  background-color: ;
	font-size: 3em;
  border: none;
}

.fa-toggle-on{
  color: #3f8223;
}

.button{
  text-align: left;
}
.button:hover{
  cursor: pointer;
}

.searchBox{
  width: 93%;
  border: none;
  border-bottom: solid 1px black;
  background-color: transparent;
  font-size: 2em;
}

#form{
  text-align: right;
}

.button, #form{
  display:inline-block;
}

.table{
  margin-top: 20px;
}

img{
  height: 95%;
  padding-top: 4%;
  border-radius: 50%;
}

.listOn, .listOff, .searchResult {
  list-style-type: none;
  padding: 0;
  margin: 0 auto;
  width: 100%;
}
.row{
  width: 100%;
  margin: 5px;
  background-color: #e8e8e8;
}


.infoOn{
  border-left: solid #3f8223 7px;
}

.fa-play-circle{
  font-size: 3em;
  color: #3f8223;
}

.fa-play-circle:hover{
  font-size: 3em;
  color: #6ea059;
}

.infoOff{
  border-left: solid red 7px;
}

.picOn, .picOff{
  height: 80px;
  border-right: solid 1px #b7b7b7;
}


.userName, .stream{
  font-size: 1em;
  font-family: sans-serif;
  padding: 4%;
}

.watchStream{
  padding-top: 3%;
}
.userName{
  border-right: solid 1px #b7b7b7;
  height: 80px;
}

.stream{
  height: 80px;
}

.watchStream{
  height: 80px;
}



              
            
!

JS

              
                var users = [
  "ESL_SC2",
  "OgamingSC2",
  "cretetion",
  "freecodecamp",
  "storbeck",
  "habathcx",
  "RobotCaleb",
  "noobs2ninjas"
];

for (var i = 0; i < users.length; i++) {
  myFunctionOn();
}

function myFunctionOn() {
  var user = users[i];

  $.getJSON(
    "https://wind-bow.glitch.me/twitch-api/streams/" + users[i] + "?callback=?",
    function(data) {
      if (!$.trim(data.stream)) {
        $.getJSON(
          "https://wind-bow.glitch.me/twitch-api/channels/" + user + "?callback=?",
          function(dataOff) {
            $(".listOff").append(
              `<li class = "row infoOff">
    <div class = "picOff col-sm-2"><a href = ${dataOff.url} target= "_blank"><img src = ${dataOff.logo}></a></div>
    <div class = "userName col-sm-3">${dataOff.display_name}</div>
    <div class = "stream col-sm-6">Offline</div>
    <div class = "watchStream col-sm-1"><i class="far fa-frown"></i></div></li>`
            );
          }
        );
      } else {
        $(".listOn").append(
          `<li class = "row infoOn">
    <div class = "picOn col-sm-2"><a href = ${data.stream.channel.url} target= "_blank"><img src = ${data.stream.channel.logo}></a></div>
    <div class = "userName col-sm-3">${data.stream.channel.display_name}</div>
    <div class = "stream col-sm-6">${data.stream.game}: ${data.stream.channel.status}</div>
    <div class = "watchStream col-sm-1"><a href =${data.stream.channel.url} target= "_blank"><i class="fa fa-play-circle"></a></i></div>  
    </li>`
        );
      }
    }
  );
}
// toggle on/off - beginning //
var clicked = 0;
function clickIt(){
  clicked ++
  
  $("#toggle").removeClass('fa-toggle-on fa-toggle-off');
  
  if (clicked % 2 === 1){
    $(".listOff").hide();
    $("#toggle").addClass('fa fa-toggle-on');
    $("#toggleText").html('Online streamer');
  }
  else {
    $(".listOff").show();
    $("#toggle").addClass('fa fa-toggle-off');
    $("#toggleText").html('All streamer');
    clicked = 0;
  }
};
// toggle on/off - end //

// search user - beginning //
function search(){
name = document.getElementById("search").value;
  $(".listOff").hide();
  $(".listOn").hide();
  $(".searchResult").html(`<a class = "clear" onclick = "cancelSearch()">Clear search</a>`);
  
 var userOff = name; 
   $.getJSON(
    "https://wind-bow.glitch.me/twitch-api/streams/" + name + "?callback=?",
    function(data) {
      if (!$.trim(data.stream)) {
        $.getJSON(
          "https://wind-bow.glitch.me/twitch-api/channels/" + name + "?callback=?",
          function(dataOff) {
            if (dataOff.status === 404){
              $(".searchResult").append(
              `<div class = "error"><i class="fa fa-exclamation"></i> Streamer name entered doesn't exists! <i class="fa fa-exclamation"></i><br> <br>Suggestions:<br><li>- Make sure name is spelled correctly.</li><li>- Try a different streamer name.</li></div>`
            );
            }
            else{
            $(".searchResult").append(
              `<li class = "row infoOff">
    <div class = "picOff col-sm-2"><a href = ${dataOff.url} target= "_blank"><img src = ${dataOff.logo}></a></div>
    <div class = "userName col-sm-3">${dataOff.display_name}</div>
    <div class = "stream col-sm-6">Offline</div>
    <div class = "watchStream col-sm-1"><i class="far fa-frown"></i></div></li>`
            )};
          }
        );
      } else {
        $(".searchResult").append(
          `<li class = "row infoOn">
    <div class = "picOn col-sm-2"><a href = ${data.stream.channel.url} target= "_blank"><img src = ${data.stream.channel.logo}></a></div>
    <div class = "userName col-sm-3">${data.stream.channel.display_name}</div>
    <div class = "stream col-sm-6">Game streaming: ${data.stream.game}</div>
    <div class = "watchStream col-sm-1"><a href =${data.stream.channel.url}><i class="fa fa-play-circle"></a></i></div>  
    </li>`
        );
      }
    }
  );

  document.getElementById("form").reset();
}
function cancelSearch(){
    $(".listOff").show();
    $(".listOn").show();
    $(".searchResult").hide();
  };

              
            
!
999px

Console