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 () { | |
console.groupCollapsed('Duplicate element IDs within DOM'); | |
var dupes = [], | |
elms = document.getElementsByTagName("*"), i, len, ids = {}, id; | |
for (i = 0, len = elms.length; i < len; i += 1) { | |
id = elms[i].id || null; | |
if (id) { | |
ids[id] = ids.hasOwnProperty(id) ? ids[id] +=1 : 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
// from http://stackoverflow.com/questions/23705051/how-do-i-mock-a-service-that-returns-promise-in-angularjs-jasmine-unit-test | |
beforeEach(inject( function(_myService_, $q){ | |
myService = _myService_; | |
myOtherServiceMock.makeRemoteCallReturningPromise = function() { | |
var deferred = $q.defer(); | |
deferred.resolve('Remote call result'); | |
return deferred.promise; | |
}; | |
} |
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 createArray(length) { | |
var arr = new Array(length || 0), | |
i = length; | |
if (arguments.length > 1) { | |
var args = Array.prototype.slice.call(arguments, 1); | |
while(i--) arr[length-1 - i] = createArray.apply(this, args); | |
} | |
return arr; |
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 getFunctionName() { | |
var re = /function (.*?)\(/ | |
var s = getFunctionName.caller.toString(); | |
var m = re.exec( s ) | |
return m[1]; | |
} | |
function me() { | |
console.log( getFunctionName() ); | |
} |
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 () { | |
var root = angular.element(document.getElementsByTagName('body')); | |
var watchers = []; | |
var f = function (element) { | |
angular.forEach(['$scope', '$isolateScope'], function (scopeProperty) { | |
if (element.data() && element.data().hasOwnProperty(scopeProperty)) { | |
angular.forEach(element.data()[scopeProperty].$$watchers, function (watcher) { | |
watchers.push(watcher); |
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
console.log("Usage Syntax: scanScope(objectToScan, 'scanFor', ['whatToIgnore']); %c(whatToIgnore is optional and can be a string, or an array of strings) (scanScope can be shortened to ss)", 'color: red'); | |
var abortAtLevel = 20, | |
callStack = 0, | |
errArray = [], | |
funArray = [], | |
scanLoop = function (whatToScan, scanValue, whatToIgnore, parentTree) { | |
scanValue = scanValue.toLowerCase(); | |
if (Array.isArray(whatToIgnore)) { | |
whatToIgnore.forEach(function (ignoreVal) { | |
ignoreVal = lowerCase(ignoreVal); |