|
| 1 | +<html> |
| 2 | +<head> |
| 3 | + <link href=" https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel=" stylesheet" integrity=" sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin=" anonymous" > |
| 4 | + <script src=" https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity=" sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin=" anonymous" ></script> |
| 5 | + <link rel="stylesheet" href="static/style.css"> |
| 6 | + <link rel="stylesheet" href="static/bootstrap.min.css"> |
| 7 | +<script> |
| 8 | + |
| 9 | +const logout = async (e) => { |
| 10 | +// Build logout URL and Make GET request to logout endpoint |
| 11 | + let logout_url = window.location.origin+"/djangoapp/logout"; |
| 12 | + const res = await fetch(logout_url, { |
| 13 | + method: "GET", |
| 14 | + }); |
| 15 | + |
| 16 | + const json = await res.json(); |
| 17 | + if (json) { |
| 18 | + // Clear session storage and reload page |
| 19 | + let username = sessionStorage.getItem('username'); |
| 20 | + sessionStorage.removeItem('username'); |
| 21 | + window.location.href = window.location.origin; |
| 22 | + window.location.reload(); |
| 23 | + // Notify user of logout |
| 24 | + alert("Logging out "+username+"...") |
| 25 | + } |
| 26 | + else { |
| 27 | + alert("The user could not be logged out.") |
| 28 | + } |
| 29 | +}; |
| 30 | + |
| 31 | +let checkSession = ()=>{ |
| 32 | + let curr_user = sessionStorage.getItem("username"); |
| 33 | + |
| 34 | + if (curr_user && curr_user !== "") { |
| 35 | + document.getElementById("loginlogout").innerHTML = |
| 36 | + '<span class="homepage_links">' + curr_user +'</span>' + |
| 37 | + '<a class="homepage_links" onclick="logout()" href="/">Logout</a>' |
| 38 | + } else { |
| 39 | + document.getElementById("loginlogout").innerHTML = |
| 40 | + '<a class="homepage_links" href="/login">Login</a>'+ |
| 41 | + '<a class="homepage_links" href="/register">Register</a>' |
| 42 | + } |
| 43 | + |
| 44 | + } |
| 45 | +</script> |
| 46 | +</head> |
| 47 | +<body onload="checkSession()"> |
| 48 | +<nav class="navbar navbar-expand-lg navbar-light" style="background-color:darkturquoise; height: 1in;"> |
| 49 | + <div class="container-fluid"> |
| 50 | + <h2 style="padding-right: 5%;">Dealerships</h2> |
| 51 | + <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarText" aria-controls="navbarText" aria-expanded="false" aria-label="Toggle navigation"> |
| 52 | + <span class="navbar-toggler-icon"></span> |
| 53 | + </button> |
| 54 | + <div class="collapse navbar-collapse" id="navbarText"> |
| 55 | + <ul class="navbar-nav me-auto mb-2 mb-lg-0"> |
| 56 | + <li class="nav-item"> |
| 57 | + <a class="nav-link active" style="font-size: larger;" aria-current="page" href="#">Home</a> |
| 58 | + </li> |
| 59 | + <li class="nav-item"> |
| 60 | + <a class="nav-link" style="font-size: larger;" href="/about">About Us</a> |
| 61 | + </li> |
| 62 | + <li class="nav-item"> |
| 63 | + <a class="nav-link" style="font-size: larger;" href="/contact">Contact Us</a> |
| 64 | + </li> |
| 65 | + </ul> |
| 66 | + <span class="navbar-text"> |
| 67 | + <div class="loginlink" id="loginlogout"> |
| 68 | + </div> |
| 69 | + </span> |
| 70 | + </div> |
| 71 | + </div> |
| 72 | +</nav> |
| 73 | +<div style="display: flex;flex-direction: column;"> |
| 74 | +<div class="card" style="width: 50%;margin-top: 50px;align-self: center;"> |
| 75 | + <img src="static/car_dealership.jpg" class="card-img-top" alt="..."> |
| 76 | + <div class="banner"> |
| 77 | + <h5>Welcome to our Dealerships!</h5> |
| 78 | + <a href="/dealers" class="btn" style="background-color: aqua;margin:10px">View Dealerships</a> |
| 79 | + </div> |
| 80 | +</div> |
| 81 | +</div> |
| 82 | +</body> |
| 83 | +</html> |
0 commit comments