<commit_before>'use strict';


angular.module('einJahrGroKo.controllers', [])
    .controller('MainCtrl', ['$scope', '$window', 'appTitle',
        function($scope, $window, appTitle) {
            $window.document.title = appTitle;
        }
    ])
    .controller('EjgQuoteCtrl', ['$scope', '$attrs', '$log', 'RandomQuoteService',
        function($scope, $attrs, $log, RandomQuoteService) {
            this.init = function(element) { // jshint unused:false
                var converter = new Markdown.Converter();
                var quote = null;

                RandomQuoteService.getRandQuote().then(function(res) {
                    // FIXME: markdown parser that does not enclose all
                    // converted markdown in paragraph tags by default
                    quote = {
                        'author': res.author,
                        'title': res.title,
                        // the paragraph tags need to be stripped because the content is already
                        // enclosed by a paragraph
                        'text': converter.makeHtml(res.quote).replace('<p>', '').replace('</p>', ''),
                        // the paragraph tags need to be stripped because <cite> may only contain
                        // other phrasing content (and <p> is not one of them)
                        // @see http://www.w3.org/TR/html-markup/cite.html#cite
                        /* jshint camelcase:false */
                        'source': converter.makeHtml(res.quote_src).replace('<p>', '').replace('</p>', '')
                    };

                    $scope.quote = quote;

                }, function(res) {
                    $log.error(res);
                });
            };
        }
    ]);<commit_msg>updated ejgQuoteCtrl to provide quote history<commit_after>'use strict';


angular.module('einJahrGroKo.controllers', [])
    .controller('MainCtrl', ['$scope', '$window', 'appTitle',
        function($scope, $window, appTitle) {
            $window.document.title = appTitle;
        }
    ])
    .controller('EjgQuoteCtrl', ['$scope', '$attrs', '$log', '$location', 'QuoteService', 'QuoteHistoryService',
        function($scope, $attrs, $log, $location, QuoteService, QuoteHistoryService) {
            /**
             * Initialize controller
             * 
             * @param  {Object} element DOM element
             */
            this.init = function(element) { // jshint unused:false
                var hash = $location.hash();
                if (!hash) {
                    $scope.setQuote();
                } else {
                    $scope.setQuote(hash);
                }
            };

            /**
             * If no id is given either the next quote in history is shown
             * or if there are nor more quotes in history a random one is shown.
             * 
             * @param {[type]} id [description]
             */
            $scope.setQuote = function(id) {
                QuoteService.getQuote(id).then(function(res) {
                    $scope.quote = res;

                    // de-/enable `previous` button
                    $scope.hasPrevious = QuoteHistoryService.hasPrevious();
 
                }, function(res) {
                    $log.error(res);
                });
            };

            /**
             * Set previous quote if there is one in the history
             */
            $scope.previousQuote = function() {
                var prevQuote = QuoteHistoryService.getPrevious();
                
                if (prevQuote) {
                    $scope.quote = prevQuote.obj;
                }

                // de-/enable `previous` button
                $scope.hasPrevious = QuoteHistoryService.hasPrevious();
            };
        }
    ]);
{'fraction_non_alphanumeric': 0.1241761138940153, 'fraction_numerical': 0.0002636435539151068, 'mean_word_length': 1.3801756587202008, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, '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': '3793736', 'n_tokens_mistral': 980, 'n_tokens_neox': 903, 'n_words': 221}