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">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/css/bootstrap.min.css" integrity="sha384-Zug+QiDoJOrZ5t4lssLdxGhVrurbmBWopoEl+M6BdEfwnCJZtKxi1KgxUyJq13dy"
        crossorigin="anonymous">
    <link rel="stylesheet" href="style.css"></link>
    <title>Document</title>
</head>

<body>
  <div class="wrapper">
    <div class="twitchBox">

        <div class="header">
            <h1 class="text-center">Search Twitch</h1>
        </div>

        <div class="btn-group" role="group" aria-label="...">
            <button type="button" class="all btn btn-default ">All</button>
            <button type="button" class="live btn btn-default">Live</button>
            <button type="button" class="offline btn btn-default">Offline</button>
        </div>
      
        <form target="iFrame">
            <input id="searchBox" type="text" placeholder="search">
        </form>
      
        <div class="resultsContainer" />
                
    </div>
  </div>

    <script src="https://code.jquery.com/jquery-3.2.1.js" integrity="sha256-DZAnKJ/6XZ9si04Hgrsxu/8s717jcIzLy3oi35EouyE=" crossorigin="anonymous"></script>
    <script defer src="https://use.fontawesome.com/releases/v5.0.8/js/all.js"></script>
    <script type="text/javascript" src="main.js"></script>
</body>


</html>
              
            
!

CSS

              
                @import url("https://fonts.googleapis.com/css?family=Permanent+Marker|Ubuntu:300");

.wrapper {
height: 100vh; 
  width: 100vw; 
  padding: 100px ;
  background: linear-gradient(
    135deg,
    rgba(34, 36, 36, 0.9),
    rgba(119, 214, 221, 0.8),
    rgba(34, 36, 36, 0.5)
  ) !important;
  background-repeat: no-repeat !important;
}
.twitchBox {
  margin: 0 auto;
  margin-top: 50px;
  font-family: "Ubuntu", sans-serif;
  width: 400px !important;
  background-color: rgb(33, 34, 33);
  padding: 20px 20px;
  background: linear-gradient(
    135deg,
    rgb(34, 36, 36),
    rgb(119, 214, 221),
    rgb(34, 36, 36)
  );
  box-shadow: 2px 2px 10px #2b2b2b, inset 0 0 10px #2b2b2b;
  border-radius: 10px;
  color: rgb(238, 241, 13);
}

#searchBox {
  /* //height: 30px; */
  border-radius: 1em;
  background-color: rgb(207, 207, 207);
}

h1 {
  font-family: "Permanent Marker", cursive;
}
.btn-group {
  display: flex !important;
}

.btn {
  flex: 1 !important;
  height: 3em;
  background: linear-gradient(
    135deg,
    rgb(27, 194, 206),
    rgb(119, 214, 221),
    rgb(27, 194, 206)
  );
}
.active {
  background-color: red;
  color: white;
  box-shadow: 0px 1px 2px rgb(46, 45, 45);
  background: linear-gradient(
    135deg,
    rgb(35, 155, 163),
    rgb(0, 216, 83),
    rgb(27, 194, 206)
  ) !important;
}

#searchBox {
  width: 100%;
  margin: 20px 0px;
  padding-left: 10px;
}
.result {
  display: flex;
  padding: 15px;
  background-color: rgba(145, 255, 0, 0.589);
  background-color: #74d4ddab;
  border-radius: 5px;

  border: 1px solid grey;
  /* max-height: 100px; */
}
.avatar {
  display: flex;
  flex: 1;
  /* background-color: blue; */
  align-items: center;
  justify-content: center;
}
.avatar img {
  border-radius: 50%;
  height: 70px;
  width: 70px;
  border: 3px solid rgb(238, 241, 13);
}

.channelInfo {
  margin-left: 10px;
  padding-left: 10px;
  flex: 4;
}

.channelInfo a {
  text-decoration: none;
  color: rgb(238, 241, 13);
}

.channelInfo a:hover {
  text-decoration: none;
  color: rgb(238, 241, 13);
  text-shadow: 2px 2px 5px rgb(56, 56, 56);
}

.channelName {
  text-decoration: none;
}

.currentStream {
  border-top: 1px solid black;
}

.streamingIndicator {
  flex: 1;
  display: flex;
  color: rgb(238, 241, 13);

  align-items: center;
  justify-content: center;
  font-size: 2em;
}

.fa-times-circle {
  color: grey;
}

.error {
  background-color: rgba(243, 17, 17, 0.781);
  color: white;
  padding: 15px 10px;
  border-radius: 5px;
  box-shadow: inset 0 0 10px #2b2b2b;
}

              
            
