Skip to content

Instantly share code, notes, and snippets.

View interfeis's full-sized avatar

Interfeis interfeis

View GitHub Profile
/* Javascript code to verify if a page is loading on a Mobile browser */
var isDesktop = false;
var isMobile = navigator.userAgent.match(/(iPhone|iPod|iPad|Android|BlackBerry|webOS)/);
if (!isMobile) {
isDesktop = true;
}
@interfeis
interfeis / sticky-footer.js
Created July 2, 2012 16:38
Sticky Footer - Fixes footer gap in large screens - calculates content height
@interfeis
interfeis / navigator.jquery.js
Created July 2, 2012 16:37
Browser detection with jQuery
function detectBrowserVersion(){
var userAgent = navigator.userAgent.toLowerCase();
$.browser.chrome = /chrome/.test(navigator.userAgent.toLowerCase());
var version = 0;
// Is this a version of IE?
if($.browser.msie){
userAgent = $.browser.version;
userAgent = userAgent.substring(0,userAgent.indexOf('.'));
version = userAgent;
@interfeis
interfeis / navigator.js
Created July 2, 2012 16:36
Browser detection
if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ //test for MSIE x.x;
var ieversion=new Number(RegExp.$1) // capture x.x portion and store as a number
if(ieversion>=9) {
//IE9
} else
if(ieversion>=8) {
//IE8
} else
@interfeis
interfeis / cookie.js
Created July 2, 2012 16:35
Cookie management
@interfeis
interfeis / get-var.js
Created July 2, 2012 16:34
Get query string variable
function getQueryVariable (variable) {
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i=0;i<vars.length;i++) {
var pair = vars[i].split("=");
if (pair[0] == variable) {return pair[1];}
@interfeis
interfeis / get-page-filename.js
Created July 2, 2012 16:34
Get page filename
location.href.split('/').pop(); //this returns for example: index.php
@interfeis
interfeis / jquery-load.js
Created July 2, 2012 16:33
Fallback jQuery load
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript">
if (typeof jQuery == 'undefined') {
document.write(unescape("%3Cscript src='/js/jquery-1.7.2.min.js' type='text/javascript'%3E%3C/script%3E"));
}
</script>
<!--
Other CDNs:
@interfeis
interfeis / jquery-plugin-boilerplate.js
Created July 2, 2012 16:32
jQuery plugin boilerplate
(function($){
$.fn.extend({
//plugin name
pluginName: function(method) {
var methods = {
init : function(options) {
var defaults = {
color: '#333333'
//more default options
@interfeis
interfeis / module.js
Created July 2, 2012 16:31
jQuery module pattern boilerplate
var clientName = window.clientName || {};
(function ($, context) {
// Add the global variables used across the module
var vars = {
variable2 : "test"
};
/*