<commit_before>'use strict';

(function (angular) {
    angular.module('youtubePluginWidget')
        .controller('WidgetSingleCtrl', ['$routeParams', '$filter', 'YoutubeApi', 'DataStore', 'TAG_NAMES', function ($routeParams, $filter, YoutubeApi, DataStore, TAG_NAMES) {
            var currentItemDetailsBgImage = ''
                , getImageUrlFilter = $filter("getImageUrl");

            var WidgetSingle = this;
            WidgetSingle.data = null;
            WidgetSingle.video = null;

            var setCurrentItemListBgImage = function (_WidgetVideoData) {
                var body = angular.element('body');
                if (_WidgetVideoData.design && _WidgetVideoData.design.itemDetailsBgImage && currentItemDetailsBgImage != _WidgetVideoData.design.itemDetailsBgImage) {
                    currentItemDetailsBgImage = _WidgetVideoData.design.itemDetailsBgImage;
                    body.css(
                        'background', '#010101 url('
                        + getImageUrlFilter(currentItemDetailsBgImage, 342, 770, 'resize')
                        + ') repeat fixed top center')
                } else if (_WidgetVideoData.design && !_WidgetVideoData.design.itemDetailsBgImage) {
                    currentItemDetailsBgImage = null;
                    body.css('background', 'none');
                }
            };

            /*
             * Fetch user's data from datastore
             */
            var init = function () {
                var success = function (result) {
                        WidgetSingle.data = result.data;
                        setCurrentItemListBgImage(WidgetSingle.data);
                    }
                    , error = function (err) {
                        console.error('Error while getting data', err);
                    };
                DataStore.get(TAG_NAMES.YOUTUBE_INFO).then(success, error);
            };
            init();

            var getSingleVideoDetails = function (_videoId) {
                var success = function (result) {
                        WidgetSingle.video = result.items && result.items[0];
                    }
                    , error = function (err) {
                        console.error('Error In Fetching Single Video Details', err);
                    };
                YoutubeApi.getSingleVideoDetails(_videoId).then(success, error);
            };
            if ($routeParams.videoId) {
                getSingleVideoDetails($routeParams.videoId);
            } else {
                console.error('Undefined Video Id Provided');
            }

            var onUpdateCallback = function (event) {
                if (event && event.tag === TAG_NAMES.YOUTUBE_INFO) {
                    WidgetSingle.data = event.obj;
                    setCurrentItemListBgImage(WidgetSingle.data);
                }
            };
            DataStore.onUpdate().then(null, null, onUpdateCallback);
        }])
})(window.angular);<commit_msg>On changing single video url, changed data in widget without refresh.<commit_after>'use strict';

(function (angular) {
  angular.module('youtubePluginWidget')
    .controller('WidgetSingleCtrl', ['$routeParams', '$filter', 'YoutubeApi', 'DataStore', 'TAG_NAMES', 'Location', function ($routeParams, $filter, YoutubeApi, DataStore, TAG_NAMES, Location) {
      var currentItemDetailsBgImage = ''
        , getImageUrlFilter = $filter("getImageUrl");

      var WidgetSingle = this;
      WidgetSingle.data = null;
      WidgetSingle.video = null;

      var setCurrentItemListBgImage = function (_WidgetVideoData) {
        var body = angular.element('body');
        if (_WidgetVideoData.design && _WidgetVideoData.design.itemDetailsBgImage && currentItemDetailsBgImage != _WidgetVideoData.design.itemDetailsBgImage) {
          currentItemDetailsBgImage = _WidgetVideoData.design.itemDetailsBgImage;
          body.css(
            'background', '#010101 url('
            + getImageUrlFilter(currentItemDetailsBgImage, 342, 770, 'resize')
            + ') repeat fixed top center')
        } else if (_WidgetVideoData.design && !_WidgetVideoData.design.itemDetailsBgImage) {
          currentItemDetailsBgImage = null;
          body.css('background', 'none');
        }
      };

      /*
       * Fetch user's data from datastore
       */
      var init = function () {
        var success = function (result) {
            WidgetSingle.data = result.data;
            setCurrentItemListBgImage(WidgetSingle.data);
          }
          , error = function (err) {
            console.error('Error while getting data', err);
          };
        DataStore.get(TAG_NAMES.YOUTUBE_INFO).then(success, error);
      };
      init();

      var getSingleVideoDetails = function (_videoId) {
        var success = function (result) {
            WidgetSingle.video = result.items && result.items[0];
          }
          , error = function (err) {
            console.error('Error In Fetching Single Video Details', err);
          };
        YoutubeApi.getSingleVideoDetails(_videoId).then(success, error);
      };
      if ($routeParams.videoId) {
        getSingleVideoDetails($routeParams.videoId);
      } else {
        console.error('Undefined Video Id Provided');
      }

      var onUpdateCallback = function (event) {
        if (event && event.tag === TAG_NAMES.YOUTUBE_INFO) {
          WidgetSingle.data = event.obj;
          if (WidgetSingle.data.content.videoID && (WidgetSingle.data.content.videoID !== $routeParams.videoId)) {
            getSingleVideoDetails(WidgetSingle.data.content.videoID);
          } else if (WidgetSingle.data.content.playListID) {
            Location.goTo("#/feed/" + WidgetSingle.data.content.playListID);
          }
          setCurrentItemListBgImage(WidgetSingle.data);
        }
      };
      DataStore.onUpdate().then(null, null, onUpdateCallback);
    }])
})(window.angular);
{'fraction_non_alphanumeric': 0.10896458227419081, 'fraction_numerical': 0.004406032875783766, 'mean_word_length': 2.0204708290685773, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '6073046', 'n_tokens_mistral': 1569, 'n_tokens_neox': 1470, 'n_words': 289}