<commit_before>(function() {
    'use strict';

    angular
        .module('app.displays', ['app.tm'])
        .directive('displaysPane', displaysPane)
        .directive('embeddedDisplay', embeddedDisplay)
        .config(configure);

    /* @ngInject */
    function displaysPane() {
        return {
            restrict: 'E',
            transclude: true,
            scope: { activePane: '@', headerTitle: '@' },
            templateUrl: '/_static/app/displays/displays.template.html'
        };
    }

    /* @ngInject */
    function embeddedDisplay(displaysService, tmService, $rootScope) {
        return {
            restrict: 'A',
            scope: { ref: '@' },
            link: function(scope, elem, attrs) {
                var spinner = new Spinner();
                spinner.spin(elem[0]);
                displaysService.getDisplay(attrs['ref']).then(function(rawDisplay) {
                    USS.drawAndConnectDisplay(rawDisplay, elem, tmService, function(display) {

                        // 'Leak' canvas color
                        // This should not be done here. But I'm not yet fully understanding angular
                        // intricacities when it comes to scopes, directives and DOM manipulations.
                        //elem.parents('.main').css('background-color', display.bgcolor);
                        $('body').css('background-color', display.bgcolor);
                        spinner.stop();
                        scope.$on('$destroy', function () {
                            $('body').css('background-color', '');
                        });
                    });
                });
            }
        }
    }

    /* @ngInject */
    function configure($routeProvider) {
        $routeProvider.when('/displays', {
            templateUrl: '/_static/app/displays/pages/displays.html',
            controller: 'DisplaysController',
            controllerAs: 'vm'
        }).when('/displays/:display', {
            templateUrl: '/_static/app/displays/pages/display.html',
            controller: 'DisplayController',
            controllerAs: 'vm'
        }).when('/displays/:group/:display', {
            templateUrl: '/_static/app/displays/pages/display.html',
            controller: 'DisplayController',
            controllerAs: 'vm'
        });
    }
})();
<commit_msg>Try and reuse spinner instances when opening displays<commit_after>(function() {
    'use strict';

    angular
        .module('app.displays', ['app.tm'])
        .directive('displaysPane', displaysPane)
        .directive('embeddedDisplay', embeddedDisplay)
        .config(configure);

    /* @ngInject */
    function displaysPane() {
        return {
            restrict: 'E',
            transclude: true,
            scope: { activePane: '@', headerTitle: '@' },
            templateUrl: '/_static/app/displays/displays.template.html'
        };
    }

    /* @ngInject */
    function embeddedDisplay(displaysService, tmService, $rootScope) {
        return {
            restrict: 'A',
            scope: { ref: '@' },
            link: function(scope, elem, attrs) {
                if (!elem.data('spinner')) {
                    elem.data('spinner', new Spinner());
                }
                elem.data('spinner').spin(elem[0]);

                displaysService.getDisplay(attrs['ref']).then(function(rawDisplay) {
                    USS.drawAndConnectDisplay(rawDisplay, elem, tmService, function(display) {

                        // 'Leak' canvas color
                        // This should not be done here. But I'm not yet fully understanding angular
                        // intricacities when it comes to scopes, directives and DOM manipulations.
                        //elem.parents('.main').css('background-color', display.bgcolor);
                        $('body').css('background-color', display.bgcolor);
                        elem.data('spinner').stop();
                        scope.$on('$destroy', function () {
                            $('body').css('background-color', '');
                        });
                    });
                });
            }
        }
    }

    /* @ngInject */
    function configure($routeProvider) {
        $routeProvider.when('/displays', {
            templateUrl: '/_static/app/displays/pages/displays.html',
            controller: 'DisplaysController',
            controllerAs: 'vm'
        }).when('/displays/:display', {
            templateUrl: '/_static/app/displays/pages/display.html',
            controller: 'DisplayController',
            controllerAs: 'vm'
        }).when('/displays/:group/:display', {
            templateUrl: '/_static/app/displays/pages/display.html',
            controller: 'DisplayController',
            controllerAs: 'vm'
        });
    }
})();

{'fraction_non_alphanumeric': 0.13921161825726142, 'fraction_numerical': 0.0004149377593360996, 'mean_word_length': 1.6243875884594448, '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': '2758161', 'n_tokens_mistral': 1255, 'n_tokens_neox': 1200, 'n_words': 220}