-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathscript.js
67 lines (63 loc) · 2.46 KB
/
script.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
55
56
57
58
59
60
61
62
63
64
65
66
67
function ChangeTheme (theme) {
document.querySelector(':root').style.setProperty('--theme', `${theme}`);
localStorage.setItem('theme', document.querySelector(':root').style.getPropertyValue('--theme'))
}
let choosenTheme = localStorage.getItem('theme');
document.querySelector(':root').style.setProperty('--theme', choosenTheme);
let share_btn = document.querySelector('#share-btn')
let share_link = location.href;
document.addEventListener('DOMContentLoaded', () => {
share_btn.addEventListener('click', async () => {
if (navigator.share) {
try {
await navigator.share({
url: share_link
})
} catch (error) {
// Handle specific errors, e.g., if user cancels the sharing
if (error.name === 'AbortError') {
} else {
// Handle other errors
alert('Something went wrong in sharing!');
}
}
}
else {
alert(`Your Browser Does't support built-in sharing feature. You Can Copy Link to share From here 👉🏻 ${share_link}`)
}
})
})
function slideRight (btn) {
let active = document.querySelector('.active');
let parent = document.querySelector('#social-icons')
if(document.querySelector('#leftBtn') === null) {
leftBtn = btn.cloneNode(false);
leftBtn.innerHTML = '‹';
leftBtn.id = 'leftBtn'
leftBtn.onclick = function () {
slideLeft(leftBtn)
};
parent.prepend(leftBtn);
}
if(active.nextElementSibling.classList.contains('group')) {
active.classList.remove('active');
active.nextElementSibling.classList.add('active');
active = document.querySelector('.active')
if(active.nextElementSibling.classList.contains('group') === false) {
btn.style.display = 'none'
}
}
}
function slideLeft(btn) {
let active = document.querySelector('.active');
let parent = document.querySelector('#social-icons')
document.querySelector('#rightBtn').style.display = 'inline';
if(active.previousElementSibling.classList.contains('group')) {
active.classList.remove('active');
active.previousElementSibling.classList.add('active');
active = document.querySelector('.active')
if(active.previousElementSibling.classList.contains('group') === false) {
parent.removeChild(btn)
}
}
}