text: (function () {
      'use strict';
  
      // Define the common module 
      // Contains services:
      //  - common
      //  - logger
      //  - spinner
      var commonModule = angular.module('common', []);
  
      // Must configure the common service and set its
      // events via the commonConfigProvider
      commonModule.provider('commonConfig', function () {
          this.config = {
              // These are the properties we need to set
              //controllerActivateSuccessEvent: '',
              //spinnerToggleEvent: ''
          };
  
          this.$get = function () {
              return {
                  config: this.config
              };
          };
      });
  
      commonModule.factory('common',
          ['$q', '$rootScope', '$timeout', 'commonConfig', 'logger', common]);
  
      function common($q, $rootScope, $timeout, commonConfig, logger) {
          var throttles = {};
  
          var service = {
              // common angular dependencies
              $broadcast: $broadcast,
              $q: $q,
              $timeout: $timeout,
              // generic
              activateController: activateController,
              createSearchThrottle: createSearchThrottle,
              debouncedThrottle: debouncedThrottle,
              isNumber: isNumber,
              logger: logger, // for accessibility
              checkArrayForVal: checkArrayForVal,
              textContains: textContains,
              setSession: setSession,
              isNotExpired: isNotExpired,
          };
  
          return service;
  
          function activateController(promises, controllerId) {
              return $q.all(promises).then(function (eventArgs) {
                  var data = { controllerId: controllerId };
                  $broadcast(commonConfig.config.controllerActivateSuccessEvent, data);
              });
          }
  
          function $broadcast() {
              return $rootScope.$broadcast.apply($rootScope, arguments);
          }
  
          function checkArrayForVal(p_val) {
              Array.prototype.in_array(p_val);
              Array.prototype.in_array = function (p_val) {
                  for (var i = 0, l = this.length; i < l; i++) {
                      if (this[i] === p_val) {
                          return true;
                      }
                  }
                  return false;
              }
  
          }
  
          function createSearchThrottle(viewmodel, list, filteredList, filter, delay) {
              // custom delay or use default
              delay = +delay || 300;
              // if only vm and list parameters were passed, set others by naming convention 
              if (!filteredList) {
                  // assuming list is named sessions,
                  // filteredList is filteredSessions
                  filteredList = 'filtered' + list[0].toUpperCase() + list.substr(1).toLowerCase(); // string
                  // filter function is named sessionFilter
                  filter = list + 'Filter'; // function in string form
              }
  
              // create the filtering function we will call from here
              var filterFn = function () {
                  // translates to ...
                  // vm.filteredSessions 
                  //      = vm.sessions.filter(function(item( { returns vm.sessionFilter (item) } );
                  viewmodel[filteredList] = viewmodel[list].filter(function (item) {
                      return viewmodel[filter](item);
                  });
              };
  
              return (function () {
                  // Wrapped in outer IFFE so we can use closure
                  // over filterInputTimeout which references the timeout
                  var filterInputTimeout;
  
                  // return what becomes the 'applyFilter' function in the controller
                  return function (searchNow) {
                      if (filterInputTimeout) {
                          $timeout.cancel(filterInputTimeout);
                          filterInputTimeout = null;
                      }
                      if (searchNow || !delay) {
                          filterFn();
                      } else {
                          filterInputTimeout = $timeout(filterFn, delay);
                      }
                  };
              })();
          }
  
          function debouncedThrottle(key, callback, delay, immediate) {
              var defaultDelay = 1000;
              delay = delay || defaultDelay;
              if (throttles[key]) {
                  $timeout.cancel(throttles[key]);
                  throttles[key] = undefined;
              }
              if (immediate) {
                  callback();
              } else {
                  throttles[key] = $timeout(callback, delay);
              }
          }
  
          function setSession(token) {
  
              if (localStorage.getItem('x-auth') || localStorage.getItem('expires_at')) {
                  localStorage.removeItem('x-auth');
                  localStorage.removeItem('expires_at');
              }
  
              //Comment SET STORAGE TOKEN
              // Set the time that the access token will expire at
              var expiresAt = JSON.stringify((5400 * 1000) + new Date().getTime());
              localStorage.setItem('x-auth', token);
              localStorage.setItem('expires_at', expiresAt);
          }
  
          function isNotExpired() {
              // Check whether the current time is past the
              // access token's expiry time
              let expiresAt = JSON.parse(localStorage.getItem('expires_at'));
              if (new Date().getTime() < expiresAt) {
                  return true;
              } else { return false; };
          }
  
          function isNumber(val) {
              // negative or positive
              return /^[-]?\d+$/.test(val);
          }
  
          function textContains(text, searchText) {
              return text && -1 !== text.toLowerCase().indexOf(searchText.toLowerCase());
          }
      }
  })();