<commit_before>var ideaControllers = angular.module('idealogue.ideaControllers', ['ngRoute','idealogue.utilityServices','idealogue.coreDirectives','idealogue.ideaServices','idealogue.authServices']);

ideaControllers.controller('IdeaListCtrl', function($scope, $q, $location, UtilSvc, ideas, AuthSvc) {
    AuthSvc.checkIfLoggedIn();

    ideas.sort(UtilSvc.sortBy('name', false, function(a){return a.toUpperCase()}));
    $scope.ideas = ideas;

    $scope.toList = function(arr, prop) {
        return UtilSvc.arrayToString(arr, prop);
    };

    $scope.addNew = function() {
        $location.path('/ideas/new');
    };

    $scope.viewIdea = function(ideaId) {
        $location.path('/ideas/view/' + ideaId);
    }
});

ideaControllers.controller('IdeaViewCtrl', function($route, $scope, $q, $location, UtilSvc, Idea, IdeaSvc, idea, people, AuthSvc) {
    AuthSvc.checkIfLoggedIn();

    IdeaSvc.transformIdeaForView(idea, people);
    $scope.idea = idea;
    $('#newCommentText').autoSize();

    $scope.back = function() {
        $location.path('/ideas');
    }

    $scope.edit = function() {
        $location.path('/ideas/edit/' + $scope.idea.id);
    }

    $scope.remove = function() {
        Idea.remove($scope.idea.id, $scope.back);
    }

    $scope.vote = function() {
        var idea = $scope.idea;
        var votes = idea.votes;
        var id = AuthSvc.currentUser();

        if ($.inArray(id, votes) === -1) {
            votes[votes.length] = id;
            idea.voteCount = parseInt(idea.voteCount)+1;
            Idea.save(idea, function() {
                $route.reload();
            });
        }
    }

    $scope.addComment = function() {
        $('#ideaNewComment').show();
        $('#ideaAddCommentButton').hide();
        $('#newCommentText').focus();
    }

    $scope.cancelComment = function() {
        $scope.newComment = null;
        $('#ideaNewComment').hide();
        $('#ideaAddCommentButton').show();
    }

    $scope.saveComment = function() {
        var newComment = $scope.newComment;
        var idea = $scope.idea;

        IdeaSvc.transformIdeaForSave(idea);

        idea.comments[idea.comments.length] = {
            id: AuthSvc.currentUser(),<commit_msg>corrected issue with idea vote functionality<commit_after>var ideaControllers = angular.module('idealogue.ideaControllers', ['ngRoute','idealogue.utilityServices','idealogue.coreDirectives','idealogue.ideaServices','idealogue.authServices']);

ideaControllers.controller('IdeaListCtrl', function($scope, $q, $location, UtilSvc, ideas, AuthSvc) {
    AuthSvc.checkIfLoggedIn();

    ideas.sort(UtilSvc.sortBy('name', false, function(a){return a.toUpperCase()}));
    $scope.ideas = ideas;

    $scope.toList = function(arr, prop) {
        return UtilSvc.arrayToString(arr, prop);
    };

    $scope.addNew = function() {
        $location.path('/ideas/new');
    };

    $scope.viewIdea = function(ideaId) {
        $location.path('/ideas/view/' + ideaId);
    }
});

ideaControllers.controller('IdeaViewCtrl', function($route, $scope, $q, $location, UtilSvc, Idea, IdeaSvc, idea, people, AuthSvc) {
    AuthSvc.checkIfLoggedIn();

    IdeaSvc.transformIdeaForView(idea, people);
    $scope.idea = idea;
    $('#newCommentText').autoSize();

    $scope.back = function() {
        $location.path('/ideas');
    }

    $scope.edit = function() {
        $location.path('/ideas/edit/' + $scope.idea.id);
    }

    $scope.remove = function() {
        Idea.remove($scope.idea.id, $scope.back);
    }

    $scope.vote = function() {
        var idea = $scope.idea;
        var votes = idea.votes;
        var id = AuthSvc.currentUser();

        if ($.inArray(id, votes) === -1) {
            votes[votes.length] = id;
            idea.voteCount = parseInt(idea.voteCount)+1;
            
            IdeaSvc.transformIdeaForSave(idea);
            Idea.save(idea, function() {
                console.log("saved");
                $route.reload();
            });
        }
    }

    $scope.addComment = function() {
        $('#ideaNewComment').show();
        $('#ideaAddCommentButton').hide();
        $('#newCommentText').focus();
    }

    $scope.cancelComment = function() {
        $scope.newComment = null;
        $('#ideaNewComment').hide();
        $('#ideaAddCommentButton').show();
    }

    $scope.saveComment = function() {
        var newComment = $scope.newComment;
        var idea = $scope.idea;

        IdeaSvc.transformIdeaForSave(idea);

        idea.comments[idea.comments.length] = {
            id: AuthSvc.currentUser(),
{'fraction_non_alphanumeric': 0.16819973718791065, 'fraction_numerical': 0.0008760402978537013, 'mean_word_length': 2.709991876523152, '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': '6268106', 'n_tokens_mistral': 1463, 'n_tokens_neox': 1434, 'n_words': 214}