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.

            
              
<div class="stripe">
  <h1>FCC twitch channels</h1>
</div>
<div id="tab-box">
  <label class="tab-label tab-active" for="tab-all">All</label>
  <input type="radio" id="tab-all" name="filter"/>
  <label class="tab-label" for="tab-online" >Online</label>
  <input type="radio" id="tab-online" name="filter"/>
  <label class="tab-label" for="tab-offline">Offline</label>
  <input type="radio" id="tab-offline" name="filter"/>
</div>
<div id="tv" class="panel border-r">
  <i class="fa fa-search" aria-hidden="true" id="magnify-img"></i>
  <input type="text" id="search-channel" placeholder="Enter a key word" class="border-r"/>
  <ul id="load-tv"></ul><i id="spinner" class="fa fa-spinner fa-spin fa-2x fa-fw" style="color:#803; margin-bottom: 20px"></i>
</div>

<div class="stripe"></div>

<script type="x-tmpl-mustache" id="tv-template">  
{{#.}}
      <a href='https://www.twitch.tv/{{hisChannel}}' target='_blank'> 
        <li id='{{id}}' class="box border-r">
          <button class="btn hover-radar {{^stream}}offline{{/stream}}">
                <img class='logo border-r' src="{{logo}}{{^logo}}https://drive.google.com/uc?id=12ftLcEQuOIEw-Ths8sOqU49YyGBV8lrD{{/logo}}" alt="logo"/>{{#mature}}<span class='tag'>mature content</span>{{/mature}}{{hisChannel}} <i class="fa fa-square float-right {{#stream}}online{{/stream}}{{^stream}}offline{{/stream}}" aria-hidden="true"></i> 
          </button>
        </li>    
      </a>
  {{#stream}}
          <div id="flip-{{id}}" class="flipper small-text border-r">
           <span># {{_id}}</span>
           <span  style="margin-left: 25%"><i class="fa fa-eye" aria-hidden="true"></i> {{viewers}}</span>
           <span  style="margin-left: 25%"><i class="fa fa-gamepad" aria-hidden="true"></i> {{game}}</span>
          </div>
  {{/stream}}
{{/.}}
</script>
            
          
!
            
              body {
    font-family: 'Roboto', sans-serif;
    text-align: center;
    font-size: 30px;
}

.box { 
    background-color: #A67;
}

.border-r {
  border-radius: 10px;
}

button {
    cursor: pointer;
    width: 100%;
    border: none;
    padding: 18px;
    background-color: transparent;
    font-size: 25px;
}

.flipper {
  position: relative;
  top: -20px;
  background-color: #CCC;
  margin: 0 20px 10px 20px;
  padding: 20px;
  display: none;
}

.float-right {
  float: right;
}

h1 {
   text-shadow: 4px 0 0 #fff, -3px 0 0 #fff, 0 4px 0 #fff, 0 -3px 0 #fff, 2px 2px #fff, -1px -1px 0 #fff, 2px -2px 0 #fff, -1px 1px 0 #fff;
   position: relative;
   top: 10px;
}

.logo {
   float: left;
   width: 40px;
   height auto;
}

li {
  padding: 5px;
  padding-left: px;
  margin: 20px;
}

#magnify-img {
  position: relative;
  color: #A67;
  top: 5px;
}
.offline {
    color: #BBB;
}

.online {
    color: #3F3;
}

.panel {
    margin-left: 20%;
    border: 2px solid gray;
    width: 60%;
    margin-bottom: 40px;
}

input[type=radio] {
    display: none;    
}

#search-channel {
  width: 75%;
  height: 35px;
  margin: 10px;
  margin-bottom: 0;
  border: 2px solid #A8F;
  padding-left: 30px;
  font-size: 20px;
}

.small-text {
    color: #444;
    font-size: 18px;
}

.stripe {
  background-color: #AAA;
  width: 100%;
  height: 100px;
}

#tab-box {
    margin-top: 50px;
    height:inherit;
}

.tab-label {
    position: relative;
    bottom: 0;
    cursor: pointer;
    padding: 10px;
    display: inline-block;
    width: 12%; 
    background:
       linear-gradient(135deg, white 12px, #803 0) top left,
       linear-gradient(225deg, white 12px, #803 0) top right,
       linear-gradient(225deg, transparent 0, #803 0) bottom left,
       linear-gradient(0deg, transparent 0, #803 0) bottom right;
    background-color: #803;
    background-repeat: no-repeat;
    background-size: 50% 50%;
    
    color: #ACD;
}

.tag {  
    float: left;
    margin-right: -45%;
    margin-left: 2%;
    font-size: 15px;
    vertical-align: 30px;
    color: #F00;
    width: 15%;
    background-color: black;
    padding: 5px;
    border: 2px solid;
    font-family: 'Russo One', sans-serif;
}

.tab-active {
     background:
       linear-gradient(135deg, white 12px, #AAA 0) top left,
       linear-gradient(225deg, white 12px, #AAA 0) top right,
       linear-gradient(225deg, transparent 0, #AAA 0) bottom left,
       linear-gradient(0deg, transparent 0, #AAA 0) bottom right;
    background-color: #AAA;
    border-bottom: 3px solid white;
    margin-bottom: -3px;
    background-repeat: no-repeat;
    background-size: 50% 50%;
    color: black;
}

ul { 
   list-style: none;
   padding-left: 0;
   margin-top: 0; 
}


            
          
!
            
              var channels = ["shroud","ESL_SC2", "OgamingSC2", "cretetion", "freecodecamp", "storbeck", "habathcx", "RobotCaleb", "noobs2ninjas", "dancinoman"];
var body = $("body");
var url = "https://wind-bow.gomix.me/twitch-api/";
var channelList = [];


// Inititate the list when the page is loaded
initiateList(channels);


function initiateList(channels) {
    // Resets the html content
    $("#load-tv").html("");
    for(var i = 0; i < channels.length; i++) {
        fetchChannel(channels[i], i, onload);
    }
}

function fetchChannel(chan, i) {   
  
      $.getJSON( url + "streams/" + chan + "?callback=?" , function(data) {
        
        // Create channel Id in the object value
        data.id = i;
        data.hisChannel = chan;
        if(data.stream)data.mature = data['stream']['channel']['mature'];
        channelList[i] = data;
          
        $.getJSON( url + "channels/" + chan + "?callback=?" , function(data) {
              
        channelList[i].logo = data['logo'];

        }).done(function(){
            if(i == channels.length - 1) {
                 setTimeout(initiateMustache, 300, channelList);
              }
          });   
      });
      
  }

// Functions in post
function initiateMustache (chan) {
    // Resets the html content
    $("#load-tv").html("");
    var list = $("#tv-template").html();
    var html = Mustache.to_html(list, chan);
    $("#load-tv").append(html);
    $("#spinner").hide();
}

function sortStreamStatus(arr, tab) {
  var newArr = [];
  // Check the status and sort them into an array 
  arr.forEach(function(val){
      if(tab == "tab-online") {
          if(val.stream != undefined) {
            newArr.push(val);
          }
      }
      else if(tab == "tab-offline") {
        if(val.stream == undefined) {
            newArr.push(val);
          }
      }
    });
    return newArr;
}
  
body.on("change", "input[type=radio]", function(){
    $("#load-tv").html("");
    // Defines this id
    thisStatus = $(this).attr("id");

    $(".tab-label").removeClass("tab-active");
    $("label[for="+ thisStatus +"]").addClass("tab-active");
    //Filter the list
    if (thisStatus != "tab-all") {
       initiateMustache(sortStreamStatus(channelList, thisStatus));
    }
    else if(thisStatus == "tab-all") {
       initiateMustache(channelList);
    }
});
  
body.on("mouseenter", ".hover-radar", function(e){
    e.preventDefault();
    var idHover = $(this).parent().attr("id");
    var flipper = $("#flip-" + idHover);
    flipper.stop().slideDown(200);  
});

body.on("mouseleave", ".hover-radar", function(e){
    e.preventDefault();
    var idHover = $(this).parent().attr("id");
    var flipper = $("#flip-" + idHover);
    flipper.stop().slideUp(200);  
});

body.on("keyup", "#search-channel", function(e){
    
    e.preventDefault();
    
    var keyVal = $("#search-channel").val();
    var filter = []; 

    channelList.forEach(function(val){
      
      if(val['hisChannel'].match(keyVal)) {
        filter.push(val);
      } 
    });
    
    initiateMustache(filter);
});
            
          
!
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