This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Get a date | |
// Requires getString and isValidDate | |
var getDate = function (selectorOrEl) { | |
// Get text | |
var text = getString(selectorOrEl); | |
// Try and get the date, return text failing that | |
var date = new Date(text); | |
if (this.isValidDate(date)) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var styleText = "body { background: black; }"; | |
$( "<style>" + styleText + "</style>" ).appendTo( "head" ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
jQuery('<div/>', { | |
id: 'foo', | |
href: 'http://google.com', | |
title: 'Become a Googler', | |
rel: 'external', | |
text: 'Go to Google!' | |
}).appendTo('#mySelector'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var multiline = function (fn) { | |
var reCommentContents = /\/\*\s*([\s\S]*?)\s*\*\//; | |
return reCommentContents.exec(fn.toString())[1]; | |
}; | |
var html = multiline(function(){/* | |
<div> | |
<marquee>HELLO</marquee> | |
</div> | |
*/}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var contains = function(arr, value) { | |
var i = arr.length; | |
while (i--) { | |
if (arr[i] === value) { | |
return true; | |
} | |
} | |
return false; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var whenPopupClosed = function (popupWindow, cb) { | |
var pollTimer = window.setInterval(function() { | |
if (popupWindow.closed !== false) { // !== is required for compatibility with Opera | |
window.clearInterval(pollTimer); | |
cb(); | |
} | |
}, 200); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var md5 = require("MD5"); | |
var trim = require("mout/string/trim"); | |
module.exports = function (email) { | |
var hash = md5(trim(email).toLowerCase()); | |
return "http://www.gravatar.com/avatar/" + hash; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var getParam = require("mout/queryString/getParam"); | |
module.exports = function (url) { | |
if (!url) { | |
return ""; | |
} | |
// Youtube | |
if (url.indexOf("youtube.com") !== -1) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
/* | |
* Key things to change: | |
* 1. The class `form.my-subscribe-form` to match your own | |
* 2. The input `input[name='email']` to match the real `name` of the input | |
*/ | |
$(function () { | |
$('form.my-subscribe-form').on('submit', function () { | |
var email = $(this).find("input[name='email']").val(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var contains = function (list, value) { | |
if (list instanceof Array) { | |
var i = list.length; | |
while (i--) { | |
if (list[i] === value) { | |
return true; | |
} | |
} | |
return false; | |
} else if (typeof list === "string") { |
OlderNewer