-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathR_path.html
200 lines (164 loc) · 5.82 KB
/
R_path.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Workshop Selector</title>
<link rel="icon" type="image/png" sizes="32x32" href="static/images/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="static/images/favicon-16x16.png">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://bootswatch.com/4/litera/bootstrap.min.css">
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<!-- jQuery -->
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<!-- Fontawesome JS -->
<script defer src="https://use.fontawesome.com/releases/v5.0.10/js/all.js" integrity="sha384-slN8GvtUJGnv6ca26v8EzVaR9DC58QEwsIk9q1QXdCU8Yu8ck/tL/5szYlBbqmS+" crossorigin="anonymous"></script>
<!-- Custom CSS -->
<link rel="stylesheet" href="static/stylesheets/style.css">
<style>
#requirements-heading {
display: none;
}
.container-fluid {
margin: 20px;
}
.card {
margin-bottom: 20px;
}
.arrow span {
font-size: 2em;
}
.flex-nowrap {
flex-wrap: nowrap !important;
}
.overflow-auto {
overflow-x: auto;
}
.card {
margin-right: 20px;
margin-bottom: 20px;
}
.arrow span {
font-size: 2em;
margin-left: 20px;
margin-right: 20px;
}
</style>
</head>
<body>
<!-- Navbar -->
<nav class="navbar navbar-expand-lg navbar-light bg-light fixed-top borderless">
<a
class="navbar-brand"
href="index.html"
>
D-Lab Workshops
</a>
<button class="navbar-toggler borderless" type="button" data-toggle="collapse" data-target="#navbarColor01" aria-controls="navbarColor01" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarColor01">
<ul class="navbar-nav ml-auto">
<li class="nav-item">
<a class="nav-link active" href="python.html">Home</a>
<li class="nav-item">
<a class="nav-link" href="library.html">Library</a>
</li>
<li class="nav-item">
<a class="nav-link" target="_blank" href="https://dlab.berkeley.edu/">About D-Lab</a>
</li>
</ul>
</div>
</nav>
<!-- End of Navbar -->
<div class="container-fluid mt-5">
<div style="text-align: center; padding-top: 20px;">
<a href="R.html"><button type="button" class="btn btn-warning">Return to default view</button></a>
<a href="https://dlab.berkeley.edu/training/upcoming-workshops"><button type="button" class="btn btn-info">Book a workshop!</button></a>
</div>
<h1>Learning Pathways for R Workshops</h1>
<select id="r-workshop-dropdown" class="form-control mb-5">
<option value="" disabled selected>Select an R workshop</option>
</select>
<h3 id="requirements-heading" style="display:none;">Workshop Requirements</h3>
<div id="prerequisite-cards" class="row flex-nowrap overflow-auto">
<script>
// Fetch JSON data
$.getJSON("data/workshop_list.json", function(data) {
// Extract columns into separate variables
var titles = data.Title;
var descriptions = data.Description;
var prerequisites = data.Prerequisites;
var materials = data['Workshop Materials'];
// Filter R workshops
var RWorkshops = [];
for (var id in titles) {
if (titles[id].includes("R")) {
RWorkshops.push({
'ID': id,
'Title': titles[id],
'Description': descriptions[id],
'Prerequisites': prerequisites[id],
'Workshop Materials': materials[id]
});
}
}
// Populate dropdown options
$.each(RWorkshops, function(index, workshop) {
$('#r-workshop-dropdown').append(new Option(workshop.Title, workshop.ID));
});
// On dropdown change, populate cards
$('#r-workshop-dropdown').change(function() {
var selectedID = $(this).val();
$("#requirements-heading").show();
// Clear existing cards
$('#prerequisite-cards').html('');
// Find the selected workshop data
var selectedWorkshop = RWorkshops.find(w => w.ID === selectedID);
// Handle the special case of "R Fundamentals"
if (selectedWorkshop && selectedWorkshop.Title === "R Fundamentals") {
var noneCard = `
<div class="card col-md-4">
<div class="card-body">
<h5 class="card-title">None!</h5>
<p class="card-text">You don't need any prerequisites for this workshop.</p>
</div>
</div>`;
$('#prerequisite-cards').append(noneCard);
} else {
// Filter prerequisites
var prereqTitles = selectedWorkshop.Prerequisites ? selectedWorkshop.Prerequisites.split(", ") : [];
// Generate cards for each prerequisite
$.each(prereqTitles, function(index, title) {
var prerequisiteData = RWorkshops.find(w => w.Title === title);
if (prerequisiteData) {
var card = `
<div class="card col-md-4" style="max-width: 350px;">
<div class="card-body">
<h5 class="card-title">${prerequisiteData.Title}</h5>
<p class="card-text">${prerequisiteData.Description}</p>
<a href="${prerequisiteData['Workshop Materials']}" class="btn btn-primary">Workshop Materials</a>
</div>
</div>`;
$('#prerequisite-cards').append(card);
// Add arrow after each card except the last one
if (index < prereqTitles.length) {
$('#prerequisite-cards').append('<div class="arrow col-auto d-flex align-items-center justify-content-center" style="margin-left: 5px; margin-right: 5px;"><span>→</span></div>');
}
}
});
}
// Add a card for the selected workshop at the end
var selectedCard = `
<div class="card col-md-4" style="max-width: 350px; background-color: #D7E3F0;">
<div class="card-body">
<h5 class="card-title">${selectedWorkshop.Title}</h5>
<p class="card-text">${selectedWorkshop.Description}</p>
<a href="${selectedWorkshop['Workshop Materials']}" class="btn btn-primary">Workshop Materials</a>
</div>
</div>`;
$('#prerequisite-cards').append(selectedCard);
});
});
</script>
</body>
</html>