Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,6 @@
/dataSources/
/dataSources.local.xml
/environment_variables/
.env
.env
/.idea/
/node_modules/
3 changes: 3 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,14 @@ <h1 id="titletxt">Interactive Map</h1>


<div id="navbar">


<button id="navbutton">&#9776;</button>
<div id="navpages">
<a href="accessible.html" id="accessible-txt">Accessible Routes</a>
<a href="weather.html" id="weather-txt">Weather Routes</a>
</div>

</div>


Expand Down
74 changes: 37 additions & 37 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,42 +1,6 @@
import { Loader } from "@googlemaps/js-api-loader";
import * as destinations from "./destinations.js";


// Navbar slide function
const sidebar = document.getElementById("sidebar");
const navbutton = document.getElementById("navbutton");
const mainMap = document.getElementById("map");


navbutton.addEventListener('click', () => {
sidebar.classList.toggle('active');
mainMap.classList.toggle('active');
});

const faveButton = document.getElementById("view-fave-button");

faveButton.addEventListener('click', () => {
const faveDiv = document.getElementById("favorites-container");
if(faveDiv.style.display === "none"){
faveDiv.style.display = "block";
}
else{
faveDiv.style.display = "none";
}
});

const recentButton = document.getElementById("recent-button");

recentButton.addEventListener('click', () => {
const faveDiv = document.getElementById("recent-container");
if(faveDiv.style.display === "none"){
faveDiv.style.display = "block";
}
else{
faveDiv.style.display = "none";
}
});

// Route display functionality
const routeDisplay = new function () {
this.directionsService;
Expand Down Expand Up @@ -196,6 +160,42 @@ function clearMarkers(markersCollection) {
});
}

function miscUISetup(){
// Navbar slide function
const sidebar = document.getElementById("sidebar");
const navbutton = document.getElementById("navbutton");
const mainMap = document.getElementById("map");

navbutton.addEventListener('click', () => {
sidebar.classList.toggle('active');
mainMap.classList.toggle('active');
});

// Hide/display favorites list on button click
const faveButton = document.getElementById("view-fave-button");

faveButton.addEventListener('click', () => {
const faveDiv = document.getElementById("favorites-container");
if(faveDiv.style.display === "none"){
faveDiv.style.display = "block";
}
else{
faveDiv.style.display = "none";
}
});

const recentButton = document.getElementById("recent-button");

recentButton.addEventListener('click', () => {
const faveDiv = document.getElementById("recent-container");
if(faveDiv.style.display === "none"){
faveDiv.style.display = "block";
}
else{
faveDiv.style.display = "none";
}
});
}

function getMap(center) {
return new google.maps.Map(document.getElementById("map"), {
Expand Down Expand Up @@ -441,7 +441,7 @@ export async function initMap() {

routeDisplay.init();
navButtonInitialization(map, allMarks);

miscUISetup();

displayFavoriteSearches(); // Display saved favorites on load

Expand Down
30 changes: 17 additions & 13 deletions index.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import {test, expect, it, describe} from 'vitest'
import {initMap} from "./index";
/*
* @vitest-environment jsdom
*/
import {test, expect, it, describe, beforeEach} from 'vitest'
import { screen, getByRole } from '@testing-library/dom';
import html from "./index.html?raw";
import {initMap} from "./index.js";
document.documentElement.innerHTML = html;


// noinspection JSUnusedLocalSymbols
const clickable_element_width = 10;
Expand All @@ -14,30 +21,27 @@ test('map deployment', () => {
})

// test that title is in the right place
test('text locations', async ({page}) => {
await expect(page.getByRole('heading', {name: `UMBC Interactive Map`, exact: true})); // not right, work on this
test('text locations', async () => {
await expect(getByRole(document.body, 'heading', { name: `Interactive Map`, exact: true })); // not right, work on this
});
describe('Campus Navigation App', () => {
describe('side matter', () => {
describe('search bars', () => {
it('destination bar', () => {
let destination_bar = document.getElementById('origin-input');
expect(destination_bar.innerText).toBe('Enter your destination');
expect(destination_bar.offsetWidth).gte(10); // make sure it's not too narrow
let destination_bar = document.getElementById('dest-input');
expect(destination_bar.getAttribute('placeholder')).toBe('Enter your destination');
});
it('start bar', () => {
let start_bar = document.getElementById('pac-input');
expect(start_bar.innerText).toBe('Enter your starting location');
expect(start_bar.offsetWidth).gte(10); // make sure it's not too narrow
let start_bar = document.getElementById('origin-input');
expect(start_bar.getAttribute('placeholder')).toBe('Enter your starting location');
});
});

describe('buttons', () => {
it('search button', () => {
let search_button = document.getElementById('search-button');
expect(search_button).toBeDefined();
expect(search_button.innerText).toBe('Go Now');
expect(search_button.fillColor).toBe('#ffffff'); // fix color
expect(screen.getByRole('button', { name: 'Go Now', hidden: true })).toBeInTheDocument();
expect(search_button.offsetWidth).gte(10);
});

Expand Down Expand Up @@ -198,4 +202,4 @@ describe('Campus Navigation App', () => {
expect(true).toBe(true);
});
});
});
});
10 changes: 7 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,12 @@
"scripts": {
"test": "vitest"
},
"devDependencies": {
"vitest": "^1.0.0"
"dependencies": {
"@googlemaps/js-api-loader": "^1.16.8",
"@testing-library/dom": "^10.4.0",
"@testing-library/jest-dom": "^6.6.3",
"esm": "^3.2.25",
"jsdom": "^26.1.0",
"vitest": "^3.1.2"
}
}