Skip to content

Instantly share code, notes, and snippets.

View TastyToast's full-sized avatar

Donnie Conner TastyToast

View GitHub Profile
@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 / killWhiteSpace.js
Created December 11, 2012 01:33
Kill White Space
String.prototype.killWhiteSpace = function() {
return this.replace(/\s/g, '');
};
$('.element').killWhiteSpace();
@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 / 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 / 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 / cookie.js
Created July 24, 2012 17:54
Set cookies
@TastyToast
TastyToast / birthday_arrange.js
Created June 29, 2012 21:17
Arrange birthday fields in page manager
//CHANGE ORDER OF BIRTHDAY SELECTS
var birthdayFields = [];
birthdayFields = $('.engagements_field_birthday').find('select');
//ARRANGE SELECTS
function arraymove(arr, fromIndex, toIndex) {
element = arr[fromIndex];
arr.splice(fromIndex,1);
arr.splice(toIndex,0,element);
};
@TastyToast
TastyToast / timeDifference.html
Last active October 5, 2015 18:18
Show elements based on difference in time with moment.js
<script src="https://s3.amazonaws.com/wildfireapp/assets/momentjs/moment.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(){
var currentDate = moment().utc();
//Time is set to PST (UTC minus 8 for time zone offset)
//var startDate = moment('1-24-2013 14 -08:00', 'MM-DD-YYYY HH Z').utc();
// Start Date should be set in following format: 1-24-2013
// Start Time should be set in 24 hour format. So, for 2pm, use following: 14
@TastyToast
TastyToast / wmode.js
Created May 31, 2012 23:55
Changing WMode with jQuery
$("embed").attr("wmode", "opaque");
var embedTag;
$("embed").each(function(i) {
embedTag = $(this).attr("outerHTML");
if ((embedTag != null) && (embedTag.length > 0)) {
embedTag = embedTag.replace(/embed /gi, "embed wmode="opaque" ");
$(this).attr("outerHTML", embedTag);
} else {
$(this).wrap("<div></div>");
}
@TastyToast
TastyToast / konamicode.js
Created May 31, 2012 23:53
Konami Code!
var kkeys = [], konami = "38,38,40,40,37,39,37,39,66,65";
$(document).keydown(function(e) {
kkeys.push( e.keyCode );
if ( kkeys.toString().indexOf( konami ) >= 0 ) {
$(document).unbind('keydown',arguments.callee);