Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ 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

Auto Save

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

              
                
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Twitch Favorites</title>
  <script src="https://use.fontawesome.com/68f3348b8b.js"></script>
  <link rel="stylesheet" href="css/style.css">
  <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">

</head>
<body>
  <header>
    <nav>
      <div class="nav-container">
        <img src="http://vignette4.wikia.nocookie.net/logopedia/images/2/26/Twitch_logo.svg/revision/latest/scale-to-width-down/639?cb=20140727180649" width="100px">
        <form onsubmit='addStreamer(document.getElementById("addStreamInput").value.toLowerCase());return false;'>
          <div style="position: relative;">
            <div id="addStreamIcon"><p><i class="fa fa-user-o" aria-hidden="true"></i></p></div>
            <input id="addStreamInput" type="text" placeholder="Add a streamer">
          </div>
        </form>
      </div>
    </nav>
  </header>

  <main>
    <div id="tab-container">
      <div id="all-tab" class="arrow-box tab-box"><h2><strong>All</strong></h2></div>
      <div id="online-tab" class="tab-box"><h2><strong>Online</strong></h2></div>
      <div id="offline-tab" class="tab-box"><h2><strong>Offline</strong></h2></div>
    </div>

    <div class="search-div">
          <div id="refreshButton" onclick="callEach(streams)"><i class="fa fa-refresh" aria-hidden="true"></i></div>
          <div id="addSearchIcon"><i class="fa fa-search" aria-hidden="true"></i></div>
          <input id="searchInput" type="text" placeholder="Search your streamers">
    </div>

    <div id="loading-div">
      <div class="loader"></div>
    </div>

    <div class="online-streams">
    </div><!--online stream -->
    </div>
    <div class="offline-streams">
    </div><!--offline stream -->


  </main>
  <script defer src="js/script.js"></script>
</body>
</html>

              
            
!

CSS

              
                /* line 5, ../../../../../../Ruby23-x64/lib/ruby/gems/2.3.0/gems/compass-core-1.0.3/stylesheets/compass/reset/_utilities.scss */
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
  margin: 0;
  padding: 0;
  border: 0;
  font: inherit;
  font-size: 100%;
  vertical-align: baseline;
}

/* line 22, ../../../../../../Ruby23-x64/lib/ruby/gems/2.3.0/gems/compass-core-1.0.3/stylesheets/compass/reset/_utilities.scss */
html {
  line-height: 1;
}

/* line 24, ../../../../../../Ruby23-x64/lib/ruby/gems/2.3.0/gems/compass-core-1.0.3/stylesheets/compass/reset/_utilities.scss */
ol, ul {
  list-style: none;
}

/* line 26, ../../../../../../Ruby23-x64/lib/ruby/gems/2.3.0/gems/compass-core-1.0.3/stylesheets/compass/reset/_utilities.scss */
table {
  border-collapse: collapse;
  border-spacing: 0;
}

/* line 28, ../../../../../../Ruby23-x64/lib/ruby/gems/2.3.0/gems/compass-core-1.0.3/stylesheets/compass/reset/_utilities.scss */
caption, th, td {
  text-align: left;
  font-weight: normal;
  vertical-align: middle;
}

/* line 30, ../../../../../../Ruby23-x64/lib/ruby/gems/2.3.0/gems/compass-core-1.0.3/stylesheets/compass/reset/_utilities.scss */
q, blockquote {
  quotes: none;
}
/* line 103, ../../../../../../Ruby23-x64/lib/ruby/gems/2.3.0/gems/compass-core-1.0.3/stylesheets/compass/reset/_utilities.scss */
q:before, q:after, blockquote:before, blockquote:after {
  content: "";
  content: none;
}

/* line 32, ../../../../../../Ruby23-x64/lib/ruby/gems/2.3.0/gems/compass-core-1.0.3/stylesheets/compass/reset/_utilities.scss */
a img {
  border: none;
}

