A unique take on the Twitch.tv app


Hey guys,

First project that I felt had a good design and interesting interaction, so I’d like a little feedback if possible. I’ve been adding to it here and there as I feel needed :slight_smile:

EDIT2: On recommendation, I’ve added a few features:

-Enter will now work with the search bar
-An alert pops up if you try to add an existing streamer
-There is an animation for adding or removing a streamer, which is now very smooth thanks to rmdawson71!
-If a streamer does not exist you get an alert




Hi Bill,

I do like the direction you have taken with the Twitch.tv app. I would like to make two suggestions which would improve the user experience.

  1. It would be great if the search worked when pressing the Enter key as well as clicking the Go button

  2. If I enter a name that does not exist, I think it would be better to have a message appear letting the visitor know there is no such streamer. You do that currently, but it creates an entry that the user must click to remove the streamer. I think a message dialogue that has a simple “Close” or “X” on it is. To me, only valid streamers should show up after a search is performed.

EDIT: I have one more suggestion.

  1. Since you have a Sort dropdown, why not sort by streamer name within each category. If someone selects All, then you could either sort by category first and then my streamer name or just overall by streamer name. Just my 2 cents worth.


Thanks for the feedback. I instinctively hit enter myself and hadn’t gotten around to making that happen, haha.

The message with an X would be much better I agree. I’ll implement that.

And I’ll optimize the sort menu as well.


I would strongly suggest only using alert() for debugging purposes only. My suggestion is to create a div (hidden by default) with a place holder for the error message you want to display. When you want to display the error, you can change out the html inside of this div with the applicable error message. This div will have a z-index of 1 so it will sit on top of your app until you click “close” or some other button. Then you will add an onclick handler for the “close” button which will change the css of the div back to display:none;.


Will do, thanks again.


To get the effect you are looking for when removing a streamer, replace the following:

          $(".remove").click(function() {
            $(this).slideUp("slow", function() {


          $(".remove").click(function() {
            $(this).parent().parent().parent().slideUp("slow", function() {

UPDATE: Below is another option for the remove if you were to add a data-user attribute which was the same as user-id variable to the button like below:

<button data-user='" + user_id + "' class='btn btn-secondary btn-sm remove'>Remove streamer</button>

then your $(".remove").click(function() would look like:

          $(".remove").click(function() {
            $("#" + $(this).attr("data-user")).slideUp("slow", function() {


Added your last option and it looks beautiful now. Thanks for all your help.


How about adding a stand alone function to handle displaying the error message instead of duplicating all that code:

function showError(user_id,message) {
    "<button type='button' id='close_button' class='close' data-dismiss='alert' aria-label='Close'><span aria-hidden='true'>&times;</span></button><strong>Whoops!</strong> " + message);
        $("#alert_box").css("display", "block");
        $("#close_button").on("click", function() {
          $("#alert_box").css("display", "none");
    //    $("#user_input").val("");  if you clear the input, someone can not just fix a typo

Then you can call the function with:

showError(user_id, "That streamer's already been added");


showError(user_id, "No such streamer");


Yes, one thing I learned was that if you need to use a bit of code more than once, you should probably use a function :slight_smile:

It works good.


HTML validator shows following errors:

Attribute “;” not allowed on element “div” at this point.

<div class="btn-group";>

The element “button” must not appear as a descendant of the “a” element.

<a href="https://..." target="_blank"><button class="btn ...

The “aria-labelledby” attribute must point to an element in the same document.

<div class="dropdown-menu dropdown-menu-right" aria-labelledby="dropdownMenu2">

It’s not recommended to use ids in CSS - they have a high specificity. Reserve them for JS and use classes for styling.

You should cache your jQuery selectors. Here

$('#alert_box').css('display', 'block');
    $('#close_button').on('click', function() {
      $('#alert_box').css('display', 'none');

jQuery each time searches the DOM for #alert_box. Save it to variable and use it (const alertBox = $('#alert_box') and then use it like alertBox.css(do stuff))

Also if you wrap input element in a form, you don’t have to do if (e.keyCode == 13), you’ll get submit on enter for free :wink:


Thanks for the pointers. I’ve been optimizing it a bunch, so some stuff might have stuck around when I didn’t mean for it to be there. :smiley:

Overall, this has improved quite a bit in the past couple of day’s so I’m quite happy with all the feedback so far.

Added your suggestions, I appreciate learning ways to simplify my code (such as saving an annoying to type jQuery request as an easy variable).


You can also chain in jQuery.

alertBox.css("display", "none");

is the same as

alertBox.css("display", "none").html("");


Good point. I’ve been using the dot chains a lot lately all over the place so I’ll keep them in mind.


In JS variables usually use camelCase: var twitchApiUser instead of var twitch_api_user.

HTML has select element for dropdown lists. It has onchange event.

You can use it like this:

      <select name="Sort" id="dropdown">
        <option class="dropdown-item" id="all" value="all">Show all</option>
        <option class="dropdown-item" id="online" value="online">Online</option>
        <option class="dropdown-item" id="offline" value="offline">Offline</option>

JS (without jQuery):

  document.getElementById('dropdown').addEventListener('change', handleFilter);

  function handleFilter(e) {
    console.log(e.target.value); // here you'll have selected value

Then if you save your list of users in an array, you can iterate over it and filter out results to show on the page.

Also as a challenge you could re-write your app without using jQuery and Bootstrap :slight_smile:


Thanks. It’s been a habit naming things a certain way from Python so I’m still getting the etiquette down lol. I definitely want to be good at vanilla JS so that’s a solid idea.