Skip to content

Instantly share code, notes, and snippets.

View qwertypants's full-sized avatar
🧶

Wilkins Fernandez qwertypants

🧶
View GitHub Profile
@qwertypants
qwertypants / iCheck.js
Created November 10, 2010 18:04
Check to see if the user is on iPad, iPod, or iPhone
function iCheck(func){
if (!(navigator.userAgent.match(/iPhone/i)) || !(navigator.userAgent.match(/iPod/i)) || !(navigator.userAgent.match(/iPad/i))) {
func(navigator.userAgent);
}
}
// Usage
iCheck(function(agent){
// You can use a case select statement to
// evaluate what actions you want to do
@qwertypants
qwertypants / jQuery_number_only.js
Created November 10, 2010 17:48
Only allow numbers in an input field
$.fn.numOnly = function() {
return this.each( function() {
// backspace(8), dot(.), tab(0) 0-9
var c = [8, 0, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58];
if ($(this).attr('type') === 'text') {
$(this).keypress( function(e) {
if (c.indexOf(e.which, c) == -1) {
e.preventDefault();
}
});
@qwertypants
qwertypants / check_host.js
Created November 10, 2010 17:39
check for SLL
// Taken from Google. Is that evil?
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");