This repository has been archived by the owner on Oct 25, 2024. It is now read-only.
generated from carpentries/workshop-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjavascript.html
54 lines (45 loc) · 1.85 KB
/
javascript.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
{% comment %}
JavaScript used in lesson and workshop pages.
{% endcomment %}
<script src="{{ relative_root_path }}/assets/js/jquery.min.js"></script>
<script src="{{ relative_root_path }}/assets/js/bootstrap.min.js"></script>
<script src="{{ relative_root_path }}/assets/js/lesson.js"></script>
<script>
/* Based on https://stackoverflow.com/a/30894829/1802726 */
var show_instructions = function() {
//set all nav tabs to inactive
$('.nav-tabs li').removeClass('active');
//get all nav tabs matching the os and set to active
$('.nav-tabs li a[href*="'+localStorage.os+'"]').closest('li').addClass('active');
//set all tabs to inactive
$('.tab-pane').removeClass('active');
//get all tabs matching the os and set to active
$('.tab-pane[id*="'+localStorage.os+'"]').addClass('active');
}
if (typeof(Storage) !== "undefined") {
if (localStorage.os == "undefined") {
localStorage.os = "windows";
}
show_instructions();
} else {
console.log("No localStorage");
}
/* Based on https://stackoverflow.com/a/30894829/1802726 */
$('.nav-tabs li a').click(function(){
//get selected os
localStorage.os = $(this)[0].dataset.os;
show_instructions();
});
// detect misssing iframe for Eventbrite
$(document).ready(function(){
if ($('iframe').height() == 0) {
$('iframe').before('<p>Looks like your adblocker blocked the registration window. Please navigate to <a href="https://www.eventbrite.com/tickets-external?eid={{page.eventbrite}}&ref=etckt">https://www.eventbrite.com/tickets-external?eid={{page.eventbrite}}&ref=etckt</a> to register.</p>');
}
});
// hide alerts when site is rendered on carpentries.github.io
$(document).ready(function() {
if (location.href.startsWith("https://carpentries.github.io/workshop-template/")) {
$("div.alert").hide();
}
});
</script>