<commit_before>(function(){
  'use strict'

  angular
    .module('thingy.posts.controllers')
    .controller('ThingiesController', ThingiesController);

  ThingiesController.$inject = ['$rootScope', '$scope', 'Authentication', 'Thingies', '$route', '$cookies', '$location'];

  function ThingiesController($rootScope, $scope, Authentication, Thingies, $route, $cookies, $location) {
    var vm = this;

    vm.isAuthenticated = Authentication.isAuthenticated();
    vm.posts = [];
    vm.create = create;
    vm.categories = [{id:1,cname:'tools'}, {id:2,cname:'cars'}];

    activate();

    function activate() {
      restoreSearch();
      Thingies.allPosts().then(postsSuccessFn, postsErrorFn);
      Thingies.allCategories().then(categoriesSuccessFn, categoriesErrorFn);


      bindEvents();

      /* Prompts the user on refresh
      window.onbeforeunload = function (e) {
        console.log("Refresh");
        return "Are you sure?";
      };*/

      /**
      * @name postsSuccessFn
      * @desc Update posts array on view
      */
      function postsSuccessFn(data, status, headers, config) {
        vm.posts = data.data;
      }

      /**
      * @name postsErrorFn
      * @desc Show snackbar with error
      */
      function postsErrorFn(data, status, headers, config) {
        alert(data.error);
      }

      function categoriesSuccessFn(data, status, headers, config) {
        vm.categories = data.data;
      }

      function categoriesErrorFn(data, status, headers, config) {
        alert(data.data.error);
      }

      function restoreSearch() {
        var tabId = $location.hash();
        var savedForm = $cookies.getObject('savedForm');
        if (!jQuery.isEmptyObject(tabId))
        {
          // Tabs
          $(".nav-tabs li").removeClass("active");
          $("#" + tabId + "-tab").addClass("active");
          // Panes
          $(".tab-pane").removeClass("in active");
          $("#" + tabId).addClass("in active");
        }
        if (savedForm)
        {
          // Forms
          vm.search = savedForm.search;
          vm.title = savedForm.title;
          vm.description = savedForm.description;
          vm.username = savedForm.username;
          vm.price = savedForm.price;
          vm.categoryId = savedForm.categoryId;
          // Actions
          //if (searchObject.action) vm.search();
        }
      }

      function bindEvents() {
        // Save form on refresh
        $rootScope.$on('login', function (event, post) {
          $cookies.putObject('savedForm', {
              search: vm.search,
              title: vm.title,
              description: vm.description,
              price: vm.price,
              categoryId: vm.categoryId
            }, {expires: new Date(Date.now() + 2000)} // valid for 2 seconds
          );
        });
      }
    }


    function create() {
      Thingies.create( vm.description, vm.title, vm.price, vm.category).then(createPostSuccessFn, createPostErrorFn);

      /**
      * @name createPostSuccessFn
      * @desc Show snackbar with success message
      */
      function createPostSuccessFn(data, status, headers, config) {
	console.log(vm.price);
        resetForms();
        $route.reload();
      }

      /**
      * @name createPostErrorFn
      * @desc Propogate error event and show snackbar with error message
      */
      function createPostErrorFn(data, status, headers, config) {
        alert('Ooops...');
      };
    }

    function resetForms() {
      vm.title = vm.description = vm.username = vm.find = "";
    }
  }
})();
<commit_msg>Hotfix<commit_after>(function(){
  'use strict'

  angular
    .module('thingy.posts.controllers')
    .controller('ThingiesController', ThingiesController);

  ThingiesController.$inject = ['$rootScope', '$scope', 'Authentication', 'Thingies', '$route', '$cookies', '$location'];

  function ThingiesController($rootScope, $scope, Authentication, Thingies, $route, $cookies, $location) {
    var vm = this;

    vm.isAuthenticated = Authentication.isAuthenticated();
    vm.posts = [];
    vm.create = create;
    vm.categories = [{id:1,cname:'tools'}, {id:2,cname:'cars'}];

    activate();

    function activate() {
      restoreSearch();
      Thingies.allPosts().then(postsSuccessFn, postsErrorFn);
      Thingies.allCategories().then(categoriesSuccessFn, categoriesErrorFn);

      bindEvents();

      /* Prompts the user on refresh
      window.onbeforeunload = function (e) {
        console.log("Refresh");
        return "Are you sure?";
      };*/

      /**
      * @name postsSuccessFn
      * @desc Update posts array on view
      */
      function postsSuccessFn(data, status, headers, config) {
        vm.posts = data.data;
      }

      /**
      * @name postsErrorFn
      * @desc Show snackbar with error
      */
      function postsErrorFn(data, status, headers, config) {
        alert(data.error);
      }

      function categoriesSuccessFn(data, status, headers, config) {
        vm.categories = data.data;
      }

      function categoriesErrorFn(data, status, headers, config) {
        alert(data.data.error);
      }

      function restoreSearch() {
        var tabId = $location.hash();
        var savedForm = $cookies.getObject('savedForm');
        if (!jQuery.isEmptyObject(tabId))
        {
          // Tabs
          $(".nav-tabs li").removeClass("active");
          $("#" + tabId + "-tab").addClass("active");
          // Panes
          $(".tab-pane").removeClass("in active");
          $("#" + tabId).addClass("in active");
        }
        if (savedForm)
        {
          // Forms
          vm.search = savedForm.search;
          vm.title = savedForm.title;
          vm.description = savedForm.description;
          vm.username = savedForm.username;
          vm.price = savedForm.price;
          vm.categoryId = savedForm.categoryId;
          // Actions
          //if (searchObject.action) vm.search();
        }
      }

      function bindEvents() {
        // Save form on refresh
        $rootScope.$on('login', function (event, post) {
          $cookies.putObject('savedForm', {
              search: vm.search,
              title: vm.title,
              description: vm.description,
              price: vm.price,
              categoryId: vm.categoryId
            }, {expires: new Date(Date.now() + 2000)} // valid for 2 seconds
          );
        });
      }
    }


    function create() {
      Thingies.create( vm.description, vm.title, vm.price, vm.category).then(createPostSuccessFn, createPostErrorFn);

      /**
      * @name createPostSuccessFn
      * @desc Show snackbar with success message
      */
      function createPostSuccessFn(data, status, headers, config) {
        resetForms();
        $route.reload();
      }

      /**
      * @name createPostErrorFn
      * @desc Propogate error event and show snackbar with error message
      */
      function createPostErrorFn(data, status, headers, config) {
        alert('Ooops...');
      };
    }

    function resetForms() {
      vm.title = vm.description = vm.username = vm.find = "";
    }
  }
})();

{'fraction_non_alphanumeric': 0.13775224215246637, 'fraction_numerical': 0.001961883408071749, 'mean_word_length': 2.1275197195442592, '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': '6125122', 'n_tokens_mistral': 2049, 'n_tokens_neox': 1985, 'n_words': 425}