-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
480 lines (480 loc) · 16.2 KB
/
Copy pathindex.html
File metadata and controls
480 lines (480 loc) · 16.2 KB
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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link rel="icon" href="icon.png" />
<link
href="https://fonts.googleapis.com/css2?family=Lexend+Deca:wght@100..900&family=Ubuntu:ital,wght@0,300;0,400;0,500;0,700;1,300;1,400;1,500;1,700&display=swap"
rel="stylesheet"
/>
<meta charset="UTF-8" />
<meta name="theme-color" content="#1a1a2e" />
<meta name="color-scheme" content="dark" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Sendup Schedule Calculator</title>
<link rel="stylesheet" href="style.css" />
<meta property="og:title" content="GCU Sendup Schedule Generator" />
<meta
property="og:description"
content="Calculates your sendup schedule. A small project by Muhammad Ali."
/>
<meta
property="og:image"
content="https://img.itch.zone/aW1hZ2UvMjg4NzEyNy8xODY4NTE0NC5wbmc=/original/ZPsh%2Bb.png"
/>
<meta property="og:url" content="https://sendup.alimad.co" />
<meta property="og:type" content="website" />
<script src="https://cdnjs.cloudflare.com/ajax/libs/html2canvas/1.4.1/html2canvas.min.js"></script>
</head>
<body>
<div id="rest">
<h1>Calculate Your Sendup Schedule</h1>
<div class="input-container">
<label for="rollNoInput" style="font-size: 20px"
>Enter Your Complete Roll Number:</label
>
<input id="rollNoInput" placeholder="e.g. 3686-1-24" /><br />
<div class="radio-group">
<label class="radio-container"
>Morning<input
type="radio"
name="time"
value="morning"
checked /><span class="radio-mark"></span
></label>
<label class="radio-container"
>Evening<input type="radio" name="time" value="evening" /><span
class="radio-mark"
></span
></label>
</div>
<div class="radio-group">
<label class="radio-container"
>ICS<input type="radio" name="subject" value="ICS" checked /><span
class="radio-mark"
></span
></label>
<label class="radio-container"
>PE<input type="radio" name="subject" value="PE" /><span
class="radio-mark"
></span
></label>
<label class="radio-container"
>PM<input type="radio" name="subject" value="PM" /><span
class="radio-mark"
></span
></label>
</div>
<div id="more">
<label class="container" for="ART"
>ARTS 
<input type="checkbox" id="ART" />
<span class="checkmark"></span
></label>
<label class="container" for="COM"
>COM 
<input type="checkbox" id="COM" />
<span class="checkmark"></span
></label>
<label class="container" for="GS"
>GS 
<input type="checkbox" id="GS" />
<span class="checkmark"></span
></label>
<br />
</div>
<br />
<label class="container" for="extra"
>Include Extra Subjects<input type="checkbox" id="extra" /><span
class="checkmark"
></span
></label>
<br /><br />
<button
onclick="generateSchedule()"
id="theButton"
style="padding: 10px 20px"
disabled
>
<strong>Get Schedule</strong></button
><br /><br />
</div>
<p id="errorMessage" style="font-weight: bold; color: red"></p>
</div>
<table id="scheduleTable" style="display: none">
<thead>
<tr>
<th>#</th>
<th>Day</th>
<th>Date</th>
<th>Subject</th>
<th>Room</th>
<th style="display: none" id="tds">Time</th>
</tr>
</thead>
<tbody></tbody>
</table>
<p id="naem"></p>
<p id="classs"></p>
<p id="time"></p>
<p id="log" style="display: none;"></p>
<center><p id="logg" style="display: inline"></p></center>
<button onclick="download()" id="down" style="display: none">
Download
</button>
<button onclick="cleanup()" id="clean" style="display: none">
Clean Up
</button>
<button
onclick="back()"
id="bb"
style="
display: none;
background: linear-gradient(135deg, #cf4410, #f9a045);
"
>
Back
</button>
<button id="subscribeBtn">YouTube Channel</button>
<a href="https://play.google.com/store/apps/details?id=com.alimad.sendup" target="_blank"><button id="downapp">Download the App</button></a>
<p id="status"></p>
<script>
const subscribeBtn = document.getElementById("subscribeBtn");
const statusText = document.getElementById("status");
document.addEventListener("DOMContentLoaded", () => {
if (localStorage.getItem("subbed") == "Y") {
subscribeBtn.style.display = "none";
statusText.style.display = "none";
}
});
subscribeBtn.addEventListener("click", () => {
const lastClick = localStorage.getItem("lastSubscribeClick");
window.open("https://www.youtube.com/@alimadco", "_blank");
const currentTime = Date.now();
subscribeBtn.disabled = true;
setTimeout(() => {
subscribeBtn.disabled = false;
}, 6000);
if (lastClick) {
const timeSinceLastClick = (currentTime - lastClick) / 1000;
if (timeSinceLastClick >= 6) {
statusText.textContent = "Thank you for subscribing!";
localStorage.setItem("subbed", "Y");
} else {
statusText.textContent = `Please wait ${(
6 - timeSinceLastClick
).toFixed(1)} more seconds.`;
}
} else {
statusText.textContent =
"Please click again after 6 seconds to confirm subscription.";
}
localStorage.setItem("lastSubscribeClick", currentTime);
});
</script>
<details>
<summary style="color: #fffc"><strong>Abbreviations</strong></summary>
<strong>NB.</strong> - New Block<br />
<strong>BJLT</strong> - Bio Junior Lecture Theatre<br />
<strong>CNLT</strong> - Chemistry New Lecture Theatre<br />
<strong>EE</strong> - Electrical Engineering<br />
<strong>PE</strong> - Pre Engineering<br />
<strong>PM</strong> - Pre Medical<br />
<strong>COM</strong> - Commerce<br />
<strong>GS</strong> - General Sciences<br />
</details>
<div class="feedback-container">
<a
target="_blank"
href="https://live.alimad.co/stats/view?app=sendup-alimad-co"
><div
id="live-counter"
style="
font-family: sans-serif;
color: #4caf50;
display: inline-flex;
align-items: center;
gap: 6px;
"
>
<span
style="
width: 10px;
height: 10px;
border-radius: 50%;
background: #4caf50;
"
id="live-dot"
></span>
<span id="live-count">Loading...</span>
</div></a
>
<script>
async function udpp() {
const dot = document.getElementById("live-dot");
const count = document.getElementById("live-count");
try {
const response = await fetch(
"https://live.alimad.co/ping?app=sendup-alimad-co"
);
if (response.ok) {
const userCount = await response.text();
dot.style.background = "#4CAF50";
count.style.color = "#4CAF50";
count.textContent = userCount + " online";
} else {
throw new Error("API error");
}
} catch (error) {
dot.style.background = "#f44336";
count.style.color = "#f44336";
count.textContent = "Offline";
}
}
setInterval(udpp, 20000);
udpp();
</script>
<div id="comments-section">
<div id="comments-list"></div>
</div>
<h1>Leave a Comment</h1>
<form id="feedbackForm">
<textarea
id="comment"
placeholder="Write your comment here..."
required
></textarea>
</form>
<button id="sub">Submit</button>
</div>
<p class="footer">
Made by <a href="https://alimad.co"><strong>Muhammad Ali</strong></a
>. In case of any errors, please
<a href="https://github.com/Alimadcorp/sendup/issues/new"
><strong>report</strong></a
>.
</p>
<p style="font-size: 9px">
All data is taken from
<a href="/extract/input.pdf">The Gazzette</a
><a
style="display: none"
href="https://gcu.edu.pk/Events/Updates/Gazzette-Inter-Part-IandII-SendUpTest-2024.pdf"
>GCU website</a
>.
</p>
<div
id="popup-overlay"
style="
display: none;
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: rgba(0, 0, 0, 0.5);
z-index: 1000;
justify-content: center;
align-items: center;
"
>
<div
style="
background: #00003388;
padding: 20px;
border-radius: 10px;
text-align: center;
width: 300px;
backdrop-filter: blur(4px);
"
>
<h2 id="popup-title">Title</h2>
<p id="popup-description">Description</p>
<p id="cleanerr" style="color: red"><strong></strong></p>
<input
id="popup-input"
type="text"
placeholder="e.g., 3, 6-11"
style="width: 90%; margin-bottom: 20px"
/>
<div>
<button
id="popup-cancel"
style="background: linear-gradient(135deg, #cf4410, #f9a045)"
>
Cancel
</button>
<button id="popup-ok" style="margin-right: 10px">OK</button>
</div>
</div>
</div>
<script src="fetch.js"></script>
<script src="script.js"></script>
<script src="popup.js"></script>
<script type="module">
import { initializeApp } from "https://www.gstatic.com/firebasejs/9.17.2/firebase-app.js";
import {
getFirestore,
collection,
query,
orderBy,
onSnapshot,
addDoc,
serverTimestamp,
} from "https://www.gstatic.com/firebasejs/9.17.2/firebase-firestore.js";
function g (e) { return document.getElementById(e); }
function getLog(){let e=g("rollNoInput"),c=e.value,t=extra.checked,l,u,o="MS";validate(c)?(l=extract(c).rollNo,u=extract(c).grade):(l=0,u=0),o=o+l.toString()+u.toString(),o+=t?"Y":"N";let r=g("ART").checked,n=g("COM").checked,a=g("GS").checked,d=document.querySelector('input[name="subject"]:checked'),S="I";return"ICS"!=d.value&&("PE"==d.value&&(S="E"),"PM"==d.value&&(S="M")),r&&(S+="A"),n&&(S+="C"),a&&(S+="G"),o+=S}
const app = initializeApp(firebaseConfig);
const db = getFirestore(app);
let firstSaturate = true;
const appname = "sendup";
const feedbackForm = g("feedbackForm");
const commentTextarea = g("comment");
const commentsList = g("comments-list");
let commentsArray = [];
let userArray = [];
async function addComment(commentText) {
try {
await addDoc(collection(db, "sendup"), {
text: commentText,
timestamp: serverTimestamp(),
roll: getLog(),
});
} catch (error) {}
}
function fetchVersion() {
const versionCheck = query(collection(db, "version"));
onSnapshot(versionCheck, (snapshot) => {
snapshot.forEach((doc) => {
let name = doc.data();
let version = doc.id;
if (version == appname) {
setversion(name.version, true);
}
});
});
}
function fetchUsers() {
const userRef = query(collection(db, "user"));
onSnapshot(userRef, (snapshot) => {
userArray = [];
snapshot.forEach((doc) => {
const userData = doc.data();
userData.id = doc.id;
userArray.push(userData);
});
});
}
function formatTimeAgo(timestamp) {
const now = new Date();
const diffInSeconds = Math.floor((now - timestamp) / 1000);
if (diffInSeconds < 60) {
return diffInSeconds <= 0
? "Just now"
: `${diffInSeconds} second${diffInSeconds === 1 ? "" : "s"} ago`;
}
const diffInMinutes = Math.floor(diffInSeconds / 60);
if (diffInMinutes < 60) {
return `${diffInMinutes} minute${diffInMinutes === 1 ? "" : "s"} ago`;
}
const diffInHours = Math.floor(diffInMinutes / 60);
if (diffInHours < 24) {
return `${diffInHours} hour${diffInHours === 1 ? "" : "s"} ago`;
}
const diffInDays = Math.floor(diffInHours / 24);
if (diffInDays <= 14) {
return `${diffInDays} day${diffInDays === 1 ? "" : "s"} ago`;
}
return timestamp.toLocaleDateString("en-US", {
day: "2-digit",
month: "short",
year: "numeric",
});
}
function refreshCom() {
let newArray = [];
const commentsRef = query(
collection(db, "sendup"),
orderBy("timestamp")
);
onSnapshot(commentsRef, (snapshot) => {
newArray = [];
snapshot.forEach((doc) => {
const commentData = doc.data();
commentData.id = doc.id;
newArray.push(commentData);
});
commentsArray = newArray;
displayCommentsWithDelay(true);
});
}
function scrollToBottom() {
const commentsContainer = g("comments-section");
commentsContainer.scrollTop = commentsContainer.scrollHeight;
}
let adding = false;
async function displayCommentsWithDelay(scrolll) {
if (adding) return;
adding = true;
commentsList.innerHTML = "";
for (const comment of commentsArray) {
if (scrolll && firstSaturate) {
await new Promise((resolve) => setTimeout(resolve, 10));
}
const timestamp = comment.timestamp
? comment.timestamp.toDate()
: new Date();
let name = "";
const timeAgo = formatTimeAgo(timestamp);
const roll = comment.roll;
let stc;
if (roll != null) {
for (const dat of userArray) {
if (roll.includes(dat.roll.trim())) {
name = dat.name;
stc = dat.stc;
break;
}
}
}
const commentElement = document.createElement("div");
commentElement.classList.add("comment");
const p = document.createElement("p");
if (name !== "") {
const strong = document.createElement("strong");
strong.classList.add("comment-name");
strong.style.cssText = stc;
strong.textContent = name + ": ";
p.appendChild(strong);
}
const textNode = document.createTextNode(comment.text);
p.appendChild(textNode);
commentElement.appendChild(p);
const timeDiv = document.createElement("div");
timeDiv.classList.add("comment-time");
timeDiv.textContent = timeAgo;
commentElement.appendChild(timeDiv);
commentsList.appendChild(commentElement);
}
firstSaturate = false;
await new Promise((resolve) => setTimeout(resolve, 50));
if (scrolll) scrollToBottom();
adding = false;
}
g("sub").addEventListener("click", () => {
const commentText = commentTextarea.value;
if (commentText) {
addComment(commentText);
commentTextarea.value = "";
}
});
document.addEventListener("DOMContentLoaded", () => {
fetchUsers();
fetchVersion();
refreshCom();
});
</script>
<script src="generate.js"></script>
</body>
</html>