Skip to content
This repository has been archived by the owner on Jul 22, 2020. It is now read-only.

Commit

Permalink
Edited code a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
piratefinn committed Oct 31, 2016
1 parent c8e4bf5 commit ffc7a20
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions src/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,30 @@ app.controller('MainController', function($rootScope, $scope, $http, $window, $l
// Have they logged in before or first time?
$scope.loggedin = false;

$rootScope.init = function() {
var nameofFile = "localaccount.json";
var store = cordova.file.dataDirectory;
window.resolveLocalFileSystemURL(store + nameofFile, function (existingusermove) {
$location.path('/receipt');
console.log('This user should have already registered!');
}, function (newusermove) {
$location.path('/token');
console.log('This user should be here for first time!');
});
}

// Needed for the loading screen
$rootScope.$on('$routeChangeStart', function(){
var nameofFile = "localaccount.json";
/* var nameofFile = "localaccount.json";
var store = cordova.file.dataDirectory;
window.resolveLocalFileSystemURL(store + nameofFile, function (existingusermove) {
$location.path('/receipt');
console.log('This user should have already registered!');
console.log('This user should have already registered!');
}, function (newusermove) {
$location.path('/token');
console.log('This user should be here for first time!');
});
}); */

/* readFromFile('localacccount.json', function (data) {
console.log(data);
if (data.keyused == true) {
Expand All @@ -64,13 +77,6 @@ app.controller('MainController', function($rootScope, $scope, $http, $window, $l
$scope.testread = function() {
readFromFile('localacccount.json', function (data) {
console.log(data);
if (data.keyused == true) {
$location.path('/receipt');
console.log('This user should be here for first time!')
} else {
$location.path('/token');
console.log('This user should have already registered!')

$http.post(foodloop_fetch_url, {"username": data.username}).then(
function(response) {
console.log('STATUS : ' + response.status);
Expand Down Expand Up @@ -441,5 +447,4 @@ function readFromFile(accountfile, cb) {

/* document.addEventListener("deviceready", function() {
angular.bootstrap(document.body, ["FoodLoop"]);
}, false); */

}, false); */

0 comments on commit ffc7a20

Please sign in to comment.