<commit_before>"use strict"

angular.module('myApp.jokes', [])

.config(['$stateProvider', '$urlRouterProvider', function($stateProvider, $urlRouterProvider) {
    $stateProvider
    .state('jokes', {
        url: '/jokes',
        data: {
            permissions: {
                except: ['anonymous'],
                redirectTo: 'auth'
            }
        },
        views: {
            'jokesContent': {
                templateUrl: "view_jokes/jokes.html",
                controller: "JokesCtrl as jokes"
            }
        }
    })
}])

.controller('JokesCtrl', ['$http', '$auth', '$rootScope', '$state', '$q', function($http, $auth, $rootScope, $state, $q) {
    let vm = this

    vm.jokes = []
    vm.error
    vm.joke

    $http.get('http://localhost:8000/api/v1/jokes').success((jokes) => {
        console.log(jokes)
        vm.jokes = jokes.data
    }).error((error) => {
        vm.error = error
    })

    vm.addJoke = () => {
        $http.post('http://localhost:8000/api/v1/jokes', {
            body: vm.joke,
            user_id: $rootScope.currentUser.id
        }).success(function(response) {
            /*console.log(vm.jokes)
            vm.jokes.push(response.data)*/
            vm.jokes.unshift(response.data)
            console.log(vm.jokes)
            vm.joke = ''
            /*alert(data.message)
            alert("Joke Created Successfully")*/
        }).error(() => {
            console.log("error")
        })
    }
}])<commit_msg>update joke<commit_after>"use strict"

angular.module('myApp.jokes', [])

.config(['$stateProvider', '$urlRouterProvider', function($stateProvider, $urlRouterProvider) {
    $stateProvider
    .state('jokes', {
        url: '/jokes',
        data: {
            permissions: {
                except: ['anonymous'],
                redirectTo: 'auth'
            }
        },
        views: {
            'jokesContent': {
                templateUrl: "view_jokes/jokes.html",
                controller: "JokesCtrl as jokes"
            }
        }
    })
}])

.controller('JokesCtrl', ['$http', '$auth', '$rootScope', '$state', '$q', function($http, $auth, $rootScope, $state, $q) {
    let vm = this

    vm.jokes = []
    vm.error
    vm.joke

    $http.get('http://localhost:8000/api/v1/jokes').success((jokes) => {
        console.log(jokes)
        vm.jokes = jokes.data
    }).error((error) => {
        vm.error = error
    })

    vm.addJoke = () => {
        $http.post('http://localhost:8000/api/v1/jokes', {
            body: vm.joke,
            user_id: $rootScope.currentUser.id
        }).success(function(response) {
            /*console.log(vm.jokes)
            vm.jokes.push(response.data)*/
            vm.jokes.unshift(response.data)
            console.log(vm.jokes)
            vm.joke = ''
            /*alert(data.message)
            alert("Joke Created Successfully")*/
        }).error(() => {
            console.log("error")
        })
    }

    vm.updateJoke = (joke) => {
        console.log(joke)
        $http.put('http://localhost:8000/api/v1/jokes/' + joke.joke_id, {
            body: joke.joke,
            user_id: $rootScope.currentUser.id
        }).success((response) => {
            // alert("Joke Updated Successfully")
        }).error(() => {
            console.log("error")
        })
    }
}])
{'fraction_non_alphanumeric': 0.17433122933573791, 'fraction_numerical': 0.007514277126540427, 'mean_word_length': 1.7323481116584565, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 14, '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': '1080070', 'n_tokens_mistral': 1069, 'n_tokens_neox': 1040, 'n_words': 150}