/*
 * Please see the included README.md file for license terms and conditions.
 */


// This file is a suggested starting place for your code.
// It is completely optional and not required.
// Note the reference that includes it in the index.html file.


/*jslint browser:true, devel:true, white:true, vars:true */
/*global $:false, intel:false app:false, dev:false, cordova:false */


// For improved debugging and maintenance of your app, it is highly
// recommended that you separate your JavaScript from your HTML files.
// Use the addEventListener() method to associate events with DOM elements.

// For example:

// var el ;
// el = document.getElementById("id_myButton") ;
// el.addEventListener("click", myEventHandler, false) ;



// The function below is an example of the best way to "start" your app.
// This example is calling the standard Cordova "hide splashscreen" function.
// You can add other code to it or add additional functions that are triggered
// by the same event or other events.

function onAppReady() {
    // if( navigator.splashscreen && navigator.splashscreen.hide ) {   // Cordova API detected
    //     navigator.splashscreen.hide() ;
    // }
    navigator.splashscreen.hide() ;
    $(".button-collapse").sideNav();
}
document.addEventListener("app.Ready", onAppReady, false) ;
// document.addEventListener("deviceready", onAppReady, false) ;
// document.addEventListener("onload", onAppReady, false) ;

// The app.Ready event shown above is generated by the init-dev.js file; it
// unifies a variety of common "ready" events. See the init-dev.js file for
// more details. You can use a different event to start your app, instead of
// this event. A few examples are shown in the sample code above. If you are
// using Cordova plugins you need to either use this app.Ready event or the
// standard Crordova deviceready event. Others will either not work or will
// work poorly.

// NOTE: change "dev.LOG" in "init-dev.js" to "true" to enable some console.log
// messages that can help you debug Cordova app initialization issues.


(function () {
    'use strict';
    // alert()

    angular
        .module('app', ['ngRoute', 'ngCookies'])
        .config(config)
        .run(run);

    config.$inject = ['$routeProvider', '$locationProvider'];
    function config($routeProvider, $locationProvider) {
      $routeProvider
            .when('/', {
                // controller: 'HomeController',
                templateUrl: 'home/home.view.html',
                controllerAs: 'vm'
            })

            .when('/login', {
                controller: 'LoginController',
                templateUrl: 'login/login.view.html',
                controllerAs: 'vm'
            })

            .when('/register', {
                controller: 'RegisterController',
                templateUrl: 'register/register.view.html',
                controllerAs: 'vm'
            })

            .when('/users', {
                controller: 'UserController',
                templateUrl: 'users/users.view.html',
                controllerAs: 'vm'
            })

            .when('/user_profile/:userId', {
                templateUrl:function(params){
                  if(params.userId == localStorage.username){
                    console.log("Own profile");
                    return 'user_profile/editProfile.view.html'
                  }else if(localStorage.is_superuser == "true"){
                    console.log("Admin app.js");
                    return 'user_profile/adminEditProfile.view.html'
                  }else{
                    return 'user_profile/userId.view.html'
                  }
                },
            })

            .when('/schools', {
                controller: 'SchoolController',
                templateUrl: 'school/school.view.html',
                controllerAs: 'vm'
            })

            .when('/classes/:schoolId', {
                controller: 'ClassController',
                templateUrl: 'class/class.view.html',
                controllerAs: 'vm'
            })

            .when('/tutors/:schoolId/:classMajor/:classNumber', {
                controller: 'TutorController',
                templateUrl: 'tutors/tutors.view.html',
                controllerAs: 'vm'
            })

            .when('/appointment', {
                controller: 'AppointmentController',
                templateUrl: 'appointment/appointment.view.html',
                controllerAs: 'vm'
            })

            .when('/makeAppt/:tutorId/:classId', {
                controller: 'MakeApptController',
                templateUrl: 'appointment/makeAppt.view.html',
                controllerAs: 'vm'
            })

            .otherwise({ redirectTo: '/login' });
    }

    run.$inject = ['$rootScope', '$location', '$cookieStore', '$http'];
    function run($rootScope, $location, $cookieStore, $http) {
        // keep user logged in after page refresh
        if (!localStorage.token) {
            console.log("HERE");
            $location.path('/');
            return;
        }
    }
})();

@@ -4631,17 +4631,17 @@
 ent/make
-A
+a
 ppt.view

change makeAppt in app.js to makeappt