This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var listener = function ( fun ) { | |
return function ( e ) { | |
//thank you IE for the wonderful fish | |
e = e || window.event; | |
e.target = e.target || e.srcElement; | |
e.stopPropagation = e.stopPropagation || function () { | |
this.cancelBubble = true; | |
}; | |
e.preventDefault = e.preventDefault || function () { | |
this.returnValue = false; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//creating an element is easy peasy | |
var divElem = document.createElement( 'div' ); | |
//divElem is now a div element. it's not related to the any other element or | |
// node, it's free-range. | |
//to add it to the body element, for example: | |
document.body.appendChild( divElem ); | |
//splendidsimo! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//a simple introduction to javascript | |
//javascript comments are C-style: inline-comments begin with two forward | |
//slashes //, and end when on EOL (End Of Line) | |
/* multi-line comments are also available, spanning from forward-slash asterisk /* | |
until an asterisk forward-slash */ | |
//variable declaration |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var IO = { | |
//event handling | |
events : {}, | |
preventDefault : false, | |
//register for an event | |
register : function ( name, fun, thisArg ) { | |
if ( !this.events[name] ) { | |
this.events[ name ] = []; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
m=Math;R=m.random;P=m.pow;D=c.width=c.height=600;t=12;T=D-t;O=256;l=e=E=N=0;setInterval(function(){if(!E&&(e>=N||L&&e<N&&l--))e=L=0,A=[],A.length=5*++l,N=l*(l+1)/2;a.fillStyle=e<N?"#778":"#eef";a.fillRect(0,0,D,D);a.strokeText(e+"/"+N,9,9);for(i=A.length;i--;)with(A[i]||(A[i]={s:L,d:L,M:40*R()+20,x:L?L.clientX:R()*T+6,y:L?L.clientY:R()*T+6,v:R()*t-6,z:R()*t-6,C:"rgb("+[R()*O|0,R()*O|0,R()*O|0].join()+")",r:6,t:30/l|0}))!d&&A.some(function(b){return b.d&&P(r+b.r,2)>P(x-b.x,2)+P(y-b.y,2)&&(s=d=1,E++,e++)}),s?t?2==s?t--:++r>M&&(s=2):--r||(A.splice(i,1),E--):(x+=v,y+=z,x<r|x+r>D&&(v=-v),y<r|y+r>D&&(z=-z)),a.beginPath(),a.fillStyle=C,a.arc(x,y,r,0,7),a.fill()},50);c.onclick=function(b){L||(L=b,E++,A.push(0))}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//a polyfill for the ordered-list reversed attribute | |
// http://www.whatwg.org/specs/web-apps/current-work/multipage/grouping-content.html#the-ol-element | |
// http://www.whatwg.org/specs/web-apps/current-work/multipage/grouping-content.html#dom-li-value | |
//uses these awesomeness: | |
// Array.prototype.forEach | |
// Element.prototype.children | |
//if you want support for older browsers *cough*IE8-*cough*, then use the other | |
// file provided | |
(function () { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//http://www.w3.org/TR/2011/WD-page-visibility-20110602/ | |
(function () { | |
"use strict"; | |
//no need to shim if it's already there | |
if ( 'hidden' in document && 'onvisibilitychange' in document ) { | |
return; | |
} | |
//fail silently if the browser sux |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//infix operator-precedence parser | |
//also supports a d operator - a dice roll | |
var parsePrecedence = (function () { | |
//we don't care about whitespace. well, most whitespace | |
var whitespace = { | |
' ' : true, | |
'\t' : true | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//looks for comments at the beginning of a line looking like this: | |
//#build fileName | |
//and replaces them with fileName contents | |
//throws an error when fileName points to a file which doesn't exist | |
//first parameter is the file on which to operate, | |
//second parameter is a function which is called at the of operation with the | |
// new content | |
//no changes are done to the original file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//a script I hacked together in 10 minutes for easily reading Questionable Content: | |
// http://questionablecontent.net | |
//A and D keys, and their corresponding arrow keys, for movement between comic strips | |
//don't be alarmed if the image is a broken one, wait some more. if the script really failed | |
//to load a comic strip, it alerts a message | |
var s = document.getElementById( 'strip' ).cloneNode(), | |
l = document.createElement( 'p' ), | |
acts = [], |
OlderNewer