Skip to content

Instantly share code, notes, and snippets.

@gregdangelo
gregdangelo / hideaddrbar.js
Created December 20, 2011 18:02 — forked from scottjehl/hideaddrbar.js
Normalized hide address bar for iOS & Android
/*
* Normalized hide address bar for iOS & Android
* (c) Scott Jehl, scottjehl.com
* MIT License
*/
(function( win ){
var doc = win.document;
// If there's a hash, or addEventListener is undefined, stop here
if( !location.hash && win.addEventListener ){
@gregdangelo
gregdangelo / logtime.js
Created January 4, 2012 16:33 — forked from ryanflorence/logtime.js
Log the time of JS operations
var logtime = (function() {
var ids = {};
return function(id) {
if (!ids[id]) {
ids[id] = +new Date();
return;
}
var time = +new Date() - ids[id];
@gregdangelo
gregdangelo / JS padding integers
Created March 16, 2012 14:57
JS padding integers
/*
src: http://jsconsole.com/?v%20%3D%204%3B%20'0'.substr(v%20%3C%2010%20%3F%200%20%3A%201)%20%2B%20v%3B
via @rem
*/
v = 4; '0'.substr(v < 10 ? 0 : 1) + v;
@gregdangelo
gregdangelo / jsGetSelection
Created April 9, 2012 11:54
Support: IE6, Fx2, Opera9, Safari Cross browser getSelection().
function getSelection() {
return (!!document.getSelection) ? document.getSelection() :
(!!window.getSelection) ? window.getSelection() :
document.selection.createRange().text;
}
@gregdangelo
gregdangelo / jsdeepExtend
Created April 9, 2012 12:34
Javascript Deep Extend with no framework
Object.deepExtend = function(destination, source) {
for (var property in source) {
if (source[property] && source[property].constructor &&
source[property].constructor === Object) {
destination[property] = destination[property] || {};
arguments.callee(destination[property], source[property]);
} else {
destination[property] = source[property];
}
}
@gregdangelo
gregdangelo / microclearfix.css
Created April 16, 2012 13:08
MicroClearfix
/*
http://css-tricks.com/snippets/css/clear-fix/
*/
.group:before,
.group:after {
content:"";
display:table;
}
.group:after {
clear:both;
@gregdangelo
gregdangelo / _ajax.js
Created April 19, 2012 13:46
No Framework Ajax
//this needs to go somewhere
var modules = {};
modules.ajax = function(){
var args = Array.prototype.slice.call(arguments), createXMLHTTPObject = function(){
var xmlhttp, XMLHttpFactories = [
function() { return new XMLHttpRequest(); }
,function() { return new ActiveXObject('Msxml2.XMLHTTP.6.0'); }
,function() { return new ActiveXObject('Msxml2.XMLHTTP.3.0'); }
,function() { return new ActiveXObject('Msxml2.XMLHTTP'); }
,function() { return new ActiveXObject('Msxml3.XMLHTTP'); }
@gregdangelo
gregdangelo / selectinputtext.js
Created April 19, 2012 13:49
Select all input's text via JS
//modify this as needed just a reminder of how to do it
function SelectAll(id)
{
document.getElementById(id).focus();
document.getElementById(id).select();
}
@gregdangelo
gregdangelo / addevent.js
Created April 19, 2012 16:27
add event function
function addEvent(target, type, handler) {
if (target.addEventListener){
target.addEventListener(type, handler, false);
}else{
target.attachEvent("on" + type,
function(event) {
// Invoke the handler as a method of target,
// passing on the event object
return handler.call(target, event);
});
@gregdangelo
gregdangelo / findlinks.js
Created May 17, 2012 17:30
Phantom JS file for finding links on a given pate