!

JS

              
                var streamers = [
  {
    stream: {
      mature: false,
      status:
        "Greg working on Electron-Vue boilerplate w/ Akira #programming #vuejs #electron",
      broadcaster_language: "en",
      display_name: "FreeCodeCamp",
      game: "Creative",
      language: "en",
      _id: 79776140,
      name: "freecodecamp",
      created_at: "2015-01-14T03:36:47Z",
      updated_at: "2016-09-17T05:00:52Z",
      delay: null,
      logo:
        "https://static-cdn.jtvnw.net/jtv_user_pictures/freecodecamp-profile_image-d9514f2df0962329-300x300.png",
      banner: null,
      video_banner:
        "https://static-cdn.jtvnw.net/jtv_user_pictures/freecodecamp-channel_offline_image-b8e133c78cd51cb0-1920x1080.png",
      background: null,
      profile_banner:
        "https://static-cdn.jtvnw.net/jtv_user_pictures/freecodecamp-profile_banner-6f5e3445ff474aec-480.png",
      profile_banner_background_color: null,
      partner: false,
      url: "https://www.twitch.tv/freecodecamp",
      views: 161989,
      followers: 10048,
      _links: {
        self: "https://api.twitch.tv/kraken/channels/freecodecamp",
        follows: "https://api.twitch.tv/kraken/channels/freecodecamp/follows",
        commercial:
          "https://api.twitch.tv/kraken/channels/freecodecamp/commercial",
        stream_key:
          "https://api.twitch.tv/kraken/channels/freecodecamp/stream_key",
        chat: "https://api.twitch.tv/kraken/chat/freecodecamp",
        subscriptions:
          "https://api.twitch.tv/kraken/channels/freecodecamp/subscriptions",
        editors: "https://api.twitch.tv/kraken/channels/freecodecamp/editors",
        teams: "https://api.twitch.tv/kraken/channels/freecodecamp/teams",
        videos: "https://api.twitch.tv/kraken/channels/freecodecamp/videos"
      }
    },
    _links: {
      self: "https://api.twitch.tv/kraken/streams/freecodecamp",
      channel: "https://api.twitch.tv/kraken/channels/freecodecamp"
    }
  },
  {
    stream: null,
    display_name: "OgamingSC2",
    _links: {
      self: "https://api.twitch.tv/kraken/streams/ogamingsc2",
      channel: "https://api.twitch.tv/kraken/channels/ogamingsc2"
    }
  },
  {
    stream: {
      mature: false,
      status:
        "RERUN: StarCraft 2 - Kane vs. HuK (ZvP) - WCS Season 3 Challenger AM - Match 4",
      broadcaster_language: "en",
      display_name: "ESL_SC2",
      game: "StarCraft II",
      language: "en",
      _id: 30220059,
      name: "esl_sc2",
      created_at: "2012-05-02T09:59:20Z",
      updated_at: "2016-09-17T06:02:57Z",
      delay: null,
      logo:
        "https://static-cdn.jtvnw.net/jtv_user_pictures/esl_sc2-profile_image-d6db9488cec97125-300x300.jpeg",
      banner: null,
      video_banner:
        "https://static-cdn.jtvnw.net/jtv_user_pictures/esl_sc2-channel_offline_image-5a8657f8393c9d85-1920x1080.jpeg",
      background: null,
      profile_banner:
        "https://static-cdn.jtvnw.net/jtv_user_pictures/esl_sc2-profile_banner-f8295b33d1846e75-480.jpeg",
      profile_banner_background_color: "#050506",
      partner: true,
      url: "https://www.twitch.tv/esl_sc2",
      views: 60843789,
      followers: 135275,
      _links: {
        self: "https://api.twitch.tv/kraken/channels/esl_sc2",
        follows: "https://api.twitch.tv/kraken/channels/esl_sc2/follows",
        commercial: "https://api.twitch.tv/kraken/channels/esl_sc2/commercial",
        stream_key: "https://api.twitch.tv/kraken/channels/esl_sc2/stream_key",
        chat: "https://api.twitch.tv/kraken/chat/esl_sc2",
        subscriptions:
          "https://api.twitch.tv/kraken/channels/esl_sc2/subscriptions",
        editors: "https://api.twitch.tv/kraken/channels/esl_sc2/editors",
        teams: "https://api.twitch.tv/kraken/channels/esl_sc2/teams",
        videos: "https://api.twitch.tv/kraken/channels/esl_sc2/videos"
      }
    },
    _links: {
      self: "https://api.twitch.tv/kraken/streams/esl_sc2",
      channel: "https://api.twitch.tv/kraken/channels/esl_sc2"
    }
  },
  {
    stream: null,
    display_name: "noobs2ninjas",
    _links: {
      self: "https://api.twitch.tv/kraken/streams/esl_sc2",
      channel: "https://api.twitch.tv/kraken/channels/esl_sc2"
    }
  }
];
var resultsHtml = [];

