diff options
| author | Kaalleen <36401965+kaalleen@users.noreply.github.com> | 2021-12-18 08:44:37 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-12-18 08:44:37 +0100 |
| commit | 1d3cb680c4ec253165fb5cd183e8b4e920f635be (patch) | |
| tree | f17f5e55d4e510dc04f41d764065519bc69916ff /print/resources | |
| parent | ffeb265e5310e3c899c27f5364b070c09e50e5ff (diff) | |
PDF: Estimated thread (#1389)
Diffstat (limited to 'print/resources')
| -rw-r--r-- | print/resources/inkstitch.js | 27 |
1 files changed, 27 insertions, 0 deletions
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}); }); }); |
