حفظ البيانات في ملف نصي او صفحة ويب مميز جدا
const downloadToFile = (content, filename, contentType) => {
const a = document.createElement('a');
const file = new Blob([content], {type: contentType});
a.href= URL.createObjectURL(file);
a.download = filename;
a.click();
URL.revokeObjectURL(a.href);
};
document.querySelector('#btnSave').addEventListener('click', () => {
const textArea = document.querySelector('textarea');
downloadToFile(textArea.value, 'my-new-file.txt', 'text/plain');
});
function gateFile() {
const fileE = document.getElementById("fileE").value;
var myBlob = new Blob([fileE], {type: "html/text/plain"});
var url = window.URL.createObjectURL(myBlob);
var anchor = document.createElement("a");
anchor.href = url;
anchor.download = "demo.html";
anchor.click();
window.URL.revokeObjectURL(url);
document.removeChild(anchor);
}
const texE=document.getElementById("codeThreeE");
let blob = new Blob([texE.value], {type: 'text/plain'});
link.href = URL.createObjectURL(blob);
link.download="save way3.text";
function fourway() {
const codeFourE = document.getElementById("codeFourE");
let link = document.createElement('a');
link.download = 'save way4.txt';
let blob = new Blob([codeFourE.value], {type: 'text/plain'});
link.href = URL.createObjectURL(blob);
link.click();
URL.revokeObjectURL(link.href);
}
function fiveway() {
const codeFiveE = document.getElementById("codeFiveE");
let link = document.createElement('a');
link.download = 'save way5.txt';
let blob = new Blob([codeFiveE.value], {type: 'text/plain'});
let reader = new FileReader();
reader.readAsDataURL(blob);
reader.onload = function() {
link.href = reader.result;
link.click();
};
};