$("document").ready(function() {
  //call the click on All button after doc ready
  setTimeout(function() {
    $(".all").trigger("click");
  }, 10);

  //keep only one button active at a time
  $(".btn-group :button").click(function() {
 
    $(this)
      .addClass("active")
      .siblings()
      .removeClass("active");
  });

  //Get status for all 4 users FCC provides
  $(".all").click(function() {
    
    $(".resultsContainer").html("");
    $("#searchBox").val("");
    resultsHtml = "";
    streamers.forEach(function(streamer) {
      if (streamer.stream !== null) {
        ajaxCall(streamer["stream"]["display_name"]);
      } else {
        ajaxCall(streamer["display_name"]);
      }
    });
  });

  //check to see if the 4 users FCC provides are streaming;

  $(".live").click(function() {
    $("#searchBox").val("");
   
    $(".resultsContainer").html("");
    resultsHtml = "";
    streamers.forEach(function(streamer) {
      if (streamer.stream !== null) {
        getLive(streamer["stream"]["display_name"]);
      } else {
        getLive(streamer["display_name"]);
      }
    });
  });

  // Check to see if the 4 users FCC provides are offline
  $(".offline").click(function() {
    $("#searchBox").val("");
    
    $(".resultsContainer").html("");
    resultsHtml = "";
    streamers.forEach(function(streamer) {
      if (streamer.stream !== null) {
        // ajaxCall(streamer[display_name]);
        getOffline(streamer["stream"]["display_name"]);
      } else {
        getOffline(streamer["display_name"]);
      }
      // return $(".resultsContainer").html(resultsHtml);
    });
  });

  // Search for any user on Twitch
  $("form").submit(function() {
    event.preventDefault();
    
    var query = $("#searchBox").val();
    $(".btn-group :button").removeClass("active");

    if (query != "") {
      $(".resultsContainer").html("");
      resultsHtml = "";
      ajaxCall(query);
    }
  });
});

function getLive(query) {
  $.get("https://wind-bow.glitch.me/twitch-api/streams/" + query, function(
    data
  ) {
    if (data.stream !== null) {
      ajaxCall(query);
    }
  });
}
function getOffline(query) {
  $.get("https://wind-bow.glitch.me/twitch-api/streams/" + query, function(
    data
  ) {
    if (data.stream === null) {
      ajaxCall(query);
    }
  });
}

function ajaxCall(query) {
  var streamingIcon = "";
  var live = false;
  query = query.replace(/\s/g, "");
 

  //check stream for null; if null, channel is either offline or invalid
  $.get("https://wind-bow.glitch.me/twitch-api/streams/" + query, function(
    data
  ) {
   

    if (data.stream !== null) {
     
      live = true;
      streamingIcon = '<i class="fas fa-eye"></i>';
    } else {
      streamingIcon = '<i class="far fa-times-circle"></i>';
      live = false;
     
    }

    $.get("https://wind-bow.glitch.me/twitch-api/channels/" + query, function(
      data
    ) {
      // if username is invalid show error message
      if (data.error) {
      
        query = $("#searchBox").val("");

        resultsHtml =
          "<p class='error text-center'> <strong>" +
          data.message +
          "</strong> </p>";
      } else {
        if (live === true) {
          status = data.status;
        } else {
          status = "offline";
        }

        // create results html

        resultsHtml +=
          '<div class="resultsContainer"><div class="result"><div class="avatar"><img src="';
        resultsHtml += data.logo;
        resultsHtml +=
          '" id="logo" height="100%" width="100%"></div><div class="channelInfo"><h3 class="channelName"><a href="';
        resultsHtml += data.url;
        resultsHtml += '" target="#blank">';
        resultsHtml += data.name;
        resultsHtml += '</a></h3><p class="currentStream">';
        resultsHtml += status;
        resultsHtml += '</p></div><div class="streamingIndicator">';
        resultsHtml += streamingIcon;
        resultsHtml += "</i></div></div> </div>";
      }
      $(".resultsContainer").html(resultsHtml);
    });
  });
}

              
            
!
999px

Console