Skip to content

Instantly share code, notes, and snippets.

Avatar
🤖
👨‍🎨 👨‍💻

Jordan Shaw jshaw

🤖
👨‍🎨 👨‍💻
View GitHub Profile
@jshaw
jshaw / eventClick.js
Last active August 29, 2015 14:05
example using underscore binding on events to keep class scope
View eventClick.js
// When using underscore this passes the class scope into the event handler (callback function)
// rather than having the click event scope in the handler (callback function)
Navigation.prototype._addClickEvent = function () {
var handler = _(this._handleEventClick).bind(this);
this.$nav_items.on('click', handler);
};
// Here this refers to Navigation.prototype rather than the event which gets passed in
Navigation.prototype._handleEventClick = function (evt) {
evt.preventDefault();
View app.navigation.js
/*
Navigation scroll to anchor w/ URL routing using pushstate
*/
(function () {
var global = this;
// Initial setup
@jshaw
jshaw / tourney.html
Last active August 29, 2015 14:13 — forked from sterlingwes/tourney.html
View tourney.html
<!DOCTYPE html>
<html>
<head>
<title>Tournament Bracket Generator</title>
<script src="http://code.jquery.com/jquery-1.8.3.min.js"></script>
<script src="http://underscorejs.org/underscore-min.js"></script>
<script>
$(document).on('ready', function() {
var knownBrackets = [2,4,8,16,32], // brackets with "perfect" proportions (full fields, no byes)
@jshaw
jshaw / heapsort.js
Last active August 29, 2015 14:13 — forked from Rosencrantz/heapsort.js
View heapsort.js
var list = [9,1,7,3,4,2,8,0,5,6];
function chunk(list) {
var chunks = [];
for(var i=0; i<list.length; i++) {
if(list.length % 2 == 1 && i+1 == list.length) {
chunks.push(list[i]);
} else {
if(i % 2 == 0) {
chunks.push(Math.max(list[i], list[i+1]));
@jshaw
jshaw / addGroupSnippit.js
Created January 13, 2012 15:19
fm-group-select sample to add groups to uploads
View addGroupSnippit.js
if ($('.groupSelectInputs').length > 0 ){
// declares the group string
var groupsString = "";
// Loops through all of the select inputs
$.each($('.groupSelectInputs'), function(i){
groupsString = groupsString == "" ? this.value : groupsString +','+ this.value;
});
@jshaw
jshaw / forminputsnippit.html
Created January 20, 2012 16:19
Update Mediasearch Gallery
View forminputsnippit.html
<fm:If value="{$$get.groupId}"><input type="hidden" name="groupId" id="groupId" value="{$$get.groupId}" /></fm:If>
@jshaw
jshaw / checkIfHTTP
Created May 23, 2012 20:57
Checks to see if there's http at the start of a url, and makes sure that it is included if missing.
View checkIfHTTP
var str="http://someurl.ca/";
str = str.search("http://") == -1 ? "http://" + str : str;
document.write(str);
@jshaw
jshaw / AnimationBounce.js
Created July 24, 2012 16:12
Animation Bounce an Percent Complete Marker
View AnimationBounce.js
// Requires jQuery & jQuery UI
$('<ELEMENT>').animate({
bottom: <VAR CalculatedPercentage>+'%',
duration: <VAR duration>
},function(){
$(this).effect("bounce", { direction:'down', times:4 }, 600);
});
@jshaw
jshaw / trackVideoPlays.js
Created July 25, 2012 20:42
Player Event Listeners and Analytics for Vimeo
View trackVideoPlays.js
Highwire.prototype._trackVideoPlays = function(){
// Gets reference to the Vimeo video player
var f = $('#VimeoPlayer'),
url = f.attr('src').split('?')[0];
// Listen for messages from the player
if (window.addEventListener){
window.addEventListener('message', onMessageReceived, false);
} else {
@jshaw
jshaw / FacebookPageTabResizeiFrame.html
Created July 26, 2012 18:28
Resize the Facebook iFrame Tab Page with resizing content and different page heights on page loads.
View FacebookPageTabResizeiFrame.html
<!DOCTYPE html>
<html lang="en" style="overflow: hidden">
<body style="overflow:hidden">
<head>
<!-- You need to include jquery & FBSDK-->
</head>
<body>
<div id="fb-root"></div>
<script>
window.fbAsyncInit = function() {