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

Show the ad for the mobile app to everyone not on an android #2203

Merged
merged 7 commits into from
Oct 25, 2024
Merged
Changes from 1 commit
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
29 changes: 14 additions & 15 deletions assets/js/mobile-app-banner.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const isNotCommuterRail = url => {
};

const isSchedulePage = url => {
return /\/schedules\/[\w.-]+\/line/.test(url);
return isNotCommuterRail(url) && /\/schedules\/[\w.-]+\/line/.test(url);
};
anthonyshull marked this conversation as resolved.
Show resolved Hide resolved

const isStopPage = url => {
Expand All @@ -22,24 +22,23 @@ const isTransitNearMePage = url => {
return /\/transit-near-me/.test(url);
};

const is = url => {
return (
isAlertsPage(url) ||
isSchedulePage(url) ||
isStopPage(url) ||
isTransitNearMePage(url)
);
};
const isIncludedPage = () => {
const url = window.location.href;

const isNot = url => {
return isNotAndroid() && isNotCommuterRail(url);
return [isAlertsPage, isSchedulePage, isStopPage, isTransitNearMePage].some(
fn => {
return fn(url);
}
);
};

// Show the mobile app banner
/**
* If the page is one of the pages we want to show the banner on
* And the user is not on an Android device
* Show the banner
*/
export default function mobileAppBanner() {
const url = window.location.href;

if (is(url) && isNot(url)) {
if (isIncludedPage() && isNotAndroid()) {
document.querySelector("#mobile-app-banner").style.display = "block";
}
}
Loading