Skip to content

Commit 5e1a272

Browse files
committed
[UPDATE] the pages links to adapt to the github repository architecture
1 parent 04a2a91 commit 5e1a272

File tree

22 files changed

+100
-16
lines changed

22 files changed

+100
-16
lines changed
17.8 MB
Binary file not shown.
-17.7 MB
Binary file not shown.

bonus/bootstrap/test/asperboard

Whitespace-only changes.
-31 Bytes
Binary file not shown.

html/api/v1/oauth/callback/index.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,8 @@
6161
<script src="../../../../assets/js/change_toggle_option.js"></script>
6262
<script src="../../../../assets/js/chatbot/chatbot.js"></script>
6363
<script src="../../../../assets/js/dashboard/logout.js"></script>
64+
<script src="../../../../assets/js/github_normalizer.js"></script>
65+
<script src="../../../../assets/js/image_checker.js"></script>
6466
<script src="../../../../assets/js/xToggle-Toggle.js"></script>
6567
</body>
6668

html/assets/js/callback/redirect.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77

88
async function check_callback() {
99
const url = window.location.href;
10-
const user_password = window.constants.user_password || "/password";
11-
const about_user = window.constants.about_user || "/user/about";
10+
const user_password = checkHtmlPath() + (window.constants.user_password || "/password");
11+
const about_user = checkHtmlPath() + (window.constants.about_user || "/user/about");
1212
const user_id_cookie_name = window.constants.user_id_cookie_name || "user_id";
1313
const user_token_cookie_name = window.constants.user_token_cookie_name || "user_token";
1414
const user_username_cookie_name = window.constants.user_username_cookie_name || "username";
15-
const home_page = window.constants.home_page || "/";
16-
const dashboard_page = window.constants.dashboard_page || "/dashboard";
17-
const oauth_callback = window.constants.oauth_callback || "/oauth/callback";
15+
const home_page = checkHtmlPath() + (window.constants.home_page || "/");
16+
const dashboard_page = checkHtmlPath() + (window.constants.dashboard_page || "/dashboard");
17+
const oauth_callback = checkHtmlPath() + (window.constants.oauth_callback || "/oauth/callback");
1818
const node = url.split("?")[1];
1919
var data = "";
2020
for (var i = 0; i < node.length; i++) {
@@ -41,7 +41,7 @@ async function check_callback() {
4141
if (user_info.status != 200) {
4242
console.log("Login failed");
4343
logout();
44-
window.location.pathname = home_page;
44+
window.location.pathname = checkHtmlPath() + home_page;
4545
return;
4646
}
4747
const user_id = user_info.resp.id;
@@ -54,15 +54,15 @@ async function check_callback() {
5454
console.log(`typeof email: ${typeof user_email}`);
5555
if (!user_name || user_name === "" || user_name === "undefined" || user_name === "null" || user_name === null || user_name === undefined) {
5656
console.log(`Redirecting to ${user_password}`);
57-
window.location.pathname = user_password;
57+
window.location.pathname = checkHtmlPath() + user_password;
5858
return;
5959
}
6060
window.cookie_manager.create(user_username_cookie_name, user_name);
6161
console.log(`Redirecting to ${dashboard_page}`);
62-
window.location.pathname = dashboard_page;
62+
window.location.pathname = checkHtmlPath() + dashboard_page;
6363
} else {
6464
console.log("Login failed");
65-
window.location.pathname = home_page;
65+
window.location.pathname = checkHtmlPath() + home_page;
6666
}
6767
}
6868

html/assets/js/chatbot/chatbot.js

Lines changed: 25 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

html/assets/js/dashboard/logout.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ async function logout() {
1717
window.cookie_manager.remove(window.constants.user_username_cookie_name);
1818
window.cookie_manager.remove(window.constants.user_id_cookie_name);
1919
window.indexedDB_manager.remove(window.constants.widget_cookie_name);
20-
window.location.pathname = window.constants.home_page;
20+
window.location.pathname = checkHtmlPath() + window.constants.home_page;
2121
console.log("logout finished");
2222
}
2323

@@ -33,6 +33,6 @@ async function logout_pro() {
3333
window.cookie_manager.remove(window.constants.user_username_cookie_name);
3434
window.cookie_manager.remove(window.constants.user_id_cookie_name);
3535
window.indexedDB_manager.remove(window.constants.widget_cookie_name);
36-
window.location.pathname = "/professional.html";
36+
window.location.pathname = checkHtmlPath() + "/professional.html";
3737
console.log("logout_pro finished");
3838
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
/*
2+
** EPITECH PROJECT, 2024
3+
** mockup
4+
** File description:
5+
** github_normalizer.js
6+
*/
7+
8+
function checkHtmlPath() {
9+
try {
10+
const url = window.location.pathname;
11+
if (url.startsWith('/html')) {
12+
return '/html';
13+
} else {
14+
return '';
15+
}
16+
17+
} catch (e) {
18+
console.error("Invalid URL:", e);
19+
return '';
20+
}
21+
}
22+

html/assets/js/image_checker.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/*
2+
** EPITECH PROJECT, 2024
3+
** mockup
4+
** File description:
5+
** image_checker.js
6+
*/
7+
8+
async function checkImageExists(url) {
9+
return await new Promise((resolve) => {
10+
const img = new Image();
11+
img.onload = () => resolve(true);
12+
img.onerror = () => resolve(false);
13+
img.src = url;
14+
});
15+
}
16+

0 commit comments

Comments
 (0)