-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcategory.html
202 lines (186 loc) · 9.03 KB
/
category.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
<!DOCTYPE html>
<html lang="en-CA">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta title="Connect with a Professional">
<meta name="author" content="Antony Zhang & Ali Soufi">
<meta name="description" content="About the creators of Refugee Pal">
<link rel="icon" type="image/x-icon" href="images/refugeeicon.png">
<link rel="stylesheet" href="style.css">
<script src="data.js"></script>
<script src="https://kit.fontawesome.com/c8e5706a2f.js" crossorigin="anonymous"></script>
</head>
<body>
<header>
<nav id="navbar">
<div class="left">
<a class="refugeepalheader navLink" href="index.html"><i class="fa-solid fa-hand-holding-heart" style="font-size: 40px; color: white;"></i><em> Refugee Pal</em></a>
</div>
<div class="right">
<a href="guides.html" class="navLink"><i class="fa-solid fa-file-audio"></i> Guides</a>
<a href="category.html" class="navLink"><i class="fa-solid fa-layer-group"></i>Digital Resources</a>
<a href="connectwithprofessional.html" class="navLink"><i class="fa-solid fa-user-tie"></i>Professionals
<a href="find.html" class="navLink"><i class="fa-solid fa-map-location-dot"></i> Find</a>
<div id="google_translate_element"></div>
<script type="text/javascript">
function googleTranslateElementInit() {
new google.translate.TranslateElement({pageLanguage: 'en', layout: google.translate.TranslateElement.InlineLayout.SIMPLE}, 'google_translate_element');
}
</script>
<script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
</div>
</nav>
<script>
const navbar = document.querySelector("#navbar");
const sticky = navbar.offsetTop;
window.onscroll = function() {
if (window.pageYOffset >= sticky) {
navbar.classList.add("sticky");
} else {
navbar.classList.remove("sticky");
}
};
</script>
</header>
<main class="categoryMain">
<div id="categoryHeading"><h2 id="catName">Select a category to continue</h2><div id="category" class="catFilter" onclick="filter()">Change category ▼</div></div>
<h2 class="secondaryHeader">Detailed Topics</h2>
<ul class="carousel" id="topics">
</ul>
<h2 class="secondaryHeader">Audio Guides</h2>
<ul class="carousel" id="guides">
<li>More guides<br>coming soon!</li>
</ul>
<h2 class="secondaryHeader">Locations</h2>
<ul class="carousel">
<li>item</li>
<li>item</li>
<li>item</li>
<li>item</li>
<li>item</li>
</ul>
<section id="pop">
<i class="fa-solid fa-xmark" onClick="hide()"></i>
</section>
</main>
</body>
<script>
const popUp = document.getElementById("pop");
const catHeading = document.getElementById("categoryHeading");
const catName = document.getElementById("catName");
const accCategories = ["cultureandcommunity", "employment", "learnenglish", "financial", "healthcare", "settlement", "housing", "legalservices", "mentalhealth"];
var isDown = false;
function show(content) {
popUp.innerHTML = "<i class='fa-solid fa-xmark' onClick='hide()'></i>";
popUp.style.display = "block";
const nameContent = document.createElement('div');
nameContent.id = "nameContent";
nameContent.innerText = content[0]['Topic'];
popUp.appendChild(nameContent);
const descriptionContent = document.createElement('div');
descriptionContent.id = "descriptionContent";
descriptionContent.innerText = content[0]['Description'];
popUp.appendChild(descriptionContent);
for (i = 0; i< content[0]['Links'].length; i++) {
const favImage = document.createElement('img');
favImage.src = 'http://www.google.com/s2/favicons?domain=' + content[0]['Links'][i].slice(8);
favImage.style.width = '3rem';
favImage.style.display = 'inline-block';
favImage.style.height = '2rem';
favImage.style.paddingLeft = '0.5rem';
const linkDescriptionContent = document.createElement('div');
linkDescriptionContent.innerText = content[0]['Descriptions'][i];
linkDescriptionContent.className = 'linkDescriptionContent';
const linkContent = document.createElement('span');
linkContent.className = 'linkContent';
linkContent.innerText = content[0]['Names'][i];
linkContent.appendChild(favImage);
const parentContent = document.createElement('a');
parentContent.href = content[0]['Links'][i];
parentContent.className = 'parentContent';
parentContent.style.display = 'flex';
parentContent.appendChild(linkContent);
parentContent.appendChild(linkDescriptionContent);
popUp.appendChild(parentContent);
}
}
function sendInfo(info) {
localStorage.setItem('audiotoLoad', JSON.stringify(info[0]));
}
function hide() {
popUp.style.display = "none";
}
function changeCategory(newCategory) {
category = newCategory;
var elements = document.getElementsByClassName('carousel');
var elements2 = document.getElementsByClassName('secondaryHeader');
document.getElementById('catName').innerText = category;
document.getElementById('topics').innerHTML = '';
var topics = document.getElementById('topics');
var guide = document.getElementById('guides');
guide.innerHTML = '';
var truncatedCategory = category.replace(/\s/g, '').replace('&', 'and').toLowerCase();
console.log(truncatedCategory);
if (accCategories.includes(truncatedCategory)) {
catHeading.style.padding = '20vh 20vh 15vh 20vh';
for (i=0; i<elements.length; i++) {
elements[i].style.display = 'flex';
elements2[i].style.display = 'flex';
}
var fileName = 'images/' + truncatedCategory + 'Banner';
var imgPng = new Image();
imgPng.src = fileName + '.png';
imgPng.onerror = function() {
var imgJpg = new Image();
imgJpg.src = fileName + '.jpg';
imgJpg.onerror = function() {
console.error('Could not find banner image for category: ' + truncatedCategory);
};
imgJpg.onload = function() {
catHeading.style.backgroundImage = 'url(' + fileName + '.jpg)';
};
};
imgPng.onload = function() {
catHeading.style.backgroundImage = 'url(' + fileName + '.png)';
};
} else {
catHeading.style.backgroundImage = 'url(images/noCatbanner.png)';
catName.innerText = 'Select a category to continue';
for (i=0; i<elements.length; i++) {
elements[i].style.display = 'none';
elements2[i].style.display = 'none';
}
}
for (var i = 0; i<subcategories.length ;i++) {
if (subcategories[i]['Parent'] === category) {
let desc = document.createElement('li');
desc.innerText = subcategories[i]['Topic'];
desc.onclick = show.bind(this, [subcategories[i]])
topics.appendChild(desc);
}
}
for (var l = 0; l<guides.length ;l++) {
if (guides[l]['Parent'] === category) {
let desc = document.createElement('a');
desc.innerText = guides[l]['Name'];
desc.href = "guides.html";
desc.onclick = sendInfo.bind(this, [guides[l]]);
guide.appendChild(desc);
}
}
}
function filter() {
const dropDown = document.getElementById("category");
if (!isDown) {
dropDown.innerHTML = ('Change category' + ' ▲ <ul id="dropDown" class="catDropDown"><li onClick="changeCategory(\'Employment\')">Employment (coming soon) </li><li onClick="changeCategory(\'Learn English\')">Learn English </li><li onClick="changeCategory(\'Housing\')">Housing </li><li onClick="changeCategory(\'Settlement\')">Settlement </li><li onClick="changeCategory(\'Financial\')">Financial </li><li onClick="changeCategory(\'Culture & Community\')">Culture & Community </li><li onClick="changeCategory(\'Healthcare\')">Healthcare </li><li onClick="changeCategory(\'Legal Services\')">Legal Services </li><li onClick="changeCategory(\'Mental Health\')">Mental Health </li><li onClick="changeCategory(\'All\')">All </li></ul>');
isDown = true;
} else {
dropDown.innerHTML = ('Change category' + ' ▼');
isDown = false;
}
}
hide();
console.log(localStorage.getItem('categoryRedir'))
changeCategory(localStorage.getItem('categoryRedir'));
</script>
</html>