Skip to content

Instantly share code, notes, and snippets.

//
// Regular Expression for URL validation
//
// Author: Diego Perini
// Updated: 2010/12/05
// License: MIT
//
// Copyright (c) 2010-2013 Diego Perini (http://www.iport.it)
//
// Permission is hereby granted, free of charge, to any person
@idanen
idanen / load-measure.js
Last active November 20, 2016 11:35
Measure load time of an element in an AngularJS app (with UI-Router)
(function () {
var nameOfState = 'name of the state we want to start the measuring from',
timingTag = 'an arbitrary tag to tag the timestamps',
elementSelector = `a selector of the element we're wating for`,
observer;
angular.element(document).injector().get('$rootScope').$on('$stateChangeSuccess', (e, toState) => {
if (toState.name === nameOfState) {
console.time(timingTag);
observer = new MutationObserver(e => {
if (document.querySelector(elementSelector)) {
@idanen
idanen / external-links.directive.js
Last active November 15, 2019 08:58
AngularJS directive to open external links in a new tab