<commit_before>module = angular.module('impac.components.widgets-common.data-not-found',[])

module.directive('commonDataNotFound', ($templateCache, ImpacAssets, ImpacTheming) ->
  return {
    restrict: 'A',
    scope: {
    	widgetEngine: '='
    },
    controller: ($scope) ->
      $scope.bgImage = ''
      $scope.content = ImpacTheming.get().dataNotFoundConfig
      baseDir = ImpacAssets.get('dataNotFound')
      if $scope.widgetEngine and baseDir.length > 0
        # checks for trailing slash and corrects.
        dir = baseDir.split('')
        dir = if dir[dir.length - 1] != '/'
        then dir.concat('/').join('')
        else dir.join('')

        $scope.bgImage = dir + $scope.widgetEngine + '.png'

    template: $templateCache.get('widgets-common/data-not-found.tmpl.html'),
  }
)
# TODO: where should this live? Is there a better way to do this?
# Checks if image is available, preventing displaying the broken image tile - if not, displays nothing.
module.directive('checkImage', ($log, $http) ->
  return {
    restrict: 'A'
    link: (scope, element, attrs) ->
      attrs.$observe('ngSrc', (ngSrc) ->
        $http.get(ngSrc).success( () ->
          # do nothing
        ).error( () ->
          # prevent broken image tile from being displayed, by attaching an empty src.
          element.attr('src', '')
        )
      )
  }
)<commit_msg>update to checkImage directive to remove image instead of append empty src<commit_after>module = angular.module('impac.components.widgets-common.data-not-found',[])

module.directive('commonDataNotFound', ($templateCache, ImpacAssets, ImpacTheming) ->
  return {
    restrict: 'A',
    scope: {
    	widgetEngine: '='
    },
    controller: ($scope) ->
      $scope.bgImage = ''
      $scope.content = ImpacTheming.get().dataNotFoundConfig
      baseDir = ImpacAssets.get('dataNotFound')
      if $scope.widgetEngine and baseDir.length > 0
        # checks for trailing slash and corrects.
        dir = baseDir.split('')
        dir = if dir[dir.length - 1] != '/'
        then dir.concat('/').join('')
        else dir.join('')

        $scope.bgImage = dir + $scope.widgetEngine + '.png'

    template: $templateCache.get('widgets-common/data-not-found.tmpl.html'),
  }
)
# TODO: where should this live? Is there a better way to do this?
# Checks if image is available, preventing displaying the broken image tile - if not, displays nothing.
module.directive('checkImage', ($log, $http) ->
  return {
    restrict: 'A'
    link: (scope, element, attrs) ->
      attrs.$observe('ngSrc', (ngSrc) ->
        $http.get(ngSrc).success( () ->
          # do nothing
        ).error( () ->
          # prevent broken image tile from being displayed.
          element.remove()
        )
      )
  }
)
{'fraction_non_alphanumeric': 0.1468354430379747, 'fraction_numerical': 0.0014466546112115732, 'mean_word_length': 2.6684350132625996, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2407350', 'n_tokens_mistral': 840, 'n_tokens_neox': 826, 'n_words': 210}