forked from GoogleChrome/chrome-extensions-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
print_jobs.js
36 lines (31 loc) · 1.27 KB
/
print_jobs.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
function showPrintJobTable() {
chrome.printingMetrics.getPrintJobs(function(printJobs) {
const tbody = document.createElement('tbody');
for (let i = 0; i < printJobs.length; ++i) {
const columnValues = [
printJobs[i].title, printJobs[i].status,
new Date(printJobs[i].completionTime), printJobs[i].numberOfPages,
printJobs[i].printer.name, printJobs[i].printer.uri,
printJobs[i].printer.source, printJobs[i].settings.color,
printJobs[i].settings.duplex, printJobs[i].settings.mediaSize.width,
printJobs[i].settings.mediaSize.height, printJobs[i].settings.copies
];
let tr = document.createElement('tr');
for (columnValue of columnValues) {
const td = document.createElement('td');
td.appendChild(document.createTextNode(columnValue));
td.setAttribute('align', 'center');
tr.appendChild(td);
}
tbody.appendChild(tr);
}
const table = document.getElementById('printJobsTable');
table.appendChild(tbody);
});
}
document.addEventListener('DOMContentLoaded', function() {
showPrintJobTable();
});