text: var usersApp=function(){return{load:function(){switch(window.location.hash.split("-")[0]){case"#create":document.getElementById("app").innerHTML='\n        <div class="card">\n          <div class="card-header clearfix">\n            <h2 class="h3 float-left">Create a New User</h2>\n            <div class="float-right">\n              <a href="#" class="btn btn-primary">Cancel</a>\n            </div>\n          </div>\n          <div class="card-body">\n            <form id="createUser" class="card-body">\n              <div id="formMsg" class="alert alert-danger text-center">Your form has errors</div>\n\n              <div class="row">\n                <div class="form-group col-md-6">\n                  <label for="first_name">First Name</label>\n                  <input type="text" id="first_name" name="first_name" class="form-control" required>\n                </div>\n\n                <div class="form-group col-md-6">\n                  <label for="last_name">Last Name</label>\n                  <input type="text" id="last_name" name="last_name" class="form-control" required>\n                </div>\n              </div>\n\n              <div class="row">\n                <div class="form-group col-md-6">\n                  <label for="username">Username</label>\n                  <input type="text" id="username" name="username" class="form-control" required>\n                </div>\n\n                <div class="form-group col-md-6">\n                  <label for="email">Email</label>\n                  <input type="email" id="email" name="email" class="form-control" required>\n                </div>\n              </div>\n\n              <div class="text-right">\n                <input type="submit" value="Submit" class="btn btn-lg btn-primary btn-sm-block">\n              </div>\n            </form>\n          </div>\n        </div>\n    ',function(e,n){let a=document.getElementById(e);a.addEventListener("submit",function(e){e.preventDefault();let t=new FormData(a),s=`${window.location.origin}${n}`,r=new XMLHttpRequest;r.open("POST",s),r.setRequestHeader("Content-Type","application/json; charset=UTF-8");let l={};t.forEach(function(e,n){l[n]=e}),r.send(JSON.stringify(l)),r.onload=function(){!0===JSON.parse(r.response).success?window.location.href="/users/app":document.getElementById("formMsg").style.display="block"}})}("createUser","/api/users");break;case"#view":console.log("VIEW");break;case"#edit":console.log("EDIT");break;case"#delete":console.log("DELETE");break;default:!function(){let e=`${window.location.origin}/api/users`,n=new XMLHttpRequest;n.open("GET",e),n.setRequestHeader("Content-Type","application/json; charset=UTF-8"),n.send(),n.onload=function(){let e=document.getElementById("app"),a=JSON.parse(n.response).users,t="",s="";for(let e=0;e<a.length;e++)s+=`<tr>\n          <td>\n            <a href="#view-${a[e]._id}">${a[e].last_name}, ${a[e].first_name}</a>\n          </td>\n          <td>${a[e].username}</td>\n          <td>${a[e].email}</td>\n        </tr>`;t=`<div class="card">\n        <div class="card-header clearfix">\n          <h2 class="h3 float-left">Users</h2>\n          <div class="float-right">\n            <a href="#create" class="btn btn-primary">New User</a>\n          </div>\n        </div>\n\n        <div class="table-responsive">\n          <table class="table table-striped table-hover table-bordered">\n            <thead>\n              <tr>\n                <td>Name</td>\n                <td>Username</td>\n                <td>Email</td>\n              </tr>\n            </thead>\n            <tbody>${s}</tbody>\n          </table>\n        </div>\n      </div>`,e.innerHTML=t}}()}}}}();usersApp.load(),window.addEventListener("hashchange",function(){usersApp.load()});