diff --git a/app/listings/listings.controller.js b/app/listings/listings.controller.js index d6428e864..f709102f5 100755 --- a/app/listings/listings.controller.js +++ b/app/listings/listings.controller.js @@ -11,7 +11,7 @@ import { loadUser } from '../services/userv3.service.js' 'TcAuthService', 'UserService', 'UserStatsService', 'ProfileService', 'ChallengeService', 'ExternalAccountService', 'ngDialog', '$anchorScroll' ] - + function ListingsCtrl($location, $scope, CONSTANTS, logger, $q, TcAuthService, UserService, UserStatsService,ProfileService, ChallengeService, ExternalAccountService, ngDialog, $anchorScroll) { var vm = this @@ -32,8 +32,8 @@ import { loadUser } from '../services/userv3.service.js' s.async = true s.src = '//api.usersnap.com/load/'+ '3e7c8f0c-6cf6-41b6-9f2c-e8e4e60dfc59.js' - var x = document.getElementsByTagName('script')[0] - x.parentNode.insertBefore(s, x) + var x = document.getElementById('react-component') + x.appendChild(s, x) })() $scope.myChallenges = [] diff --git a/app/listings/listings.jade b/app/listings/listings.jade index 6401773e0..23a54d428 100755 --- a/app/listings/listings.jade +++ b/app/listings/listings.jade @@ -1 +1 @@ -react-component.listings(name="ChallengeFiltersExample" props="reactProps" watch-depth="reference") +react-component.listings(name="ChallengeFiltersExample" props="reactProps" watch-depth="reference" id="react-component") diff --git a/app/listings/listings.routes.js b/app/listings/listings.routes.js index c6a89efd3..03993bd86 100755 --- a/app/listings/listings.routes.js +++ b/app/listings/listings.routes.js @@ -14,6 +14,13 @@ import angular from 'angular' // $state.go('404') // } }) + $rootScope.$on('$stateChangeSuccess', function(event, toState, toParams, fromState, fromParams, error) { + if (toState.name !== 'listings') { + // remove usersnap widget if not in listings page + var usersnapWidget = document.getElementById("us_report_button") + if (usersnapWidget) usersnapWidget.remove() + } + }) }]) function routes($stateProvider) {