Emoji Ajax Type Ahead
How do I make an emoji ajax type ahead?
Ajax type ahead emoji search using the fabulous Fetch API. It started as my own spin on Wes Bos' JS30 Ajax Type Ahead screencast. What followed was my desire to jump on the Codepen emoji bandwagon!. What is a emoji ajax type ahead? How do you make a emoji ajax type ahead? This script and codes were developed by Tobi Weinstock on 19 December 2022, Monday.
Emoji Ajax Type Ahead - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Emoji Ajax Type Ahead</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <svg xmlns="http://www.w3.org/2000/svg" version="1.1"> <pattern id="pattern" x="0" y="0" width="210" height="210" patternUnits="userSpaceOnUse" > <text class='emoji-pattern' x="0" y="100" width="80" font-size="80">
Emoji Ajax Type Ahead - Script Codes CSS Codes
@import url(https://fonts.googleapis.com/css?family=Francois+One);
body { background-color: #393E41; color: #F6F7EB; overflow-x: hidden; font-size: 100%; font-family: 'Francois One', Helvetica, Arial, sans-serif;
}
svg { position: absolute; top: 0; width: 100%; height: 100%; z-index: -1;
}
section { min-width: 600px;
}
text { opacity: 0.7;
}
h1, h2, p { text-align: center; color: #F6F7EB; font-size: 4em; line-height: 1; margin: 20px 0 0; text-shadow: 0px 5px 15px #393E41;
}
h2 { font-size: 2.5em;
}
p { font-size: 1.5em;
}
.search-form { padding-top: 5vh; text-align: center; position: relative;
}
input { background-color: #F6F7EB; font-size: 15px; padding: 20px; width: 40%; border: 1px solid #F6F7EB; border-radius: 5px;
}
.emoji-container { height: 40vh; overflow-y: scroll; background-color: #F6F7EB; width: 50%; margin: 0 auto; border-radius: 5px; margin-top: 5vh; padding: 25px;
}
ul { margin: 0; padding: 0; text-align: left;
}
li { list-style: none; padding: 0 15px 5px 0; width: 40px; display: inline; font-size: 35px;
}
abbr { text-decoration: none; cursor: pointer; font-family: Times;
}
abbr[title="undefined"] { display: none;
}
Emoji Ajax Type Ahead - Script Codes JS Codes
'use strict';
var endpoint = 'https://raw.githubusercontent.com/github/gemoji/master/db/emoji.json';
var emojis = [];
var searchInput = document.querySelector('.search');
var suggestions = document.querySelector('.suggestions');
var emojiPattern = Array.from(document.querySelectorAll('.emoji-pattern'));
fetch(endpoint).then(function (blob) { return blob.json();
}).then(function (data) { return emojis.push.apply(emojis, data);
}).then(setTimeout(function () { renderMatches(emojis);
}, 100)).catch(function (err) { console.log(err);
});
function findMatches(wordToMatch, emojis) { return emojis.filter(function (emoji) { return emoji.aliases.some(function (alias) { return alias.indexOf(wordToMatch) !== -1; }); });
}
function renderMatches(arr) { var html = arr.map(function (emo) { var emoji = emo.emoji; var description = emo.description; return '\n <li class="icon">\n <abbr title="' + description + '">' + emoji + '</abbr>\n </li>\n '; }).join(''); suggestions.innerHTML = html;
}
function updateMatches() { var matchArray = findMatches(this.value, emojis); renderMatches(matchArray);
}
function changeBackground(e) { if (!e.target.matches('abbr')) return; var emoj = e.target.innerText; emojiPattern.map(function (pattern) { return pattern.textContent = emoj; });
}
searchInput.addEventListener('change', updateMatches);
searchInput.addEventListener('keyup', updateMatches);
suggestions.addEventListener('click', changeBackground);
Developer | Tobi Weinstock |
Username | tvweinstock |
Uploaded | December 19, 2022 |
Rating | 4.5 |
Size | 4,619 Kb |
Views | 22,264 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
Paparazzi Drone | 2,608 Kb |
React Tabs | 3,970 Kb |
Love for Paris | 2,502 Kb |
Liz Lemon Valentine | 3,538 Kb |
Google Maps Practice Pen | 2,221 Kb |
French Words | 4,348 Kb |
V Day Countdown | 3,467 Kb |
Halloween Tooltips | 4,977 Kb |
Keep Ya Head Up | 2,532 Kb |
A Pen by Tobi Weinstock | 3,159 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
Underlined form fields | Mitchdot | 2,323 Kb |
Right Click Menu | Anodpixels | 2,252 Kb |
A Pen by Final Boss tommyb9 | FBtommyb9 | 55,354 Kb |
Fluid Layout with Float | Jxqr97 | 1,785 Kb |
Twitch JSON API | Jvhti | 2,808 Kb |
Clock with full screen background | Owebboy | 2,415 Kb |
APortfolio | Skybutterfly | 5,174 Kb |
Simple animated hover effect | Pobee-norris | 3,044 Kb |
Waveform function for a siren tone modulation | Clafou | 1,656 Kb |
CSS3 Latte Art Logo | Esambino | 2,036 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!