Skip to content

Instantly share code, notes, and snippets.

View omniosi's full-sized avatar

Ornette Coleman omniosi

View GitHub Profile
@omniosi
omniosi / svg-png-swap
Last active December 20, 2015 04:59
use modernizr to swap PNGs for SVG files depending on device/browser support
/*SVG CHECK*/
function svgCheck(){
if (!Modernizr.svg) {
$('img.svg').each(function () {
svg = $(this).attr('src');
svg = svg.replace('svg', 'png');
$(this).attr('src', svg);
});
}
}
@omniosi
omniosi / smooth scrolling
Last active December 12, 2015 09:19
animated scrolling to links in jQuery
The function for the horizontal scrolling effect is the following:
$(function() {
$('ul.nav a').bind('click',function(event){
var $anchor = $(this);
/*
if you want to use one of the easing effects:
$('html, body').stop().animate({
scrollLeft: $($anchor.attr('href')).offset().left
}, 1500,'easeInOutExpo');
@omniosi
omniosi / HTML5 skeleton
Created June 19, 2012 21:53
an HTML5 skeleton page with HTML5shiv, jQuery and fallback, and normalise styling
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="utf-8">
<title>GREYnyc boilerplate</title>
<link rel="stylesheet" href="css/normalize.css" type="text/css" media="screen"> <!-- Cross browser styling standardization -->
<link rel="stylesheet" href="css/style.css" type="text/css" media="screen"> <!-- Custom styling for this page -->
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> <!-- Cloud hosted jQuery code -->
<script type="text/javascript">window.jQuery || document.write('<script type="text/javascript" src="path/to/your/jquery"><\/script>')</script> <!-- Local jQuery file fallback -->
<script src="js/script.js" charset="utf-8"></script> <!-- Custom scripts for this page -->
@omniosi
omniosi / Capitalize input text value
Created May 31, 2012 00:11
Capitalize input text value
/*Add to your script:*/
jQuery.fn.capitalize = function() {
$(this[0]).keyup(function(event) {
var box = event.target;
var txt = $(this).val();
var start = box.selectionStart;
var end = box.selectionEnd;
$(this).val(txt.replace(/^(.)|(\s|\-)(.)/g, function($1) {
return $1.toUpperCase();
}));
@omniosi
omniosi / browser audio target script
Created May 16, 2012 16:22
target audio format and deliver correct format to HTML audio
var ispeech;
var message;
var canPlayOgg = !!(new Audio().canPlayType('audio/ogg; codecs="vorbis"'));
if(canPlayOgg == true){
ispeech = "http://api.ispeech.org/api/rest?apikey=developerdemokeydeveloperdemokey&action=convert&voice=usenglishmale&format=ogg&text=";
} else{
ispeech = "http://api.ispeech.org/api/rest?apikey=developerdemokeydeveloperdemokey&action=convert&voice=usenglishmale&text=";
}
$("#submit").click(function(){
message = $("#text").val();
@omniosi
omniosi / Jquery Cloud and local
Created May 13, 2012 17:11
JQuery CDN hosted with local fallback
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript">window.jQuery || document.write('<script type="text/javascript" src="path/to/your/jquery"><\/script>')</script>