{"size": 1089, "ext": "js", "max_stars_repo_path": "scripts/views/book-admin-view.js", "max_stars_repo_name": "Once-Upon-A-Book/book-list-client", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "scripts/views/book-admin-view.js", "max_issues_repo_name": "Once-Upon-A-Book/book-list-client", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "scripts/views/book-admin-view.js", "max_forks_repo_name": "Once-Upon-A-Book/book-list-client", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 23.6739130435, "max_line_length": 79, "alphanum_fraction": 0.5472910927}
'use strict';

var app = app || {};

(module => {
  const adminView = {};

  const $view = $('#admin-view');

  adminView.username = 'admin';
  adminView.password = '1234';

  adminView.verify = () => {
    if (localStorage.getItem('loggedIn')) {
      console.log('we have local storage ture');
      $('.admin-only').show();
      $('.public').hide();
    } else {
      $('.admin-only').hide();
      $('.public').show();
    }
  };

  adminView.init = () => {
    $('#login-form').one('submit', function (e) {
      e.preventDefault();
      console.log('login form submit');
      let username = $('#username').val();
      let password = $('#password').val();
      console.log('username ' + username);
      console.log('password ' + password);
      if (username === adminView.username && password === adminView.password) {
        console.log('user login matches');
        let isLoggedIn = JSON.stringify('true');
        localStorage.setItem('loggedIn', isLoggedIn);
        adminView.verify();
      }
    });
    $view.show();
  };



  module.adminView = adminView;

})(app);