Skip to content

Commit

Permalink
updates after 2nd review
Browse files Browse the repository at this point in the history
  • Loading branch information
JoeArmani committed Dec 5, 2024
1 parent 9ad9cda commit f6ecde3
Show file tree
Hide file tree
Showing 6 changed files with 101 additions and 97 deletions.
15 changes: 4 additions & 11 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { renderSettingsPage } from "./js/pages/settings.js";
import { renderSupportPage } from "./js/pages/support.js";
import { renderPaymentPage } from "./js/pages/payment.js";
import { renderSamplesPage } from "./js/pages/samples.js";
import { footerTemplate } from "./js/pages/footer.js";
import { renderVerifiedPage } from "./js/pages/verifiedPage.js";
import { firebaseConfig as devFirebaseConfig } from "./dev/config.js";
import { firebaseConfig as stageFirebaseConfig } from "./stage/config.js";
Expand All @@ -30,15 +29,16 @@ if ("serviceWorker" in navigator) {

navigator.serviceWorker.ready.then(() => {
if (navigator.serviceWorker.controller) {
navigator.serviceWorker.controller.postMessage({ action: "getAppVersion" });
navigator.serviceWorker.controller.postMessage({ action: "getAppVersion" });
}
});

navigator.serviceWorker.addEventListener("message", (event) => {
if (event.data.action === "sendAppVersion") {
document.getElementById("appVersion").textContent = event.data.payload;
document.getElementById("appVersion").textContent = event.data.payload;
}
});

}

let auth = '';
Expand Down Expand Up @@ -128,11 +128,6 @@ window.onload = async () => {
inactivityTime();
}
});

const footer = document.getElementById('footer');
if (footer) {
footer.innerHTML = footerTemplate();
}
}

