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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

              
                <h1 class="well" style="border-radius: 40px;">Twitch.tv</h1>
<!-- Tab links -->
<div class="container" style="padding-top: 15px; padding-bottom: 10px; width: 90%;">
    <div class="row">
        <div class="tab poppins">
            <div class="col-xs-4 center">
                <button class="tablinks" onclick="openTab(event, 'All')">All</button>
            </div>
            <div class="col-xs-4 center">
                <button class="tablinks" onclick="openTab(event, 'Online')">Online</button>
            </div>
            <div class="col-xs-4 center">
                <button class="tablinks" onclick="openTab(event, 'Offline')">Offline</button>
            </div>
        </div>
    </div>
</div>
<!-- Tab content -->
<div id="All" class="tabcontent left" style="display: block;">
    <div class="tab-header-border">
        <h3 class="center h3-font-size">All Channels</h3>
    </div>
    <ul id="All-list"></ul>
</div>
<div id="Online" class="tabcontent left">
    <div class="tab-header-border">
        <h3 class="center h3-font-size">Online</h3>
    </div>
    <ul id="Online-list"></ul>
</div>
<div id="Offline" class="tabcontent left">
    <div class="tab-header-border">
        <h3 class="center h3-font-size">Offline</h3>
    </div>
    <ul id="Offline-list"></ul>
</div>
              
            
!

CSS

              
                html {
    overflow: scroll;
    overflow-x: hidden;
}

::-webkit-scrollbar {
    width: 0px;
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #FF0000;
}

body {
    font-family: 'Comfortaa', cursive;
    font-weight: bold;
    color: black;
    background-image: url('https://www.twitchinstalls.com/img/pic1.png');
    background-repeat: no-repeat;
    background-position: fixed;
}

h1 {
    text-align: center;
    font-size: 3vmax;
}

h3 {
    font-size: 9vmin;
    padding: 10px 0px 10px 0px;
}

.tab-header-border {
    border-style: solid;
    margin-left: 25%;
    margin-right: 25%;
}

a:link {
    color: black;
}

a:visited {
    color: grey;
}

a:hover {
    color: #9f9f9f;
    text-decoration: none;
}

a:active {
    color: white;
}

img {
    height: 80px;
    width: 80px;
    border-radius: 50px;
    margin: 10px;
}

li {
    list-style: none;
    margin: 10px;
}

.poppins {
    font-family: 'Poppins', sans-serif;
}

.well {
    margin-left: 10%;
    margin-right: 10%;
    margin-bottom: 0;
}

.twitch-well {
    background-color: rgba(0, 0, 0, 0.1);
    border-radius: 30px;
    width: 95%;
    margin: 0 auto;
    margin-left: 0%;
    margin-right: 0%;
    padding-bottom: 1px;
}


.center {
    margin: 0 auto;
    text-align: center;
}

.left {

    width: 100%;
    text-align: left;
}

.tab {
    overflow: hidden;
    border: 1px solid #ccc;
    background-color: #f1f1f1;
}

.tab button {
    background-color: inherit;
    border: none;
    outline: none;
    cursor: pointer;
    padding-bottom: 14px;
    padding-top: 14px;
    transition: 0.3s;
    width: 100%;
}

.tab button:hover {
    background-color: #ddd;
}

.tab button.active {
    background-color: #ccc;
}

.tabcontent {
    display: none;
    padding: 6px 12px;
    border-top: none;
}

.channel-description {
    font-size: 2.5vmin;
}

.channel-status {
    font-size: 2.5vmin;
}

.twitch-name {
    font-size: 5vmin;
}
              
            
!

