css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

Pen Settings

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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

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.

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.

            
              <head>
  <script src="https://cdn.rawgit.com/zenorocha/clipboard.js/v1.5.10/dist/clipboard.min.js"></script>
</head>
<div class="main_content">
<!-- <form class="form-group"> -->
  <div class="form-group">
        <input id="search" type="text" placeholder=":poop: :wink:" class="form-control wdt-emoji-bundle-enabled">
  <div id="result_count">
  </div>
    </div>
<!-- </form> -->
<div class="results_list">
  <p class="loading">Give it a moment. There're a bunch of emoji to load!</p>
  <!--   THIS IS AN EXAMPLE OF WHAT THE JAVASCRIPT CREATES -->
  <!--   <div id="+1" class="result">
    <div class="ec_wrapper">
      <span class="emoji">👍</span>
      <span class="token">:+1:</span> or <span class="token">:thumbsup:</span>
    </div>
    <div class="max_emoji_wrapper">
      <span class="max">10 = Max emoji</span>
      <span>👍👍👍👍👍👍👍👍👍👍</span>
    </div>
  </div> -->
</div>
</div>

<div class="wdt-emoji-popup">
  <a href="#" class="wdt-emoji-popup-mobile-closer"> &times; </a>
  <div class="wdt-emoji-menu-content">
    <div id="wdt-emoji-menu-header">
      <a class="wdt-emoji-tab active" data-group-name="Recent"></a>
      <a class="wdt-emoji-tab" data-group-name="People"></a>
      <a class="wdt-emoji-tab" data-group-name="Nature"></a>
      <a class="wdt-emoji-tab" data-group-name="Foods"></a>
      <a class="wdt-emoji-tab" data-group-name="Activity"></a>
      <a class="wdt-emoji-tab" data-group-name="Places"></a>
      <a class="wdt-emoji-tab" data-group-name="Objects"></a>
      <a class="wdt-emoji-tab" data-group-name="Symbols"></a>
      <a class="wdt-emoji-tab" data-group-name="Flags"></a>
      <a class="wdt-emoji-tab" data-group-name="Custom"></a>
    </div>
    <div class="wdt-emoji-scroll-wrapper">
      <div id="wdt-emoji-menu-items">
        <input id="wdt-emoji-search" type="text" placeholder="Search">
        <h3 id="wdt-emoji-search-result-title">Search Results</h3>
        <div class="wdt-emoji-sections"></div>
        <div id="wdt-emoji-no-result">No emoji found</div>
      </div>
    </div>
    <div id="wdt-emoji-footer">
      <div id="wdt-emoji-preview">
        <span id="wdt-emoji-preview-img"></span>
        <div id="wdt-emoji-preview-text">
          <span id="wdt-emoji-preview-name"></span>
          <br>
          <span id="wdt-emoji-preview-aliases"></span>
        </div>
      </div>

      <div id="wdt-emoji-preview-bundle">
        <span>WDT Emoji Bundle</span>
      </div>
    </div>
  </div>
</div>

<!-- <footer>Made with 🍀 by <a href="https://twitter.com/cmchap">@cmchap</a> in Boston</footer> -->
            
          
!
            
              html,
body {
  height: 100%;
  overflow: hidden;
  margin: 0 0;
  font-family: sans-serif;

}

.main_content {
  height: 100%;
  padding: 20px 20px 0 20px;
}

.form-group {
  width: 100%;
  height: 40px;
}
#search {
  width: 100%;
  height: 2em;
  position: relative;
}
#result_count {
  position: absolute;
  right: 35px;
  top: 4px;
}
.wdt-emoji-picker {
  position: absolute;
  right: 5px;
  top: 3px;
}
.results_list {
  overflow-y: auto;
  overflow-x: hidden;
  height: calc(100% - 61px);
}

.result {
  position: relative;
  margin-bottom: 1em;
  padding: 10px 10px;
}

.result:hover {
  background-color: #EEE;
}

.big_emoji {
  font-size: 2em;
}

.token {
  border: 1px solid #DAD9E3;
  border-radius: 0.25em;
  color: #BE0544;
  background-color: #F5F5F8;
  padding: 0.2em;
  font-family: "Lucida Console", Monaco, monospace;
  margin-left: 0.25em;
}

.copy {
  position: absolute;
  top: 10px;
  right: 10px;
/*   width: 40px; */
  height: 20px;
  line-height: 20px;
  padding: 5px;
  background-color: white;
  border: 1px solid #ccc;
  display: none;
}
.copy:hover {
  cursor: pointer;
  background-color: #ddd;
}
.result:hover .copy, .result.hover .copy {
  display: block;
}
            
          
!
            
              var char_limit = 40; //Keep this around 40 for development. The real 4000 character limit is super slow without asyncronous loading.

var emoji_json; //a placeholder for our JSON file

