-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
215 lines (202 loc) · 7.93 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link
rel="icon"
type="image/png"
href="/src/client/src/assets/logos/icon-152x152.png"
/>
<link
rel="apple-touch-icon"
type="image/png"
href="/src/client/src/assets/logos/icon-128x128.png"
/>
<link
rel="mask-icon"
type="image/png"
href="/src/client/src/assets/logos/icon-384x384.png"
/>
<link rel="manifest" href="/src/client/manifest.json" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>FrontiersCabal</title>
<meta
name="description"
content="Frontierscabal - your ultimate all-in-one platform designed to cater to every student's needs. Access extensive database of pastquestions and answers, helping you excel in exams with ease. Unleash Your creativity with built-in blog editor, where you can write and explore insightful articles on various topics. Stay updated with importants event through our handy notifier, Frontierscabal is here to empower and enrich your educational journey like never before! "
/>
<!-- Additional Meta Tags for SEO -->
<meta
name="keywords"
content="education, past questions, answers, exams, blog, events, Frontierscabal"
/>
<meta
name="robots"
content="index, follow, max-image-preview:large, max-snippet:-1, max-video-preview:-1"
/>
<meta property="og:locale" content="en_US" />
<meta
name="og:title"
content="Frontierscabal - Your Ultimate Educational Platform"
/>
<meta
name="og:description"
content="Frontierscabal is your ultimate all-in-one platform designed to cater to every student's needs. Access an extensive database of past questions and answers, excel in exams with ease, unleash your creativity with our built-in blog editor, and stay updated with important events. Frontierscabal empowers and enriches your educational journey like never before."
/>
<meta name="og:url" content="https://frontierscabal.com" />
<meta name="og:type" content="website" />
<meta property="og:site_name" content="FrontiersCabal" />
<link rel="canonical" href="https://frontierscabal.com" />
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:site" content="@frontierscabal" />
<!-- Global site tag (gtag.js) - Google Analytics -->
<script
async
src="https://www.googletagmanager.com/gtag/js?id=G-CZN50NEF3P"
defer
></script>
<script defer>
window.dataLayer = window.dataLayer || [];
function gtag() {
window.dataLayer.push(arguments);
}
gtag("js", new Date());
gtag("config", "G-CZN50NEF3P");
</script>
<style type="text/css">
.pwa-install {
width: 100%;
display: none;
align-items: center;
justify-content: center;
z-index: 9999;
padding: 10px 20px;
background-color: azure;
gap: 2px;
}
.pwa-install-btn {
padding: 9px 18px;
height: fit-content;
width: fit-content;
color: white;
border-radius: 4px;
border: none;
background-color: #176984;
cursor: pointer;
}
.pwa-text {
padding: 5px;
font-size: 12px;
text-align: left;
}
</style>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div class="pwa-install">
<p class="pwa-text">
<b>Frontierscabal</b> - your ultimate all-in-one platform designed to
cater to every student's needs.
</p>
<button class="pwa-install-btn">Install</button>
</div>
<div id="root"></div>
<script type="module" src="/src/client/src/main.tsx"></script>
<script type="module">
import getToken from "./src/client/src/utils/getToken.ts";
import axiosInstance from "./src/client/src/utils/axiosInstance.ts";
// Function to send the subscription to the server
const sendSubscriptionToServer = async (subscription) => {
try {
const authToken = await getToken();
if (authToken) {
await axiosInstance(authToken).post(
"/api/v1/push-subscription",
JSON.stringify(subscription)
);
console.log("Subscription to webpush done successfully!");
}
} catch (err) {
console.log(err);
}
};
window.addEventListener("load", () => {
navigator.serviceWorker && navigator.serviceWorker.register("");
navigator.serviceWorker.ready
.then(async (registration) => {
try {
let subscription =
await registration.pushManager.getSubscription();
if (!subscription) {
// If there's no existing subscription, create one
subscription = await registration.pushManager.subscribe({
userVisibleOnly: true,
applicationServerKey:
"BP_zBx8Se411U33MhcPWFMPwurhn9mP7YLnQI8CRUJXp35hk3lnYM6ZPfAZ0L4g7Ws7EhBSdqGlcE_nreH7YZNw",
});
// Send the initial subscription to your server
await sendSubscriptionToServer(subscription);
}
// Listen for push subscription change
navigator.serviceWorker.addEventListener(
"pushsubscriptionchange",
async (event) => {
console.log("Push subscription has changed.");
const newSubscription = event.newSubscription;
await sendSubscriptionToServer(newSubscription);
}
);
} catch (err) {
console.log(err);
}
registration.onupdatefound = () => {
const installingWorker = registration.installing;
if (installingWorker) {
installingWorker.onstatechange = () => {
if (installingWorker.state === "installed") {
// A new service worker is installed but not yet active.
// You can notify the user or take some action here.
console.log(
"New content is available and will be used when all " +
"tabs for this page are closed. See https://bit.ly/CRA-PWA."
);
// Optionally, you can force the new service worker to become active
// by calling registration.waiting.postMessage({ action: "skipWaiting" });
// This will skip the "waiting" state and activate the new service worker immediately.
// You might want to show a UI message to the user, asking them to reload the page.
}
};
}
};
})
.catch((error) => {
console.error("Error during service worker registration:", error);
});
});
let deferredPrompt;
const installBtn = document.querySelector(".pwa-install-btn");
const pwaBanner = document.querySelector(".pwa-install");
if (
(window.addEventListener("beforeinstallprompt", (e) => {
e.preventDefault(),
(deferredPrompt = e),
(pwaBanner.style.display = "flex");
installBtn.addEventListener("click", (e) => {
e.preventDefault(),
(pwaBanner.style.display = "none"),
deferredPrompt.prompt(),
deferredPrompt.userChoice.then((e) => {
"accepted" === e.outcome
? console.log("A2HS prompt accepted")
: console.log("A2HS prompt dismissed"),
(deferredPrompt = null);
});
});
}),
!deferredPrompt)
) {
let e = window.location.href;
-1 != e.indexOf("pwa") && (pwaBanner.style.display = "flex");
}
</script>
</body>
</html>