/* line 116, ../../../../../../Ruby23-x64/lib/ruby/gems/2.3.0/gems/compass-core-1.0.3/stylesheets/compass/reset/_utilities.scss */
article, aside, details, figcaption, figure, footer, header, hgroup, main, menu, nav, section, summary {
  display: block;
}

/* line 21, ../../../../../../Ruby23-x64/lib/ruby/gems/2.3.0/gems/susy-2.2.12/sass/susy/language/susy/_box-sizing.scss */
*, *:before, *:after {
  -moz-box-sizing: border-box;
  -webkit-box-sizing: border-box;
  box-sizing: border-box;
}

/* line 1, ../../../components/sass/_base.scss */
body {
  background: #FFFFFF;
  color: #000000;
  font: 400 1em/1.5em "Helvetica Neue", Helvetica, Arial, sans-serif;
}

/* line 7, ../../../components/sass/_base.scss */
nav {
  background-image: url('data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4gPHN2ZyB2ZXJzaW9uPSIxLjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PGRlZnM+PGxpbmVhckdyYWRpZW50IGlkPSJncmFkIiBncmFkaWVudFVuaXRzPSJvYmplY3RCb3VuZGluZ0JveCIgeDE9IjAuMCIgeTE9IjAuNSIgeDI9IjEuMCIgeTI9IjAuNSI+PHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iIzE3MTQxZiIvPjxzdG9wIG9mZnNldD0iMTAwJSIgc3RvcC1jb2xvcj0iIzM3MzA0YSIvPjwvbGluZWFyR3JhZGllbnQ+PC9kZWZzPjxyZWN0IHg9IjAiIHk9IjAiIHdpZHRoPSIxMDAlIiBoZWlnaHQ9IjEwMCUiIGZpbGw9InVybCgjZ3JhZCkiIC8+PC9zdmc+IA==');
  background-size: 100%;
  background-image: -webkit-gradient(linear, 0% 50%, 100% 50%, color-stop(0%, #17141f), color-stop(100%, #37304a));
  background-image: -moz-linear-gradient(left, #17141f, #37304a);
  background-image: -webkit-linear-gradient(left, #17141f, #37304a);
  background-image: linear-gradient(to right, #17141f, #37304a);
}

/* line 11, ../../../components/sass/_base.scss */
strong {
  font-weight: 600;
}

/* line 15, ../../../components/sass/_base.scss */
p {
  font-weight: 400;
  padding-bottom: 10px;
}

/* line 20, ../../../components/sass/_base.scss */
a, u {
  text-decoration: none;
  color: black;
}

/* line 1, ../../../components/sass/_layout.scss */
body {
  position: absolute;
  width: 100%;
  height: 100%;
}

/* line 7, ../../../components/sass/_layout.scss */
nav {
  padding: 0px;
  top: 0;
  width: 100%;
}
/* line 11, ../../../components/sass/_layout.scss */
nav .nav-container {
  margin: 0 auto;
  width: 95%;
  max-width: 520px;
  height: 50px;
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
  align-items: center;
  -webkit-justify-content: space-between;
  justify-content: space-between;
}
/* line 18, ../../../components/sass/_layout.scss */
nav .nav-container p {
  padding-bottom: 0px;
}

/* line 24, ../../../components/sass/_layout.scss */
main {
  margin: 0 auto;
  max-width: 520px;
}
/* line 27, ../../../components/sass/_layout.scss */
main #tab-container {
  display: -webkit-flex;
  display: flex;
}
@media (min-width: 521px) {
  /* line 24, ../../../components/sass/_layout.scss */
  main {
    border: 1px solid black;
    border-top: none;
  }
}

/* line 1, ../../../components/sass/modules/_nav.scss */
#addStreamInput {
  border: 1px solid #392e5c;
  background-color: rgba(255, 255, 255, 0.23);
  padding: 5px;
  padding-left: 30px;
  color: #898395;
  width: 130px;
}
/* line 8, ../../../components/sass/modules/_nav.scss */
#addStreamInput:focus {
  outline: none;
  box-shadow: 0 0 5px #6441a4;
}
@media (min-width: 350px) {
  /* line 1, ../../../components/sass/modules/_nav.scss */
  #addStreamInput {
    width: 170px;
  }
}

/* line 17, ../../../components/sass/modules/_nav.scss */
#addStreamIcon {
  color: #898395;
  position: absolute;
  left: 5px;
  top: 3px;
}

