<commit_before>angular.module("flooshie", [])
.controller("toiletCtrl", ["$scope", "$http", function($scope, $http){
    
    $scope.peeCount;
    $scope.pooCount;
    $scope.gender;
    var data;
    
    initFromLocalStorage();
    
    $scope.accessToken = "4fdb248ad771e101c196f31e5be93dffaa247d6994ebe490e303c1e55f1970ed";
    
    $scope.deviceId1 = "00e04c035ad5";
    $scope.URL1 = "https://api-http.littlebitscloud.cc/devices/" + $scope.deviceId1 + "/output";
    
    $scope.deviceId2 = "243c200bf913";
    $scope.URL2 = "https://api-http.littlebitscloud.cc/devices/" + $scope.deviceId2 + "/output";
    
    $http.defaults.headers.common.Authorization = "Bearer " + $scope.accessToken;
    
    $scope.poo = function(){
        console.log("POO");
        $http.post($scope.URL2, {percent: 100, duration_ms: 2000})
        .success(function(data){
            $scope.pooCount++;
            console.log("Poo count increased to " + $scope.pooCount)
            alert("Flooshed!");
            updateLocalStorage();
        })
        .error(function(err){
            console.log(err);
        })
    };
    
    $scope.pee = function(){
        console.log("PEE");
        $http.post($scope.URL2, {percent: 100, duration_ms: 1250})
        .success(function(data){
            $scope.peeCount++;
            console.log("Pee count increased to " + $scope.peeCount)
            alert("Flooshed!");
            updateLocalStorage();
        })
        .error(function(err){
            console.log(err);
        })
    };
    
    $scope.updateLocalStorage = function () {
        var data = {
            peeCount: $scope.peeCount,
            pooCount: $scope.pooCount,
            gender: $scope.gender
        };
        localStorage.setItem("data", JSON.stringify(data));

    }
    
    $scope.initFromLocalStorage = function () {
        console.log("init from local storage");
       if(localStorage["data"]){
            data = JSON.parse(localStorage.getItem("data"));
            $scope.peeCount = data.peeCount;
            $scope.pooCount = data.pooCount;
            $scope.gender = data.gender;
        } else {
            data = {peeCount: 0, pooCount: 0, gender: "male"};
            settings ();
            localStorage.setItem("data",JSON.stringify(data));
            initFromLocalStorage();
        }; 
    }

    $scope.toggleSettings function () {
        $("#settingsPanel").slideToggle ();
    }
    
    
    
}]);

<commit_msg>Bugs fixed<commit_after>angular.module("flooshie", [])
.controller("toiletCtrl", ["$scope", "$http", function($scope, $http){
    
    $scope.peeCount;
    $scope.pooCount;
    $scope.gender;
    var data;
    
    
    $scope.accessToken = "4fdb248ad771e101c196f31e5be93dffaa247d6994ebe490e303c1e55f1970ed";
    
    $scope.deviceId1 = "00e04c035ad5";
    $scope.URL1 = "https://api-http.littlebitscloud.cc/devices/" + $scope.deviceId1 + "/output";
    
    $scope.deviceId2 = "243c200bf913";
    $scope.URL2 = "https://api-http.littlebitscloud.cc/devices/" + $scope.deviceId2 + "/output";
    
    $http.defaults.headers.common.Authorization = "Bearer " + $scope.accessToken;
    
    $scope.poo = function(){
        console.log("POO");
        $http.post($scope.URL2, {percent: 100, duration_ms: 2000})
        .success(function(data){
            $scope.pooCount++;
            console.log("Poo count increased to " + $scope.pooCount)
            alert("Flooshed!");
            $scope.updateLocalStorage();
        })
        .error(function(err){
            console.log(err);
        })
    };
    
    $scope.pee = function(){
        console.log("PEE");
        $http.post($scope.URL2, {percent: 100, duration_ms: 1250})
        .success(function(data){
            $scope.peeCount++;
            console.log("Pee count increased to " + $scope.peeCount)
            alert("Flooshed!");
            $scope.updateLocalStorage();
        })
        .error(function(err){
            console.log(err);
        })
    };
    
    $scope.updateLocalStorage = function () {
        var data = {
            peeCount: $scope.peeCount,
            pooCount: $scope.pooCount,
            gender: $scope.gender
        };
        localStorage.setItem("data", JSON.stringify(data));

    };
    
    $scope.initFromLocalStorage = function () {
       if(localStorage["data"]){
            data = JSON.parse(localStorage.getItem("data"));
            $scope.peeCount = data.peeCount;
            $scope.pooCount = data.pooCount;
            $scope.gender = data.gender;
        } else {
            data = {peeCount: 0, pooCount: 0, gender: "male"};
            $scope.toggleSettings ();
            localStorage.setItem("data",JSON.stringify(data));
            $scope.initFromLocalStorage();
        }; 
    };

    $scope.toggleSettings = function () {
        $("#settingsPanel").slideToggle ();
    };
    
    $scope.initFromLocalStorage();
    
    
}]);


{'fraction_non_alphanumeric': 0.15431472081218275, 'fraction_numerical': 0.03208121827411167, 'mean_word_length': 2.1078864353312303, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 4, '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': '3975687', 'n_tokens_mistral': 1659, 'n_tokens_neox': 1535, 'n_words': 213}