Skip to content

Instantly share code, notes, and snippets.

View dmolsen's full-sized avatar

Dave Olsen dmolsen

View GitHub Profile
@dmolsen
dmolsen / gist:1567142
Created January 5, 2012 20:32
MQSugr Demo Page Code
// to start the snowflakes
var oncomplete = function() { snowflakes = new Snowflakes('about','snowflakesContainer'); snowflakes.create(40); };
// set-up the breakpoints
var mqsugr = new MQSugr();
var breakpoints = {
breakpoint1: '320px',
breakpoint2: { mq: '600px', tests: 'indexeddb' },
breakpoint3: { mq: '801px', tests: 'cssanimations', yep: ['{cssPath}snowflakes.css', '{jsPath}snowflakes.js'], complete: oncomplete },
breakpoint4: '801px'
@dmolsen
dmolsen / gist:1495085
Created December 19, 2011 01:46
Holiday card timed events code
// don't change these variables
var p = false; // currently playing
var e = false; // ended
var j = true; // first play
var videoTimeRaw = 0;
var currentTime = 0;
var defaultInterval = 100;
// configure these variables
var vidId = 'videoEmbed'; // the ID of the div holding the video
@dmolsen
dmolsen / gist:1495049
Created December 19, 2011 01:29
Example of setting an event to happen at particular times during a video
// between 13secs and 17secs shoot off a firework every half a second (500ms)
YTVideo.at('13000-16500', function() {
createFirework(14,73,3,2,null,null,null,20,true,true);
}, 500);
@dmolsen
dmolsen / gist:1495027
Created December 19, 2011 01:20
Examples of two onStateChange events
// listen for when the viewer decides to start playing the video
// hide the intro & outro text divs as well as "lower the lights"
YTVideo.on('playing', function() {
document.getElementById('intro').setAttribute('class', 'text hide');
document.getElementById('outro').setAttribute('class', 'text hide');
document.getElementById('lights').setAttribute('class', 'darken');
});
// listen for when the video ends
// show the outro text div as well as "bring up the lights"
@dmolsen
dmolsen / gist:1494961
Created December 19, 2011 00:42
Initializing the YouTubePlayer object to listen to onStateChange events
var vidId = 'videoEmbed'; // the ID of the div holding the video
var vidYTId = 'XhLrlhFzAjA'; // the ID of the video from YouTube
var YTVideo = new YoutubePlayer(vidId, vidYTId,{
width: 640,
height: 360,
objparams: { allowFullscreen: "true" },
ytparams: { rel: 0, showsearch: 0, showinfo: 0, modestbranding: 1 }
});
@dmolsen
dmolsen / gist:1282062
Created October 12, 2011 18:15
simple test of an ajax success function
$.ajax({
url: "test.html",
dataType: 'xml',
success: function (data) {
$('#cancelPayment',data).attr('bar','element');
var str = (new XMLSerializer()).serializeToString(data);
$('#appDiv').html(str).trigger('create');
}
});
@dmolsen
dmolsen / ga.php
Created January 6, 2011 20:46
A fix to the sendRequestToGoogleAnalytics() function from ga.php to support cURL
<?
function sendRequestToGoogleAnalytics($utmUrl) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER["HTTP_USER_AGENT"]);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Accepts-Language: " . $_SERVER["HTTP_ACCEPT_LANGUAGE"]));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //Set curl to return the data instead of printing it to the browser.
curl_setopt($ch, CURLOPT_URL, $utmUrl);
@dmolsen
dmolsen / federated.html.php
Created December 28, 2010 20:36
The map module federated template that adds the appropriate HTML to $html to be used in the final template
<?
// a template for web/search/ feature hence why it's totally different than all others
$html .= "<div class='nonfocal'><strong>Campus Map Results</strong></div>";
$html .= "<p class='focal results'>";
if ($total == 0) {
$html .= "No results returned.";
} else {
@dmolsen
dmolsen / federated.php
Created December 28, 2010 20:35
the federated search script for the map module
<?php
/**
* Copyright (c) 2010 West Virginia University
*
* Licensed under the MIT License
* Redistributions of files must retain the above copyright notice.
*
*/
@dmolsen
dmolsen / index.php
Created December 28, 2010 20:33
The main file for the federated search feature
<?php
/**
* Copyright (c) 2010 West Virginia University
*
* Licensed under the MIT License
* Redistributions of files must retain the above copyright notice.
*
*/