- jQuery - The de-facto library for the modern age. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers.
- Backbone - Backbone.js gives structure to web applications by providing models with key-value binding and custom events, collections with a rich API of enumerable functions, views with declarative event handling, and connects it all to your existing API over a RESTful JSON interface.
- AngularJS - Conventions based MVC framework for HTML5 apps.
- Underscore - Underscore is a utility-belt library for JavaScript that provides a lot of the functional programming support that you would expect in Prototype.js (or Ruby), but without extending any of the built-in JavaScript objects.
- lawnchair - Key/value store adapter for indexdb, localStorage
This file contains hidden or 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
// demo: http://jsfiddle.net/adamculpepper/9bf2r9uj | |
centerElement($(".center-it.me"), $(".center-it.to")); | |
function centerElement(me, to) { | |
var toWidth = to.outerWidth(); | |
var meWidth = me.outerWidth(); | |
var meCenter = Math.abs(meWidth / 2) - (toWidth / 2); | |
me.css({ |
This file contains hidden or 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
// Break out of iframes | |
if (window != window.top) { | |
top.location.href = location.href | |
} |
This file contains hidden or 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 year = new Date().getFullYear(); |
This file contains hidden or 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 loc = window.location; | |
var url = (location.href); | |
loc.origin || (loc.origin = loc.protocol + '//' + loc.host); | |
url = url.split('?')[0]; | |
var slugs = $.trim((url.replace(loc.origin, '')).split("/").join(" ")); | |
if (slugs == "") { | |
slugs = "home"; | |
} |
This file contains hidden or 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
// Coming from secure protocol and user is NOT inside the store, redirect to a non-secure connection | |
if (location.protocol == "https:") { | |
if (url.search("worldsecuresystems.com") < 0) { | |
location.protocol = "http:"; | |
} | |
} |
This file contains hidden or 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
if (url.search("Default.aspx?A=Search")) { | |
$("body").addClass("search"); | |
} |
This file contains hidden or 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
//Simple form | |
$("form").submit(function(e) { | |
e.preventDefault(); | |
$.ajax({ | |
type: 'POST', | |
url: 'https://formkeep.com/f/7212a0cb4563', | |
data: $(this).serialize(), | |
success: function() { | |
//window.location = "http://google.com"; |
This file contains hidden or 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
<? | |
$start = (float) array_sum(explode(' ',microtime())); | |
?> | |
<!-- CONTENT HERE --> | |
<? | |
$end = (float) array_sum(explode(' ',microtime())); | |
echo "Processing time: ". sprintf("%.4f", ($end-$start))." seconds"; | |
?> |
This file contains hidden or 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
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |