<commit_before>'use strict';

define(['angular'], function(angular) {

  var app = angular.module('portal.widgets.services', []);

  app.factory('widgetService', ['$http', '$log', 'SERVICE_LOC', function($http, $log, SERVICE_LOC) {

    /**
     * Get the a single app's full entity file as JSON
     * @param fname The app's fname value (<fname> in entity files)
     * @returns {*}
     */
    var getSingleWidgetData = function getSingleWidgetData(fname) {
      return $http.get(SERVICE_LOC.widgetApi.entry + fname + '.json')
        .then(function(result) {
          if (result.data.entry.layoutObject != undefined) {
            return result.data.entry.layoutObject;
          }
        })
        .catch(function(error) {
          return getErrorPage(fname);
          $log.warn('Error getting marketplace entry for ' + fname);
          $log.error(error);
        });
    };

    var getErrorPage = function(fname) {
      var layoutObject={title:fname, 
        mdIcon:"md-help", widgetType: "generic",
      widgetConfig:{additionalText: "Please contact your help desk if you feel you should be able to access this content"},
        widgetTemplate:"<i class='fa fa-exclamation-triangle fa-3x pull-left' style='color: #b70101;'></i><span style='color: #898989;'>You do not have permission to access this content. If you feel this is an error, please contact your help desk.</span>"}
      return layoutObject;
    }

    /**
     * Get additional values/configuration not provided by the widget's basic configuration.
     * Used by Option Link and Custom widgets
     * @param widget
     * @returns {*}
     */
    var getWidgetJson = function(widget) {<commit_msg>Reordering to preserve logging statements<commit_after>'use strict';

define(['angular'], function(angular) {

  var app = angular.module('portal.widgets.services', []);

  app.factory('widgetService', ['$http', '$log', 'SERVICE_LOC', function($http, $log, SERVICE_LOC) {

    /**
     * Get the a single app's full entity file as JSON
     * @param fname The app's fname value (<fname> in entity files)
     * @returns {*}
     */
    var getSingleWidgetData = function getSingleWidgetData(fname) {
      return $http.get(SERVICE_LOC.widgetApi.entry + fname + '.json')
        .then(function(result) {
          if (result.data.entry.layoutObject != undefined) {
            return result.data.entry.layoutObject;
          }
        })
        .catch(function(error) {
          $log.warn('Error getting marketplace entry for ' + fname);
          $log.error(error);
          return getErrorPage(fname);
      });
    };

    var getErrorPage = function(fname) {
      var layoutObject={title:fname, 
        mdIcon:"md-help", widgetType: "generic",
      widgetConfig:{additionalText: "Please contact your help desk if you feel you should be able to access this content"},
        widgetTemplate:"<i class='fa fa-exclamation-triangle fa-3x pull-left' style='color: #b70101;'></i><span style='color: #898989;'>You do not have permission to access this content. If you feel this is an error, please contact your help desk.</span>"}
      return layoutObject;
    }

    /**
     * Get additional values/configuration not provided by the widget's basic configuration.
     * Used by Option Link and Custom widgets
     * @param widget
     * @returns {*}
     */
    var getWidgetJson = function(widget) {
{'fraction_non_alphanumeric': 0.12640283520378026, 'fraction_numerical': 0.0070880094506792675, 'mean_word_length': 2.980023501762632, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '7312522', 'n_tokens_mistral': 981, 'n_tokens_neox': 943, 'n_words': 280}