Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Harshit2012 authored May 15, 2024
1 parent d1554f4 commit da82f33
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
function saveText() {
var textToSave = document.getElementById("python-code").value;
var blob = new Blob([textToSave], { type: "text/plain" });
var a = document.createElement("a");
a.download = "saved_code.py";
a.href = window.URL.createObjectURL(blob);
a.click();
}

function importText() {
var fileInput = document.createElement("input");
fileInput.type = "file";
fileInput.accept = ".py";
fileInput.addEventListener("change", function (event) {
var file = event.target.files[0];
var reader = new FileReader();
reader.onload = function (event) {
var importedText = event.target.result;
document.getElementById("python-code").value = importedText;
};
reader.readAsText(file);
});
fileInput.click();
}

0 comments on commit da82f33

Please sign in to comment.