summaryrefslogtreecommitdiff
path: root/gerbonara/cad/protoserve_data
diff options
context:
space:
mode:
authorjaseg <git@jaseg.de>2023-04-09 17:53:54 +0200
committerjaseg <git@jaseg.de>2023-04-09 17:53:54 +0200
commitf74bd30c0f9e4550a50fa68a9580a047fcc6d566 (patch)
treee6b9c0830b2d82acfb8bd530e11b9465e4f9dab3 /gerbonara/cad/protoserve_data
parentc9dff5450fa40f49727f5c447081d0df28484b1b (diff)
downloadgerbonara-f74bd30c0f9e4550a50fa68a9580a047fcc6d566.tar.gz
gerbonara-f74bd30c0f9e4550a50fa68a9580a047fcc6d566.tar.bz2
gerbonara-f74bd30c0f9e4550a50fa68a9580a047fcc6d566.zip
protoserve: Gerber download works
Diffstat (limited to 'gerbonara/cad/protoserve_data')
-rw-r--r--gerbonara/cad/protoserve_data/protoserve.html28
1 files changed, 26 insertions, 2 deletions
diff --git a/gerbonara/cad/protoserve_data/protoserve.html b/gerbonara/cad/protoserve_data/protoserve.html
index 4b116b2..7bc9a30 100644
--- a/gerbonara/cad/protoserve_data/protoserve.html
+++ b/gerbonara/cad/protoserve_data/protoserve.html
@@ -268,7 +268,7 @@ input {
<div id="links">
<a href="#controls">Settings</a>
<a href="#preview">Preview</a>
- <a href='/download'>
+ <a id="link-gerbers" href='#'>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" width="1em">
<title>Download</title>
<!--! Font Awesome Pro 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2023 Fonticons, Inc. --><path d="M288 32c0-17.7-14.3-32-32-32s-32 14.3-32 32V274.7l-73.4-73.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3l128 128c12.5 12.5 32.8 12.5 45.3 0l128-128c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L288 274.7V32zM64 352c-35.3 0-64 28.7-64 64v32c0 35.3 28.7 64 64 64H448c35.3 0 64-28.7 64-64V416c0-35.3-28.7-64-64-64H346.5l-45.3 45.3c-25 25-65.5 25-90.5 0L165.5 352H64zm368 56a24 24 0 1 1 0 48 24 24 0 1 1 0-48z"/>
@@ -863,7 +863,7 @@ input {
}
}
- previewBlobURL = null;
+ let previewBlobURL = null;
previewReloader = new RateLimiter(async () => {
const response = await fetch('preview.svg', {
method: 'POST',
@@ -892,6 +892,30 @@ input {
});
}
+ let downloadObjectURL = null;
+ document.querySelector('#link-gerbers').addEventListener('click', async () => {
+ const response = await fetch('gerbers.zip', {
+ method: 'POST',
+ mode: 'same-origin',
+ cache: 'no-cache',
+ headers: {'Content-Type': 'application/json'},
+ body: serialize(),
+ });
+ const data = await response.blob();
+ /* cf. https://gist.github.com/devloco/5f779216c988438777b76e7db113d05c */
+ const zipBlob = new Blob([data], { type: 'application/zip' });
+
+ if (downloadObjectURL) {
+ URL.revokeObjectURL(downloadObjectURL);
+ }
+
+ downloadObjectURL = URL.createObjectURL(zipBlob);
+ let link = document.createElement('a');
+ link.href = downloadObjectURL;
+ link.download = 'gerbers.zip';
+ link.click();
+ });
+
hookupPreviewUpdate(document.querySelector('.group.board'));
previewReloader.scheduleCall();
</script>