/* line 2, ../../../components/sass/modules/_tabs.scss */
#tab-container > div {
  border-right: 1px solid black;
}
/* line 4, ../../../components/sass/modules/_tabs.scss */
#tab-container > div:last-child {
  border: none;
}
/* line 9, ../../../components/sass/modules/_tabs.scss */
#tab-container:hover {
  cursor: pointer;
}

/* line 14, ../../../components/sass/modules/_tabs.scss */
.tab-box {
  position: relative;
  width: 33.33%;
  background: #7d5bbe;
  text-align: center;
  padding: 10px 0px;
}

/* line 22, ../../../components/sass/modules/_tabs.scss */
.arrow-box {
  position: relative;
  width: 33.3%;
  background: #6441a4;
  text-align: center;
  padding: 10px 0px;
}

/* line 29, ../../../components/sass/modules/_tabs.scss */
.arrow-box:after, .arrow-box:before {
  top: 100%;
  left: 50%;
  border: solid transparent;
  content: " ";
  height: 0;
  width: 0;
  position: absolute;
  pointer-events: none;
}

/* line 40, ../../../components/sass/modules/_tabs.scss */
.arrow-box:after {
  border-color: rgba(136, 183, 213, 0);
  border-top-color: #6441a4;
  border-width: 10px;
  margin-left: -10px;
}

/* line 1, ../../../components/sass/modules/_search.scss */
.search-div {
  width: 100%;
  padding: 12px 0;
  text-align: center;
  display: -webkit-flex;
  display: flex;
  -webkit-justify-content: center;
  justify-content: center;
}

/* line 9, ../../../components/sass/modules/_search.scss */
#searchInput {
  width: 70%;
  padding: 7px;
  padding-left: 30px;
  border: 1px solid black;
  border-left: none;
}
/* line 15, ../../../components/sass/modules/_search.scss */
#searchInput:focus {
  outline: none;
}

/* line 20, ../../../components/sass/modules/_search.scss */
#addSearchIcon {
  border: 1px solid black;
  border-right: none;
}
/* line 23, ../../../components/sass/modules/_search.scss */
#addSearchIcon i {
  position: relative;
  margin-left: 20px;
  top: 3px;
}

/* line 30, ../../../components/sass/modules/_search.scss */
#refreshButton {
  border-right: none;
}
/* line 32, ../../../components/sass/modules/_search.scss */
#refreshButton i {
  position: relative;
  right: 7px;
  top: 6px;
  font-size: 1.3em;
}

/* line 1, ../../../components/sass/modules/_streams.scss */
#loading-div {
  display: -webkit-flex;
  display: flex;
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
  align-items: center;
  height: 160px;
  background-color: white;
}

/* line 8, ../../../components/sass/modules/_streams.scss */
.loader {
  margin: 0 auto;
  border: 10px solid #efeef1;
  border-radius: 50%;
  border-top: 10px solid #6441a4;
  width: 90px;
  height: 90px;
  -webkit-animation: spin .5s linear infinite;
  animation: spin .5s linear infinite;
}

@-webkit-keyframes spin {
  0% {
    -webkit-transform: rotate(0deg);
  }
  100% {
    -webkit-transform: rotate(360deg);
  }
}
@keyframes spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}
/* line 29, ../../../components/sass/modules/_streams.scss */
.online-streams {
  background-color: #d4c9e9;
  border-top: 1px solid black;
}

