-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathresource-search.html
More file actions
222 lines (192 loc) · 7.57 KB
/
resource-search.html
File metadata and controls
222 lines (192 loc) · 7.57 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Urban and Regional Planning Resource Search</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.0/css/all.min.css">
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/fuse.js/dist/fuse.js"></script>
<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-RTR9SSJEHM"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments); }
gtag('js', new Date());
gtag('config', 'G-RTR9SSJEHM');
</script>
<!-- <meta name="viewport" content="width=device-width, initial-scale=1.0"> -->
<!--
--------------------------------------------------------------------------------
| Thanks for checking out this page's source! |
| If you've made it this far, you should consider contributing to the |
| urban-and-regional-planning-resources GitHub repository. We'd love |
| your help in continuing to make this available for planners! |
--------------------------------------------------------------------------------
-->
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.3.1/dist/css/bootstrap.min.css"
integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css">
<!-- Custom CSS -->
<link rel="stylesheet" href="https://apa-technology-division.github.io/css/pagestyles.css">
<style>
.no-linebreak {
display: flex;
align-items: center;
}
.magnifying-glass-icon {
height: 5em; /* Adjust as needed */
margin-right: 40px; /* Optional spacing */
}
.no-linebreak h1 {
margin: 0; /* Optional, for tighter spacing */
}
#controls {
display: flex;
gap: 1em;
margin-bottom: 1em;
}
#search,
#category-filter {
padding: 0.5em;
font-size: 1em;
width: 100%;
max-width: 300px;
}
.result {
padding: 1em;
margin-bottom: 1em;
background-color: #f9f9f9;
border: 1px solid #ddd;
border-radius: 5px;
}
.result h3 {
margin: 0;
}
.result a {
color: #0645AD;
}
#controls input,#controls select {
font-family: 'Courier New', monospace;
}
</style>
</head>
<body>
<div id="navbar-container"></div>
<div style="background-color:white;border-radius:25px; ">
<div class="card" id="overview"
style="padding-left: 10%; padding-right: 10%; padding-top:30px; padding-bottom:50px; border:transparent">
<div class="container">
<br><br>
<div class="no-linebreak">
<img src="https://upload.wikimedia.org/wikipedia/commons/5/55/Magnifying_glass_icon.svg"
alt="Magnifying Glass" class="magnifying-glass-icon">
<h1><b>Urban & Regional Planning Resource Search</b></h1>
</div>
<hr>
<p style="text-rendering:center;">Use this tool to search the datasets, tools, and educational resources in the
APA Technology Division's urban-and-regional-planning-resources GitHub repository.</p>
<br>
<div id="controls">
<input type="text" id="search" placeholder="Search resources...">
<select id="category-filter">
<option value="all">All Categories</option>
</select>
</div>
<div id="results">Loading...</div>
</div>
</div>
</div>
<script>
document.addEventListener("DOMContentLoaded", async () => {
const markdownUrl = "https://raw.githubusercontent.com/APA-Technology-Division/urban-and-regional-planning-resources/main/README.md";
try {
const response = await fetch(markdownUrl);
const markdown = await response.text();
const lines = markdown.split('\n');
const resources = [];
let currentCategory = "";
for (let line of lines) {
line = line.trim();
const categoryMatch = line.match(/^###\s+(.*)/);
if (categoryMatch) {
currentCategory = categoryMatch[1].trim();
continue;
}
const entryMatch = line.match(/^- \[(.*?)\]\((.*?)\)\s*-\s*(.*)/);
if (entryMatch && currentCategory) {
const [, name, url, description] = entryMatch;
resources.push({
category: currentCategory,
name: name.trim(),
url: url.trim(),
description: description.trim()
});
}
}
// Setup Fuse.js
const fuse = new Fuse(resources, {
keys: ['name', 'description', 'category'],
threshold: 0.3
});
const searchInput = document.getElementById("search");
const categorySelect = document.getElementById("category-filter");
const resultsDiv = document.getElementById("results");
// Populate category filter
const uniqueCategories = [...new Set(resources.map(r => r.category))].sort();
uniqueCategories.forEach(cat => {
const option = document.createElement("option");
option.value = cat;
option.textContent = cat;
categorySelect.appendChild(option);
});
const renderResults = (data) => {
if (data.length === 0) {
resultsDiv.innerHTML = "<p>No results found.</p>";
return;
}
resultsDiv.innerHTML = data.map(entry => `
<div class="result">
<h3><a href="${entry.url}" target="_blank">${entry.name}</a></h3>
<p><strong>Category:</strong> ${entry.category}</p>
<p>${entry.description}</p>
</div>
`).join('');
};
const filterAndRender = () => {
const query = searchInput.value.trim();
const selectedCategory = categorySelect.value;
let result = query ? fuse.search(query).map(r => r.item) : [...resources];
if (selectedCategory !== 'all') {
result = result.filter(r => r.category === selectedCategory);
}
renderResults(result);
};
searchInput.addEventListener("input", filterAndRender);
categorySelect.addEventListener("change", filterAndRender);
// Initial render
renderResults(resources);
} catch (error) {
document.getElementById("results").innerHTML = "Error loading or parsing markdown:<br>" + error;
}
});
</script>
<script>
fetch('assets/navbar.html')
.then(response => response.text())
.then(data => {
document.getElementById('navbar-container').innerHTML = data;
});
</script>
<!--Bring in Local and CDN Dependencies-->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
<script src="https://apa-technology-division.github.io/scripts/image-it-scripts.js"></script>
<script src="https://apa-technology-division.github.io/scripts/gallery.js"></script>
</body>
</html>