JS

              
                       var emptyArr = [];

       // OnError handler for missing images
       function fallbackTwitchIcon(_this) {
         var twitchMissingIcon = 'https://www.eglsf.info/wp-content/uploads/image-missing.png';
         _this.src = twitchMissingIcon;
       }

       // Tabs Setup
       function openTab(evt, tabName) {
           // Variables
           var i, tabcontent, tablinks;
           // Get all elements with class="tabcontent" and hide them  
           tabcontent = document.getElementsByClassName("tabcontent");
           for (i = 0; i < tabcontent.length; i++) {
               tabcontent[i].style.display = "none";
           }
           // Get all elements with class="tablinks" and remove the class "active"
           tablinks = document.getElementsByClassName("tablinks");
           for (i = 0; i < tablinks.length; i++) {
               tablinks[i].className = tablinks[i].className.replace(" active", "");
           }
           // Show the current tab, and add an "active" class to the button that opened the tab
           document.getElementById(tabName).style.display = "block";
           evt.currentTarget.className = +" active";
       }
       // JSON Request
       $(document).ready(function() {
           var test;
           var fccArray = ["ESL_SC2", "OgamingSC2", "cretetion", "freecodecamp", "storbeck", "habathcx", "RobotCaleb", "noobs2ninjas"];
           // All Array  
           var resultArrJoin;
           // Online Array  
           var emptyOnlineArr = [];
           var resultOnlineArrJoin;
           // Offline Array  
           var emptyOfflineArr = [];
           var resultOfflineArrJoin;
           // Twitch Variables
           var onlineOfflineStatus;
           var twitchName;
           var twitchStreamURL;
           var twitchGame;
           var twitchIcon;

           for (i = 0; i < fccArray.length; i++) {
               ajaxRequest(fccArray[i]);
           }

           function ajaxRequest(arr) {
               $.ajax({
                   type: 'GET',
                   url: "https://wind-bow.glitch.me/twitch-api/streams/" + arr,
                   dataType: 'jsonp',
                   success: function(twitchData) {
                       if (twitchData.stream === null) {
                           $.ajax({
                               type: 'GET',
                               url: "https://wind-bow.glitch.me/twitch-api/channels/" + arr,
                               dataType: 'jsonp',
                               success: function(twitchChannelData) {
                                   twitchName = arr;
                                   onlineOfflineStatus = "<span style=\"color: red; font-size: 4vmin;\"> &#10005; </span>";
                                   twitchStreamURL = twitchChannelData.url;
                                   twitchGame = "";
                                   twitchIcon = twitchChannelData.logo;
                                   if (!twitchIcon) {
                                    twitchIcon = twitchMissingIcon;
                                   }
                                   // Offline Tab   
                                   emptyOfflineArr.push("<div class=\"twitch-well wrapper\">" + "<a href=" + twitchStreamURL + " target=\"_blank\">" + "<li>" + "<img onerror='fallbackTwitchIcon(this)' src =" + twitchIcon + " alt=\"Twitch Icon\">" + "<span class=\"twitch-name\">" + twitchName + "</span>" + "&nbsp;" + "<span class=\"channel-status\">" + onlineOfflineStatus + "</span>" + "<br>" + "<div class=\"channel-description\">" + "<span style=\"margin-left: 28px;\">" + twitchGame + "</span>" + "</div>" + "</li>" + "</a>" + "</div>");
                                   resultOfflineArrJoin = emptyOfflineArr.join('');
                                   document.getElementById("Offline-list").innerHTML = resultOfflineArrJoin;
                                   // Offline section of the "All" tab     
                                   emptyArr.push("<div class=\"twitch-well\">" + "<a href=" + twitchStreamURL + " target=\"_blank\">" + "<li>" + "<img onerror='fallbackTwitchIcon(this)' src =" + twitchIcon + " alt=\"Twitch Icon\">" + "<span class=\"twitch-name\">" + twitchName + "</span>" + "&nbsp;" + "<span class=\"channel-status\">" + onlineOfflineStatus + "</span>" + "<br>" + "<div class=\"channel-description\">" + "<span style=\"margin-left: 28px;\">" + twitchGame + "</span>" + "</div>" + "</li>" + "</a>" + "</div>");
                                   // All tab   
                                   resultArrJoin = emptyArr.join('');
                                   document.getElementById("All-list").innerHTML = resultArrJoin;
                               }
                           });
                       } else {
                           twitchName = arr;
                           onlineOfflineStatus = "<span style=\"color: green; font-size: 4vmin;\"> &#10003; </span>";
                           twitchStreamURL = twitchData.stream.channel.url;
                           twitchGame = twitchData.stream.channel.game;
                           twitchIcon = twitchData.stream.channel.logo;
                           if (!twitchIcon) {
                            twitchIcon = twitchMissingIcon;
                           }
                           // Online Tab           
                           emptyOnlineArr.push("<div class=\"twitch-well\">" + "<a href=" + twitchStreamURL + " target=\"_blank\">" + "<li>" + "<img onerror='fallbackTwitchIcon(this)' src =" + twitchIcon + " alt=\"Twitch Icon\">" + "<span class=\"twitch-name\">" + twitchName + "</span>" + "&nbsp;" + "<span class=\"channel-status\">" + onlineOfflineStatus + "</span>" + "<br>" + "<div class=\"channel-description\">" + "<span style=\"margin-left: 28px;\">" + twitchGame + "</span>" + "</div>" + "</li>" + "</a>" + "</div>");
                           resultOnlineArrJoin = emptyOnlineArr.join('');
                           document.getElementById("Online-list").innerHTML = resultOnlineArrJoin;
                           // Online section of "All" category      
                           emptyArr.push("<div class=\"twitch-well\">" + "<a href=" + twitchStreamURL + " target=\"_blank\">" + "<li>" + "<img onerror='fallbackTwitchIcon(this)' src =" + twitchIcon + " alt=\"Twitch Icon\">" + "<span class=\"twitch-name\">" + twitchName + "</span>" + "&nbsp;" + "<span class=\"channel-status\">" + onlineOfflineStatus + "</span>" + "<br>" + "<div class=\"channel-description\">" + "<span style=\"margin-left: 28px;\">" + twitchGame + "</span>" + "</div>" + "</li>" + "</a>" + "</div>");
                       }
                   }
               });
           }
       });
              
            
!
999px

Console