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. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

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 Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

HTML

              
                <div class="container">
  <header>
    <h1>Underscore Awesomeness</h1>
  </header>
  <main>
    <div class="center-block">
      <div id="filter-container" class="col-sm-2 col-md-2 col-lg-2 pull-left">
        <p class="lead">Filter by genre</p>
        <div class="center-block">
          <ul class="list-unstyled">
            <li>
              <button class="btn btn-default" data-filter-field="genres" data-filter-value="album rock" data-action="filter">album rock</button>
            </li>
            <li>
              <button class="btn btn-default" data-filter-field="genres" data-filter-value="blues-rock" data-action="filter">blues-rock</button>
            </li>
            <li>
              <button class="btn btn-default" data-filter-field="genres" data-filter-value="classic rock" data-action="filter">classic rock</button>
            </li>
            <li>
              <button class="btn btn-default" data-filter-field="genres" data-filter-value="rock" data-action="filter">rock</button>
            </li>
            <li>
              <button class="btn btn-default" data-filter-field="genres" data-filter-value="hard rock" data-action="filter">hard rock</button>
            </li>
            <li>
              <button class="btn btn-default" data-filter-field="genres" data-filter-value="british blues" data-action="filter">british blues</button>
            </li>
            <li>
              <button class="btn btn-default" data-filter-field="genres" data-filter-value="pop rap" data-action="filter">pop rap</button>
            </li>
            <li>
              <button class="btn btn-default" data-filter-field="genres" data-filter-value="pop" data-action="filter">pop</button>
            </li>
          </ul>
        </div>
      </div>
      <div class="col-sm-10 col-md-10 col-lg-10 pull-left">
        <p class="lead">Some artists</p>
        <div id="item-container"></div>
      </div>
      <div class="clearfix visible-xs-block"></div>
    </div>
  </main>
  <footer>&copy; 2015 - Sitepoint</footer>
</div>

<!-- Templates -->
<script type="underscore/template" id="item-tpl">
  <div class="row">
    <div class="col-sm-2 col-md-2 col-lg-2">
      <a href="<%= item.href %>" target="blank" title="Go to <%=item.name%> profile.">
				        <img class="img-responsive" src="<%= item.images[1].url %>" alt="<%= item.name %>" />
			      </a>
    </div>
    <div class="col-sm-6 col-md-6 col-lg-6">
      <ul class="list-unstyled">
        <li>
          <a href="<%= item.href %>" target="blank" title="Go to <%=item.name%> profile.">
            <span><%= item.name %></span>
          </a>
        </li>
        <li>
          <small><%= item.followers.total %> followers</small>
        </li>
      </ul>
    </div>
  </div>
</script>
<script type="underscore/template" id="item-list-tpl">
  <ul class="list-unstyled">
    <% _.each(items, function(item) { %>
      <li>
        <%= itemTpl({ item: item }) %>
      </li>
      <% }); %>
  </ul>
</script>
              
            
!

CSS

              
                html,
body {
  color: #FFFFFF;
  background: #000000;
}

.lead {
  color: #84bd00;
}

.row {
  border-bottom: #828282;
  min-width: 400px;
}

.row img {
  max-width: 150px;
  padding-right: 10px
}

a {
  color: #FFFFFF;
}

a:hover,
a:active {
  color: #FFFFFF;
  text-decoration: underline;
}

#item-container >ul >li {
  border-bottom: 1px solid #828282;
  padding: 20px;
}

.btn {
  min-width: 150px;
}
              
            
!

JS

              
                /**
 * Config module
 */
(function(window, document, undefined) {

  if (!window._isAwesome) {
    window._isAwesome = {};
  }

  window._isAwesome.Config = (function() {

    var apiUrl = 'https://api.spotify.com/v1/artists?ids=',
      artistsIds = [
        /**
         * The ones that I love (I know, I'm getting old)
         */
        '36QJpDe2go2KgaRleHCDTp', // Led Zeppelin id
        '711MCceyCBcFnzjGY4Q7Un', // ACDC id
        '22bE4uQ6baNwSHPVcDxLCe', // Rolling Stones id

        /**
         * The ones that are only for this application purposes
         */
        '2RdwBSPQiwcmiDo9kixcl8', // Pharrel Williams id ('cause he's funny)
        '4dpARuHxo51G3z768sgnrY', // Adele ('cause it rhymes with Pharrel)
        '4ZDoy7AWNgQVmX7T0u0B1j', // No te va gustar ('cause they are from my country)
        '0yNSzH5nZmHzeE2xn6Xshb'
      ],

      templates = {
        itemList: '#item-list-tpl',
        item: '#item-tpl'
      };

    return {

      getSearchURL: function() {
        return apiUrl + artistsIds.join(',');
      },

      getTemplates: function() {
        return templates;
      }
    }

  })();

})(window, document);

/**
 * Template module
 */
(function($, _, Config, window, document, undefined) {

  if (!window._isAwesome) {
    window._isAwesome = {};
  }

  window._isAwesome.Template = (function() {

    var config = Config,

      getTemplateContent = function(selector) {
        return $(selector).html();
      };

    return {

      compileTemplates: function() {
        var templates = config.getTemplates(),
          compiledTemplates = {};

        for (templateKey in templates) {
          compiledTemplates[templateKey] = _.template(getTemplateContent(templates[templateKey]));
        }

        return compiledTemplates;
      }
    }

  })();

})(jQuery, _, _isAwesome.Config, window, document);

/**
 * Main module
 */
(function($, _, Config, Template, window, document, undefined) {

  window._isAwesome = (function() {

    var results = [],
      filteredResults = [],

      templates = Template.compileTemplates(),
      itemContainer = $('#item-container'),

      setContent = function(results) {
        return templates.itemList({
          items: results,
          itemTpl: templates.item
        });
      },

      render = function(results) {
        itemContainer.html(setContent(results));
      },

      filter = function(filter) {
        filteredResults = _.filter(results, function(item) {
          return _.indexOf(item[filter.filterField], filter.filterValue) !== -1;
        });

        return filteredResults;
      },

      updateView = function(clicked) {
        clicked
          .closest('ul')
          .find('.active')
          .removeClass('active')
          .end()
          .end()
          .addClass('active');
      },

      bindEvents = function() {
        $('[data-action="filter"]').on('click', function(e) {
          var clicked = $(e.target);

          updateView(clicked);
          filter(clicked.data());
          render(filteredResults);
        });
      },

      getArtists = function() {
        return $.ajax({
          url: Config.getSearchURL(),
          method: 'GET',
          type: 'post',
          contentType: 'applications/json'
        });
      };

    return {

      init: function() {
        getArtists().then(function(data) {
          results = data.artists;

          render(results);
          bindEvents();

        });
      }
    }

  })();

})(jQuery, _, _isAwesome.Config, _isAwesome.Template, window, document);

window._isAwesome.init();
              
            
!
999px

Console