FreePad/static/js/pad.js

27 lines
686 B
JavaScript
Raw Normal View History

class Pad {
title = '';
content = '';
timestmap = '';
constructor(t, ts) {
this.title = t;
this.content = document.getElementById(`pad-content`).value;
this.timestmap = ts;
}
downloadPadContents() {
// Create a new blob of the contents of the pad
var blob = new Blob([ document.getElementById(`pad-content`).value ], { type: "text/plain;charset=utf-8" });
2022-06-01 17:00:23 +03:00
let downloadFileName = this.title;
if ( !this.title.includes(`.`) ) {
// Append a default file format
downloadFileName += `.txt`;
}
// Save the blob as
2022-06-01 17:00:23 +03:00
saveAs(blob, `${downloadFileName}`);
}
}