Skip to content

Commit

Permalink
Fix formatting in printing sample (#1033)
Browse files Browse the repository at this point in the history
  • Loading branch information
oliverdunk authored Nov 21, 2023
1 parent 37b9846 commit 21beba4
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions api-samples/printing/printers.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
// found in the LICENSE file.

let listOfPrinters = [];
let filename;

function rollPrintingEnabled() {
return document.getElementById('rollPrinters').checked;
Expand Down Expand Up @@ -36,7 +37,7 @@ function onPrintButtonClicked(printerId, dpi, performTrim) {
// This only makese sense to specify if the printer supports the trim
// option.
if (performTrim) {
ticket.print.vendor_ticket_item = [{id: 'finishings', value: 'trim'}];
ticket.print.vendor_ticket_item = [{ id: 'finishings', value: 'trim' }];
}
} else {
filename = 'test.pdf';
Expand Down Expand Up @@ -100,7 +101,8 @@ function addCell(parent) {
function supportsRollPrinting(printerInfo) {
// If any of the media size options support continuous feed, return true.
return printerInfo.capabilities.printer.media_size.option.find(
(option) => option.is_continuous_feed);
(option) => option.is_continuous_feed
);
}

function createPrintersTable() {
Expand All @@ -116,8 +118,9 @@ function createPrintersTable() {
// The printer needs to support this specific vendor capability if the
// print job ticket is going to specify the trim option.
const supportsTrim =
printer.info.capabilities.printer.vendor_capability.some(
(capability) => capability.display_name == "finishings/11");
printer.info.capabilities.printer.vendor_capability.some(
(capability) => capability.display_name == 'finishings/11'
);
const columnValues = [
printer.data.id,
printer.data.name,
Expand All @@ -134,13 +137,13 @@ function createPrintersTable() {
let tr = document.createElement('tr');
const printTd = document.createElement('td');
printTd.appendChild(
createButton('Print', () => {
onPrintButtonClicked(
printer.data.id,
printer.info.capabilities.printer.dpi.option[0],
supportsTrim
);
})
createButton('Print', () => {
onPrintButtonClicked(
printer.data.id,
printer.info.capabilities.printer.dpi.option[0],
supportsTrim
);
})
);

tr.appendChild(printTd);
Expand Down Expand Up @@ -191,14 +194,14 @@ document.addEventListener('DOMContentLoaded', () => {
chrome.printing.getPrinters().then((printers) => {
printers.forEach((printer) => {
chrome.printing.getPrinterInfo(printer.id).then((printerInfo) => {
listOfPrinters.push({data: printer, info: printerInfo});
listOfPrinters.push({ data: printer, info: printerInfo });
createPrintersTable();
});
});
});

let checkbox = document.getElementById('rollPrinters')
checkbox.addEventListener('change', function() {
let checkbox = document.getElementById('rollPrinters');
checkbox.addEventListener('change', function () {
createPrintersTable();
});
});

0 comments on commit 21beba4

Please sign in to comment.