-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdynamic.js
54 lines (46 loc) · 2 KB
/
dynamic.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
42
43
44
45
46
47
48
49
50
51
52
53
54
// Fetch profile image from GitHub or Instagram
fetchProfileImage();
async function fetchProfileImage() {
try {
// Fetching profile image from GitHub
let githubResponse = await fetch('https://api.github.com/users/SzBenedek2006');
let githubData = await githubResponse.json();
document.getElementById('profile-image').src = githubData.avatar_url;
} catch (error) {
console.error('Error fetching GitHub profile image:', error);
try {
// Fetching profile image from Instagram
let instagramResponse = await fetch('https://www.instagram.com/szbenedek2006/?__a=1');
let instagramData = await instagramResponse.json();
let profilePicURL = instagramData.graphql.user.profile_pic_url_hd;
document.getElementById('profile-image').src = profilePicURL;
} catch (error) {
console.error('Error fetching Instagram profile image:', error);
}
}
}
// Dynamically load high res background
var img = new Image();
// Set the src attribute to the URL of the high-resolution image
img.src = 'background-image.jpg';
// When the image is loaded, apply it as the background
img.onload = function() {
document.body.style.backgroundImage = 'url(' + img.src + ')';
document.body.classList.add('loaded');
};
// Button
document.addEventListener('DOMContentLoaded', function () {
var menuButton = document.getElementById('toggle-menu');
var menu = document.getElementById('menu');
var headerContents = document.querySelector('.header');
//menu.style.display = 'block'; // Initially display the menu
menuButton.addEventListener('click', function () {
if (menu.style.display === 'none' || menu.style.display === '') {
menu.style.display = 'block';
headerContents.style.display = 'none'; // Hide header contents
} else {
menu.style.display = 'none';
headerContents.style.display = 'block'; // Show header contents
}
});
});