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 URL parameters | |
* @return array of URL parameters | |
*/ | |
function getUrlParams() | |
{ | |
var params = [], hash; | |
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&'); | |
for(var i = 0; i < hashes.length; i++) | |
{ |
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
function isToday(d) | |
{ | |
var date_param = new Date(d).toDateString(); | |
var date_today = new Date().toDateString(); | |
var is_today = (date_today == date_param); | |
return is_today; | |
} | |
// Example use: console.log(isToday("01/01/2014")); |
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 gallery = "div[class*='gallery']"; | |
var prev = jQuery("a[class*='prev'], img[class*='prev'], li[class*='prev'] a, div[class*='prev'] a, li[id*='prev'] a, a[id*='prev'], img[id*='prev'], div[id*='prev'] a"); | |
var next = jQuery("a[class*='next'], img[class*='next'], li[class*='next'] a, div[class*='next'] a, li[id*='next'] a, a[id*='next'], img[id*='next'], div[id*='next'] a"); | |
jQuery("body").keydown(function(e) | |
{ | |
if ( e.keyCode == 37 ) | |
{ | |
prev[prev.length - 1].click(); | |
} |
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
// This script replaces harder words with easier ones for faster reading. | |
jQuery('p,li,blockquote').each(function() { | |
var text = jQuery(this).html(); | |
jQuery(this).html( | |
text.replace(/\baccompanying\b/, 'going with') | |
.replace(/\baccompanied\b/, 'went with') | |
.replace(/\baccompanies\b/, 'goes with') | |
.replace(/\baccompany\b/, 'go with') | |
.replace(/\baccomplishing\b/, 'doing') | |
.replace(/\baccomplished\b/, 'did') |
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
function setCount(source, target, limit) | |
{ | |
var chars = source.val().length; | |
if (chars > limit) | |
{ | |
// Disable submit button | |
jQuery("input#submit").attr('disabled', 'disabled'); | |
source.css("background", "#fee"); | |
target.css("color", "red"); | |
if ((chars - limit) > 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
javascript:var getCalories=function(){var e=prompt("Enter (separated by spaces):\n- Sex\n- Age (yrs)\n- Weight (lbs)\n- Avg heart rate (rpm)\n- Workout time (min)");var t=e.split(" ");var n=t[0];var r=t[1];var i=t[2];var s=t[3];var o=t[4];var u=((r*.2017+i*.09036+s*.6309-55.0969)*(o/4.184)).toFixed(2);var a=((r*.074+i*.05741+s*.4472-20.4022)*(o/4.184)).toFixed(2);var f=n=="m"?u:a;return f};var setCalories=function(){alert("You burned "+getCalories()+" calories today!")}(); |
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
/* | |
* Instructions: | |
* - Create a new bookmark and name it "Get Calories Burned!" | |
* - Then, paste the following code into the URL field. | |
* - At the prompt, enter your sex, age, weight, average heart rate during exercise, and exercise duration. | |
* - E.g.: m 38 150 150 30 | |
* Data source: http://fitnowtraining.com/2012/01/formula-for-calories-burned/ | |
*/ | |
var getCalories = function() { | |
var questions = prompt("Enter (separated by spaces):\n- Sex\n- Age (yrs)\n- Weight (lbs)\n- Avg heart rate (rpm)\n- Workout time (min)"); |
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
// ==UserScript== | |
// @name Close Amazon Preview with Esc Key | |
// @namespace http://www.therobbiedshow.com/ | |
// @version 0.1 | |
// @description Close Amazon preview window when clicking the Esc key! | |
// @match http://www.amazon.com | |
// @include http://*/* | |
// @copyright 2014+, Robert Dawson | |
// @require http://code.jquery.com/jquery-latest.min.js | |
// ==/UserScript== |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Lazy Loading without JavaScript</title> | |
<style type="text/css"> | |
/* Hide images on page load. */ | |
#img1, #img2, #img3 { | |
display: none; | |
} | |
/* Show images when targeted. */ |
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
// ref 1: http://toddmotto.com/mastering-the-module-pattern/ | |
// ref 2: https://developer.mozilla.org/en-US/docs/Web/API/CanvasRenderingContext2D/fillText | |
// create basic diagram module (w/ "revealing module" pattern from ref 1) | |
var D_ = (function() { | |
// draw container | |
var draw = function(label) { | |
var canvas = document.getElementById('canvas'); | |
if (canvas.getContext) { | |
var ctx = canvas.getContext('2d'); |
OlderNewer