Skip to content

Instantly share code, notes, and snippets.

@gregdangelo
gregdangelo / ElementInView
Last active April 10, 2019 19:42
Identify if an Element is in View
function getClientHeight(){
return (document.documentElement.clientHeight || window.innerHeight || document.body.clientHeight);
}
function getScrollTop(){
return document.getElementsByTagName('html')[0].scrollTop;
}
function getLazyLoadScroll(){
return window._config.lazyload_scroll_px || 500;
}
@gregdangelo
gregdangelo / browser_plugin_list.html
Created March 5, 2015 16:51
List out the installed browser plugins
<html>
<body>
<div id="example"></div>
<script type="text/javascript">
var x=navigator.plugins.length; // store the total no of plugin stored
var txt="Total plugin installed: "+x+"<br/>";
txt+="Available plugins are->"+"<br/>";
for(var i=0;i<x;i++)
{
txt+=navigator.plugins[i].name + "<br/>";
@gregdangelo
gregdangelo / fontsize.less
Created November 12, 2012 18:29
LESS for setting fontsize and creating a mixin to handle it
/*
REM vs PX Based off of this
http://snook.ca/archives/html_and_css/font-size-with-rem
*/
/* IMPORTANT: Don't ever change this */
@broswerfontsize : 16;
/* CHANGE: THIS IS THE BASE FONT SIZE AND SHOULD BE SET ONLY ONCE */
@gregdangelo
gregdangelo / findlinks.js
Created May 17, 2012 17:30
Phantom JS file for finding links on a given pate
@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 / 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 / _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 / 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 / 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];
}
}