Skip to content

Instantly share code, notes, and snippets.

View adamsilver's full-sized avatar

Adam Silver adamsilver

View GitHub Profile
body {
font-size: 62.5%;
}
h1 {
font-size: 2em;
}
h2 {
font-size: 1.8em;
}
h3 {
input, textarea, select {
font-size: 1.2em;
}
h1 span {
font-size: 1.6em; /* useful if the mark-up is normal size different size */
}
#welcomeMessage p {
font-size: 1.5em;
}
var down = "mousedown", up = "mouseup";
if("createTouch" in document) {
down = "touchstart", up = "touchend";
}
el.addEventListener(down, func, false);
el.addEventListener(up, func, false);
var testEl = document.getElementById("el");
testEl.onmousedown = function () {
// initialize mouse interface
}
testEl.ontouchstart = function () {
testEl.onmousedown = null; // initialize touch interface
}
var obj = (function() {
if(...) {
return function() {
//...
}
}
else {
return function() {
//...
}
var A = function() {}
var B = function() {}
// factory
var Type = function(name) {
if(name === "a") {
return new A();
}
else {
return new B();
var Field = function() {
this.validate = function() {
// ...
}
}
// the form holds many fields but they both have the same named public method "validate"
var FormValidator = function() {
var fields = [];
var flashvars = {htmlSrc: encodeURIComponent(""+document.getElementById("containerId").innerHTML +"")};
swfobject.embedSWF(..., flashvars, ...);