Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix formatting in printing sample #1033

Merged
merged 1 commit into from
Nov 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
});
});
Loading