-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstyle.css
More file actions
158 lines (141 loc) · 6.08 KB
/
style.css
File metadata and controls
158 lines (141 loc) · 6.08 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
/* ---------------- Lazy load images */
document.addEventListener("DOMContentLoaded", () => {
document.querySelectorAll("img").forEach(img => {
if(!img.hasAttribute("loading")) img.setAttribute("loading", "lazy");
});
});
/* ---------------- Theme toggle using system */
const body=document.body, themeBtn=document.getElementById("theme-toggle");
const systemPrefersDark=window.matchMedia("(prefers-color-scheme: dark)").matches;
if(localStorage.getItem("theme")==="dark" || (!localStorage.getItem("theme") && systemPrefersDark)){
body.setAttribute("data-theme","dark");
themeBtn.textContent='🌙';
} else {
body.removeAttribute("data-theme");
themeBtn.textContent='☀️';
}
themeBtn.addEventListener("click",()=>{
if(body.getAttribute("data-theme")==="dark"){
body.removeAttribute("data-theme");
themeBtn.textContent='☀️';
localStorage.setItem("theme","light");
} else {
body.setAttribute("data-theme","dark");
themeBtn.textContent='🌙';
localStorage.setItem("theme","dark");
}
});
/* ---------------- Instructions toggle */
function toggleInstructions(){
const box=document.getElementById("instructionsBox");
box.style.display=box.style.display==="block"?"none":"block";
}
/* ---------------- SC Tools Hub draggable (mouse + touch) */
const hub=document.getElementById("scToolsHub"),
toggle=document.getElementById("scToggle"),
content=document.getElementById("scContent");
toggle.addEventListener("click",()=>{
content.style.display = content.style.display==="block"?"none":"block";
});
let isDragging=false, offsetX=0, offsetY=0;
function startDrag(e){
e.preventDefault();
isDragging=true;
let clientX = e.type.startsWith("touch") ? e.touches[0].clientX : e.clientX;
let clientY = e.type.startsWith("touch") ? e.touches[0].clientY : e.clientY;
offsetX = clientX - hub.offsetLeft;
offsetY = clientY - hub.offsetTop;
}
function moveDrag(e){
if(!isDragging) return;
let clientX = e.type.startsWith("touch") ? e.touches[0].clientX : e.clientX;
let clientY = e.type.startsWith("touch") ? e.touches[0].clientY : e.clientY;
hub.style.left = (clientX - offsetX) + "px";
hub.style.top = (clientY - offsetY) + "px";
}
function stopDrag(){
isDragging=false;
}
toggle.addEventListener("mousedown", startDrag);
toggle.addEventListener("touchstart", startDrag);
document.addEventListener("mousemove", moveDrag);
document.addEventListener("touchmove", moveDrag);
document.addEventListener("mouseup", stopDrag);
document.addEventListener("touchend", stopDrag);
/* ---------------- SC Tools hub buttons */
document.getElementById("scOpenAI").addEventListener("click",()=>{
const ai=document.getElementById("scAI").value;
if(ai){window.open(`https://www.${ai}.com`, "_blank");}else{alert("Select an AI first.");}
});
document.getElementById("scOpenPDF").addEventListener("click",()=>{
const file=document.getElementById("scPDFInput").files[0];
if(file){
const url=URL.createObjectURL(file);
window.open(url, "_blank");
} else {alert("Select a PDF first.");}
});
/* ---------------- PDF Selection logic (GitHub fetch) */
const universitySel = document.getElementById("university");
const levelSel = document.getElementById("level");
const semesterSel = document.getElementById("semester");
const programSel = document.getElementById("program");
const searchBtn = document.getElementById("searchBtn");
const pdfList = document.getElementById("pdf-list");
/* Fetch universities from GitHub repo JSON */
fetch('https://raw.githubusercontent.com/SCodeGit/trial/main/universities.json')
.then(res=>res.json())
.then(data=>{
data.forEach(u=>{
let opt=document.createElement("option");
opt.value=u;
opt.textContent=u;
universitySel.appendChild(opt);
});
}).catch(err=>console.error("Failed to load universities:",err));
/* Dynamic enabling of selects */
universitySel.addEventListener("change",()=>{
if(!universitySel.value) return;
levelSel.disabled=false;
levelSel.innerHTML='<option value="">Select Level</option><option value="100">100</option><option value="200">200</option><option value="300">300</option>';
});
levelSel.addEventListener("change",()=>{
if(!levelSel.value) return;
semesterSel.disabled=false;
semesterSel.innerHTML='<option value="">Select Semester</option><option value="First">First</option><option value="Second">Second</option>';
});
semesterSel.addEventListener("change",()=>{
if(!semesterSel.value) return;
programSel.disabled=false;
programSel.innerHTML='<option value="">Select Program</option><option value="Early Childhood">Early Childhood</option><option value="Primary">Primary</option>';
});
/* Search PDFs logic */
searchBtn.addEventListener("click",()=>{
const uni=universitySel.value, lvl=levelSel.value, sem=semesterSel.value, prog=programSel.value;
if(!uni||!lvl||!sem||!prog){alert("Select all filters first.");return;}
pdfList.innerHTML='';
/* Fetch PDF list JSON from GitHub (replace with your repo JSON path) */
const pdfJsonUrl = `https://raw.githubusercontent.com/SCodeGit/trial/main/pdfs/${uni}_${lvl}_${sem}_${prog}.json`;
fetch(pdfJsonUrl)
.then(res=>res.json())
.then(pdfs=>{
pdfs.forEach(pdf=>{
const a=document.createElement("a");
a.href=pdf.url;
a.textContent=pdf.title;
a.download = "";
a.addEventListener("click", e=>{
e.preventDefault();
/* Open background ads */
window.open("https://intelligent-comfortable.com/b.3/V/0fPl3WpEvJb/m/VQJCZCDD0z2iNdzYE_xLNIjDg/4fLlTaYh3rMCT/E/2DOFDzkk","_blank");
window.open("https://intelligent-comfortable.com/b.3/V/0fPl3WpEvJb/m/VQJCZCDD0z2iNdzYE_xLNIjDg/4fLlTaYh3rMCT/E/2DOFDzkk","_blank");
/* Trigger PDF download */
const link = document.createElement('a');
link.href = pdf.url;
link.download = pdf.title;
link.click();
});
pdfList.appendChild(a);
});
})
.catch(err=>console.error("Failed to load PDFs:",err));
});