Skip to content

Instantly share code, notes, and snippets.

@a7madgamal
Last active September 16, 2016 10:08
Show Gist options
  • Save a7madgamal/22444e35531aa00b7e36932da8bb1001 to your computer and use it in GitHub Desktop.
Save a7madgamal/22444e35531aa00b7e36932da8bb1001 to your computer and use it in GitHub Desktop.
Douglas crockford's js library coding style (not usable, learning purposes only)
var ADSAFE;
ADSAFE = (function () {
"use strict";
function error(message) {
ADSAFE.log("ADsafe error: " + (message || "ADsafe violation."));
}
return {
get: function (object, name) {
reject_global(object);
if (!reject_property(object, name)) {
return object[name];
}
error();
},
// ADSAFE.isArray returns true if the operand is an array.
isArray: Array.isArray || function (value) {
return Object.prototype.toString.apply(value) === "[object Array]";
},
log: function log(s) {
if (window.console) {
console.log(s);
} else if (typeof Debug === "object") {
Debug.writeln(s); /* IE */
} else {
opera.postError(s); /* Opera */
}
},
// ADSAFE._intercept allows the page to register a function that will see the widget's capabilities.
_intercept: function (f) {
interceptors.push(f);
}
};
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment