function saveTextAsFile() {
var textToSave = document.getElementById("inputTextToSave").value;
var textToSaveAsBlob = new Blob([textToSave], { type: "text/plain" });
var textToSaveAsURL = window.URL.createObjectURL(textToSaveAsBlob);
var fileNameToSaveAs = document.getElementById("inputFileNameToSaveAs").value;
var downloadLink = document.createElement("a");
downloadLink.download = fileNameToSaveAs;
downloadLink.innerHTML = "Download File";
downloadLink.href = textToSaveAsURL;
downloadLink.onclick = countClicks;
// downloadLink.onclick = destroyClickedElement;
downloadLink.style.display = "none";
document.body.appendChild(downloadLink);
downloadLink.click();
}
function countClicks() {
if (localStorage.clickcount >= 5) {
localStorage.clickcount = 0; // reset count
localStorage.clickcount1++; // increase next count
}
if (typeof (Storage) !== "undefined") {
if (localStorage.clickcount) {
localStorage.clickcount = Number(localStorage.clickcount) + 1;
} else {
localStorage.clickcount = 1;
}
document.getElementById("result").innerHTML = "Number of Notes Saved:" + localStorage.clickcount ;
} else {
document.getElementById("result").innerHTML = "Sorry, your browser does not support web storage...";
}
}
I am successful in downloading the text file from the blob. But I want the notes to be saved on the website but could not find a correct solution to it. This is the code I have tried so far. I can just count the number of notes instead of getting the notes getting saved in the website itself. Please help.