Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added alternative names for search #80

  • Loading branch information...
commit d28665870ef347bb34e6d617be3ceca93cbb6fbf 1 parent ea6a907
@bitboxer bitboxer authored
Showing with 37 additions and 27 deletions.
  1. +9 −9 public/index.html
  2. +28 −18 public/script.js
View
18 public/index.html
@@ -38,7 +38,7 @@
&#x2708; <b>Got flash enabled? Click the emoji code and it will be copied to your clipboard.</b>
</p>
<h2>People</h2>
- <ul class="people" id="emoji-people">
+ <ul class="people emojis" id="emoji-people">
<li><div><img src="graphics/emojis/bowtie.png"> :<span class="name">bowtie</span>:</div></li>
<li><div><img src="graphics/emojis/smile.png"> :<span class="name">smile</span>:</div></li>
<li><div><img src="graphics/emojis/laughing.png"> :<span class="name">laughing</span>:</div></li>
@@ -81,8 +81,8 @@
<li><div><img src="graphics/emojis/fearful.png"> :<span class="name">fearful</span>:</div></li>
<li><div><img src="graphics/emojis/cold_sweat.png"> :<span class="name">cold_sweat</span>:</div></li>
<li><div><img src="graphics/emojis/persevere.png"> :<span class="name">persevere</span>:</div></li>
- <li><div><img src="graphics/emojis/cry.png"> :<span class="name">cry</span>:</div></li>
- <li><div><img src="graphics/emojis/sob.png"> :<span class="name">sob</span>:</div></li>
+ <li><div><img src="graphics/emojis/cry.png"> :<span class="name" data-alternative-name="sad, unhappy">cry</span>:</div></li>
+ <li><div><img src="graphics/emojis/sob.png"> :<span class="name" data-alternative-name="sad, unhappy">sob</span>:</div></li>
<li><div><img src="graphics/emojis/joy.png"> :<span class="name">joy</span>:</div></li>
<li><div><img src="graphics/emojis/astonished.png"> :<span class="name">astonished</span>:</div></li>
<li><div><img src="graphics/emojis/scream.png"> :<span class="name">scream</span>:</div></li>
@@ -164,8 +164,8 @@
<li><div><img src="graphics/emojis/family.png"> :<span class="name">family</span>:</div></li>
<li><div><img src="graphics/emojis/two_men_holding_hands.png"> :<span class="name">two_men_holding_hands</span>:</div></li>
<li><div><img src="graphics/emojis/two_women_holding_hands.png"> :<span class="name">two_women_holding_hands</span>:</div></li>
- <li><div><img src="graphics/emojis/dancer.png"> :<span class="name">dancer</span>:</div></li>
- <li><div><img src="graphics/emojis/dancers.png"> :<span class="name">dancers</span>:</div></li>
+ <li><div><img src="graphics/emojis/dancer.png"> :<span class="name" data-alternative-name="party">dancer</span>:</div></li>
+ <li><div><img src="graphics/emojis/dancers.png"> :<span class="name" data-alternative-name="party">dancers</span>:</div></li>
<li><div><img src="graphics/emojis/ok_woman.png"> :<span class="name">ok_woman</span>:</div></li>
<li><div><img src="graphics/emojis/no_good.png"> :<span class="name">no_good</span>:</div></li>
<li><div><img src="graphics/emojis/information_desk_person.png"> :<span class="name">information_desk_person</span>:</div></li>
@@ -235,7 +235,7 @@
<li><div><img src="graphics/emojis/trollface.png"> :<span class="name">trollface</span>:</div></li>
</ul>
<h2>Nature</h2>
- <ul class="nature" id="emoji-nature">
+ <ul class="nature emojis" id="emoji-nature">
<li><div><img src="graphics/emojis/sunny.png"> :<span class="name">sunny</span>:</div></li>
<li><div><img src="graphics/emojis/umbrella.png"> :<span class="name">umbrella</span>:</div></li>
<li><div><img src="graphics/emojis/cloud.png"> :<span class="name">cloud</span>:</div></li>
@@ -353,7 +353,7 @@
<li><div><img src="graphics/emojis/squirrel.png"> :<span class="name">squirrel</span>:</div></li>
</ul>
<h2>Objects</h2>
- <ul class="objects" id="emoji-objects">
+ <ul class="objects emojis" id="emoji-objects">
<li><div><img src="graphics/emojis/bamboo.png"> :<span class="name">bamboo</span>:</div></li>
<li><div><img src="graphics/emojis/gift_heart.png"> :<span class="name">gift_heart</span>:</div></li>
<li><div><img src="graphics/emojis/dolls.png"> :<span class="name">dolls</span>:</div></li>
@@ -615,7 +615,7 @@
<li><div><img src="graphics/emojis/corn.png"> :<span class="name">corn</span>:</div></li>
</ul>
<h2>Places</h2>
- <ul class="places" id="emoji-places">
+ <ul class="places emojis" id="emoji-places">
<li><div><img src="graphics/emojis/house.png"> :<span class="name">house</span>:</div></li>
<li><div><img src="graphics/emojis/house_with_garden.png"> :<span class="name">house_with_garden</span>:</div></li>
<li><div><img src="graphics/emojis/school.png"> :<span class="name">school</span>:</div></li>
@@ -724,7 +724,7 @@
<li><div><img src="graphics/emojis/de.png"> :<span class="name">de</span>:</div></li>
</ul>
<h2>Symbols</h2>
- <ul class="symbols" id="emoji-symbols">
+ <ul class="symbols emojis" id="emoji-symbols">
<li><div><img src="graphics/emojis/one.png"> :<span class="name">one</span>:</div></li>
<li><div><img src="graphics/emojis/two.png"> :<span class="name">two</span>:</div></li>
<li><div><img src="graphics/emojis/three.png"> :<span class="name">three</span>:</div></li>
View
46 public/script.js
@@ -39,16 +39,6 @@ return version;};var getActiveXObject=function(name){var obj=-1;try{obj=new Acti
return obj;};var parseActiveXVersion=function(str){var versionArray=str.split(",");return{"raw":str,"major":parseInt(versionArray[0].split(" ")[1],10),"minor":parseInt(versionArray[1],10),"revision":parseInt(versionArray[2],10),"revisionStr":versionArray[2]};};var parseStandardVersion=function(str){var descParts=str.split(/ +/);var majorMinor=descParts[2].split(/\./);var revisionStr=descParts[3];return{"raw":str,"major":parseInt(majorMinor[0],10),"minor":parseInt(majorMinor[1],10),"revisionStr":revisionStr,"revision":parseRevisionStrToInt(revisionStr)};};var parseRevisionStrToInt=function(str){return parseInt(str.replace(/[a-zA-Z]/g,""),10)||self.revision;};self.majorAtLeast=function(version){return self.major>=version;};self.minorAtLeast=function(version){return self.minor>=version;};self.revisionAtLeast=function(version){return self.revision>=version;};self.versionAtLeast=function(major){var properties=[self.major,self.minor,self.revision];var len=Math.min(properties.length,arguments.length);for(i=0;i<len;i++){if(properties[i]>=arguments[i]){if(i+1<len&&properties[i]==arguments[i]){continue;}else{return true;}}else{return false;}}};self.FlashDetect=function(){if(navigator.plugins&&navigator.plugins.length>0){var type='application/x-shockwave-flash';var mimeTypes=navigator.mimeTypes;if(mimeTypes&&mimeTypes[type]&&mimeTypes[type].enabledPlugin&&mimeTypes[type].enabledPlugin.description){var version=mimeTypes[type].enabledPlugin.description;var versionObj=parseStandardVersion(version);self.raw=versionObj.raw;self.major=versionObj.major;self.minor=versionObj.minor;self.revisionStr=versionObj.revisionStr;self.revision=versionObj.revision;self.installed=true;}}else if(navigator.appVersion.indexOf("Mac")==-1&&window.execScript){var version=-1;for(var i=0;i<activeXDetectRules.length&&version==-1;i++){var obj=getActiveXObject(activeXDetectRules[i].name);if(!obj.activeXError){self.installed=true;version=activeXDetectRules[i].version(obj);if(version!=-1){var versionObj=parseActiveXVersion(version);self.raw=versionObj.raw;self.major=versionObj.major;self.minor=versionObj.minor;self.revision=versionObj.revision;self.revisionStr=versionObj.revisionStr;}}}}}();};FlashDetect.JS_RELEASE="1.0.4";
/*
- * List.js
- * https://github.com/javve/list
- *
- * Copyright (c) 2012 Jonny Strömberg
- * Released under the MIT license.
- * http://www.opensource.org/licenses/mit-license.php
- */
-(function(a,b){"use strict";var c=a.document,d;var e=function(a,e,f){var g=this,i,j,k,l,m,n,o={updated:[]};this.listContainer=typeof a=="string"?c.getElementById(a):a;if(!this.listContainer)return;this.items=[];this.visibleItems=[];this.matchingItems=[];this.searched=false;this.filtered=false;this.list=null;this.templateEngines={};this.page=e.page||200;this.i=e.i||1;j={start:function(a,b){b.plugins=b.plugins||{};this.classes(b);i=new m(g,b);this.callbacks(b);this.items.start(a,b);g.update();this.plugins(b.plugins)},classes:function(a){a.listClass=a.listClass||"list";a.searchClass=a.searchClass||"search";a.sortClass=a.sortClass||"sort"},callbacks:function(a){g.list=d.getByClass(a.listClass,g.listContainer,true);d.addEvent(d.getByClass(a.searchClass,g.listContainer),"keyup",g.search);n=d.getByClass(a.sortClass,g.listContainer);d.addEvent(n,"click",g.sort)},items:{start:function(a,c){if(c.valueNames){var d=this.get(),e=c.valueNames;if(c.indexAsync){this.indexAsync(d,e)}else{this.index(d,e)}}if(a!==b){g.add(a)}},get:function(){var a=g.list.childNodes,c=[];for(var d=0,e=a.length;d<e;d++){if(a[d].data===b){c.push(a[d])}}return c},index:function(a,b){for(var c=0,d=a.length;c<d;c++){g.items.push(new l(b,a[c]))}},indexAsync:function(a,b){var c=a.splice(0,100);this.index(c,b);if(a.length>0){setTimeout(function(){j.items.indexAsync(a,b)},10)}else{g.update()}}},plugins:function(a){var b={templater:i,init:j,initialItems:k,Item:l,Templater:m,sortButtons:n,events:o,reset:r};for(var c=0;c<a.length;c++){a[c][1]=a[c][1]||{};var d=a[c][1].name||a[c][0];g[d]=g.plugins[a[c][0]].call(g,b,a[c][1])}}};this.add=function(a,c){if(c){p(a,c)}var d=[],e=false;if(a[0]===b){a=[a]}for(var f=0,h=a.length;f<h;f++){var i=null;if(a[f]instanceof l){i=a[f];i.reload()}else{e=g.items.length>g.page?true:false;i=new l(a[f],b,e)}g.items.push(i);d.push(i)}g.update();return d};var p=function(a,b,c){var d=a.splice(0,100);c=c||[];c=c.concat(g.add(d));if(a.length>0){setTimeout(function(){p(a,b,c)},10)}else{g.update();b(c)}};this.show=function(a,b){this.i=a;this.page=b;g.update()};this.remove=function(a,b,c){var d=0;for(var e=0,f=g.items.length;e<f;e++){if(g.items[e].values()[a]==b){i.remove(g.items[e],c);g.items.splice(e,1);f--;d++}}g.update();return d};this.get=function(a,b){var c=[];for(var d=0,e=g.items.length;d<e;d++){var f=g.items[d];if(f.values()[a]==b){c.push(f)}}if(c.length==0){return null}else if(c.length==1){return c[0]}else{return c}};this.sort=function(a,c){var e=g.items.length,f=null,i=a.target||a.srcElement,j="",k=false,l="asc",m="desc",c=c||{};if(i===b){f=a;k=c.asc||false}else{f=d.getAttribute(i,"data-sort");k=d.hasClass(i,l)?false:true}for(var o=0,p=n.length;o<p;o++){d.removeClass(n[o],l);d.removeClass(n[o],m)}if(k){if(i!==b){d.addClass(i,l)}k=true}else{if(i!==b){d.addClass(i,m)}k=false}if(c.sortFunction){c.sortFunction=c.sortFunction}else{c.sortFunction=function(a,b){return d.sorter.alphanum(a.values()[f].toLowerCase(),b.values()[f].toLowerCase(),k)}}g.items.sort(c.sortFunction);g.update()};this.search=function(a,c){g.i=1;var d=[],e,f,h,j,k,c=c===b?g.items[0].values():c,a=a===b?"":a,l=a.target||a.srcElement;a=l===b?(""+a).toLowerCase():""+l.value.toLowerCase();k=g.items;a=a.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&");i.clear();if(a===""){r.search();g.searched=false;g.update()}else{g.searched=true;for(var m=0,n=k.length;m<n;m++){e=false;f=k[m];j=f.values();for(var o in c){if(j.hasOwnProperty(o)&&c[o]!==null){h=j[o]!=null?j[o].toString().toLowerCase():"";if(a!==""&&h.search(a)>-1){e=true}}}if(e){f.found=true;d.push(f)}else{f.found=false}}g.update()}return g.visibleItems};this.filter=function(a){g.i=1;r.filter();if(a===b){g.filtered=false}else{g.filtered=true;var c=g.items;for(var d=0,e=c.length;d<e;d++){var f=c[d];if(a(f)){f.filtered=true}else{f.filtered=false}}}g.update();return g.visibleItems};this.size=function(){return g.items.length};this.clear=function(){i.clear();g.items=[]};this.on=function(a,b){o[a].push(b)};var q=function(a){var b=o[a].length;while(b--){o[a][b]()}};var r={filter:function(){var a=g.items,b=a.length;while(b--){a[b].filtered=false}},search:function(){var a=g.items,b=a.length;while(b--){a[b].found=false}}};this.update=function(){var a=g.items,b=a.length;g.visibleItems=[];g.matchingItems=[];i.clear();for(var c=0;c<b;c++){if(a[c].matching()&&g.matchingItems.length+1>=g.i&&g.visibleItems.length<g.page){a[c].show();g.visibleItems.push(a[c]);g.matchingItems.push(a[c])}else if(a[c].matching()){g.matchingItems.push(a[c]);a[c].hide()}else{a[c].hide()}}q("updated")};l=function(a,c,d){var e=this,f={};this.found=false;this.filtered=false;var h=function(a,c,d){if(c===b){if(d){e.values(a,d)}else{e.values(a)}}else{e.elm=c;var f=i.get(e,a);e.values(f)}};this.values=function(a,c){if(a!==b){for(var d in a){f[d]=a[d]}if(c!==true){i.set(e,e.values())}}else{return f}};this.show=function(){i.show(e)};this.hide=function(){i.hide(e)};this.matching=function(){return g.filtered&&g.searched&&e.found&&e.filtered||g.filtered&&!g.searched&&e.filtered||!g.filtered&&g.searched&&e.found||!g.filtered&&!g.searched};this.visible=function(){return e.elm.parentNode?true:false};h(a,c,d)};m=function(a,c){if(c.engine===b){c.engine="standard"}else{c.engine=c.engine.toLowerCase()}return new g.constructor.prototype.templateEngines[c.engine](a,c)};j.start(f,e)};e.prototype.templateEngines={};e.prototype.plugins={};e.prototype.templateEngines.standard=function(a,e){function j(a){if(a===b){var d=f.childNodes,g=[];for(var h=0,i=d.length;h<i;h++){if(d[h].data===b){return d[h]}}return null}else if(a.indexOf("<")!==-1){var j=c.createElement("div");j.innerHTML=a;return j.firstChild}else{return c.getElementById(e.item)}}var f=d.getByClass(e.listClass,a.listContainer,true),g=j(e.item),i=this;var k={created:function(a){if(a.elm===b){i.create(a)}}};this.get=function(a,b){k.created(a);var c={};for(var e=0,f=b.length;e<f;e++){var g=d.getByClass(b[e],a.elm,true);c[b[e]]=g?g.innerHTML:""}return c};this.set=function(a,b){k.created(a);for(var c in b){if(b.hasOwnProperty(c)){var e=d.getByClass(c,a.elm,true);if(e){e.innerHTML=b[c]}}}};this.create=function(a){if(a.elm!==b){return}var c=g.cloneNode(true);c.id="";a.elm=c;i.set(a,a.values())};this.remove=function(a){f.removeChild(a.elm)};this.show=function(a){k.created(a);f.appendChild(a.elm)};this.hide=function(a){if(a.elm!==b&&a.elm.parentNode===f){f.removeChild(a.elm)}};this.clear=function(){if(f.hasChildNodes()){while(f.childNodes.length>=1){f.removeChild(f.firstChild)}}}};d={getByClass:function(){if(c.getElementsByClassName){return function(a,b,c){if(c){return b.getElementsByClassName(a)[0]}else{return b.getElementsByClassName(a)}}}else{return function(a,b,d){var e=[],f="*";if(b==null){b=c}var g=b.getElementsByTagName(f);var h=g.length;var i=new RegExp("(^|\\s)"+a+"(\\s|$)");for(var j=0,k=0;j<h;j++){if(i.test(g[j].className)){if(d){return g[j]}else{e[k]=g[j];k++}}}return e}}}(),addEvent:function(a,c){if(c.addEventListener){return function(c,e,f){if(c&&!(c instanceof Array)&&!c.length&&!d.isNodeList(c)&&c.length!==0||c===a){c.addEventListener(e,f,false)}else if(c&&c[0]!==b){var g=c.length;for(var i=0;i<g;i++){d.addEvent(c[i],e,f)}}}}else if(c.attachEvent){return function(c,e,f){if(c&&!(c instanceof Array)&&!c.length&&!d.isNodeList(c)&&c.length!==0||c===a){c.attachEvent("on"+e,function(){return f.call(c,a.event)})}else if(c&&c[0]!==b){var g=c.length;for(var i=0;i<g;i++){d.addEvent(c[i],e,f)}}}}}(this,c),getAttribute:function(a,c){var d=a.getAttribute&&a.getAttribute(c)||null;if(!d){var e=a.attributes;var f=e.length;for(var g=0;g<f;g++){if(c[g]!==b){if(c[g].nodeName===c){d=c[g].nodeValue}}}}return d},isNodeList:function(a){var b=Object.prototype.toString.call(a);if(typeof a==="object"&&/^\[object (HTMLCollection|NodeList|Object)\]$/.test(b)&&(a.length==0||typeof a[0]==="object"&&a[0].nodeType>0)){return true}return false},hasClass:function(a,b){var c=this.getAttribute(a,"class")||this.getAttribute(a,"className")||"";return c.search(b)>-1},addClass:function(a,b){if(!this.hasClass(a,b)){var c=this.getAttribute(a,"class")||this.getAttribute(a,"className")||"";c=c+" "+b+" ";c=c.replace(/\s{2,}/g," ");a.setAttribute("class",c)}},removeClass:function(a,b){if(this.hasClass(a,b)){var c=this.getAttribute(a,"class")||this.getAttribute(a,"className")||"";c=c.replace(b,"");a.setAttribute("class",c)}},sorter:{alphanum:function(a,c,d){if(a===b||a===null){a=""}if(c===b||c===null){c=""}a=a.toString().replace(/&(lt|gt);/g,function(a,b){return b=="lt"?"<":">"});a=a.replace(/<\/?[^>]+(>|$)/g,"");c=c.toString().replace(/&(lt|gt);/g,function(a,b){return b=="lt"?"<":">"});c=c.replace(/<\/?[^>]+(>|$)/g,"");var e=this.chunkify(a);var f=this.chunkify(c);for(var g=0;e[g]&&f[g];g++){if(e[g]!==f[g]){var h=Number(e[g]),i=Number(f[g]);if(d){if(h==e[g]&&i==f[g]){return h-i}else{return e[g]>f[g]?1:-1}}else{if(h==e[g]&&i==f[g]){return i-h}else{return e[g]>f[g]?-1:1}}}}return e.length-f.length},chunkify:function(a){var b=[],c=0,d=-1,e=0,f,g;while(f=(g=a.charAt(c++)).charCodeAt(0)){var h=f==45||f==46||f>=48&&f<=57;if(h!==e){b[++d]="";e=h}b[d]+=g}return b}}};a.List=e;a.ListJsHelpers=d})(window)
-
-/*
* Emoji cheat sheet
*/
@@ -87,20 +77,40 @@ $(function() {
});
}
- var listIds = ["people", "nature", "objects", "places", "symbols"];
- var lists = [];
- for (var i = listIds.length - 1; i >= 0; i--) {
- lists[i] = new List("content", { valueNames: ['name'], listClass: listIds[i], page: 1000 });
- };
+ function isElementMatching(element, needle) {
+ var alternative = element.attr("data-alternative-name");
+ return ($(element).text().toLowerCase().indexOf(needle) >= 0) ||
+ (alternative != null && alternative.toLowerCase().indexOf(needle) >= 0);
+ }
+
+ function highlightElements(needle) {
+ if (needle.length == 0) {
+ highlightAll();
+ return;
+ }
+ needle = needle.toLowerCase();
+ $(".emojis li").each(function (index, el) {
+ if (isElementMatching($('.name', el), needle)) {
+ $(el).show();
+ } else {
+ $(el).hide();
+ }
+ });
+ }
+
+ function highlightAll() {
+ $(".emojis li").show();
+ }
$("#header .search").keyup(function(e) {
if (e.keyCode == 27) { // ESC
$(this).val('').blur();
- for (var i = lists.length - 1; i >= 0; i--) {
- lists[i].search('');
- };
+ highlightAll();
}
});
+ $("#header .search").on("change paste keyup", function() {
+ highlightElements($("#header .search").val());
+ });
$("#header .search").focus();
var po = document.createElement('script');
Please sign in to comment.
Something went wrong with that request. Please try again.