Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Audio and attendee dress colors #11

Merged
merged 6 commits into from
Feb 12, 2024
Merged
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
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
<img src="./src/images/wole-joko-logo.png" />

A fun little app that mimics admitting people into an event hall and getting them well seated.
A fun little pure HTML/Javascript app that mimics admitting
people into an event hall and getting them well seated.


![the even hall](./auditorium.png "the event hall")
![Chrome dev console](./chrome-dev-console.png "custom console logs")

[See it live!](https://wole-joko.netlify.app/). Also, there's some [code documentation here](https://chalu.github.io/wole-joko/)

Expand Down
Binary file added auditorium.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added cathedral_st_marys_sydney_cbd.mp3
Binary file not shown.
Binary file added chrome-dev-console.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
55 changes: 53 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,60 @@
margin-top: -12px;
border-top-left-radius: 50%;
border-top-right-radius: 50%;
background: #ccc;
}

[data-seating-side] .seat .attendee {
width: 8px;
height: 8px;
margin: 2px;
border-radius: 100%;
}

.row .seat .attendee.dress-white {
background: #f1f1f1;
}

.row .seat .attendee.dress-black {
background: #333;
}

.row .seat .attendee.dress-maroon {
background: maroon;
}

.row .seat .attendee.dress-lightblue {
background: #6feaf6;
}

.row .seat .attendee.dress-lighterblue {
background: #6fd5f6;
}

.row .seat .attendee.dress-mediumblue {
background: #6fc1f6;
}

.row .seat .attendee.dress-deeperblue {
background: #6fa0e6;
}

.row .seat .attendee.dress-orange {
background: #f6945a;
}

.row .seat .attendee.dress-purple {
background: #9f5af6;
}

.row .seat .attendee.dress-darkerorange {
background: #f67c41;
}

.row .seat .attendee.dress-darkersoftorange {
background: #f69841;
}

[data-rows-left] .row .seat:nth-of-type(1) {
margin-left: 0.8em;
}
Expand Down Expand Up @@ -163,8 +214,8 @@
</div>
</div>

<audio loop autoplay>
<source src="https://www.zapsplat.com/wp-content/uploads/2015/sound-effects-31172/zapsplat_public_places_cathedral_st_marys_sydney_cbd_internal_amb_traffic_outside_people_organist_tuning_sydney_australia002_32683.mp3" type="audio/mp3">
<audio preload="auto" loop>
<source src="cathedral_st_marys_sydney_cbd.mp3" type="audio/mp3">
</audio>

<script type="module" src="./src/js/index.js"></script>
Expand Down
9 changes: 7 additions & 2 deletions src/js/attendee.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Person from './person.js';
import {
logs, rAF, select, intFromId
logs, rAF, select, intFromId, getRandomDressColorFromPallate
} from './utils.js';

const { info } = logs;
Expand Down Expand Up @@ -36,8 +36,13 @@ class Attendee extends Person {
const row = select(`[data-rows-${hallSide}] [data-row-${rowIndex}]`);
const seating = document.createElement('div');
seating.classList.add('seat', `seat-${seatNum}`);
seating.setAttribute(`data-seating-attendee-${idNum}`, '');
// seating.setAttribute(`data-seating-attendee-${idNum}`, '');
row.appendChild(seating);

const attendee = document.createElement('div');
attendee.classList.add('attendee', `dress-${getRandomDressColorFromPallate()}`);
attendee.setAttribute(`data-seating-attendee-${idNum}`, '');
seating.appendChild(attendee);
});

// make sure, then signal you are seated!
Expand Down
12 changes: 12 additions & 0 deletions src/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@ import { init, doorsOpen } from './auditorium.js';

const startApp = () => {
init().then(() => doorsOpen());

document.body.addEventListener('click', () => {
const audio = document.querySelector('audio');
if (!audio) return;

if (audio.currentTime <= 0 || audio.paused) {
audio.play();
return;
}

audio.pause();
});
};

document.addEventListener('DOMContentLoaded', startApp);
9 changes: 9 additions & 0 deletions src/js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,12 @@ const logr = (realm) => {
};

export const logs = logr('App');

const DRESS_COLORS = [
'lightblue', 'lighterblue', 'mediumblue', 'deeperblue', 'orange',
'purple', 'darkerorange', 'darkersoftorange', 'white', 'black'
];
export const getRandomDressColorFromPallate = () => {
const index = Math.floor(Math.random() * DRESS_COLORS.length);
return DRESS_COLORS[index % DRESS_COLORS.length];
};