From 9ccf2f552be246f7912e9dc923f8da8ae47fe544 Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Wed, 10 Apr 2019 23:37:16 -0400 Subject: switch print pdf gui to electron --- print/resources/inkstitch.js | 24 +----------------------- 1 file changed, 1 insertion(+), 23 deletions(-) (limited to 'print/resources/inkstitch.js') diff --git a/print/resources/inkstitch.js b/print/resources/inkstitch.js index 86bc213e..c58aed8a 100644 --- a/print/resources/inkstitch.js +++ b/print/resources/inkstitch.js @@ -11,12 +11,6 @@ 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) { @@ -199,7 +193,6 @@ function setSVGTransform(figure, transform) { } $(function() { - setTimeout(ping, 1000); /* SCALING AND MOVING SVG */ /* Mousewheel scaling */ @@ -369,22 +362,7 @@ $(function() { /* Settings Bar */ $('button.close').click(function() { - $.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("" + data + ""); - document.close(); - }, 1000); - }); + window.close(); }); $('button.print').click(function() { -- cgit v1.2.3 From 9b2a47136b34a4b9cfcc42282a39fdd909e9f8af Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Fri, 12 Apr 2019 17:45:57 -0400 Subject: enable print button --- print/resources/inkstitch.js | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'print/resources/inkstitch.js') diff --git a/print/resources/inkstitch.js b/print/resources/inkstitch.js index c58aed8a..32a9a207 100644 --- a/print/resources/inkstitch.js +++ b/print/resources/inkstitch.js @@ -1,3 +1,5 @@ +var electron = require('electron'); + $.postJSON = function(url, data, success=null) { return $.ajax(url, { type: 'POST', @@ -366,13 +368,8 @@ $(function() { }); $('button.print').click(function() { - // 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"); - }); + var pageSize = $('select#printing-size').find(':selected').text(); + electron.ipcRenderer.send('print', pageSize) }); $('button.settings').click(function(){ -- cgit v1.2.3 From 1edd5c86355bb3bb02754fe729a2b51a3a8b1a60 Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Mon, 15 Apr 2019 19:56:44 -0400 Subject: remove last vestige of /printing/start --- print/resources/inkstitch.js | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) (limited to 'print/resources/inkstitch.js') diff --git a/print/resources/inkstitch.js b/print/resources/inkstitch.js index 32a9a207..7c972c7a 100644 --- a/print/resources/inkstitch.js +++ b/print/resources/inkstitch.js @@ -661,15 +661,11 @@ $(function() { // rendering slows down the browser enough that we can miss sending // pings, so tell the server side to wait for us - $.get("/printing/start") - .done(function() { - ctx.drawImage(image, 0, 0, image.width, image.height, 0, 0, canvas.width, canvas.height); - realistic_cache[item] = '' + - '' + - ''; - finalize(realistic_cache[item]); - $.get("/printing/end"); - }); + ctx.drawImage(image, 0, 0, image.width, image.height, 0, 0, canvas.width, canvas.height); + realistic_cache[item] = '' + + '' + + ''; + finalize(realistic_cache[item]); }; image.src = '/realistic/' + item; } else { -- cgit v1.2.3 From 09c46e0fb499987899a2e67819099eba2c121487 Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Thu, 18 Apr 2019 10:15:13 -0400 Subject: add 'save pdf' button and print opens PDF --- print/resources/inkstitch.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'print/resources/inkstitch.js') diff --git a/print/resources/inkstitch.js b/print/resources/inkstitch.js index 7c972c7a..57f62b1a 100644 --- a/print/resources/inkstitch.js +++ b/print/resources/inkstitch.js @@ -369,9 +369,14 @@ $(function() { $('button.print').click(function() { var pageSize = $('select#printing-size').find(':selected').text(); - electron.ipcRenderer.send('print', pageSize) + electron.ipcRenderer.send('open-pdf', pageSize) }); + $('button.save-pdf').click(function() { + var pageSize = $('select#printing-size').find(':selected').text(); + electron.ipcRenderer.send('save-pdf', pageSize) + }); + $('button.settings').click(function(){ $('#settings-ui').show(); }); -- cgit v1.2.3 From 953990739b742bdad5221c39b35d47fd530502bb Mon Sep 17 00:00:00 2001 From: Lex Neva Date: Tue, 23 Apr 2019 19:58:51 -0400 Subject: remove obselete comment --- print/resources/inkstitch.js | 3 --- 1 file changed, 3 deletions(-) (limited to 'print/resources/inkstitch.js') diff --git a/print/resources/inkstitch.js b/print/resources/inkstitch.js index 57f62b1a..a5d57e26 100644 --- a/print/resources/inkstitch.js +++ b/print/resources/inkstitch.js @@ -663,9 +663,6 @@ $(function() { canvas.height = image.height / 96 * 600; var ctx = canvas.getContext('2d'); - - // rendering slows down the browser enough that we can miss sending - // pings, so tell the server side to wait for us ctx.drawImage(image, 0, 0, image.width, image.height, 0, 0, canvas.width, canvas.height); realistic_cache[item] = '' + '' + -- cgit v1.2.3