summaryrefslogtreecommitdiffstats
path: root/script.js
diff options
context:
space:
mode:
authorGravatar biswakalyan890@gamil.com 2022-11-18 17:09:38 +0530
committerGravatar biswakalyan890@gamil.com 2022-11-18 17:09:38 +0530
commit55817a35387928d76d1b269bf1ed9b823f0c9838 (patch)
tree958c1d6a984e5e6c26a1051f352f0f20a8054b97 /script.js
downloadwriting-pad-master.tar.gz
writing-pad-master.tar.bz2
writing-pad-master.zip
Diffstat (limited to 'script.js')
-rw-r--r--script.js19
1 files changed, 19 insertions, 0 deletions
diff --git a/script.js b/script.js
new file mode 100644
index 0000000..dc32149
--- /dev/null
+++ b/script.js
@@ -0,0 +1,19 @@
+function copytext() {
+ var Text = document.getElementById("text");
+ Text.select();
+ navigator.clipboard.writeText(Text.value);
+}
+
+function download(filename, textInput) {
+ var element = document.createElement('a');
+ element.setAttribute('href', 'data:text/plain;charset=utf-8, ' + encodeURIComponent(textInput));
+ element.setAttribute('download', filename);
+ document.body.appendChild(element);
+ element.click();
+}
+
+document.getElementById("save").addEventListener("click", function() {
+ var text = document.getElementById("text").value;
+ var filename = "output.txt";
+ download(filename, text);
+}, false);