Skip to content

Instantly share code, notes, and snippets.

View brianswisher's full-sized avatar

Brian Swisher brianswisher

View GitHub Profile
@brianswisher
brianswisher / orientation.js
Created September 23, 2011 23:00
A mobile web dev script to toggle through portrait & landscape classes on a document's body element.
/*global document */
var orientation;
(function () {
"use strict";
orientation = function () {
var isPortrait, isLandscape;
isPortrait = document.body.className.indexOf('portrait') !== -1;
isLandscape = document.body.className.indexOf('landscape') !== -1;
document.body.className = document.body.className.split(' portrait ').join('');
document.body.className = document.body.className.split(' landscape ').join('');
@brianswisher
brianswisher / orientationBookmarklet.txt
Created September 23, 2011 23:41
Bookmarklet for orientation, a mobile web dev utility.
javascript:(function(){try{orientation();}catch(B){var A=document.createElement("script");A.src="https://raw.github.com/gist/1238678/0900a6e5cbac75b600942c33be8994b93830b5c4/orientation.js";document.body.appendChild(A);}}());
@brianswisher
brianswisher / jqDom.js
Created December 5, 2011 19:21
Create a DOM element w/ jQuery
$('<div/>', {
id: 'myDiv',
title: 'my div',
text: 'This is my div'
}).prependTo('body');
@brianswisher
brianswisher / show-data.js
Created February 23, 2012 18:10
Display data-attribute with corresponding classname
(function() {
var O,N,M,K,J,I,H,G,F,E,D,C,B,A,L;
M = "ref";
C = "number";
E = "." + M + ":before{";
E += "display:inline-block;";
E += "position:absolute;";
E += "padding:2px;";
E += "color:white;";
E += "background-color:black;";
@brianswisher
brianswisher / multi-phone-link
Created April 12, 2012 16:47
Handle multiple phone number w/ a single click
@brianswisher
brianswisher / protoAppAlias
Created April 23, 2012 22:50
profile addon from node prototype demo
function app {
if [ -z "$2" ]
then
appbranch=main;
else
appbranch=$2;
fi
webapp=$1WebApp;
builddir=/p4/phoenix/$appbranch/build;
appdir=/p4/phoenix/$appbranch/phoenixApp/$webapp;
@brianswisher
brianswisher / sessionTimeout.js
Created May 1, 2012 19:01
Interactively Times Out Session
setTimeout("document.location.href='/mobile/?sessionTimedOut=true'",0);
@brianswisher
brianswisher / sortStarAscend.js
Created May 1, 2012 19:29
Sort Results by Star Rating in Ascending Order
document.location.replace("sort?sortCriterion=starRating&isSortAscending=true&searchTokenId="+document.location.toString().split('searchTokenId=').pop().split('&').shift())
@brianswisher
brianswisher / localeUs.js
Created May 1, 2012 21:20
Change locale to us
var re = /\/..\//gi;
var url = document.location.href;
var pDelim = (url.split('?').length>1) ? '&' : '?';
url = url.replace(re, '/').split('/mobile/').join('/mobile/us/') + pDelim + 'currencyCode=USD';
document.location.replace(url);
@brianswisher
brianswisher / localeUk.js
Created May 1, 2012 21:23
Change locale to uk
var re = /\/..\//gi;
var url = document.location.href;
var pDelim = (url.split('?').length>1) ? '&' : '?';
url = url.replace(re, '/').split('/mobile/').join('/mobile/uk/') + pDelim + 'currencyCode=GBP';
document.location.replace(url);