-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Show the ad for the mobile app to everyone not on an android (#2203)
* check that user agent isnt android * add new pages * rework * remove commuter rail alerts * dont need to check for CR on schedule page
- Loading branch information
1 parent
d4dcc2e
commit 19da78e
Showing
5 changed files
with
43 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,52 @@ | ||
const isAlertsPage = () => { | ||
const url = window.location.href; | ||
const isNotAndroid = () => { | ||
return !/Android/.test(navigator.userAgent); | ||
}; | ||
|
||
return /\/alerts\/[\w.-]+/.test(url); | ||
const isNotCommuterRail = url => { | ||
return !/\/schedules\/CR-/.test(url); | ||
}; | ||
|
||
const isIPhone = () => { | ||
return /iPhone/.test(navigator.userAgent); | ||
const isNotFerry = url => { | ||
return !/\/schedules\/Boat-/.test(url); | ||
}; | ||
|
||
const isSchedulePage = () => { | ||
const url = window.location.href; | ||
const isAlertsPage = url => { | ||
return isNotCommuterRail(url) && isNotFerry(url) && /\/alerts/.test(url); | ||
}; | ||
|
||
const isSchedulePage = url => { | ||
return ( | ||
isNotCommuterRail(url) && | ||
isNotFerry(url) && | ||
/\/schedules\/[\w.-]+\//.test(url) | ||
); | ||
}; | ||
|
||
return /\/schedules\/[\w.-]+\/line/.test(url); | ||
const isStopPage = url => { | ||
return /\/stops\/[\w.-]+/.test(url); | ||
}; | ||
|
||
const isStopPage = () => { | ||
const isTransitNearMePage = url => { | ||
return /\/transit-near-me/.test(url); | ||
}; | ||
|
||
const isIncludedPage = () => { | ||
const url = window.location.href; | ||
|
||
return /\/stops\/[\w.-]+/.test(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() { | ||
if (isIPhone() && (isAlertsPage() || isSchedulePage() || isStopPage())) { | ||
if (isIncludedPage() && isNotAndroid()) { | ||
document.querySelector("#mobile-app-banner").style.display = "block"; | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters