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
window.requires_urls = {}; | |
(function($){ | |
$.requires = function(url, callback) { | |
// look for the url in our cached url results | |
for(called_url in window.requires_urls) { | |
var cached = window.requires_urls[called_url].cached; | |
// if a url matches and it has cached results | |
if(url_equals(url, called_url) && cached.data) { |
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
// zero dependency $.getScript for loading external javascript (like jQuery.js | |
// or other big libraries) in a way that does not block the normal page load | |
// (http://www.yuiblog.com/blog/2008/07/22/non-blocking-scripts/). | |
// | |
// heavily influenced by/copied from jQuery's ajax functions (http://jquery.com) | |
window.$ = { | |
getScript: function(script_src, callback) { | |
var done = false; | |
var head = document.getElementsByTagName("head")[0] || document.documentElement; |
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
window.match_protocol = function(url) { | |
var RE_PROTO = /^\w+:\/\//; | |
if(RE_PROTO.test(url)) { | |
var protocol = window.location.protocol; | |
url = url.replace(RE_PROTO, protocol + "//"); | |
} | |
return url; | |
}; |
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
// Checks if a DOM object is valid. | |
// Expects an array of functions in data('validations') that return true when | |
// valid. | |
// | |
// Triggers field_invalid or field_valid. | |
// Calls options.invalid() or options.valid(). | |
$.fn.validate = function(options) { | |
var $this = $(this); | |
/* $this.data('validations') is an array of functions, each of which |
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
/* | |
Based off of Gruber's awesome url regex: http://daringfireball.net/2010/07/improved_regex_for_matching_urls | |
In addition: | |
- Should match 'example.com', 'google.net', 'google.org'. (only com, net, and org are whitelisted). | |
- Should not match 'sam@samuelcole.name'. | |
*/ | |
var URL_RE = /(?:(?=[\s`!()\[\]{};:'".,<>?«»“”‘’])|\b)((?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/|[a-z0-9.\-]+[.](?:com|org|net))(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))*(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]|\b))/gi |
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
/* | |
Storage Polyfill by Remy Sharp. | |
Delinted by Samuel Cole. | |
*/ | |
if (typeof window.localStorage === 'undefined' || typeof window.sessionStorage === 'undefined') { | |
(function () { | |
var Storage = function (type) { | |
function createCookie(name, value, days) { |
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 ($) { | |
function background_image_url($object) { | |
var string = $object.css('backgroundImage'), | |
url_regex = /[("]([^()"]+)[")]/; | |
return url_regex.exec(string)[1]; | |
} | |
$.fn.preload_background_image = function () { | |
return $(this).each(function () { | |
(new Image()).src = background_image_url($(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
function Model(object) { | |
this.initialize(object); | |
} | |
Model.prototype.initialize = function (object) { | |
this.listeners = {}; | |
this.listeners._global = []; | |
for (var key in object) { | |
if (object.hasOwnProperty(key)) { | |
this.set(key, object[key]); |
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>TIC TAC TOE</title> | |
<style> | |
td { | |
height: 100px; | |
width: 100px; | |
border-color: black; | |
border-width: 1px; |
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
// require something | |
var hogan = require('hogan.js'); | |
var handlebars = require('handlebars'); | |
var template = 'Hello {{name}}'; | |
console.log(hogan.compile(template)); | |
console.log(handlebars.compile(template)); |
OlderNewer