Skip to content

Commit

Permalink
added user selected duration
Browse files Browse the repository at this point in the history
  • Loading branch information
abutler911 committed Oct 10, 2023
1 parent fd54e39 commit 6726d47
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 23 deletions.
16 changes: 15 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,21 @@ <h1>Emotional Freedom Journey</h1>
balance.
</p>
<hr />
<button id="start-button">Start App</button>
<div class="control-container">
<label for="duration" class="label"
>Choose affirmation duration: <br />
<span class="tip">(7 seconds works well!)</span></label
>
<select id="duration">
<option value="1">1 second</option>
<option value="5">5 seconds</option>
<option value="7">7 seconds</option>
<option value="10">10 seconds</option>
<option value="15">15 seconds</option>
</select>

<button id="start-button">Start App</button>
</div>
</div>
</div>

Expand Down
28 changes: 6 additions & 22 deletions script.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ let currentSectionIndex = 0;
let currentPhraseIndex = 0;
let isPaused = false;
let countdown;
let countdownValue = 5;
let defaultCountdownValue = 7;

const displayElement = document.getElementById("affirmation-display");
const sectionNameElement = document.getElementById("section-name");
Expand All @@ -80,26 +80,20 @@ const pauseButton = document.getElementById("pause-button");
function updateDisplay() {
const affirmationContainer = document.getElementById("affirmation-container");
const currentSection = affirmationSections[currentSectionIndex];
const meridianElement = document.getElementById("meridian-point"); // New element for the meridian point
const meridianElement = document.getElementById("meridian-point");

if (currentPhraseIndex < currentSection.phrases.length) {
displayElement.textContent = currentSection.phrases[currentPhraseIndex];
sectionNameElement.textContent = currentSection.section;

// Display the meridian point
meridianElement.innerHTML = `Meridian Point: <span style="color: #c7522a;">${meridianPoints[currentPhraseIndex]}</span>`;

countdownValue = 7;
countdownValue = defaultCountdownValue; // Set to user-selected value
affirmationContainer.classList.remove("breathe");
} else {
displayElement.textContent =
"Place a hand on your heart and belly, and take three deep breaths.";
sectionNameElement.textContent = "";

// Clear the meridian point when not applicable
meridianElement.textContent = "";

countdownValue = 15;
countdownValue = 15; // Set to fixed value for breathing part
affirmationContainer.classList.add("breathe");
}

Expand Down Expand Up @@ -184,25 +178,15 @@ function showPage(pageId) {
});
}

// Initial load shows landing page
showPage("landing-page");

// Start button event listener to switch to affirmation page
document.getElementById("start-button").addEventListener("click", () => {
const selectedDuration = document.getElementById("duration").value;
defaultCountdownValue = parseInt(selectedDuration, 10);
showPage("affirmation-page");
});

showPage("landing-page");

document.getElementById("start-button").addEventListener("click", () => {
showPage("affirmation-page");
// Call updateDisplay when the Start App button is clicked
updateDisplay();
});

// Update display initially
// updateDisplay();

// Add event listeners
prevButton.addEventListener("click", moveToPrev);
nextButton.addEventListener("click", moveToNext);
Expand Down
50 changes: 50 additions & 0 deletions styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,56 @@ hr {
border-top: 3px solid var(--green);
border-radius: 9px;
}
/* Container for dropdown and button */
.control-container {
display: flex;
flex-direction: column;
align-items: center;
}

/* Style for button */
#start-button {
margin-top: 30px; /* Add some margin for spacing */
}
.label {
font-size: 1.3rem;
margin-bottom: 10px;
}

.tip {
font-size: 0.7rem;
}
/* Style the dropdown */
#duration {
width: 100%;
padding: 10px;
margin-top: 10px;
margin-bottom: 20px;
background-color: var(--light-blue);
color: var(--white);
border: none;
border-radius: 5px;
font-size: 1.2rem;
cursor: pointer;
margin: auto;
}

/* Style dropdown options */
#duration option {
background-color: var(--dark-blue);
color: var(--white);
}

/* Add hover effect */
#duration:hover {
background-color: var(--dark-blue);
}

/* Add focus effect */
#duration:focus {
outline: none;
box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.4);
}

.affirmation-header {
text-align: center;
Expand Down

0 comments on commit 6726d47

Please sign in to comment.