Map a sequence of keypresses to a callback.
cheet.js is a library that listens to key events and invokes a callback if the criteria of your easter egg is met.
npm install cheet.js
cheet('U U D D L R L R b a', function () {
alert('+30 lives');
});
cheet('i d d q d', function () {
alert('god mode enabled');
});
cheet('o n e a t a t i m e', {
next: function (str, key, num, seq) {
console.log('key pressed: ' + key);
console.log('progress: ' + num / seq.length);
console.log('seq: ' + seq.join(' '));
},
fail: function () {
console.log('sequence failed');
},
done: function () {
console.log('I am proud of you');
}
});
cheet('o n c e', function () {
console.log('This will only fire once.');
cheet.disable('o n c e');
});
var sequences = {
cross: 'up down left right',
circle: 'left up right down'
};
cheet(sequences.cross);
cheet(sequences.circle);
cheet.done(function (seq) {
if (seq === sequences.cross) {
console.log('cross!');
} else {
console.log('circle!');
}
});
Because who doesn't need to create their own unique font?
“I will never entertain the thought of creating my own font, but you're going to show us how to create one anyway aren't you?” -Michael Scott
Plumin.js is a library that creates and manipulates fonts using javascript.
npm install plumin.js
(function(p) {
var font = new p.Font({
familyName: 'Demo',
ascender: 800,
descender: -100
}),
a = new p.Glyph({
name: 'a',
unicode: 'a',
advanceWidth: 496
}),
i = new p.Glyph({
name: 'i',
unicode: 'i',
advanceWidth: 268
}),
o = new p.Glyph({
name: 'o',
unicode: 'o',
advanceWidth: 536
}),
shape;
// a contour
shape = new p.Path.RegularPolygon({
center: [268, 124],
sides: 3,
radius: 248
});
shape.rotate(180, [268, 124]);
shape.scale(1, 1.4, [268, 0]);
a.addContour(shape);
// i contour
shape = new p.Path.Rectangle({
point: [60, 0],
size: [140, 500]
});
i.addContour(shape);
// o contour
shape = new p.Path.Ellipse({
point: [50, 0],
size: [436, 510]
});
o.addContour(shape);
font.addGlyphs([ a, i, o ]);
font.updateOTCommands()
.addToFonts();
})(plumin.paper);
It even works in IE!
Blast text apart to make it manipulable.
npm install blast-text
// Blast apart an element using the "word" delimiter
$("div").blast({ delimiter: "word" });
// Before
Hello World
// After
Hello
World
// All Done
$("div").blast(false);
$("div").blast({
delimiter: "character" // Set the delimiter type
search: false // Perform a search *instead* of delimiting
tag: "span" // Set the wrapping element type (e.g. "div")
customClass: "" // Add a custom class to wrappers
generateIndexID: false // Add #customClass-i to wrappers
generateValueClass: false // Add .blast-word-val to wrappers
stripHTMLTags: false // Strip HTML before blasting
returnGenerated: true // Return generated elements to stack
aria: true // Avoid speechflow disruption for screenreaders
});
Because you hate your users.
A library that incrementally loads the elements on the page
https://github.com/theonion/comcastifyjs
$(document).ready(function () {
comcastifyjs.letsPrepareTheseImages();
});
$(window).load(function () {
comcastifyjs.fixMyImagesLoadingSoFast({
loadMaxPercent: 0.75,
loadSpeed: 1000,
loadIncrement: 5,
boxColor: '#ece4d8'
})();
});
Because you are developing web sites for small children.
A library that provides a sticker effect.
https://github.com/cmiscm/stickerjs
Create some sticker DOM elements
Add the CSS to configure size and image/color
.sticker {
width: 180px;
height: 180px;
}
// add image
.example-1 .sticker-img {
background-image: url(example.png);
}
// add color
.example-2 .sticker-img {
background-color: #ff4a85;
}
Tell stickerjs what to target.
Sticker.init('.sticker');
Because no important talk is complete without farts.
A library that delivers fart audio to your web page.
https://github.com/theonion/fartscroll.js
// Fart every 400 pixels scrolled in the window
fartscroll();
// Fart every 800 pixels scrolled
fartscroll(800);
// Fart every 2000 pixels scrolled. Maybe this is a long
// article and you want the user to question if they're hearing things
fartscroll(2000);
// SO MANY FARTS
fartscroll(5);
// Alright, that's probably enough examples. Just wanted one more excuse
// to say 'fart'.
fartscroll(400);