-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
82 lines (74 loc) · 3.04 KB
/
index.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
// listen for the DOMContentLoaded event, then call init()
window.addEventListener('DOMContentLoaded', init);
const menuButton = document.querySelector('.index-menu-button');
const menu = document.querySelector('.index-menu');
const dropdown = document.getElementById('Language');
/**
* clears local storage of FutureNowState item and creates a new states for future
*/
async function init() {
try {
// Clear global state
localStorage.removeItem('FutureNowState');
// Set clean new states
localStorage.setItem(
'FutureNowState',
JSON.stringify({
TarotState: {
selectedCards: [],
isSelectingCard: false,
},
EightBallState: {},
})
);
menuButton.addEventListener('click', () => {
menu.classList.toggle('index-menu-open');
});
window.addEventListener('click', (event) => {
if (
!menu.contains(event.target) &&
!menuButton.contains(event.target)
) {
menu.classList.remove('index-menu-open');
}
});
dropdown.addEventListener('change', (event) => {
const selectedValue = dropdown.value;
console.log(selectedValue);
localStorage.setItem('language', selectedValue);
if (selectedValue == 'Español') {
let linkElement = document.getElementById('History');
linkElement.textContent = 'Historia';
linkElement = document.getElementById('Help');
linkElement.textContent = 'Ayudame!';
linkElement = document.getElementById('8-ball');
linkElement.textContent = 'Bola 8';
linkElement = document.getElementById('title');
linkElement.textContent = 'Futuro Ahora!';
linkElement = document.getElementsByClassName(
'intro-tarot-start-button'
);
linkElement[0].textContent = 'Empezar!';
} else {
let linkElement = document.getElementById('History');
linkElement.textContent = 'Tarot History';
linkElement = document.getElementById('Help');
linkElement.textContent = 'Help!';
linkElement = document.getElementById('8-ball');
linkElement.textContent = '8-ball';
linkElement = document.getElementById('title');
linkElement.textContent = 'Future Now!';
linkElement = document.getElementsByClassName(
'intro-tarot-start-button'
);
linkElement[0].textContent = 'Get Started';
}
});
localStorage.setItem('language', 'English');
} catch (error) {
console.error('An error occurred while initializing:', error);
}
}
if (performance.getEntriesByType('navigation')[0].type === 'reload') {
menu.classList.remove('index-menu-open');
}