const handleVerifyEmail = (auth, actionCode) => {
Expand Down Expand Up @@ -417,8 +412,6 @@ export const signOut = async () => {
window.DD_RUM.stopSession();
isDataDogUserSessionSet = false;
}

console.log("signing current user out!");
localforage.clear();

await firebase.auth().signOut();
Expand Down Expand Up @@ -512,4 +505,4 @@ const updateFirebaseAuthPhoneTrigger = async (phone) => {
hideAnimation();
throw error;
}
};
};
69 changes: 68 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,74 @@ <h5 class="modal-title" data-i18n="ssn.responseRequested">Response Requested</h5
</div>
</main>
<footer role="contentinfo">
<div id="footer"></div>
<div id="footer">
<div class="row footer-content" style="margin:0">
<div class="row w-100" style="margin:0">
<div class="col content-wrapper" data-i18n="footer.nci-dceg">
<div class="dceg-footer align-left text-center text-sm-center">Division of Cancer Epidemiology and Genetics
</div>
<div class="nci-dceg-footer align-left text-center text-sm-center">at the National Cancer Institute</div>
</div>
</div>
<div class="row w-100 pt-0 align-left" style="margin:0">
<div class="col-lg-4 pt-3 content-wrapper text-center text-sm-center">
<div class="footer-heading" data-i18n="footer.Questions">HAVE QUESTIONS?</div>
<div class="footer-sub-heading pt-3" data-i18n="footer.contactLink"><a class="footer-links" target="__blank"
href="https://norcfedramp.servicenowservices.com/recruit">Contact the Connect Support Center</a>
</div>
<div class="footer-sub-heading pt-3" data-i18n="footer.emailUs"><a class="footer-links"
href="mailto:[email protected]">Email Us</a></div>
</div>
<div class="col-lg-4 pt-3 content-wrapper text-center text-sm-center">
<div class="footer-heading" data-i18n="footer.policies">POLICIES</div>
<div class="footer-sub-heading pt-3" data-i18n="footer.accessibility"><a class="footer-links"
target="__blank" href="https://www.cancer.gov/global/web/policies/accessibility">Accessibility</a>
</div>
<div class="footer-sub-heading pt-3" data-i18n="footer.disclaimer"><a class="footer-links" target="__blank"
href="https://www.cancer.gov/policies/disclaimer">Disclaimer</a></div>
<div class="footer-sub-heading pt-3" data-i18n="footer.foia"><a class="footer-links" target="__blank"
href="https://www.cancer.gov/global/web/policies/foia">FOIA</a></div>
<div class="footer-sub-heading pt-3" data-i18n="footer.privacySecurity"><a class="footer-links"
target="__blank" href="https://www.cancer.gov/policies/privacy-security">Privacy & Security</a>
</div>
<div class="footer-sub-heading pt-3" data-i18n="footer.vulnerability"><a class="footer-links"
target="__blank" href="https://www.hhs.gov/vulnerability-disclosure-policy/index.html">HHS
Vulnerability Disclosure</a></div>
<div class="footer-sub-heading pt-3" data-i18n="footer.siteMap"><a class="footer-links" target="__blank"
href="https://dceg.cancer.gov/about/sitemap">Site Map</a></div>
</div>
</div>
<div class="row w-100 pt-5 align-center" style="margin:0">
<ul class="menu w-100" style="padding:0" data-i18n="footer.menuList">
<li class="menu-item p-0 footer-menu-item"><a target="__blank" class="footer-links gov-dept-links p-0"
href="http://www.hhs.gov/">U.S. Department of Health and Human Services</a></li>
<li class="menu-item p-0 footer-menu-item"><a target="__blank" class="footer-links gov-dept-links p-0"
href="http://www.nih.gov/">National Institutes of Health</a></li>
<li class="menu-item p-0 footer-menu-item"><a target="__blank" class="footer-links gov-dept-links p-0"
href="http://www.cancer.gov/">National Cancer Institute</a></li>
<li class="menu-item p-0"><a target="__blank" class="footer-links gov-dept-links p-0"
href="http://www.usa.gov/">USA.gov</a></li>
</ul>
</div>
<div class="row w-100">
<div class="col-md-2">
</div>
<div class="col-md-8">
<p class="gov-dept-links" data-i18n="footer.cancerPrevention">Connect for Cancer Prevention Study, the
Connect for Cancer Prevention Study logo, and “Connect today. Prevent cancer tomorrow.” are trademarks
of the U.S. Department of Health and Human Services (HHS).<sup>®</sup></p>
</div>
<div class="col-md-2">
</div>
</div>
<div class="row w-100" style="margin:0">
<div class="col">
<p class="nih-tagline" data-i18n="footer.nihHealth">NIH…Turning Discovery Into Health<sup>®</sup></p>
<p id="appVersion"></p>
</div>
</div>
</div>
</div>
</footer>
<script type="text/javascript" src="https://translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
<script type="module" src="./app.js"></script>
Expand Down
4 changes: 1 addition & 3 deletions js/event.js
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,7 @@ export const environmentWarningModal = () => {
const devWarningShown = appState.getState()?.isDevWarningShown;
if (devWarningShown === true) return;

appState.setState({ isDevWarningShown: false });
appState.setState({ isDevWarningShown: true });

document.getElementById('connectWarningModalHeader').style.display = 'block';
document.getElementById('connectWarningModalHeader').innerHTML = `
Expand Down Expand Up @@ -838,8 +838,6 @@ export const environmentWarningModal = () => {
if (signInBtn) {
signInBtn.focus();
}

appState.setState({ isDevWarningShown: true });
});

modalElement.addEventListener('hidden.bs.modal', (event) => {
Expand Down
56 changes: 0 additions & 56 deletions js/pages/footer.js

This file was deleted.

38 changes: 28 additions & 10 deletions js/pages/homePage.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getMyData, hasUserData, urls, fragment, checkAccount, debounceClick, validEmailFormat, validPhoneNumberFormat, getCleanSearchString, firebaseSignInRender, signInAnonymously, usGov, translateHTML, translateText, getFirebaseUI, showAnimation, hideAnimation } from "../shared.js";
import { getMyData, hasUserData, urls, fragment, checkAccount, validEmailFormat, validPhoneNumberFormat, getCleanSearchString, firebaseSignInRender, signInAnonymously, usGov, translateHTML, translateText, getFirebaseUI, showAnimation, hideAnimation } from "../shared.js";
import { signInConfig } from "./signIn.js";
import { environmentWarningModal, downtimeWarning } from "../event.js";

Expand Down Expand Up @@ -529,14 +529,31 @@ export function signInSignUpEntryRender() {

document.getElementById('signInWrapperDiv').replaceChildren(df);

signInBtn.addEventListener('click', debounceClick(async (e) => {
signInBtn.addEventListener('click', async (e) => {
e.preventDefault();
await signInCheckRender();
}));
signUpBtn.addEventListener('click', debounceClick(async (e) => {
signInBtn.disabled = true;

try {
await signInCheckRender();
} catch (error) {
console.error('Error during sign-in:', error);
} finally {
signInBtn.disabled = false;
}
});

signUpBtn.addEventListener('click', async (e) => {
e.preventDefault();
await signUpRender({ signUpType: "phone" });
}));
signUpBtn.disabled = true;

try {
await signUpRender({ signUpType: "phone" });
} catch (error) {
console.error('Error during sign-up:', error);
} finally {
signUpBtn.disabled = false;
}
});
}

export function signInCheckRender () {
Expand Down Expand Up @@ -576,8 +593,9 @@ export function signInCheckRender () {

document.getElementById('signInWrapperDiv').replaceChildren(df);

signInBtn.addEventListener('click', debounceClick(async (e) => {
signInBtn.addEventListener('click', async (e) => {
e.preventDefault();
signInBtn.disabled = true;
const inputStr = accountInput.value.trim();
const isEmail = !!inputStr.match(validEmailFormat);
const isPhone = !!inputStr.match(validPhoneNumberFormat);
Expand Down Expand Up @@ -626,9 +644,9 @@ export function signInCheckRender () {
} finally {
hideAnimation();
accountInput.value = '';
signInBtn.disabled = false;
}

}));
});

signUpAnchor.addEventListener('click', async () => {
await signUpRender({ signUpType: "phone" });
Expand Down
16 changes: 0 additions & 16 deletions js/shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -2246,19 +2246,3 @@ export const getFirebaseUI = async () => {
}
}
}

/**
* Set a short timeout to disallow multiple repetitive actions (button clicks).
* @param {Function} func - Function to execute.
* @param {number} delay - Delay in milliseconds.
* @returns
*/
export const debounceClick = (func, delay) => {
let timeoutId;
return function(...args) {
clearTimeout(timeoutId);
timeoutId = setTimeout(() => {
func.apply(this, args);
}, delay);
}
}

0 comments on commit f6ecde3

Please sign in to comment.