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

              
                <html>

<body style="background-color:#7D0552">

  <div class="container-fluid  main_page">
    <div class="btn-group">
      <button class="btn btn-secondary btn-sm" type="button" aria-haspopup="true" aria-expanded="false"><a href="https://m.twitch.tv" target="_blank">
   <img class="img-fluid"  alt="Twitch Logo"  src="https://www.seeklogo.net/wp-content/uploads/2016/08/twitch-logo-preview.png"/>
         </a> </button>
      <button type="button" class="btn btn-sm btn-secondary dropdown-toggle dropdown-toggle-split" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Sort
    <span class="sr-only">Toggle Dropdown</span>
  </button>
      <div class="dropdown-menu dropdown-menu-right">
        <button class="dropdown-item" type="button" id="all">All</button>
        <button class="dropdown-item" type="button" id="online">Online</button>
        <button class="dropdown-item" type="button" id="offline">Offline</button>
      </div>
    </div>

    <div class="input-group input_bar">
      <input type="text" class="form-control" id="user_input" placeholder="Enter a streamer" aria-label="Text input with dropdown button">
      <div class="input-group-btn">
        <button type="button" class="btn btn-md btn-secondary" id="player">Go
        </button>
      </div>
    </div>
    <div class="alert alert-warning alert-dismissible alert_box" role="alert">
    </div>
    <div id="display"></div>
  </div>


</body>

</html>
              
            
!

CSS

              
                .remove {
  margin-left: auto;
  margin-right: auto;
}

button:hover {
  cursor: pointer;
}

.online_text {
  color: green;
}

.offline_text {
  color: red;
}

.alert_box {
  display: none;
}

.streamerInfo {
  font-size: 20px;
}

.main_page {
  max-width:550px;
  padding: 0 0 0 0;
  margin-top:20px;
}

.input_bar {
   margin: 20px 0 20px 0;
}

.user_box {
  background-color: #565051;
  color: white;
  padding: 10px;
  border-radius: 20px;
  margin-bottom: 20px;
  text-align: left;
}

.userLogo {
  box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);
  height: 125px;
  margin-bottom: -20px;
}

@media (max-width: 600px) {
  .user_box {
    text-align: center;
      margin: 20px 20px 20px 20px;
  }
}

              
            
!

JS

              
                $(document).ready(function() {
  $(".dropdown-toggle").dropdown();

  //function for error display
  function showError(user_id, message) {
    const alertBox = $('.alert_box')
    alertBox.html(
      "<button type='button' class='close' data-dismiss='alert' aria-label='Close'><span aria-hidden='true'>&times;</span></button><strong>Whoops!</strong> " +
        message
    );
    alertBox.css("display", "block");
    $(".close").on("click", function() {
     alertBox.css("display", "none").html("");
    });
  }

  //call function to add a new streamer
  function add_streamer() {
    //set variables for input bar and APIs
    var user_id = $("#user_input").val();
    var twitch_api_user =
      "https://wind-bow.glitch.me/twitch-api/users/" + user_id;
    var twitch_api_stream =
      "https://wind-bow.glitch.me/twitch-api/streams/" + user_id;

    //gets JSON info from the twitch API
    $.getJSON(twitch_api_stream, function(data) {
      //if the user entered a streamer that exists an error appears
      if ($("#" + user_id).length == 1) {
        showError(user_id, "You've already added this streamer");
        //if theres no stream information, the user is offline
      } else if (data.stream === null) {
        //gets JSON info for the offline user
        $.getJSON(twitch_api_user, function(data) {
          //if there is no such user an error appears
          if (data.error === "Not Found") {
            showError(user_id, "No such streamer exists");
            //if it is a valid ID it displays their information in a new div
          } else {
            $("#user_input").val("");
            $("#display").prepend(
              "<div id='" + user_id + "' style='display:none;'></div>"
            );
            $("#" + user_id)
              .prepend(
                "<div class='container stream_offline user_box'>" +
                  "<div class='row'>" +
                  "<div class='col-sm-4'>" +
                  "<a href='https://m.twitch.tv/" +
                  data.name +
                  "' target='_blank'>" +
                  "<img class='img-fluid rounded-circle userLogo circle' alt='' src='" +
                  data.logo +
                  "'/></a></div>" +
                  "<br>" +
                  "<div class='col-sm-8'><p class='streamerInfo'><strong>" +
                  data.display_name +
                  "</strong>" +
                  "<br>Stream <span class='offline_text'>offline</span></p></div><br><button data-user='" +
                  user_id +
                  "' class='btn btn-secondary btn-sm remove'>Remove streamer</button></div></div>"
              )
              .slideDown("slow");
          }
          //button removes streamer from list
          $(".remove").click(function() {
            $("#" + $(this).attr("data-user")).slideUp("slow", function() {
              this.remove();
            });
          });
        });
      } else {
        //if user is online, gets stream information
        $.getJSON(twitch_api_stream, function(data) {
          //adds new div with stream information
          $("#user_input").val("");
          $("#display").prepend(
            "<div id='" + user_id + "' style='display:none;'></div>"
          );
          $("#" + user_id)
            .prepend(
              "<div class='container stream_online user_box'>" +
                "<div class='row'>" +
                "<div class='col-sm-4'>" +
                "<a href='https://m.twitch.tv/" +
                data.stream.channel.name +
                "'target='_blank'>" +
                "<img class='img-fluid userLogo rounded-circle' alt='' src='" +
                data.stream.channel.logo +
                "'/></a></div>" +
                "<br>" +
                "<div class='col-sm-8'><p class='streamerInfo'><strong>" +
                data.stream.channel.display_name +
                "</strong>" +
                "<br>Stream <span class='online_text'>online</span>" +
                "<br>Playing: " +
                data.stream.game +
                "</p></div><br><button data-user='" +
                user_id +
                "' class='btn btn-secondary btn-sm remove'>Remove streamer</button></div></div>"
            )
            .slideDown("slow");
          //button to remove streamer
          $(".remove").click(function() {
            $("#" + $(this).attr("data-user")).slideUp("slow", function() {
              this.remove();
            });
          });
        });
      }
    });
  }
  //in sort dropdown to show all streamers
  $("#all").on("click", function() {
    $(".stream_offline").show();
    $(".stream_online").show();
  });
  //in sort dropdown to only show online
  $("#online").on("click", function() {
    $(".stream_offline").hide();
    $(".stream_online").show();
  });
  //in sort dorpdown to only show offline
  $("#offline").on("click", function() {
    $(".stream_online").hide();
    $(".stream_offline").show();
  });
  //clicking Go will run this function
  $("#games").on("click", function() {});
  $("#player").on("click", function() {
    add_streamer();
  });
  //allows enter to use Go button
  $(document).bind("keypress", function(e) {
    if (e.keyCode == 13) {
      $("#player").trigger("click");
    }
  });
});

              
            
!
999px

Console