NOTE I now use the conventions detailed in the SUIT framework
Used to provide structural templates.
Pattern
t-template-name
| (function (global) { | |
| if ( !global.Event && !('keys' in Object) && !('bind' in Function) ) { return } | |
| var eventProto = Event.prototype, | |
| EVENTS = { | |
| 'mouse': [ 'click', 'dblclick', 'contextmenu', 'mousedown', 'mouseup', 'mouseover', 'mousemove', 'mouseout', 'drag', 'dragend', 'dragenter', 'dragleave', 'dragover', 'drop'], | |
| 'key': [ 'keydown', 'keypress', 'keyup', 'input'], | |
| 'res': [ 'load', 'unload', 'beforeunload', 'abort', 'error', 'resize', 'scroll', 'readystatechange' ], | |
| 'form': [ 'select', 'change', 'submit', 'reset', 'focus', 'blur' ], | |
| 'ui': [ 'DOMFocusIn', 'DOMFocusOut', 'DOMActivate', 'DOMCharacterDataModified', 'DOMNodeInserted', 'DOMNodeRemoved', 'DOMSubtreeModified' ], |
NOTE I now use the conventions detailed in the SUIT framework
Used to provide structural templates.
Pattern
t-template-name
| // Don't actually use this. Ever. Thx. | |
| (function fn() { | |
| var slice = fn.call.bind([].slice); | |
| Function.overload = function(obj) { | |
| return function() { | |
| var key = slice(arguments).map(function(a) { return typeof a; }).join(', '); | |
| if (obj[key]) { |
| // http://paulirish.com/2011/requestanimationframe-for-smart-animating/ | |
| // http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating | |
| // requestAnimationFrame polyfill by Erik Möller. fixes from Paul Irish and Tino Zijdel | |
| // MIT license | |
| (function() { | |
| var lastTime = 0; | |
| var vendors = ['ms', 'moz', 'webkit', 'o']; |
| var http = require('http'); | |
| var server = http.createServer(function(req, res) { | |
| // console.log(req); // debug dump the request | |
| // If they pass in a basic auth credential it'll be in a header called "Authorization" (note NodeJS lowercases the names of headers in its request object) | |
| var auth = req.headers['authorization']; // auth is in base64(username:password) so we need to decode the base64 | |
| console.log("Authorization Header is: ", auth); |
| { | |
| // -------------------------------------------------------------------- | |
| // JSHint Configuration, Strict Edition | |
| // -------------------------------------------------------------------- | |
| // | |
| // This is a options template for [JSHint][1], using [JSHint example][2] | |
| // and [Ory Band's example][3] as basis and setting config values to | |
| // be most strict: | |
| // | |
| // * set all enforcing options to true |
| /* | |
| * Abstraction.js | |
| * | |
| * Copyright (c) 2012 "Cowboy" Ben Alman | |
| * Licensed under the MIT license. | |
| * http://benalman.com/about/license/ | |
| */ | |
| var Abstraction = (function($) { | |
| var _ = $.prototype; |
| var fs = require('fs'); | |
| var confess = { | |
| run: function () { | |
| var cliConfig = {}; | |
| confess.performancecache = this.clone(confess.performance); | |
| if (!this.processArgs(cliConfig, [ | |
| { | |
| name: 'url', | |
| def: 'http://google.com', |
| var page = require('webpage').create(); | |
| page.open('http://twitter.com/ID_AA_Carmack', function (status) { | |
| if (status !== 'success') { | |
| console.log('Unable to access network'); | |
| } else { | |
| var hitRockBottom = false; | |
| while (!hitRockBottom) { | |
| //scroll the page (not sure if this is the best way to do so...) |
| var system = require('system'); | |
| // Exit in case of wrong parameter count. | |
| if (system.args.length !== 3) { | |
| console.log('Usage: scriptname targetUrl referrer'); | |
| console.log('example: $> phantomjs fake-referrer.phantom.js http://example.com http://referrer.example.com'); | |
| phantom.exit(); | |
| } | |
| // Set the important pieces |