Skip to content

Instantly share code, notes, and snippets.

View TastyToast's full-sized avatar

Donnie Conner TastyToast

View GitHub Profile
@TastyToast
TastyToast / cookie.js
Created July 24, 2012 17:54
Set cookies
@TastyToast
TastyToast / ieplaceholdertext.js
Last active October 12, 2015 01:08
IE Sucks, So let's force placeholders to work!
if ($.browser.msie){
$(document).ready(function(){
$('[placeholder]').focus(function() {
var input = $(this);
if (input.val() == input.attr('placeholder')) {
input.val('');
input.removeClass('placeholder');
}
}).blur(function() {
var input = $(this);
@TastyToast
TastyToast / array-remove.js
Created October 30, 2012 18:35
Array Remove By John Resig
// Array Remove - By John Resig (MIT Licensed)
Array.prototype.remove = function(from, to) {
var rest = this.slice((to || from) + 1 || this.length);
this.length = from < 0 ? this.length + from : from;
return this.push.apply(this, rest);
};
@TastyToast
TastyToast / fade-senquentially.js
Created November 1, 2012 20:57
Fade images in sequentially
(function() {
// Hide the elements initially
var lis = $('li').hide();
// When some anchor tag is clicked. (Being super generic here)
$('a').click(function() {
var i = 0;
// FadeIn each list item over 200 ms, and,
// when finished, recursively call displayImages.
// When eq(i) refers to an element that does not exist,
// jQuery will return an empty object, and not continue
@TastyToast
TastyToast / killWhiteSpace.js
Created December 11, 2012 01:33
Kill White Space
String.prototype.killWhiteSpace = function() {
return this.replace(/\s/g, '');
};
$('.element').killWhiteSpace();
@TastyToast
TastyToast / getpramfromurl.js
Created January 3, 2013 19:26
Get a pram from url
function getParameterByName(name) {
var match = RegExp('[?&]' + name + '=([^&]*)').exec(window.location.search);
return match && decodeURIComponent(match[1].replace(/\+/g, ' '));
}
// Useful for a url like www.iframe.com/93493434?pram_name=2323
@TastyToast
TastyToast / timeline-videos.html
Created January 14, 2013 22:24
Playable videos in Facebook Timeline
<a href="#">Click me</a>
<object width="420" height="315"><param name="movie" value="http://www.youtube.com/v/EzNhaLUT520?version=3&amp;hl=en_US"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/EzNhaLUT520?version=3&amp;hl=en_US" type="application/x-shockwave-flash" width="420" height="315" allowscriptaccess="always" allowfullscreen="true"></embed></object>
<script type="text/javascript">
(function($){
$(document).bind('afterfbinit', function(){
$('a').on('click', function(e){
e.preventDefault();
FB.ui({
@TastyToast
TastyToast / localstorageexample.html
Last active December 11, 2015 13:58
Using Local Storage with cookies
<script src="https://s3.amazonaws.com/wildfireapp/assets/jstorage.min.js"></script>
<div class="sweeps-tab tab clearfix">
<div class="header">
<h1>Buy one get one FREE. Kodak 5x7 folded greeting card. Register for your FREE COUPON!</h1>
</div>
<div class="left-col">
<div class="sweeps-container cvs" style="display: none;" data-store="cvs">
{% plugin sweeps cvs_sweeps %}
{% marker cvs_sweeps %}
@TastyToast
TastyToast / handlebars-truncate-helper.js
Last active April 21, 2021 09:08
Truncate helper for Handlebars.js
Handlebars.registerHelper ('truncate', function (str, len) {
if (str.length > len) {
var new_str = str.substr (0, len+1);
while (new_str.length) {
var ch = new_str.substr ( -1 );
new_str = new_str.substr ( 0, -1 );
if (ch == ' ') {
break;
@TastyToast
TastyToast / debug-handlebars.js
Created March 1, 2013 19:12
Debugging helper for Handlebars
Handlebars.registerHelper("debug", function(optionalValue) {
console.log("Current Context");
console.log("====================");
console.log(this);
if (optionalValue) {
console.log("Value"); console.log("===================="); console.log(optionalValue);
}
});