Repository navigation
Expand file tree
/
Copy pathscript.js
More file actions
157 lines (131 loc) · 4.14 KB
/
Copy pathscript.js
File metadata and controls
157 lines (131 loc) · 4.14 KB
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
async function copyTextToClipboard(text) {
try {
await navigator.clipboard.writeText(text);
return true;
} catch (err) {
console.error('Failed to copy: ', err);
}
return false;
}
async function copyInstallCommand() {
const commandInput = document.querySelector('.install-command input');
const commandText = commandInput.value;
if (!await copyTextToClipboard(commandText)) {
alert('Failed to copy the command. Please copy it manually.');
return;
}
const copyButton = document.getElementById('copy-install-command');
copyButton.textContent = 'Copied!';
setTimeout(() => {
copyButton.textContent = 'Copy';
}, 2000);
}
function createRainDrop(imageUrl) {
const rainContainer = document.getElementById('rain');
const drop = document.createElement('img');
drop.src = imageUrl;
drop.className = 'rain-drop';
drop.style.position = 'absolute';
drop.style.left = `${Math.random() * window.innerWidth}px`;
drop.style.top = `-${Math.random() * 100}px`;
drop.style.width = '30px';
drop.style.height = '30px';
drop.style.opacity = Math.random();
rainContainer.appendChild(drop);
const fallDuration = Math.random() * 3 + 2;
drop.animate(
[
{ transform: `translateY(0)` },
{ transform: `translateY(${window.innerHeight + 50}px)` }
],
{
duration: fallDuration * 1000,
iterations: Infinity,
easing: 'linear'
}
);
setTimeout(() => {
rainContainer.removeChild(drop);
}, fallDuration * 1000);
}
function startRain(imageUrl) {
const interval = setInterval(() => {
createRainDrop(imageUrl);
}, 200);
setTimeout(() => {
clearInterval(interval);
}, 5000);
}
function mixedRain() {
const images = [
'/assets/brunch1.png',
'/assets/brunch2.png',
'/assets/brunch3.png',
'/assets/brunch4.png'
];
for (const image of images) {
startRain(image);
}
}
function restartVideo() {
const video = document.getElementById('demo-video');
video.currentTime = 0;
}
function toggleVideoPlayPause() {
const video = document.getElementById('demo-video');
const playPauseButton = document.getElementById('demo-playstate-button');
const pauseWarning = document.getElementById('demo-pause-warning');
if (video.paused) {
video.play();
playPauseButton.textContent = 'Halt';
pauseWarning.style.display = 'none';
} else {
video.pause();
playPauseButton.textContent = 'Play';
pauseWarning.style.display = 'block';
}
}
function toggleVideoMute() {
const video = document.getElementById('demo-video');
const muteButton = document.getElementById('demo-mute-button');
video.muted = !video.muted;
muteButton.textContent = video.muted ? 'Sounds' : 'Silent';
}
function toggleVideoFullscreen() {
const video = document.getElementById('demo-video');
if (video.requestFullscreen) {
video.requestFullscreen();
} else if (video.mozRequestFullScreen) { // Firefox
video.mozRequestFullScreen();
} else if (video.webkitRequestFullscreen) { // Chrome, Safari and Opera
video.webkitRequestFullscreen();
} else if (video.msRequestFullscreen) { // IE/Edge
video.msRequestFullscreen();
}
}
async function loadProviders() {
const providersContainer = document.getElementById('providers-list');
const providersResponse = await fetch('/bashbrunch/meta/providers.txt');
if (!providersResponse.ok)
return;
const providers = await providersResponse.text();
const providerList = providers.split('\n').filter(Boolean);
const cards = [];
for (const provider of providerList) {
const card = document.createElement('div');
const title = document.createElement('h3');
card.className = 'card';
title.textContent = provider;
card.appendChild(title);
cards.push(card);
}
providersContainer.replaceChildren(...cards);
}
function showCommandPreview(button) {
const layout = button.parentElement.parentElement;
const content = button.querySelector('.command-card-content');
const commandPreview = layout.querySelector('.commands-preview');
const clonedContent = content.cloneNode(true);
clonedContent.className = 'command-card-content-preview';
commandPreview.innerHTML = clonedContent.outerHTML;
}