//get the JSON from the gemoji github page. Served through rawgit so we don't break github's terms of use. 
$.getJSON("https://raw.githubusercontent.com/github/gemoji/master/db/emoji.json", function(json) {
  //find the results list, and save that, since it will be the same for each action below.
  var results_list = $(".results_list");

  //for each sub-item in the json file, do the following function...
  $.each(json, function() {
    //Get the shortest alias, since this is the one that will yeild the highest count.      
    var shortest_alias = this.aliases.sort(function(a, b) {
      return a.length - b.length;
    })[0];

    //calculate the maximum number of descriptions that will fit within a our character limit. The +2 is to include the colons on each end that are not present in the json file. 
    var count = Math.floor(char_limit / (shortest_alias.length + 2));
    //create a result div. Look at the HTML above to see a commented-out version of what this whole section creates. 
    var result = $('<div id="id_' + shortest_alias.replace(/(\-)/g, "minus").replace(/(\+)/g, "plus") + '" class="result"></div>').appendTo(results_list);

    //The result div has three main parts, the emoji code wrapper (ec_wrapper), the max_emoji_wrapper, and a list of aliases/tags for that emoji. 
    var ec_wrapper = $('<div class="ec_wrapper"></div>').appendTo(result);
    //The ec_wrapper has two parts, the emoji, and the code that represents it. 
    var big_emoji = $('<span class="big_emoji">' + this.emoji + '</span>').appendTo(ec_wrapper);

    // add the aliases and any alternates, separated by " or ".
    $('<span class="token">:' + this.aliases[0] + ':</span>').appendTo(ec_wrapper);
    this.aliases.slice(1, this.aliases.length + 1).forEach(function(val) {
      $(document.createTextNode(" or ")).appendTo(ec_wrapper);
      $('<span class="token">:' + val + ':</span>').appendTo(ec_wrapper);
    });

    //max_emoji_wrapper is the second main part of the result.
    var max_emoji_wrapper = $('<div class="max_emoji_wrapper"></div>').appendTo(result);
    //show the number of emoji that will fit within a our character limit. 
    var max = $('<span class="max">' + count + ' = Max emoji</span><br/>').appendTo(max_emoji_wrapper);
    //this is a container for the for loop below
    var max_emoji = $('<span></span>').appendTo(max_emoji_wrapper);
    //add as many emoji to the max_emoji container as will fit within the character limit. 
    var emoji_string = "";
    for (var i = 0; i < count; i++) {
      // max_emoji.append(this.emoji);
      emoji_string += this.emoji;
    }
    max_emoji.text(emoji_string);

    //Make a list of the description and tags, and append that as a hidden element to the result.
    var d_and_t_list = this.description + " " + this.tags.join(" ");
    var description_and_tags = $('<span class="aliases_and_tags">' + d_and_t_list + '</span>').appendTo(result).hide();

    var copy_button = $('<div class="copy">Copy</div>').appendTo(result);

    var copier_string = '#id_' + shortest_alias.replace(/(\-)/g, "minus").replace(/(\+)/g, "plus") + " .copy";
    
    new Clipboard(copier_string, {
      text: function(trigger) {
        $(copier_string).text("Copied!");
        return Array(count + 1).join(':' + shortest_alias + ':');
      }
    });

    result.on("mouseleave", function() {
      copy_button.text("Copy");
    });

    //When all this stuff is loaded, hide the loading text.
    $('.loading').hide();
  });
});

//Search Function modified from http://www.designchemical.com/blog/index.php/jquery/live-text-search-function-using-jquery/
$(document).ready(function() {
  $("#search").on("input", function(ev) {
    search(ev.target);
  });

  function search(self) {

    // Retrieve the input field text and reset the count to zero
    var query = $(self).val(),
      count = 0;

    //Sanitize the query, so it doesn't break our regular expression
    query = query.replace(/\s/g, '');
    query = query.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');

    // Loop through the results list
    $(".results_list .result").each(function() {

      // If the list item does not contain the text phrase hide it
      if ($(this).text().search(new RegExp(query, "i")) < 0) {
        $(this).hide();

        // Show the list item if the phrase matches and increase the count by 1
      } else {
        $(this).show();
        count++;
      }
    });

    // Update the count
    var count_text = "Result"
    if (count > 1) count_text += "s";
    $("#result_count").text(count + " " + count_text);
    if (query == "") {
      $("#result_count").text("");
    }

  }

  //Emoji Picker from http://ned.im/wdt-emoji-bundle/
  (function() {

    wdtEmojiBundle.defaults.emojiSheets = {
      // 'apple': 'https://cdn.rawgit.com/needim/wdt-emoji-bundle/master/sheets/sheet_apple_64.png'
      'apple': 'https://cdn.rawgit.com/needim/wdt-emoji-bundle/master/sheets/sheet_apple_64_indexed_128.png'
      // 'apple': 'https://cdn.rawgit.com/iamcal/emoji-data/a7721c84/sheets-indexed-256/sheet_apple_64_indexed_256.png'
    };

    wdtEmojiBundle.init('.wdt-emoji-bundle-enabled');

  })();
});
            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................

Console