/* line 34, ../../../components/sass/modules/_streams.scss */
.online-stream,
.offline-stream {
  display: -webkit-flex;
  display: flex;
  -webkit-flex-wrap: nowrap;
  flex-wrap: nowrap;
  width: 100%;
  min-height: 80px;
  overflow: hidden;
}

/* line 44, ../../../components/sass/modules/_streams.scss */
.stream-logo {
  display: -webkit-flex;
  display: flex;
  width: 30%;
  max-width: 100px;
}
/* line 48, ../../../components/sass/modules/_streams.scss */
.stream-logo img {
  width: 80px;
  height: 100%;
  max-height: 87px;
}

/* line 56, ../../../components/sass/modules/_streams.scss */
.stream-basic-info {
  display: -webkit-flex;
  display: flex;
  width: 70%;
  padding: 15px;
  padding-bottom: 0;
}
/* line 61, ../../../components/sass/modules/_streams.scss */
.stream-basic-info p {
  padding: 0;
}

/* line 66, ../../../components/sass/modules/_streams.scss */
.status {
  padding: 0;
  margin: 0;
  font-size: .8em;
}

/* line 72, ../../../components/sass/modules/_streams.scss */
.offline-streams {
  background-color: #efeef1;
  border-top: 1px solid black;
}
/* line 75, ../../../components/sass/modules/_streams.scss */
.offline-streams a {
  color: #807b8b;
}

/* line 80, ../../../components/sass/modules/_streams.scss */
.online-light {
  display: inline-block;
  height: 10px;
  width: 10px;
  background-color: #00fa4f;
  border-radius: 50%;
  box-shadow: 0 0 3px #00fa4f, 0 0 10px #00fa4f;
  animation: inex 1.5s infinite linear;
  margin-right: 5px;
  margin-top: 5px;
}

@keyframes inex {
  50% {
    opacity: 0.4;
  }
  60% {
    opacity: 1;
  }
}
/* line 102, ../../../components/sass/modules/_streams.scss */
.delete-container {
  display: -webkit-flex;
  display: flex;
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
  align-items: center;
}

/* line 107, ../../../components/sass/modules/_streams.scss */
.delete-checkbox {
  width: 15px;
  height: 15px;
}

              
            
!

JS

              
                /*Sometimes this needs to be reloaded to work. I really wanted to practice vanilla
JavaScript for this assignment and so had to make little hacks to get everything
working asynchronously with the limits of the API without breaking CORS */

var streams = ["chu8", "jowetv", "hiko", "ttches", "followgrubby", "trikslyr"],
  streamsJSONP = {},
  online = {},
  offline = {},
  apiURL = 'https://wind-bow.gomix.me/twitch-api/';

/* Appends scripts to HTML in order to save JSONP data to a variable from a
different domain without being blocked by CORS and then deletes the script from
the html to avoid clutter*/
function appendAndRemove(script) {
  document.getElementsByTagName('head')[0].appendChild(script);
  document.head.removeChild(script);
}

// the /streams/ api tells me whether or not a streamer is online.
function callEach(streams) {
  //I clear streamsJSONP to avoid duplicates when this function is run a second time
  streamsJSONP = {};
  streams.forEach(function(stream, index) {
    var script = document.createElement('script');
    script.src = apiURL + 'streams/' + stream + '?callback=sortStreamJSONP';
    appendAndRemove(script);
    console.log('done with callEach');
    console.log(stream + " " + Object.keys(streamsJSONP).length);
    console.log(streamsJSONP);
  });
}

//collects data from the /streams API so sortOnline() can sort each stream as
//online or offline
function sortStreamJSONP(data) {
  document.getElementById('loading-div').style.display = 'flex';
  document.getElementsByClassName('online-streams')[0].style.display = 'none';
  document.getElementsByClassName('offline-streams')[0].style.display = 'none';
  if (data._links === undefined) {
    console.log('readloading');
    alert('API error, please reload');
    return;
  }
  var link = data._links.channel;
  var username = link.substr(38, link.length);
  streamsJSONP[username] = data;
  console.log(Object.keys(streamsJSONP).length+ " "+ streams.length);
  if (Object.keys(streamsJSONP).length == streams.length) {
    console.log('success');
    console.log(streams);
    sortOnline(streamsJSONP);
  }
}

