From 1d3cb680c4ec253165fb5cd183e8b4e920f635be Mon Sep 17 00:00:00 2001 From: Kaalleen <36401965+kaalleen@users.noreply.github.com> Date: Sat, 18 Dec 2021 08:44:37 +0100 Subject: PDF: Estimated thread (#1389) --- print/resources/inkstitch.js | 27 +++++++++++++++++++++++++++ print/templates/operator_overview.html | 5 +++-- print/templates/print_overview.html | 2 +- print/templates/ui.html | 22 ++++++++++++++++++++++ 4 files changed, 53 insertions(+), 3 deletions(-) (limited to 'print') diff --git a/print/resources/inkstitch.js b/print/resources/inkstitch.js index 8bdc4ec0..01908246 100644 --- a/print/resources/inkstitch.js +++ b/print/resources/inkstitch.js @@ -146,6 +146,16 @@ function writeEstimatedTime( selector, estimatedTime ) { $(selector).text( hours + ':' + minutes + ':' + seconds ); } +function setEstimatedThread() { + var multiplyThread = ($('#multiply-thread').val() == '') ? 2 : parseInt($('#multiply-thread').val()); + var estimatedThread = (parseFloat($('#estimated-thread').text()) * multiplyThread).toFixed(2); + var multiplyBobbin = ($('#multiply-bobbin').val() == '') ? 1 : parseInt($('#multiply-bobbin').val()); + var estimatedBobbin = (parseFloat($('#estimated-thread').text()) * multiplyBobbin).toFixed(2); + $('.total-estimated-thread').each(function(index, item) { + $(this).text(estimatedThread + "m / " + estimatedBobbin + "m"); + }) +} + // Scale SVG (fit || full size) function scaleSVG(element, scale = 'fit') { @@ -596,6 +606,20 @@ $(function() { $('.modal').hide(); }); + // Estimated thread and bobbin + $('#multiply-thread').on('input initialize', function() { + setEstimatedThread(); + }).on('change', function() { + var field_name = $(this).attr('data-field-name'); + $.postJSON('/settings/' + field_name, {value: $(this).val()}); + }); + $('#multiply-bobbin').on('input initialize', function() { + setEstimatedThread(); + }).on('change', function() { + var field_name = $(this).attr('data-field-name'); + $.postJSON('/settings/' + field_name, {value: $(this).val()}); + }); + // View selection checkboxes $(':checkbox.view').on('change initialize', function() { var field_name = $(this).attr('data-field-name'); @@ -684,6 +708,7 @@ $(function() { setTimeout(function() { setEstimatedTime(); + setEstimatedThread(); }, 100); $('button.svg-realistic').click(function(e){ @@ -729,6 +754,8 @@ $(function() { settings["time-opo"] = $("[data-field-name='time-opo']").val(); settings["time-opd"] = $("[data-field-name='time-opd']").val(); + settings["multiply-thread"] = $("[data-field-name='multiply-thread']").val(); + $.postJSON('/defaults', {'value': settings}); }); }); diff --git a/print/templates/operator_overview.html b/print/templates/operator_overview.html index a7f33a85..f61c2a6f 100644 --- a/print/templates/operator_overview.html +++ b/print/templates/operator_overview.html @@ -12,8 +12,9 @@
{{ _('Design box size') }}:{{ "%0.1fmm X %0.1fmm" | format(*job.dimensions) }}
-{{ _('Total stitch count') }}:{{job.num_stitches }}
-{{ _('Total thread used') }}:{{job.total_thread_used }}
+{{ _('Total stitch count') }}:{{ job.num_stitches }}
+{{ _('Total thread used') }}:
+{{ _('Design box size') }}:{{ "%0.1fmm X %0.1fmm" | format(*job.dimensions) }}
{{ _('Total stitch count') }}:{{job.num_stitches }}
-{{ _('Total thread used') }}:{{job.estimated_thread }}
+{{ _('Total thread used') }}:
-- cgit v1.2.3