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
/** | |
* Load javascript resources asynchronously. Accepts additional parameters that can be passed to the specified callback function | |
* Author: Frederick King | |
* Date: 3/8/2012 | |
* References/Credits : http://css-tricks.com/thinking-async/ , http://mathiasbynens.be/notes/async-analytics-snippet | |
* | |
**/ | |
var async_load_js = function( url, callback ){ | |
var js, args, rs, s; |
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
// geo-location shim | |
// currentely only serves lat/long | |
// depends on jQuery | |
;(function(geolocation){ | |
if (geolocation) return; | |
var cache; |
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
<?php | |
add_image_size('thumbnail-bw', 400, 0, false); | |
add_filter('wp_generate_attachment_metadata','bw_images_filter'); | |
function bw_images_filter($meta) { | |
$file = wp_upload_dir(); | |
$file = trailingslashit($file['path']).$meta['sizes']['thumbnail-bw']['file']; | |
list($orig_w, $orig_h, $orig_type) = @getimagesize($file); | |
$image = wp_load_image($file); | |
imagefilter($image, IMG_FILTER_GRAYSCALE); |
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 weather for charlotte using YQL + Yahoo weather | |
var xdr = new XDomainRequest(); | |
xdr.open("get", "http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20rss%20where%20url%3D'http%3A%2F%2Fxml.weather.yahoo.com%2Fforecastrss%2F28215_f.xml'&format=json"); | |
xdr.onload = function() { | |
// the string now looks like.. json = { ... }; | |
json = 'json = ' + xdr.responseText; | |
// json is now a regular JSON object | |
eval(json); | |
// parse using same function as for jQuery's success event | |
self.draw(json.query.results.item.forecast, $elem); |
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
$.fn.center = function () { | |
this.css("position","absolute"); | |
this.css("top", (($(window).height() - this.outerHeight()) / 2) + $(window).scrollTop() + "px"); | |
this.css("left", (($(window).width() - this.outerWidth()) / 2) + $(window).scrollLeft() + "px"); | |
return this; | |
} |
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
// Evaluates a script in a global context | |
// Workarounds based on findings by Jim Driscoll | |
// http://weblogs.java.net/blog/driscoll/archive/2009/09/08/eval-javascript-global-context | |
// pulled from jquery.core source | |
var globalEval = function( data ){ | |
if ( data ) { | |
// We use execScript on Internet Explorer | |
// We use an anonymous function so that context is window | |
// rather than jQuery in Firefox |
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
/* Queue to use in conjuction with xhr functionality */ | |
var requestQ = (function() { | |
var numRequestToComplete, requestsCompleted, callBacks, singleCallBack; | |
return function(options) { | |
if (!options) options = {}; | |
numRequestToComplete = options.numRequest || 0; | |
requestsCompleted = options.requestsCompleted || 0; | |
callBacks = []; | |
var fireCallbacks = function() { | |
/* alert("we're all complete"); */ |
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 snippet allowes function to user jQuery dom ready before jquery is loaded */ | |
window.$ = (function() { | |
var q = [], f = function (cb) { | |
q.push(cb); | |
}; | |
f.attachReady = function ($) { | |
$(function () { | |
$.each(q, function(i, f) { | |
f(); | |
}); |
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
/** | |
Quick and dirty plugin to generate qr code on the fly | |
@author Frederick King | |
**/ | |
(function($, undefined) { | |
/** | |
Generate qr code on the fly | |
@parameter {object} options | |
**/ | |
$.fn.qrCode = function(options) { |
OlderNewer