Skip to content

Instantly share code, notes, and snippets.

View freshsnippets's full-sized avatar

Freshmade freshsnippets

View GitHub Profile
@freshsnippets
freshsnippets / jquery.ba-tinypubsub.js
Created March 21, 2012 17:15 — forked from cowboy/HEY-YOU.md
JavaScript: jQuery Tiny Pub/Sub
/* jQuery Tiny Pub/Sub - v0.7 - 10/27/2011
* http://benalman.com/
* Copyright (c) 2011 "Cowboy" Ben Alman; Licensed MIT, GPL */
(function($) {
var o = $({});
$.subscribe = function() {
o.on.apply(o, arguments);
@freshsnippets
freshsnippets / ellipsis.js
Created March 8, 2012 16:53 — forked from qwertypants/ellipsis.js
JavaScript: Add ellipsis
function ellipsis(numOfWords, text, wordCount ) {
wordCount = text.trim().replace(/\s+/g, ' ').split(' ').length;
if(numOfWords <= 0 || numOfWords === wordCount){
return text;
} else {
text = text.trim().split(' ');
text.splice(numOfWords, wordCount, '...');
return text.join(' ');
}
}