-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
32 lines (27 loc) · 1.01 KB
/
script.js
File metadata and controls
32 lines (27 loc) · 1.01 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
// logic to generate the blob
function generateTextFile() {
var textInput = document.getElementById("textInput").value;
// Convert the text to Blob using UTF-8 encoding
var blob = new Blob([decodeURIComponent(encodeURIComponent(textInput))], { type: "text/plain;charset=utf-8" });
var url = URL.createObjectURL(blob);
window.open(url, "_blank");
}
// Function to oprn the popup
function openPopup() {
document.getElementById('popup').style.display = 'flex';
document.getElementById('wrapper').classList.add('blur');
}
// Function to close the popup
function closePopup() {
document.getElementById('popup').style.display = 'none';
document.getElementById('wrapper').classList.remove('blur');
}
// Function to check textarea before calling generateTextFile
function validateAndGenerate() {
const textarea = document.getElementById('textInput');
if (!textarea.value.trim()) {
alert('Please enter some text before submitting!');
return;
}
generateTextFile();
}