Export in progress

This commit is contained in:
Claude Brisson
2023-12-27 11:39:50 +01:00
parent 515767355d
commit 519d73fefe
4 changed files with 29 additions and 26 deletions

View File

@@ -163,34 +163,16 @@ function close_modal() {
$(`.popup`).removeClass('shown');
}
function screenshot() {
const bodyContent = document.body.innerHTML;
// Create an SVG element
const svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
svg.setAttribute('width', window.innerWidth);
svg.setAttribute('height', window.innerHeight);
// Create a foreignObject element
const foreignObject = document.createElementNS('http://www.w3.org/2000/svg', 'foreignObject');
foreignObject.setAttribute('width', '100%');
foreignObject.setAttribute('height', '100%');
// Append the body content to foreignObject
foreignObject.innerHTML = bodyContent;
// Append foreignObject to the SVG
svg.appendChild(foreignObject);
// Create a data URL from the SVG
const dataUrl = 'data:image/svg+xml,' + encodeURIComponent(new XMLSerializer().serializeToString(svg));
// Open the screenshot in a new window/tab (optional)
const screenshotWindow = window.open();
screenshotWindow.document.write('<img src="' + dataUrl + '" alt="Screenshot">');
function downloadFile(blob, filename) {
let url = URL.createObjectURL(blob);
link.setAttribute("href", url);
link.setAttribute("download", filename);
link.style.visibility = 'hidden';
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}
onLoad(() => {
$('button.close').on('click', e => {
let modal = e.target.closest('.popup');