<commit_before>/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, you can obtain one at http://mozilla.org/MPL/2.0/. */

"use strict";

treeherder.controller('MainCtrl', [
    '$scope', '$rootScope', '$routeParams', '$location', 'ThLog',
    'ThRepositoryModel', 'thPinboard',
    'thClassificationTypes', 'thEvents', '$interval', '$window',
    'ThExclusionProfileModel', 'thJobFilters', 'ThResultSetModel',
    'thDefaultRepo',
    function MainController(
        $scope, $rootScope, $routeParams, $location, ThLog,
        ThRepositoryModel, thPinboard,
        thClassificationTypes, thEvents, $interval, $window,
        ThExclusionProfileModel, thJobFilters, ThResultSetModel,
        thDefaultRepo) {

        var $log = new ThLog("MainCtrl");

        thClassificationTypes.load();

        $rootScope.getWindowTitle = function() {
            var ufc = $scope.getUnclassifiedFailureCount($rootScope.repoName);
            return "[" + ufc + "] " + $rootScope.repoName;
        };

        $scope.closeJob = function() {
            // Setting the selectedJob to null closes the bottom panel
            $rootScope.selectedJob = null;

            // Clear the selected job display style
            $rootScope.$emit(thEvents.clearJobStyles, $rootScope.selectedJob);

            // Reset selected job to null to initialize nav position
            ThResultSetModel.setSelectedJob($rootScope.repoName);
        };

        $scope.processKeyboardInput = function(ev){

            // If the user is in an editable element or the user is pressing
            // shift, then disable keyboard events
            var activeElement = document.activeElement;
            if (activeElement.tagName === 'INPUT' ||
                activeElement.tagName === 'SELECT' ||
                activeElement.tagName === 'TEXTAREA' ||
                activeElement.isContentEditable || ev.keyCode === 16) {
                return;
            }
            
            // Shortcut: highlight previous job
            Mousetrap.bind(['left'], function() {
                $rootScope.$emit(thEvents.selectPreviousJob);
            });

            // Shortcut: highlight next job
            Mousetrap.bind(['right'], function() {
                $rootScope.$emit(thEvents.selectNextJob);
            });

            // test for key modifiers to allow browser shortcuts eg.
            // console, new/private browsing window, history, print
            if (!ev.metaKey && !ev.shiftKey && !ev.ctrlKey) {
                if (ev.keyCode === 73) {
                    // toggle display in-progress jobs(pending/running), key:i
                    $scope.toggleInProgress();

                } else if ((ev.keyCode === 74) || (ev.keyCode === 78)) {
                    //Highlight next unclassified failure keys:j/n
                    $rootScope.$emit(
                        thEvents.selectNextUnclassifiedFailure
                    );

                } else if ((ev.keyCode === 75) || (ev.keyCode === 80)) {
                    //Highlight previous unclassified failure keys:k/p
                    $rootScope.$emit(
                        thEvents.selectPreviousUnclassifiedFailure
                    );

                } else if (ev.keyCode === 32) {
                    // If a job is selected add it otherwise
                    // let the browser handle the spacebar
                    if ($scope.selectedJob) {
                        // Pin selected job to pinboard, key:[spacebar]
                        // and prevent page down propagating to the jobs panel
                        ev.preventDefault();
                        $rootScope.$emit(thEvents.jobPin, $rootScope.selectedJob);
                    }

                } else if (ev.keyCode === 85) {
                    // Display only unclassified failures, keys:u
                    $scope.toggleUnclassifiedFailures();

                } else if (ev.keyCode === 82) {
                    // Pin selected job to pinboard and add a related bug, key:r
                    if ($scope.selectedJob) {
                        $rootScope.$emit(thEvents.addRelatedBug, $rootScope.selectedJob);
                    }

                } else if (ev.keyCode === 27) {
                    // Escape closes any open panels and clears the selected job
                    $scope.setFilterPanelShowing(false);
                    $scope.setSettingsPanelShowing(false);
                    $scope.setSheriffPanelShowing(false);
                    $scope.closeJob();
                }
<commit_msg>reverting to ev.keyCode instead of mousetrap<commit_after>/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, you can obtain one at http://mozilla.org/MPL/2.0/. */

"use strict";

treeherder.controller('MainCtrl', [
    '$scope', '$rootScope', '$routeParams', '$location', 'ThLog',
    'ThRepositoryModel', 'thPinboard',
    'thClassificationTypes', 'thEvents', '$interval', '$window',
    'ThExclusionProfileModel', 'thJobFilters', 'ThResultSetModel',
    'thDefaultRepo',
    function MainController(
        $scope, $rootScope, $routeParams, $location, ThLog,
        ThRepositoryModel, thPinboard,
        thClassificationTypes, thEvents, $interval, $window,
        ThExclusionProfileModel, thJobFilters, ThResultSetModel,
        thDefaultRepo) {

        var $log = new ThLog("MainCtrl");

        thClassificationTypes.load();

        $rootScope.getWindowTitle = function() {
            var ufc = $scope.getUnclassifiedFailureCount($rootScope.repoName);
            return "[" + ufc + "] " + $rootScope.repoName;
        };

        $scope.closeJob = function() {
            // Setting the selectedJob to null closes the bottom panel
            $rootScope.selectedJob = null;

            // Clear the selected job display style
            $rootScope.$emit(thEvents.clearJobStyles, $rootScope.selectedJob);

            // Reset selected job to null to initialize nav position
            ThResultSetModel.setSelectedJob($rootScope.repoName);
        };

        $scope.processKeyboardInput = function(ev){

            // If the user is in an editable element or the user is pressing
            // shift, then disable keyboard events
            var activeElement = document.activeElement;
            if (activeElement.tagName === 'INPUT' ||
                activeElement.tagName === 'SELECT' ||
                activeElement.tagName === 'TEXTAREA' ||
                activeElement.isContentEditable || ev.keyCode === 16) {
                return;
            }

            // test for key modifiers to allow browser shortcuts eg.
            // console, new/private browsing window, history, print
            if (!ev.metaKey && !ev.shiftKey && !ev.ctrlKey) {
                if (ev.keyCode === 73) {
                    // toggle display in-progress jobs(pending/running), key:i
                    $scope.toggleInProgress();

                } else if ((ev.keyCode === 74) || (ev.keyCode === 78)) {
                    //Highlight next unclassified failure keys:j/n
                    $rootScope.$emit(
                        thEvents.selectNextUnclassifiedFailure
                    );

                } else if ((ev.keyCode === 75) || (ev.keyCode === 80)) {
                    //Highlight previous unclassified failure keys:k/p
                    $rootScope.$emit(
                        thEvents.selectPreviousUnclassifiedFailure
                    );

                } else if (ev.keyCode === 32) {
                    // If a job is selected add it otherwise
                    // let the browser handle the spacebar
                    if ($scope.selectedJob) {
                        // Pin selected job to pinboard, key:[spacebar]
                        // and prevent page down propagating to the jobs panel
                        ev.preventDefault();
                        $rootScope.$emit(thEvents.jobPin, $rootScope.selectedJob);
                    }

                } else if(ev.keyCode == 39) {
                    // Highlight next job, key: right arrow
                    $rootScope.$emit(
                        thEvents.selectNextJob
                    );

                } else if(ev.keyCode == 37) {
                    // Highlight previous job, key: left arrow
                    $rootScope.$emit(
                        thEvents.selectPreviousJob
                    );

                } else if (ev.keyCode === 85) {
                    // Display only unclassified failures, keys:u
                    $scope.toggleUnclassifiedFailures();

                } else if (ev.keyCode === 82) {
                    // Pin selected job to pinboard and add a related bug, key:r
                    if ($scope.selectedJob) {
                        $rootScope.$emit(thEvents.addRelatedBug, $rootScope.selectedJob);
                    }

                } else if (ev.keyCode === 27) {
                    // Escape closes any open panels and clears the selected job
                    $scope.setFilterPanelShowing(false);
                    $scope.setSettingsPanelShowing(false);
                    $scope.setSheriffPanelShowing(false);
                    $scope.closeJob();
                }

{'fraction_non_alphanumeric': 0.10347761352759757, 'fraction_numerical': 0.005530149952142933, 'mean_word_length': 1.6085991678224687, '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': '4301321', 'n_tokens_mistral': 2439, 'n_tokens_neox': 2236, 'n_words': 615}