-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'working' into feat/last-grades
- Loading branch information
Showing
5 changed files
with
69 additions
and
30 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
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
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,5 +1,32 @@ | ||
|
||
export function getProxiedURL(url) { | ||
const proxyURL = "https://raspi.ecole-directe.plus:3000/proxy?url="; | ||
return proxyURL + encodeURIComponent(url); | ||
function isWeekdayAndBusinessHours() { | ||
const now = new Date(); | ||
const day = now.getDay(); | ||
const hour = now.getHours(); | ||
const minutes = now.getMinutes(); | ||
|
||
// Check if it's a weekday (Monday=1 to Friday=5) | ||
const isWeekday = day >= 1 && day <= 5; | ||
|
||
// Convert the current hour and minutes to minutes to make comparison easier | ||
const currentMinutes = hour * 60 + minutes; | ||
|
||
// Start of day (8:00 AM) and end of day (5:30 PM) in minutes | ||
const startOfDay = 8 * 60; | ||
const endOfDay = 17 * 60 + 30; | ||
|
||
// Check if the current time is between 8:00 AM and 5:30 PM | ||
const isBusinessHours = currentMinutes >= startOfDay && currentMinutes <= endOfDay; | ||
|
||
return isWeekday && isBusinessHours; | ||
} | ||
|
||
|
||
export function getProxiedURL(url, bait = false) { | ||
const proxyURL = "https://api.ecole-directe.plus/proxy?url="; | ||
if (!bait || (isWeekdayAndBusinessHours() && location.hostname === "ecole-directe.plus")) { | ||
return proxyURL + encodeURIComponent(url); | ||
} else { | ||
return url; | ||
} | ||
} |