<commit_before>'use strict';

(function (angular) {
  angular.module('eventsFeedPluginWidget')
    .controller('WidgetEventCtrl', ['$scope', 'DataStore', 'TAG_NAMES', 'Location', '$routeParams', 'CalenderFeedApi', 'LAYOUTS',
      function ($scope, DataStore, TAG_NAMES, Location, $routeParams, CalenderFeedApi, LAYOUTS) {

        var WidgetEvent = this;
        WidgetEvent.data = null;
        WidgetEvent.event = null;

        var getEventDetails = function (url) {
          var success = function (result) {
              console.log(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>", result);
              WidgetEvent.event = result;
            }
            , error = function (err) {
              console.error('Error In Fetching events', err);
            };
          if ($routeParams.eventIndex)
            CalenderFeedApi.getSingleEventDetails(url, $routeParams.eventIndex).then(success, error);
        };

        /*
         * Fetch user's data from datastore
         */

        var init = function () {
          var success = function (result) {
              WidgetEvent.data = result.data;
              if (!WidgetEvent.data.design)
                WidgetEvent.data.design = {};
              if (!WidgetEvent.data.content)
                WidgetEvent.data.content = {};
              if (!WidgetEvent.data.design.itemDetailsLayout) {
                WidgetEvent.data.design.itemDetailsLayout = LAYOUTS.itemDetailsLayout[0].name;
              }
              getEventDetails(WidgetEvent.data.content.feedUrl);<commit_msg>Implemented the widget sync with design part.<commit_after>'use strict';

(function (angular) {
  angular.module('eventsFeedPluginWidget')
    .controller('WidgetEventCtrl', ['$scope', 'DataStore', 'TAG_NAMES', 'Location', '$routeParams', 'CalenderFeedApi', 'LAYOUTS','Buildfire',
      function ($scope, DataStore, TAG_NAMES, Location, $routeParams, CalenderFeedApi, LAYOUTS,Buildfire) {

        var WidgetEvent = this;
        WidgetEvent.data = null;
        WidgetEvent.event = null;
          var currentListLayout = null;
        var getEventDetails = function (url) {
          var success = function (result) {
              console.log(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>", result);
              WidgetEvent.event = result;
            }
            , error = function (err) {
              console.error('Error In Fetching events', err);
            };
          if ($routeParams.eventIndex)
            CalenderFeedApi.getSingleEventDetails(url, $routeParams.eventIndex).then(success, error);
        };

          /*declare the device width heights*/
          WidgetEvent.deviceHeight = window.innerHeight;
          WidgetEvent.deviceWidth = window.innerWidth;

          /*initialize the device width heights*/
          function initDeviceSize(callback) {
              WidgetEvent.deviceHeight = window.innerHeight;
              WidgetEvent.deviceWidth = window.innerWidth;
              if (callback) {
                  if (WidgetEvent.deviceWidth == 0 || WidgetEvent.deviceHeight == 0) {
                      setTimeout(function () {
                          initDeviceSize(callback);
                      }, 500);
                  } else {
                      callback();
                      if (!$scope.$$phase && !$scope.$root.$$phase) {
                          $scope.$apply();
                      }
                  }
              }
          }

          /*crop image on the basis of width heights*/
          WidgetEvent.cropImage = function (url, settings) {
              var options = {};
              if (!url) {
                  return "";
              }
              else {
                  if (settings.height) {
                      options.height = settings.height;
                  }
                  if (settings.width) {
                      options.width = settings.width;
                  }
                  return Buildfire.imageLib.cropImage(url, options);
              }
          };
            /*update data on change event*/
          var onUpdateCallback = function (event) {
              setTimeout(function () {
                  $scope.imagesUpdated = false;
                  $scope.$digest();
                  if (event && event.tag === TAG_NAMES.EVENTS_FEED_INFO) {
                      WidgetEvent.data = event.data;
                      if (!WidgetEvent.data.design)
                          WidgetEvent.data.design = {};
                      if (!WidgetEvent.data.content)
                          WidgetEvent.data.content = {};
                  }
                  if (!WidgetEvent.data.design.itemDetailsLayout) {
                      WidgetEvent.data.design.itemDetailsLayout = LAYOUTS.itemDetailsLayout[0].name;
                  }

                  currentListLayout = WidgetEvent.data.design.itemDetailsLayout;
                  console.log("hhhhh",currentListLayout)
                  $scope.imagesUpdated = !!event.data.content;
                  $scope.$digest();
              }, 0);
          };
          DataStore.onUpdate().then(null, null, onUpdateCallback);

          /*
           * Fetch user's data from datastore
           */
        var init = function () {
          var success = function (result) {
              WidgetEvent.data = result.data;
              if (!WidgetEvent.data.design)
                WidgetEvent.data.design = {};
              if (!WidgetEvent.data.content)
                WidgetEvent.data.content = {};
              if (!WidgetEvent.data.design.itemDetailsLayout) {
                WidgetEvent.data.design.itemDetailsLayout = LAYOUTS.itemDetailsLayout[0].name;
              }
              getEventDetails(WidgetEvent.data.content.feedUrl);
{'fraction_non_alphanumeric': 0.12071067758230274, 'fraction_numerical': 0.001567671137432503, 'mean_word_length': 1.6088141753748295, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 87, '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': '5208234', 'n_tokens_mistral': 1454, 'n_tokens_neox': 1376, 'n_words': 268}