//the /channels/ api gives me information about the streamer's channel
//categorizes each channel into offline or online
function sortOnline(data) {
  offline = {};
  online = {};
  for (var key in data) {
    console.log(key);
    console.log(data[key].stream === null);
    if (data[key].stream) {
      console.log('sending online' + key);
      var script = document.createElement('script');
      script.src = apiURL + 'channels/' + key + '?callback=addOnline';
      appendAndRemove(script);
    }
    else if (data[key].stream === null) {
      console.log('sending offline' + key);
      var script = document.createElement('script');
      script.src = apiURL + 'channels/' + key + '?callback=addOffline';
      appendAndRemove(script);
    } else {
      alert('The Twitch API has been changed or is offline');
    }
  }
}

//adds jsonp data for all of the online stream channels.
function addOnline(data) {
  online[data.name] = data;
  if (Object.keys(online).length + Object.keys(offline).length === Object.keys(streamsJSONP).length) {
    console.log('writing html');
    writeHTMLOnline(online);
    writeHTMLOffline(offline);
  }
}
//adds jsonp data for all of the offline stream channels.
function addOffline(data) {
  offline[data.name] = data;
  console.log(Object.keys(online).length + Object.keys(offline).length + "streamers offline and online");
  if (Object.keys(online).length + Object.keys(offline).length === Object.keys(streamsJSONP).length) {
    console.log('writing html');
    writeHTMLOnline(online);
    writeHTMLOffline(offline);
  }
}

//Appends streams to DOM
function writeHTMLOnline(data) {
  document.getElementsByClassName("online-streams")[0]
  .innerHTML='';
  var frag = document.createDocumentFragment(),
  sortedData = Object.keys(data).sort();
  for (var i = 0; i < sortedData.length; i++) {
    var div = document.createElement('div');
    div.innerHTML =
      `<div class="online-stream" id="`+ (data[sortedData[i]].display_name+
        data[sortedData[i]].game).toLowerCase() +`">
        <div class="stream-logo">
          <a href="` + data[sortedData[i]].url +`">
            <img src="`+ logoOrDefault(data[sortedData[i]].logo) +`">
          </a>
        </div> <!--logo-->
        <div class="stream-basic-info">
        <div class="online-light"></div>
          <a href="` + data[sortedData[i]].url +`">
            <h1><strong>` + data[sortedData[i]].display_name + `</strong></h1>
            <p>` + data[sortedData[i]].game +`</p>
          </a>
        </div><!--basic info-->
      </div><!--online stream -->`;
    frag.appendChild(div.firstChild);
  }
  document.getElementById('loading-div').style.display = 'none';
  document.getElementsByClassName('online-streams')[0].style.display = 'block';
  document.getElementsByClassName('offline-streams')[0].style.display = 'block';
  document.getElementsByClassName("online-streams")[0].appendChild(frag);
}

function writeHTMLOffline(data) {
  document.getElementsByClassName("offline-streams")[0]
  .innerHTML='';
  var frag = document.createDocumentFragment();
  sortedData = Object.keys(data).sort();
  for (var i = 0; i < sortedData.length; i++) {
    var div = document.createElement('div');
    div.innerHTML =
      `<div class="offline-stream" id="`+ (data[sortedData[i]].display_name+
        data[sortedData[i]].game).toLowerCase() +`">
        <div class="stream-logo">
          <a href="` + data[sortedData[i]].url +`">
            <img src="` + logoOrDefault(data[sortedData[i]].logo) + `">
          </a>
        </div> <!--logo-->
        <div class="stream-basic-info">
          <a href="` + data[sortedData[i]].url +`">
            <h1><strong>` + data[sortedData[i]].display_name + `</strong></h1>
            <p>` + (data[sortedData[i]].game || "") +`</p>
          </a>
        </div><!--basic info-->
      </div><!--offline stream -->`;
    frag.appendChild(div.firstChild);
  }
  document.getElementById('loading-div').style.display = 'none';
  document.getElementsByClassName('online-streams')[0].style.display = 'block';
  document.getElementsByClassName('offline-streams')[0].style.display = 'block';
  document.getElementsByClassName("offline-streams")[0].appendChild(frag);
}

