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
Function.prototype.notifier = (function () {"use strict"; | |
// (C) WebReflection - Mit Style License | |
function create(callback) { | |
function notifier() { | |
var args = [].slice.call(arguments), output; | |
if (fire(notifier, "before", callback, this, args, null)) { | |
try { | |
output = callback.apply(this, args); | |
} catch(e) { | |
fire(notifier, "error", callback, this, args, e); |
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
<!doctype html> | |
<html> | |
<head> | |
<title>Function.prototype.notifier</title> | |
<!-- https://github.com/WebReflection/wru --> | |
<script src="callback.js"></script> | |
<script>function wru(wru){var assert=wru.assert,async=wru.async; | |
// enojy your tests! |
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
// I know it's for demo purpose from MS: | |
// http://ie.microsoft.com/testdrive/HTML5/TypedArrays/js/binaryReader.js | |
BinaryReader.prototype = { | |
readUint8: function () { var result = this.dataView.getUint8(this.streamPosition, true); this._movePointerTo(this.streamPosition + 1); return result; }, | |
readInt8: function () { var result = this.dataView.getInt8(this.streamPosition, true); this._movePointerTo(this.streamPosition + 1); return result; }, | |
readUint16: function () { var result = this.dataView.getUint16(this.streamPosition, true); this._movePointerTo(this.streamPosition + 2); return result; }, | |
readInt16: function () { var result = this.dataView.getInt16(this.streamPosition, true); this._movePointerTo(this.streamPosition + 2); return result; }, | |
readUint32: function () { var result = this.dataView.getUint32(this.streamPosition, true); this._movePointerTo(this.streamPosition + 4); return result; }, | |
readInt32: function () { var result = this.dataView.getInt32(this.s |
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
(function (Object) { | |
// (C) WebReflection - Mit Style License | |
// @wtf? Array extras applied to Objects | |
function OPmap(key, i, arr) { | |
this.n[key] = invoke(this, key); | |
} | |
function OPfilter(key, i, arr) { | |
invoke(this, key) && (this.n[key] = this.s[key]); | |
} | |
function define(key, callback) { |
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
!function (Object) { | |
// (C) WebReflection - Mit Style License | |
var // private scope shortcuts | |
BOUND_TO = "boundTo", // or maybe "asContextOf" ? | |
// ad-hoc partial private shims for "not there yet" ES5 browsers | |
indexOf = [].indexOf || function indexOf(value) { |
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
<!doctype html> | |
<html> | |
<head> | |
<title>WeakMap</title> | |
<!-- https://github.com/WebReflection/wru --> | |
<script src="WeakMap.js">/* | |
https://gist.github.com/1571878 | |
*/</script> | |
<script>function wru(wru){var assert=wru.assert,async=wru.async; |
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 mutations = (function (document) { | |
// (C) WebReflection - Mit Style License | |
var | |
type = [ | |
"DOMSubtreeModified", | |
"DOMNodeInserted", | |
"DOMNodeRemoved", | |
"DOMNodeRemovedFromDocument", | |
"DOMNodeInsertedIntoDocument", | |
"DOMAttrModified", |
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
// @see http://www.thespanner.co.uk/2011/07/25/the-json-specification-is-now-wrong/ | |
// fix it via RegExp and feature detection | |
if (JSON.stringify("\u2028") == '"\u2028"') { | |
JSON.stringify = function (stringify) { | |
function place(m) { | |
return "\\u202" + (m == "\u2028" ? "8" : "9"); | |
} | |
var re = /\u2028|\u2029/g; | |
return function fixed(data) { | |
return stringify(data).replace(re, place); |
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 each = function (Array) {"use strict"; | |
/*! all you need to `each(obj, cb [,context])` | |
* @author WebReflection | |
* @license WTFPL - http://en.wikipedia.org/wiki/WTFPL | |
* @gist https://gist.github.com/2294934 | |
*/ | |
var | |
toString = {}.toString, | |
hasOwnProperty = {}.hasOwnProperty, | |
array = toString.call([]), |
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
function ifClickedElsewhere(el, callback) { | |
// add prioritized 'click' listener | |
document.addEventListener( | |
'click', | |
function onClick(e) { | |
var parentNode = e.target; | |
// until we reach the current node or no node at all | |
while (parentNode && parentNode !== el) { | |
// grab the parent | |
parentNode = parentNode.parentNode; |