Skip to content

Sheffield | May-2025 | Hassan Osman | Alarm Clock App #602

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

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

HassanOHOsman
Copy link

Learners, PR Template

Self checklist

  • I have committed my files one by one, on purpose, and for a reason
  • I have titled my PR with REGION | COHORT_NAME | FIRST_NAME LAST_NAME | PROJ_NAME
  • I have tested my changes
  • My changes follow the style guide
  • My changes meet the requirements of this task

Changelist

Implemented alarm functionality with time display update, countdown, continuous sound on zero, stop button control, and background colour change to red on timer end.

Questions

Ask any questions you have for your reviewer.

@HassanOHOsman HassanOHOsman added Needs Review Participant to add when requesting review 📅 Sprint 3 Assigned during Sprint 3 of this module labels Jul 14, 2025
Copy link
Contributor

@cjyuan cjyuan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Could consider resetting the background color and the clock display when the "stop" button is clicked.

  • Some unusual input values can disrupt the clock display momentarily. Can you add code to reject this kind of input?

Otherwise code is good.

@cjyuan cjyuan added Reviewed Volunteer to add when completing a review and removed Needs Review Participant to add when requesting review labels Jul 16, 2025
@HassanOHOsman
Copy link
Author

The background now resets to white after click "stop alarm". The issue is the text area does not clear for some reason. Aslo positive numbers over zero are now only is not accepted as a valid input.

@HassanOHOsman HassanOHOsman added Needs Review Participant to add when requesting review and removed Reviewed Volunteer to add when completing a review labels Jul 18, 2025
Copy link
Contributor

@cjyuan cjyuan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean by "The issue is the text area does not clear for some reason."?

text area usually refers to a UI control that supports multiline text input.
In HTML, it usually refers to the <textarea> element.

UI that accepts only a single line of text input is normally called a text field.

@@ -14,6 +14,12 @@ function setAlarm() {
const input = document.getElementById("alarmSet");
let seconds = parseInt(input.value, 10);

if (isNaN(seconds) || seconds <= 0 || input.value.trim() === "") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

parseInt(" ") or parseInt("") return NaN, so input.value.trim() === "" is redundant.

pauseAlarm();
document.body.style.backgroundColor = "white";
document.getElementById("timeRemaining").textContent = "";
Copy link
Contributor

@cjyuan cjyuan Jul 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When the page is first loaded, the clock shows "Time Remaining: 00:00".

You could also consider resetting the content to its "initial value" instead of clearing it.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All this time I thought you were referring to the input bos next to "set time to" LOL Anyway, this has now been sorted

@cjyuan cjyuan added Reviewed Volunteer to add when completing a review and removed Needs Review Participant to add when requesting review labels Jul 18, 2025
@HassanOHOsman HassanOHOsman added Needs Review Participant to add when requesting review and removed Reviewed Volunteer to add when completing a review labels Jul 19, 2025
Copy link
Contributor

@cjyuan cjyuan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good! Well done.

@@ -58,7 +58,7 @@ function setup() {
clearInterval(countdownInterval);
pauseAlarm();
document.body.style.backgroundColor = "white";
document.getElementById("timeRemaining").textContent = "";
document.getElementById("timeRemaining").textContent = "Time Remaining: 00:00";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could also just call updateDisplay(0).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how silly i am!! done it. and code now clears input too :)

@cjyuan cjyuan added Complete Volunteer to add when work is complete and review comments have been addressed and removed Needs Review Participant to add when requesting review labels Jul 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Complete Volunteer to add when work is complete and review comments have been addressed 📅 Sprint 3 Assigned during Sprint 3 of this module
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants