-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.js
More file actions
67 lines (52 loc) · 1.73 KB
/
main.js
File metadata and controls
67 lines (52 loc) · 1.73 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
function copyProgram(programId, copiedId) {
const copyText = document.getElementById(programId).querySelector('code');
const copiedElement = document.getElementById(copiedId);
navigator.clipboard.writeText(copyText.textContent)
.then(() => {
copiedElement.textContent = "Copied!";
setTimeout(() => {
copiedElement.textContent = "";
}, 5000);
})
.catch(err => {
console.error('Failed to copy:', err);
alert('Copying failed. Please try again or copy manually.');
});
}
function copyProgramTextarea(program, button) {
console.log("copied");
var copyText = document.getElementById(program);
copyText.select();
navigator.clipboard.writeText(copyText.value);
var copiedElement = document.getElementById(button);
copiedElement.innerHTML = "Copied!";
setTimeout(function() {
if (copiedElement.innerHTML === "Copied!") {
copiedElement.innerHTML = "";
}
}, 5000);
}
function switchProgram(current_pgm) {
var containers = document.getElementsByClassName('textarea_container');
for (var i = 0; i < containers.length; i++) {
var container = containers[i];
container.style.display = "none";
document.getElementById(current_pgm).style.display="flex";
}
}
function closeProgram() {
var containers = document.getElementsByClassName('textarea_container');
for (var i = 0; i < containers.length; i++) {
var container = containers[i];
container.style.display = "none";
}
}
function openNav() {
var navWidth = document.getElementById('pgmList');
if (navWidth.style.width === "60vw") {
navWidth.style.width = "0";
} else {
navWidth.style.width = "60vw";
}
}
//window.location.href="https://examrestrict.netlify.app/";