Class Project

by Alex Cowan

HTML

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Spaceships and Finance</title>
    <link href="https://fonts.googleapis.com/css2?family=Open+Sans&display=swap" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Avenir&display=swap" rel="stylesheet">
    <link rel="stylesheet" href="styles.css">
</head>
    <header>
        <h1>Spaceships and Finance</h1>
    </header>
    <nav>
        <button id="Home" onclick="navigateToIndex()">Home</button>
        <button id="Market">Market</button>
        <button id="Character">Character</button>
        <button id="Submit Choices" onclick="navigateToLeaderboard()">Leaderboard</button>
        <button id="Submit Choices">Submit Choices</button>
        <button id="Logout">Logout</button>
    </nav>
    
    <div id="indexPage" class="content">
    <div class="left-section">
        <div class="box game-progress">
            <h2>Game Progress</h2>
            <div class="progress-bar-background">
                <div class="progress-bar gray"></div>
            </div>
        </div>
           <div class="task-container">
    <h2>Task List</h2>
    <br>
    <h3>Required</h3>
    <ul class="task-list">
        <li><button class="task-item incomplete"><img src='https://drive.google.com/thumbnail?id=16erBayQ3XSWHvJdGn6b1SFNW4DFuH5nM' alt="Task icon" class="task-icon" id="Task 1">Upgrade spaceship engine</button></li>
        <li><button class="task-item complete"><img src='https://drive.google.com/thumbnail?id=1IWVe_sQsn0X12PlS5Ph81L40Tvvjf6gF' alt="Task icon" class="task-icon" id="Task 2">Attend finance seminar</button></li>
        <li><button class="task-item complete"><img src='https://drive.google.com/thumbnail?id=1IWVe_sQsn0X12PlS5Ph81L40Tvvjf6gF' alt="Task icon" class="task-icon" id="Task 3">Complete asteroid mining</button></li>
    </ul>
     <h3>Optional</h3>
    <ul class="task-list">
        <li><button class="task-item...

CSS

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Open Sans', sans-serif;
    background-color: #E1DFD9;
    color: #000000;
}

header {
    background-image: url("https://drive.google.com/thumbnail?id=12QXWlaccSvh4BZVXznveaQK1_b28lyHH");
    background-size: cover;
    text-align: center;
    padding: 20px 0;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

header h1 {
    font-family: 'Avenir', sans-serif; /* Updated to use Avenir as per your link */
    text-transform: uppercase;
    color: #FFFFFF;
    font-size: 2rem;
}

nav {
    display: 300;
    justify-content: space-between;
    background-color: #0205D3;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    text-align: center;

}

nav button {
    background-color: transparent; 
    color: #FFFFFF;
    border: none;
    padding: 10px 20px;
    cursor: pointer;
    font-size: 1rem;
    border-radius: 8px;
    transition: background-color 0.3s ease;
    margin:auto
}

nav button:hover {
    background-color: #1D31C1;
    transform: scale(1.05);
}

.content {
    display: flex;
    justify-content: space-between;
    padding: 20px;
    max-width: 1200px;
    margin: 0 auto;
}

@media (max-width: 500px) {
    .content {
        flex-direction: column;
        align-items: stretch;
    }
}

.left-section {
    display: flex;
    flex-direction: column;
    flex: 0 0 30%;
    margin-right: 5px;
}

.box {
    background-color: #FFFFFF;
    padding: 20px;
    margin-bottom: 10px;
    margin-right: 10px; /* Added margin to the right */
    width: calc(100% - 10px); /* Adjusted width to account for the added margin */
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    border-radius: 8px;
}

h2 {
    font-family: 'Avenir', sans-serif;
    font-size: 1.5rem;
}

h3 {
    font-family: 'Avenir', sans-serif;
    font-size: 1.2rem;
}

.progress-bar-background {
    background-color: #E1DFD9;
    height: 20px;
    border-radius: 5px;
    border: 1px;
    margin-bottom:...

JavaScript

// Attach a click event listener to the entire document
document.addEventListener("click", function(event) {
  // Store the clicked HTML element in a constant named 'clickedElement'
  const clickedElement = event.target;

  // Call the 'logEvent' function to handle logging and any other desired behavior
  logEvent(clickedElement);
});

// Attach a keypress event listener to the entire document
document.addEventListener("keypress", function(event) {
  // Store the element where the keypress event occurred in a constant named 'clickedElement'
  const clickedElement = event.target;

  // Call the 'logEvent' function to handle logging and any other desired behavior
  logEvent(clickedElement);
});

// Function to handle the logging logic for both click and keypress events
function logEvent(target) {
  // Store the ID of the target element (where the event occurred) in a constant named 'clickedElementId'
  const clickedElementId = target.id;

  // Store the ID of the parent element of the target element in a constant named 'parentElementID'
  const parentElementID = target.parentNode.id;

  // Check if the target element has an ID and log it to the console if it does
  if (clickedElementId !== "") {
    console.log(`User CT on element with ID: ${clickedElementId}`);

  // If the target element doesn't have an ID, check if its parent element has an ID and log it to the console if it does
  } else if (parentElementID !== "") {
    console.log(`User CT on element with parent ID: ${parentElementID}`);

  // If neither the target element nor its parent have an ID, log a generic message to the console
  } else {
    console.log('User clicked on element with no ID or parent ID.');
  }
}

        function navigateToLeaderboard() {
            document.getElementById('indexPage').style.display = 'none';
            document.getElementById('leaderboardPage').style.display = 'block';
        }

        function navigateToIndex() {
           ...