Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make changes on filter category function #192

Open
wants to merge 1 commit into
base: gh-pages
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions emoji/CNAME
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
emoji.muan.co
25 changes: 25 additions & 0 deletions emoji/CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# CONTRIBUTING

Thanks for thinking about contributing to this project. :heart_eyes:

## What do you want to do?

#### JavaScript changes

Change the files in `/javascripts`.

#### CSS changes

The CSS is currently compiled from SCSS, so you will need to install and develop in SASS, then include the compiled CSS file in your commits.

## Coding Style

When in doubt, follow https://github.com/styleguide.

## Commiting, sending the pull request

- Make sure you have a good description in the pull request if your changes contain more than keyword changes.<br>
:x: `Update html`<br>
:o: `Change a typo in the toggle text button`

- Include at least one emoji in your pull request description.
21 changes: 21 additions & 0 deletions emoji/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2014 Mu-An Chiou

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
20 changes: 20 additions & 0 deletions emoji/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
## Emoji finder [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://github.com/feross/standard)

:heart: me some emoji. Go to https://emoji.muan.co/

![unicorn](http://cl.ly/image/1p110H2M0r0O/unicorn.gif)

:octopus: :zap: :cat: = :octocat:<br />
Find the emoji that echoes your heart using keywords

:raised_hands::gun::moneybag::police_car::boom::hospital::syringe::skull:<br />
Tell a story

:oden::spaghetti::cookie::stew::ice_cream::icecream::sushi::curry::custard::dango::pizza::ramen::fried_shrimp::fries::chocolate_bar::hamburger:<br />
View emoji in groups and food-attack hungry people

#### Please contribute :pray:

**As of 2015/07/10, the emoji keyword library has been migrated to its own repository [muan/emojilib](https://github.com/muan/emojilib).**

There are almost 900 emoji, more keywords let you find emoji more easily. Go to [`emojis.json`](https://github.com/muan/emojilib/blob/master/emojis.json) for the list of emoji & keywords.
Binary file added emoji/appicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added emoji/fav.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
95 changes: 95 additions & 0 deletions emoji/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link href='/fav.png' rel='shortcut icon'>
<meta content="width=device-width, initial-scale=1.0, user-scalable=no" name="viewport">
<meta content="Emoji searcher" property="og:title">
<meta content="Emoji searcher" property="title">
<meta content="Find the emoji that echoes your heart using keywords! No need to remember all the names of emoji." property="description">
<meta content="Find the emoji that echoes your heart using keywords! No need to remember all the names of emoji." property="og:description">
<meta content="https://emoji.muan.co/appicon.png" property="og:image">
<link rel="search" type="application/opensearchdescription+xml" href="/opensearch.xml" title="Emoji searcher" />
<title>Emoji searcher</title>
<link rel="apple-touch-icon-precomposed" sizes="64x64" href="/appicon.png">
<link href="stylesheets/style.css" rel="stylesheet">
<script>
if(location.hostname === "muan.co") {
location.href = "https://emoji.muan.co/" + location.hash
}
</script>
</head>

<body>
<header class="site-header">
<button type="button" class="button pull-right js-twemoji">Twemoji</button>
<button type="button" class="button pull-right js-remove-twemoji">Remove Twemoji</button>
<input type="search" class="input-search speedy-filter" placeholder="Search" autofocus aria-label="Search emoji">
<a href="#" class="button js-clear-search clear-search">❌</a>
<a href="#face" class="mojigroup button">
😃
</a>
<a href="#fingers" class="mojigroup button">
🤚
</a>
<a href="#animal" class="mojigroup button">
🐤
</a>
<a href="#transportation" class="mojigroup button">
🚗
</a>
<a href="#food" class="mojigroup button">
🍱
</a>
<a href="#building" class="mojigroup button">
🏫
</a>
<a href="#arrow" class="mojigroup button">
⬆️
</a>
<a href="#chinese" class="mojigroup button">
🈳
</a>
<a href="#numbers" class="mojigroup button">
1️⃣
</a>
<a href="#flag" class="mojigroup button">
🏳️‍🌈
</a>


</header>

<main class="list">
<ul class="emojis-container">
</ul>

<div class="loading">
Loading
<noscript>but not really, becasue this needs JavaScript.</noscript>
</div>

<div class="no-results">
<span class="text-big">😭</span>
<br><div class="no-results-text">No results</div>
<p>
Help your future self by adding
<strong class="keyword"></strong>
to the library.
</p>
<p>
<a class="button js-contribute contribute-button" href="https://github.com/muan/emojilib/edit/master/emojis.json" target="_blank">Contribute to emojilib</a>
</p>
</div>
</main>

<footer class="site-footer">
<a href="https://twitter.com/muanchiou" target="_blank">@muanchiou</a> |
<a href="https://github.com/muan/emoji/" target="_blank">Site source</a> |
<a href="https://github.com/muan/emojilib" target="_blank">Data source</a>
</footer>
<script type="text/javascript" src="javascripts/stuff.js"></script>
<script type="text/javascript" src="javascripts/search.js"></script>
</body>
</html>
54 changes: 54 additions & 0 deletions emoji/javascripts/search.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
var filter = document.querySelector('.speedy-filter')

function searchHash() {
if (window.location.hash.length) {
filter.value = window.location.hash.substr(1)
search(filter.value)
} else {
search()
}
}
document.addEventListener('emoji:ready', searchHash)

function search (keyword) {
keyword = typeof keyword === 'undefined' ? '' : keyword
document.querySelector('.keyword').textContent = keyword
keyword = keyword.trim()

if (window.speedyKeyword !== keyword) {
window.speedyKeyword = keyword
for (const result of document.querySelectorAll('.result')) {
result.hidden = keyword.length > 0 ? result.getAttribute('title').toLowerCase().indexOf(keyword.toLowerCase()) < 0 : false
}
}
setRelatedDOMVisibility(keyword)
}

function setRelatedDOMVisibility (keyword) {
var foundSomething = !!document.querySelector('.result:not([hidden])')
document.querySelector('.no-results').hidden = foundSomething
}

function updateHashWithInputValue() {
window.location.hash = filter.value.replace(' ', '_')
}

filter.addEventListener('input', updateHashWithInputValue)

document.addEventListener('click', event => {
if (event.target.classList.contains('group')) {
filter.value = event.target.href.substr(1)
search(filter.value)
} else if (event.target.classList.contains('js-clear-search')) {
filter.value = ''
}
})

window.onhashchange = function () {
searchHash()
for (const link of document.querySelectorAll('.active[href^="#"]')) {
link.classList.remove('active')
}
var active = document.querySelector("[href='#{window.location.hash}']")
if (active) active.classList.add('active')
}
72 changes: 72 additions & 0 deletions emoji/javascripts/stuff.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/* global $, localStorage */
var searchField = document.querySelector('.input-search')
var container = document.querySelector('.emojis-container')
var url = '//unpkg.com/emojilib@^3.0.0'

document.addEventListener('click', function (evt) {
const emoji = evt.target.closest('.js-emoji')
if (emoji) {
getSelection().removeAllRanges()
var range = document.createRange()
const node = emoji.querySelector('.js-emoji-char')
range.selectNodeContents(node)
getSelection().addRange(range)
document.execCommand('copy')
alertCopied(node.getAttribute('data-emoji'))
} else if (evt.target.classList.contains('js-twemoji')) {
prepareTwemoji()
evt.target.hidden = true
document.querySelector('.js-remove-twemoji').hidden = false
localStorage.setItem('twemoji-display', 'true')
} else if (evt.target.classList.contains('js-remove-twemoji')) {
localStorage.setItem('twemoji-display', 'false')
window.location.reload()
}
})

function prepareTwemoji () {
var twemojiScript = document.createElement('script')
twemojiScript.src = '//twemoji.maxcdn.com/2/twemoji.min.js?2.2.3'
twemojiScript.onload = function () {
twemoji.parse(document.body)
document.body.classList.add('twemojified')
}
document.head.append(twemojiScript)
}

function alertCopied (emoji) {
var alert = document.createElement('div')
alert.classList.add('alert')
alert.textContent = `Copied ${emoji}`
document.body.append(alert)
setTimeout(function() {
alert.remove()
}, 1000)
}

document.addEventListener('keydown', event => {
if (event.key === '/' && searchField) {
if (searchField.value.length) {
searchField.selectionStart = 0
searchField.selectionEnd = searchField.value.length
}
searchField.focus()
event.preventDefault()
}
})

const showingTwemoji = localStorage.getItem('twemoji-display') === 'true'
document.querySelector('.js-remove-twemoji').hidden = !showingTwemoji
document.querySelector('.js-twemoji').hidden = showingTwemoji

fetch(url).then(data => data.json()).then(json => {
var html
if (showingTwemoji) prepareTwemoji()
for (emoji in json) {
html += `<li class="result emoji-wrapper js-emoji" title="${json[emoji]}">
<div class="js-emoji-char native-emoji" data-emoji="${emoji}" >${emoji}</div></li>`
}
container.innerHTML = html
document.querySelector('.loading').remove()
document.dispatchEvent(new CustomEvent('emoji:ready'))
})
7 changes: 7 additions & 0 deletions emoji/opensearch.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
<ShortName>Emoji searcher</ShortName>
<Description>Find the emoji that echoes your mind.</Description>
<Image height="64" width="64" type="image/png">https://emoji.muan.co/fav.png</Image>
<Url type="text/html" method="get" template="https://emoji.muan.co/#{searchTerms}"/>
<Url type="application/opensearchdescription+xml" rel="self" template="https://emoji.muan.co/opensearch.xml"/>
</OpenSearchDescription>
Loading