summaryrefslogtreecommitdiff
path: root/print/resources
diff options
context:
space:
mode:
authorLex Neva <lexelby@users.noreply.github.com>2024-04-24 22:38:32 -0400
committerGitHub <noreply@github.com>2024-04-24 22:38:32 -0400
commit3b16235821afafc4bb29a94059037fe138ed0907 (patch)
tree77c28adab1b0f05d9a6f54281e08022d897efe9d /print/resources
parent129dfa019bcb80713add7cc00d2d582181e7b1a8 (diff)
move print PDF back to web browser (#2849)
* move print PDF back to web browser * fix line wrapping for macOS --------- Co-authored-by: Kaalleen <reni@allenka.de>
Diffstat (limited to 'print/resources')
-rw-r--r--print/resources/inkstitch.js40
-rw-r--r--print/resources/style.css2
2 files changed, 32 insertions, 10 deletions
diff --git a/print/resources/inkstitch.js b/print/resources/inkstitch.js
index 382ced3b..540ed7f0 100644
--- a/print/resources/inkstitch.js
+++ b/print/resources/inkstitch.js
@@ -11,6 +11,12 @@ var realistic_rendering = {};
var realistic_cache = {};
var normal_rendering = {};
+function ping() {
+ $.get("/ping")
+ .done(function() { setTimeout(ping, 1000) })
+ .fail(function() { $('#errors').attr('class', 'show') });
+}
+
//function to chunk opd view into pieces
// source: https://stackoverflow.com/questions/3366529/wrap-every-3-divs-in-a-div
$.fn.chunk = function(size) {
@@ -203,6 +209,7 @@ function setSVGTransform(figure, transform) {
}
$(function() {
+ setTimeout(ping, 1000);
/* SCALING AND MOVING SVG */
/* Mousewheel scaling */
@@ -372,20 +379,35 @@ $(function() {
/* Settings Bar */
$('button.close').click(function() {
- window.close();
+ $.post('/shutdown', {})
+ .always(function(data) {
+ window.close();
+
+ /* Chrome and Firefox both have a rule: scripts can only close windows
+ * that they opened. Chrome seems to have an exception for windows that
+ * were opened by an outside program, so the above works fine. Firefox
+ * steadfastly refuses to allow us to close the window, so we'll tell
+ * the user (in their language) that they can close it.
+ */
+ setTimeout(function() {
+ document.open();
+ document.write("<html><body>" + data + "</body></html>");
+ document.close();
+ }, 1000);
+ });
});
$('button.print').click(function() {
- var pageSize = $('select#printing-size').find(':selected').text();
- window.inkstitchAPI.openpdf(pageSize)
+ // printing halts all javascript activity, so we need to tell the backend
+ // not to shut down until we're done.
+ $.get("/printing/start")
+ .done(function() {
+ window.print();
+ $.get("/printing/end");
+ });
});
- $('button.save-pdf').click(function() {
- var pageSize = $('select#printing-size').find(':selected').text();
- window.inkstitchAPI.savepdf(pageSize)
- });
-
- $('button.settings').click(function(){
+$('button.settings').click(function(){
$('#settings-ui').show();
});
diff --git a/print/resources/style.css b/print/resources/style.css
index db5ba603..a3200744 100644
--- a/print/resources/style.css
+++ b/print/resources/style.css
@@ -125,7 +125,7 @@ body {
color: white;
}
- .ui button.print, .ui button.save-pdf {
+ .ui button.print {
border: 1px solid rgb(50,132,50);
}