// Copyright 2019 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// function revealLogin() {
//     console.log("fetching login status");
//     //fetches login staus
//     // document.getElementById("username").style.visibility = "hidden";

//     fetch('/login').then(response => response.json()).then((person) => {
//       console.log("is user logged in? " + person.status);
//       if(person.status == true){
//         var a = document.createElement('a');  
//         var link = document.createTextNode("Log out Here"); 
//         a.appendChild(link);  
//         a.title = "Log out Here";  
//         a.href = person.url;  
//         document.body.appendChild(a);
  
//         //after they logout, they are directed to the home page
//         // window.open("/_ah/logout?continue\u003d%2Flogin");


//       }
//       else if (person.status == false){
//         // var a = document.createElement('a');  
//         // var link = document.createTextNode("Log in Here"); 
//         // a.appendChild(link);  
//         // a.title = "Log in Here";  
//         // a.href = person.url;  
//         // document.body.appendChild(a);
        
//         window.open("/_ah/login?continue\u003d%2Flogin");

//         window.open("/nickname.html");

        
//         //after they login, they create their username
//         // document.getElementById("username").style.visibility = "visible";
//       }
//     });
//   }
  
function setNickname(){
  fetch('/nickname').then(response => response.json()).then((status) => {
    if(person.status == true){
      document.getElementById("name").value = status.name;

      window.open("/index.html");
    }
    else{
      var a = document.createElement('a');  
      var link = document.createTextNode("Log in Here"); 
      a.appendChild(link);  
      a.title = "Log in Here";  
      a.href = person.url;  
      document.body.appendChild(a);
      window.open("/login.html");
    }
  });
}

function revealLogin() {
  fetch('/login').then(response => response.json()).then((person) => {
    console.log("is user logged in? " + person.status);
    if(person.status == true){
      var a = document.createElement('a');  
      var link = document.createTextNode("Log out Here"); 
      a.appendChild(link);  
      a.title = "Log out Here";  
      a.href = person.url;  
      document.body.appendChild(a);
    }
    else if (person.status == false){
      var a = document.createElement('a');  
      var link = document.createTextNode("Log in Here"); 
      a.appendChild(link);  
      a.title = "Log in Here";  
      a.href = person.url;  
      document.body.appendChild(a);
    }
  });
}

function backHome(){
  var a = document.createElement('a');  
  var link = document.createTextNode("Home"); 
  a.appendChild(link);  
  a.title = "Home";  
  a.href = index.html;  
  // a.onclick = window.open("/index.html");
  document.body.appendChild(a);
}

@@ -584,1381 +584,8 @@
 nse.
-%0A%0A// function revealLogin() %7B%0A//     console.log(%22fetching login status%22);%0A//     //fetches login staus%0A//     // document.getElementById(%22username%22).style.visibility = %22hidden%22;%0A%0A//     fetch('/login').then(response =%3E response.json()).then((person) =%3E %7B%0A//       console.log(%22is user logged in? %22 + person.status);%0A//       if(person.status == true)%7B%0A//         var a = document.createElement('a');  %0A//         var link = document.createTextNode(%22Log out Here%22); %0A//         a.appendChild(link);  %0A//         a.title = %22Log out Here%22;  %0A//         a.href = person.url;  %0A//         document.body.appendChild(a);%0A  %0A//         //after they logout, they are directed to the home page%0A//         // window.open(%22/_ah/logout?continue%5Cu003d%252Flogin%22);%0A%0A%0A//       %7D%0A//       else if (person.status == false)%7B%0A//         // var a = document.createElement('a');  %0A//         // var link = document.createTextNode(%22Log in Here%22); %0A//         // a.appendChild(link);  %0A//         // a.title = %22Log in Here%22;  %0A//         // a.href = person.url;  %0A//         // document.body.appendChild(a);%0A        %0A//         window.open(%22/_ah/login?continue%5Cu003d%252Flogin%22);%0A%0A//         window.open(%22/nickname.html%22);%0A%0A        %0A//         //after they login, they create their username%0A//         // document.getElementById(%22username%22).style.visibility = %22visible%22;%0A//       %7D%0A//     %7D);%0A//   %7D
 %0A  %0A

remove useless comments