<commit_before>(function() {

var app = angular.module('optc');

var directives = { };

/*****************
 * UI directives *
 *****************/

directives.autoFocus = function($timeout) {
	return {
		restrict: 'A',
		link: function(scope, element, attrs) {
			$timeout(function(){ element[0].focus(); });
		}
	};
};

directives.decorateSlot = function() {
    return {
        restrict: 'A',
        scope: { uid: '=', udata: '=' },
        link: function(scope, element, attrs) {
            var update = function() { 
                var target = element[0];
                if (!scope.uid && !scope.udata) {
                    target.style.backgroundImage = null;
                    target.removeAttribute('title');
                } else {
                    target.style.backgroundImage = 'url(' + Utils.getThumbnailUrl(scope.uid) + ')';
                    if (attrs.decorateSlot.indexOf('notitle') == -1)
                        target.setAttribute('title', Utils.getThumbnailTitle(scope.udata || scope.uid));
                }
            };
            scope.$watch('uid',update);
            scope.$watch('udata',update);
        }
    };
};

directives.expandableDamage = function() {
    return {
        restrict: 'A',
        link: function(scope, element, attrs) {
            scope.detailsVisible = false;
            element.click(function(e) {
                if (e.which != 1 || e.ctrlKey) return;
                element.toggleClass('details');
                if (!scope.detailsVisible) {
                    element[0].style.zIndex = 5;
                    setTimeout(function() { scope.detailsVisible = true; scope.$apply();
                    },500);
                } else {
                    scope.detailsVisible = false;
                    scope.$apply();
                    setTimeout(function() { element[0].style.zIndex = 4; },500);
                }
            });
        },
    };
};

directives.detailPane = function() {
    return {
        restrict: 'A',
        templateUrl: 'views/details.html',
        scope: true,
        link: function(scope, element, attrs) {
            var modifiers = [ 'Miss', 'Good', 'Great', 'Perfect' ];
            scope.modifyDamage = function(e,n) {
                if (e.which != 2 && (e.which != 1 || !e.ctrlKey)) return;
                var custom = $.extend([ ],scope.numbers[scope.type].hitModifiers);
                custom[n] = modifiers[(modifiers.indexOf(custom[n])+1)%4];
                scope.tdata.customHitModifiers = custom;
                e.preventDefault();
                e.stopPropagation();
                return false;
            };
        }
    };
};

directives.attachPicker = function() {
    return {
        restrict: 'A',
        scope: true,
        controller: function($scope, $state) { $scope.$state = $state; },
        link: function(scope, element, attrs) {
            element.click(function(e) {
                if (e.which != 1 || e.ctrlKey) return;
                if ($(e.target).parent().hasClass('slide') || Utils.isClickOnOrb(e,e.target)) return;
                scope.$state.go('.pick',{ slot: scope.slot });
            });
        }
    };
};

directives.defenseOnClick = function() {
    return {
        restrict: 'A',
        controller: function($scope, $state) { $scope.go = $state.go; },
        link: function(scope, element, attrs) {
            element.click(function(e) {
                if (e.which == 2 || (e.which == 1 && e.ctrlKey))
                    scope.go('.defense');
                else if (e.which == 1)
                    element.find('input').focus();
            });
        }
    };
};

directives.shipManager = function() {
    return {
        restrict: 'A',
        scope: true,
        controller: function($scope, $state) { $scope.go = $state.go; },
        link: function(scope, element, attrs) {
            var background = element.find('#ship-background')[0];
            background.style.width = Math.round(scope.data.ship.level * 10)  + '%';
            scope.level = scope.data.ship.level;
            element.click(function(e) {
                if (e.which == 2 || (e.which == 1 && e.ctrlKey))
                    scope.go('.ship');
            });
            var updateBackground = function(perc) {
                perc = Math.min(1,perc);
                background.style.width = Math.min(Math.round(perc * 100),100)  + '%';
                background.style.background =
                    'rgb(' + [ Math.floor(240-148*perc), Math.floor(173+11*perc), Math.floor(78+14*perc) ].join(',') + ')';
            };
            var mouseup = function(e) {
                $(document).off('mouseup');
                $(document).off('mousemove');
                scope.data.ship.level = scope.level;
                scope.$apply();
                updateBackground(scope.level / 10);
            };
            var mousemove = function(e) {
                var level = Math.max(1,Math.min(Math.round(e.clientX / 230 * 10),10));
                if (level == scope.data.ship.level) return;
                e.preventDefault();
                e.stopPropagation();
                scope.level = level;
                scope.$apply();
                updateBackground(e.clientX / 230);
            };
            element.mousedown(function(e) {
                if (e.which != 1 || e.ctrlKey) return;
                var level = Math.round(e.clientX / 230 * 10);
                $(document).mouseup(mouseup);
                $(document).mousemove(mousemove);<commit_msg>fixed ship level slider<commit_after>(function() {

var app = angular.module('optc');

var directives = { };

/*****************
 * UI directives *
 *****************/

directives.autoFocus = function($timeout) {
	return {
		restrict: 'A',
		link: function(scope, element, attrs) {
			$timeout(function(){ element[0].focus(); });
		}
	};
};

directives.decorateSlot = function() {
    return {
        restrict: 'A',
        scope: { uid: '=', udata: '=' },
        link: function(scope, element, attrs) {
            var update = function() { 
                var target = element[0];
                if (!scope.uid && !scope.udata) {
                    target.style.backgroundImage = null;
                    target.removeAttribute('title');
                } else {
                    target.style.backgroundImage = 'url(' + Utils.getThumbnailUrl(scope.uid) + ')';
                    if (attrs.decorateSlot.indexOf('notitle') == -1)
                        target.setAttribute('title', Utils.getThumbnailTitle(scope.udata || scope.uid));
                }
            };
            scope.$watch('uid',update);
            scope.$watch('udata',update);
        }
    };
};

directives.expandableDamage = function() {
    return {
        restrict: 'A',
        link: function(scope, element, attrs) {
            scope.detailsVisible = false;
            element.click(function(e) {
                if (e.which != 1 || e.ctrlKey) return;
                element.toggleClass('details');
                if (!scope.detailsVisible) {
                    element[0].style.zIndex = 5;
                    setTimeout(function() { scope.detailsVisible = true; scope.$apply();
                    },500);
                } else {
                    scope.detailsVisible = false;
                    scope.$apply();
                    setTimeout(function() { element[0].style.zIndex = 4; },500);
                }
            });
        },
    };
};

directives.detailPane = function() {
    return {
        restrict: 'A',
        templateUrl: 'views/details.html',
        scope: true,
        link: function(scope, element, attrs) {
            var modifiers = [ 'Miss', 'Good', 'Great', 'Perfect' ];
            scope.modifyDamage = function(e,n) {
                if (e.which != 2 && (e.which != 1 || !e.ctrlKey)) return;
                var custom = $.extend([ ],scope.numbers[scope.type].hitModifiers);
                custom[n] = modifiers[(modifiers.indexOf(custom[n])+1)%4];
                scope.tdata.customHitModifiers = custom;
                e.preventDefault();
                e.stopPropagation();
                return false;
            };
        }
    };
};

directives.attachPicker = function() {
    return {
        restrict: 'A',
        scope: true,
        controller: function($scope, $state) { $scope.$state = $state; },
        link: function(scope, element, attrs) {
            element.click(function(e) {
                if (e.which != 1 || e.ctrlKey) return;
                if ($(e.target).parent().hasClass('slide') || Utils.isClickOnOrb(e,e.target)) return;
                scope.$state.go('.pick',{ slot: scope.slot });
            });
        }
    };
};

directives.defenseOnClick = function() {
    return {
        restrict: 'A',
        controller: function($scope, $state) { $scope.go = $state.go; },
        link: function(scope, element, attrs) {
            element.click(function(e) {
                if (e.which == 2 || (e.which == 1 && e.ctrlKey))
                    scope.go('.defense');
                else if (e.which == 1)
                    element.find('input').focus();
            });
        }
    };
};

directives.shipManager = function() {
    return {
        restrict: 'A',
        scope: true,
        controller: function($scope, $state) { $scope.go = $state.go; },
        link: function(scope, element, attrs) {
            var background = element.find('#ship-background')[0];
            background.style.width = Math.round(scope.data.ship.level * 10)  + '%';
            scope.level = scope.data.ship.level;
            element.click(function(e) {
                if (e.which == 2 || (e.which == 1 && e.ctrlKey))
                    scope.go('.ship');
            });
            var updateBackground = function(perc) {
                perc = Math.min(1,perc);
                background.style.width = Math.min(Math.round(perc * 100),100)  + '%';
                background.style.background =
                    'rgb(' + [ Math.floor(240-148*perc), Math.floor(173+11*perc), Math.floor(78+14*perc) ].join(',') + ')';
            };
            var mouseup = function(e) {
                $(document).off('mouseup');
                $(document).off('mousemove');
                scope.data.ship.level = scope.level;
                scope.$apply();
                updateBackground(scope.level / 10);
            };
            var mousemove = function(e) {
                var level = Math.max(1,Math.min(Math.round(e.clientX / 230 * 10),10));
                if (level == scope.data.ship.level) return;
                e.preventDefault();
                e.stopPropagation();
                scope.level = level;
                scope.$apply();
                updateBackground(e.clientX / 230);
            };
            element.mousedown(function(e) {
                if (e.which != 1 || e.ctrlKey) return;
                var level = Math.max(1,Math.round(e.clientX / 230 * 10));
                $(document).mouseup(mouseup);
                $(document).mousemove(mousemove);
{'fraction_non_alphanumeric': 0.15981240981240982, 'fraction_numerical': 0.012355699855699856, 'mean_word_length': 1.5987813452074058, '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': '5412779', 'n_tokens_mistral': 3257, 'n_tokens_neox': 3059, 'n_words': 550}