function logoOrDefault(logo) {
  return logo || 'http://vignette3.wikia.nocookie.net/logopedia/images/8/83/Twitch_icon.svg/revision/latest?cb=20140727180700';
}

/****
Add streamer functions
*****/

function addStreamer(streamer) {
  var script = document.createElement('script');
  script.src = apiURL + 'channels/' + streamer + '?callback=verifyStreamer';
  appendAndRemove(script);
}

//Checks to see if the streamer exists on twitch and if the streamer
//is already in the list
function verifyStreamer(data) {
  if (Object.keys(streamsJSONP).indexOf(data.name) > -1) {
    alert('Streamer already in list');
  }
  else if (data.display_name) {
    document.getElementById("addStreamInput").value='';
    streams.push(data.name);
    var script = document.createElement('script');
    script.src = apiURL + 'streams/' + data.name + '?callback=sortStreamJSONP';
    appendAndRemove(script);
  } else {
    alert('Streamer not found.');
  }
}

/***********************************************/
/****This code will make sorting tabs work*****/
/**********************************************/

//turn this into a self running function to save global space
var tabElements = document.getElementsByClassName('tab-box'),
onlineDisplay = document.getElementsByClassName('online-streams')[0].style,
offlineDisplay = document.getElementsByClassName('offline-streams')[0].style;
Array.from(tabElements).forEach(function(element) {
  element.addEventListener('click', function() {
    var sibBoxes = document.getElementById('tab-container').childNodes,
        target = event.target;
    removeArrowBoxCSS(sibBoxes);
    event.target.closest('div').className="tab-box arrow-box";
    if (target.closest('div') === sibBoxes[1]) {
      offlineDisplay.display = "block";
      onlineDisplay.display = "block";
    }
    else if (target.closest('div') === sibBoxes[3]) {
      offlineDisplay.display = "none";
      onlineDisplay.display = "block";
    }
    else if (target.closest('div') === sibBoxes[5]) {
      offlineDisplay.display = "block";
      onlineDisplay.display = "none";

    }
  });
});

//removes the arrow-box class from all tabs
function removeArrowBoxCSS(sib) {
  sib.forEach(function(box) {
    box.className = "tab-box";
  });
}

/***********************************************/
/****This code will allow search to work********/
/**********************************************/

document.getElementById('searchInput').addEventListener('keyup', function() {
  var input = document.getElementById('searchInput').value.toLowerCase(),
  onlineStreams = document.querySelectorAll('.online-stream');
  offlineStreams = document.querySelectorAll('.offline-stream');
  console.log(input);
  if (input === '') {
    console.log('input nothing');
    onlineStreams.forEach(function(div) {
      div.style.display = 'flex';
    });
    offlineStreams.forEach(function(div) {
      div.style.display = 'flex';
    });
  } else {
    onlineStreams.forEach(function(div) {
      if (div.id.indexOf(input) > -1) {
        div.style.display = 'flex';
      } else {
        div.style.display = 'none';
      }
    });
    offlineStreams.forEach(function(div) {
      if (div.id.indexOf(input) > -1) {
        div.style.display = 'flex';
      } else {
        div.style.display = 'none';
      }
    });
  }
});

setTimeout(function(){ callEach(streams); }, 1000);

              
            
!
999px

Console