-
-
Notifications
You must be signed in to change notification settings - Fork 184
/
Copy pathmain.js
42 lines (36 loc) · 1.28 KB
/
main.js
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
$(document).ready(function () {
$(window).scroll(function () {
if ($(this).scrollTop() > 500) {
$('#back-to-top').fadeIn();
} else {
$('#back-to-top').fadeOut();
}
});
patchAssetIntoDom('/assets/logos/cc/logomark.svg');
patchAssetIntoDom('/assets/logos/cc/letterheart.svg');
// Check for click events on the navbar burger icon
$(".navbar-burger").click(function() {
// Toggle the "is-active" class on both the "navbar-burger" and the "navbar-menu"
$(".navbar-burger").toggleClass("is-active");
$(".navbar-menu").toggleClass("is-active");
});
});
const getFullyQualifiedUrl = (path, version) => {
let baseUrl = "https://unpkg.com/@creativecommons/vocabulary"
if (version) {
baseUrl = `${baseUrl}@${version}`
}
return `${baseUrl}/${path}`
}
const patchAssetIntoDom = (asset, version = null) => {
const ajax = new XMLHttpRequest();
ajax.open("GET", getFullyQualifiedUrl(asset, version), true);
ajax.onload = () => {
var div = document.createElement("div");
// Render SVG in the page
div.innerHTML = ajax.responseText;
div.style.display = 'none';
document.body.insertBefore(div, document.body.childNodes[0]);
}
ajax.send();
}