-
Notifications
You must be signed in to change notification settings - Fork 0
/
javascript.js
137 lines (123 loc) · 4.16 KB
/
javascript.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
var copyAlert;
var moveAlert;
var comingsoonAlert;
/*
var prevButton;
var nextButton;
*/
document.addEventListener("DOMContentLoaded", function() {
console.log("DOMContentLoaded event fired");
copyAlert = document.getElementById("copyalert");
console.log("copyAlert:", copyAlert);
moveAlert = document.getElementById("movealert");
console.log("moveAlert:", moveAlert);
comingsoonAlert = document.getElementById("comingsoonalert")
console.log("comingsoonAlert:", comingsoonAlert);
/*
prevButton = document.getElementById('prev');
console.log("prevButton:", prevButton);
nextButton = document.getElementById('next');
console.log("nextButton:", nextButton);
const games = document.querySelectorAll('.game');
let currentGameIndex = 0;
prevButton.addEventListener('click', () => {
if (currentGameIndex > 0) {
currentGameIndex--;
updateDisplayedGame();
}
});
nextButton.addEventListener('click', () => {
if (currentGameIndex < games.length - 1) {
currentGameIndex++;
updateDisplayedGame();
}
});
function updateDisplayedGame() {
games.forEach((game, index) => {
if (index === currentGameIndex) {
game.style.display = 'block';
} else {
game.style.display = 'none';
}
});
}
updateDisplayedGame();
*/
})
function copyBtn() { // For blog posts
// Select the entire blog post
const blogPost = document.querySelector('.post');
console.log("Getting blog post");
const range = document.createRange();
range.selectNode(blogPost);
window.getSelection().removeAllRanges();
window.getSelection().addRange(range);
console.log("copy");
// Copy the selected text to the clipboard
navigator.clipboard.writeText(window.getSelection().toString());
console.log("clipboard");
// Deselect the text
window.getSelection().removeAllRanges();
console.log("deselect");
// Show the copy alert
copyAlert.style.opacity = 1;
console.log("opacity 1");
copyAlert.style.visibility = "visible";
console.log("visible");
setTimeout(function() {
copyAlert.style.opacity = 0;
console.log("opacity 0");
copyAlert.style.transition = "opacity 1s ease-out";
console.log("transition");
setTimeout(function() {
copyAlert.style.visibility = "hidden";
console.log("gone....");
copyAlert.style.transition = "none";
}, 1000);
}, 5000);
console.log("we're done");
}
function moveBtns() { // For blog posts moving
moveAlert.style.opacity = 1;
console.log("opacity 1");
moveAlert.style.visibility = "visible";
console.log("visible");
setTimeout(function() {
moveAlert.style.opacity = 0;
console.log("opacity 0");
moveAlert.style.transition = "opacity 1s ease-out";
console.log("transition");
setTimeout(function() {
moveAlert.style.visibility = "hidden";
console.log("gone....");
moveAlert.style.transition = "none";
}, 1000);
}, 5000);
console.log("we're done");
}
function comingSoonAlertt() { // For coming soon games
comingsoonAlert.style.opacity = 1;
console.log("opacity 1");
comingsoonAlert.style.visibility = "visible";
console.log("visible");
setTimeout(function() {
comingsoonAlert.style.opacity = 0;
console.log("opacity 0");
comingsoonAlert.style.transition = "opacity 1s ease-out";
console.log("transition");
setTimeout(function() {
comingsoonAlert.style.visibility = "hidden";
console.log("gone....");
comingsoonAlert.style.transition = "none";
}, 1000);
}, 5000);
console.log("we're done");
}
function responsiveTopNav() { // For the Top Bar
var x = document.getElementById("NavTop");
if (x.className === "topnav") {
x.className += " responsive";
} else {
x.className = "topnav";
}
}