Skip to content

Instantly share code, notes, and snippets.

@FelipeBudinich
Created June 5, 2014 17:17
Show Gist options
  • Save FelipeBudinich/e1840e0b719c128414b8 to your computer and use it in GitHub Desktop.
Save FelipeBudinich/e1840e0b719c128414b8 to your computer and use it in GitHub Desktop.
ImpactJs, Domain Validation Plugin
/*global ig*/
ig.module(
'plugins.domain'
).requires().defines(function () {
'use strict';
var DomainUtils = {
isCurrentDomainAllowed: function () {
var allowed = ['127.0.0.1', 'www.example.com', 'example.com'],
isAllowed = false,
i;
for (i = 0; i < allowed.length; i += 1) {
if (window.location.hostname === allowed[i]) {
isAllowed = true;
}
}
return isAllowed;
}
},
methodName;
function installFunction(name, fn) {
if (ig[name]) {
throw ("method " + name + "() already defined elsewhere.");
}
Object.defineProperty(ig, name, {
value: fn
});
}
for (methodName in DomainUtils) {
if (DomainUtils.hasOwnProperty(methodName)) {
installFunction(methodName, DomainUtils[methodName]);
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment