cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

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.

            
              <div class="container">
  <div class="outer">
   <div class="banner">
     <div class="inner"><img id="twitch_logo" src="https://www.filepicker.io/api/file/vL2cljiRdefa2gBxqsSV" alt="Twitch Logo">
     </div>
      
     <div id="button_cluster" class="inner">
        <ul>
          <li><button id = "addBtn" class="button">Add</button></li>
          <li><button id = "delBtn" class="button">Delete</button></li>
          
       </ul>
      </div>
     <!-- The Modal -->
      <div id="myModal" class="modal">

  <!-- Modal content -->
  <div class="modal-content">
    <span class="close">&times;</span>
    <p>Enter streamer to add...</p>
    
    <form id="outerForm">
      <div   class="inner">  
      <input id = "form1" class = "textForm" type="text" size="20">
      <button type="button" id="formBtn" onclick="myFunction()" class = "btn">Submit</button>
      </div>
    </form>
  </div>

</div>
     </div>
     <ul id="list">
     </ul>
</div>
            
          
!
            
              body, html {
  height:100%;
  width:100%;
  min-width:400px;
  background-color:#462a7a;
}
.container{
  display:flex;
  flex-flow:row;
  justify-content:center;
  min-height:100%;
  min-width:100%;
  border-style:solid;
}
.outer{
  align-self:flex-start;
  display:flex;
  flex-flow:column;
  border-style:solid;
  width:80%;
  max-width:600px;
}
.button{
  display:flex;
  flex-flow:row;
  justify-content:center;
  margin:0px;
  width:100%;
  border-radius:15%;
}
#button_cluster{
  margin:0px;
  padding:0px;
  width:auto;
}
.banner{
  padding-left:10px;
  display:flex;
  flex-flow:row;
  justify-content:center;
  align-items:center;
  width:100%;
  height:100px;
  background-color: #6441A4;
}
#twitch_logo{
  height:100px;
  width:auto;
}
.inner_row{
  padding:5px;
  display:flex;
  flex-flow:row; 
  align-items:center;
  width:100%;  
  border-top:solid;
  background-color:#c9b9e8;
}
.inner{
  display:flex;
  flex-flow:row;
  align-items: center;
  width:auto;
  height:auto;
  padding:5px;
}
.inner_row_mid{
  display:flex;
  flex-flow:row;
  justify-content:center;
  margin:0px;
  padding:0px;
  width:100%;
}
.twitch_name{
  padding-left:5px;
  max-width:100%;
  min-width:30%; 
}
.indicator{
  min-width:30px;
  min-height:30px;
  align-content:center;
}
.m_icon{
  min-width:45px;
  min-height:30px;
  align-content:center;
  max-height: 50px;
  max-width:auto;  
}
.game_title{
  padding-left:5px;
  width:100%;
  justify-content:flex-start;
}
ul {
  padding:0px;
  margin:0px;
  list-style-type: none;
}
.icon{
 max-height: 50px;
 max-width:auto;
 border-radius:50%; 
}
.led-red {
  margin: 0 auto;
  width: 24px;
  height: 24px;
  background-color: #F00;
  border-radius: 50%;
  box-shadow: rgba(0, 0, 0, 0.2) 0 -1px 7px 1px, inset #304701 0 -1px 9px, #FF0000 0 2px 12px;
}
.led-yellow {
  margin: 0 auto;
  width: 24px;
  height: 24px;
  background-color: #FF0;
  border-radius: 50%;
  box-shadow: rgba(0, 0, 0, 0.2) 0 -1px 7px 1px, inset #304701 0 -1px 9px, #FFFF00 0 2px 12px;
  
  -webkit-animation: blinkYellow 4s infinite;
  -moz-animation: blinkYellow 4s infinite;
  -ms-animation: blinkYellow 4s infinite;
  -o-animation: blinkYellow 4s infinite;
  animation: blinkYellow 4s infinite;
}

@-webkit-keyframes blinkYellow {
    from { background-color: #FF0; }
    50% { background-color: #c7c715; box-shadow: rgba(0, 0, 0, 0.2) 0 -1px 7px 1px, inset #441313 0 -1px 9px, rgba(0, 255, 0, 0.5) 0 2px 0;}
    to { background-color: #FF0; }
}
@-moz-keyframes blinkYellow {
    from { background-color: #FF0; }
    50% { background-color: #c7c715; box-shadow: rgba(0, 0, 0, 0.2) 0 -1px 7px 1px, inset #441313 0 -1px 9px, rgba(0, 255, 0, 0.5) 0 2px 0;}
    to { background-color: #FF0; }
}
@-ms-keyframes blinkYellow {
    from { background-color: #Ff0; }
    50% { background-color: #c7c715; box-shadow: rgba(0, 0, 0, 0.2) 0 -1px 7px 1px, inset #441313 0 -1px 9px, rgba(0, 255, 0, 0.5) 0 2px 0;}
    to { background-color: #FF0; }
}
@-o-keyframes blinkYellow {
    from { background-color: #FF0; }
    50% { background-color: #c7c715; box-shadow: rgba(0, 0, 0, 0.2) 0 -1px 7px 1px, inset #441313 0 -1px 9px, rgba(0, 255, 0, 0.5) 0 2px 0;}
    to { background-color: #FF0; }
}
@keyframes blinkYellow {
    from { background-color: #FF0; }
    50% { background-color: #c7c715; box-shadow: rgba(0, 0, 0, 0.2) 0 -1px 7px 1px, inset #441313 0 -1px 9px, rgba(0,255, 0, 0.5) 0 2px 0;}
    to { background-color: #FF0; }
}

.led-green {
  margin: 0 auto;
  width: 24px;
  height: 24px;
  background-color: #0F0;
  border-radius: 50%;
  box-shadow: rgba(0, 0, 0, 0.2) 0 -1px 7px 1px, inset #441313 0 -1px 9px, rgba(0, 255, 0, 0.5) 0 2px 12px;
  -webkit-animation: blinkGreen 1s infinite;
  -moz-animation: blinkGreen 1s infinite;
  -ms-animation: blinkGreen 1s infinite;
  -o-animation: blinkGreen 1s infinite;
  animation: blinkGreen 1s infinite;
}

@-webkit-keyframes blinkGreen {
    from { background-color: #0F0; }
    50% { background-color: #0A0; box-shadow: rgba(0, 0, 0, 0.2) 0 -1px 7px 1px, inset #441313 0 -1px 9px, rgba(0, 255, 0, 0.5) 0 2px 0;}
    to { background-color: #0F0; }
}
@-moz-keyframes blinkGreen {
    from { background-color: #0F0; }
    50% { background-color: #0A0; box-shadow: rgba(0, 0, 0, 0.2) 0 -1px 7px 1px, inset #441313 0 -1px 9px, rgba(0, 255, 0, 0.5) 0 2px 0;}
    to { background-color: #0F0; }
}
@-ms-keyframes blinkGreen {
    from { background-color: #F00; }
    50% { background-color: #0A0; box-shadow: rgba(0, 0, 0, 0.2) 0 -1px 7px 1px, inset #441313 0 -1px 9px, rgba(0, 255, 0, 0.5) 0 2px 0;}
    to { background-color: #F00; }
}
@-o-keyframes blinkGreen {
    from { background-color: #0F0; }
    50% { background-color: #0A0; box-shadow: rgba(0, 0, 0, 0.2) 0 -1px 7px 1px, inset #441313 0 -1px 9px, rgba(0, 255, 0, 0.5) 0 2px 0;}
    to { background-color: #0F0; }
}
@keyframes blinkGreen {
    from { background-color: #0F0; }
    50% { background-color: #0A0; box-shadow: rgba(0, 0, 0, 0.2) 0 -1px 7px 1px, inset #441313 0 -1px 9px, rgba(0,255, 0, 0.5) 0 2px 0;}
    to { background-color: #0F0; }
}

/* The Modal (background) */
.modal {
    display: none; /* Hidden by default */
    position: fixed; /* Stay in place */
    z-index: 1; /* Sit on top */
    left: 0;
    top: 0;
    width: 100%; /* Full width */
    height: 100%; /* Full height */
    overflow: auto; /* Enable scroll if needed */
    background-color: rgb(0,0,0); /* Fallback color */
    background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
}
/* Modal Content/Box */
.modal-content {
    background-color: #fefefe;
    margin: 15% auto; /* 15% from the top and centered */
    padding: 15px;
    border: 1px solid #888;
    width: 50%; /* Could be more or less, depending on screen size */
    display:flex;
    flex-flow:column;
    justify-content: center;
    align-content:center;
}

/* The Close Button */
.close {
    color: #F00;
    align-self:flex-end;
    font-size: 28px;
    font-weight: bold;
}

.close:hover,
.close:focus {
    color: black;
    text-decoration: none;
    cursor: pointer;
}
.textForm {
  
}
            
          
!
            
              function del(){
  var args = Array.prototype.slice.call(event.target.id)
  element = document.getElementById(event.target.id);
  element = element.parentNode;
  //console.log(args);
  var index = args[6];
  element.parentNode.remove();
  streamlist.splice(index, 1);
  console.log(streamlist);
  populate();
  //var gparents = element.parents();
  
  //element.parentNode.removeChild(element);
  
}


var streamlist=["Wasted", "HyperRPG", "GeekandSundry", "Sacriel", "fcc"];

//For-loop to make the API call for each streamer
function populate(){
  document.getElementById("list").innerHTML = "";
  for(var i=0; i<streamlist.length; i++){
  var url="https://wind-bow.glitch.me/twitch-api/streams/"+streamlist[i];
  
  //append li to HTML
  $("#list").append('<li id "li'+i+'" class="inner_row"><div class="inner"><div id = "indicator'+i+'" class="indicator"></div></div><div class="icon"><a id="link'+i+'" href =""><img id="user_icon'+i+'" class="icon" src="" Alt="Twitch Icon"></a></div><div class="inner inner_row_mid"><div class="twitch_name"><div id="twitch_name'+i+'" class="twitch_name"></div></div><div class="game_title"><div id= "game_title'+i+'" class="game_title"></div></div></div><div class="inner" id="m_container'+i+'"><img id="m_icon'+i+'" onClick = "del()" class="m_icon"  src="https://upload.wikimedia.org/wikipedia/commons/a/a9/ESRB_Everyone.svg" alt="Everyone"></div></li>');
  
  //AJAX call
  $.ajax({url, async: false,
    success:function(data){
    
    //**Assign data**
    
    //If data is null, streamer is offline
    if(data.stream == null){
      $("#game_title"+i).text("Offline");
      $("#indicator"+i).addClass("led-red");
      $("#twitch_name"+i).text(streamlist[i]);
      $("#user_icon"+i).attr("src", "http://res.cloudinary.com/mdrisk/image/upload/v1509456422/no-internet-required-at-all-300x300_kcfjc7.png");
      $("#link"+i).attr("href", "https://www.twitch.tv/"+streamlist[i]);
    } 
    else { //The streamer is online
      $("#game_title"+i).text(data.stream.game);
      $("#twitch_name"+i).text(data.stream.channel.name);
      $("#indicator"+i).addClass("led-green");
      $("#user_icon"+i).attr("src", data.stream.channel.logo);
      $("#link"+i).attr("href", data.stream.channel.url);
    
      //Checks for channel mature rating
      if(data.stream.channel.mature){
        $("#m_icon"+i).attr("src", "https://upload.wikimedia.org/wikipedia/commons/c/cb/ESRB_2013_Mature.svg");
        $("#m_icon"+i).attr("alt","Mature Icon");
      }
    }
   }
  });
}
  
}

$(document).ready(function(){

//Call widthCheck() whenever resized
$(window).resize(function(){
  widthCheck();
});

//This updates CSS to stack certain items and change max width
function widthCheck(){
  if($( document ).width()<750){
    $(".inner_row_mid").css("flex-flow", "column");
    $(".twitch_name").css("max-width","100%");
    $(".twitch_name").css("width","100%");
    $(".twitch_name").css("align-content","flex-start");
  } else {
    $(".inner_row_mid").css("flex-flow", "row");
    $(".twitch_name").css("max-width","100%");
    $(".twitch_name").css("width","auto");
     $(".twitch_name").css("align-content","flex-start");
  }
}

//Array of Streamers



populate();
var modal = document.getElementById('myModal');

// Get the button that opens the modal
var addBtn = document.getElementById("addBtn");
var delBtn = document.getElementById("delBtn");
var formBtn = document.getElementById("formBtn");
// Get the <span> element that closes the modal
var span = document.getElementsByClassName("close")[0];

// When the user clicks on the button, open the modal 
addBtn.onclick = function() {
  modal.style.display = "block";
  document.getElementById("outerForm").reset();
}

formBtn.onclick = function(){
  var nameValue = document.getElementById("form1").value;
  streamlist.push(nameValue);
  
  console.log(streamlist);
  populate();
  modal.style.display = "none";
  
}

delBtn.onclick = function(){
  for(var i = 0; i<streamlist.length; i++){
      $("#m_icon"+i).attr("src", "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQSsb_LOhEPGj3hajUR-7kM0YXdY8W2bmjbaGlp_s66N7_iqBuPTA");
      $("#m_icon"+i).css("cursor","pointer" );
  }
}


// When the user clicks on <span> (x), close the modal
span.onclick = function() {
    modal.style.display = "none";
}
  
//Calls function to verify and update based on window size
widthCheck();

});
            
          
!
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