-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
39 lines (34 loc) · 1.14 KB
/
script.js
File metadata and controls
39 lines (34 loc) · 1.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
function rot13(str) {
return str.replace(/[A-Za-z]/g, function (char) {
let ascii = char.charCodeAt(0);
if (char >= 'A' && char <= 'Z') {
return String.fromCharCode(((ascii - 65 + 13) % 26) + 65);
}
if (char >= 'a' && char <= 'z') {
return String.fromCharCode(((ascii - 97 + 13) % 26) + 97);
}
return char; // Return unchanged if not a letter
});
}
function convertROT13() {
let inputText = document.getElementById('inputText').value;
let outputText = rot13(inputText);
document.getElementById('outputText').value = outputText;
}
function copyToClipboard() {
const outputText = document.getElementById('outputText');
outputText.select();
document.execCommand('copy');
alert('Text copied to clipboard');
}
// Function to open the modal
function openModal() {
const modal = document.getElementById('infoModal');
modal.style.display = 'block';
}
// Function to close the modal
function closeModal() {
const modal = document.getElementById('infoModal');
modal.style.display = 'none';
}
// Your existing ROT13 conversion functions (convertROT13, copyToClipboard, etc.)