Skip to content

Commit baadbaa

Browse files
committed
Simplify code
Signed-off-by: DL6ER <[email protected]>
1 parent f649453 commit baadbaa

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

app/static/js/main.js

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -201,11 +201,10 @@ function updateStyles(style = null) {
201201
});
202202
}
203203

204-
function gen_label(print = false, cut_once = false) {
204+
function gen_label(preview = true, cut_once = false) {
205205
// Check label against installed label in the printer
206206
updatePrinterStatus();
207207

208-
const preview = !print;
209208
if(preview)
210209
{
211210
// Update preview image based on label size
@@ -240,13 +239,13 @@ function gen_label(print = false, cut_once = false) {
240239

241240
// Process image upload
242241
if ($('input[name=printType]:checked').val() == 'image') {
243-
dropZoneMode = 'preview';
242+
dropZoneMode = preview ? 'preview' : 'print';
244243
imageDropZone.processQueue();
245244
return;
246245
}
247246

248247
// Send printing request
249-
const url = preview ? url_for_get_preview + '?return_format=base64' : url_for_print_label;
248+
const url = preview ? (url_for_get_preview + '?return_format=base64') : url_for_print_label;
250249
$.ajax({
251250
type: 'POST',
252251
url: url,
@@ -265,11 +264,11 @@ function gen_label(print = false, cut_once = false) {
265264
}
266265

267266
function print(cut_once = false) {
268-
gen_label(true, cut_once);
267+
gen_label(false, cut_once);
269268
}
270269

271270
function preview() {
272-
gen_label(false);
271+
gen_label(true);
273272
}
274273

275274
function setStatus(data, what = null) {

0 commit comments

Comments
 (0)