qzconnect().then(function() {return qzprint(data);}).then(function() {qzsuccess();}).catch(qzfail);
function qzconnect() {
return new Promise(function(resolve, reject) {
if (qz.websocket.isActive()) { // if already active, resolve immediately
resolve();
} else {
// try; to connect once before firing the mimetype launcher
qz.websocket.connect().then(resolve, function retry() {
// if a connect was not successful, launch the mimetime, try 3 more times
window.location.assign("qz:launch");
qz.websocket.connect({ retries: 2, delay: 1 }).then(resolve, reject);
});
}
});
}
function qzprint(data) {
var printer = 'canon';
var top = 0.25, right = 0, bottom = 0, left = 0.25;
var config = qz.configs.create(printer, { margins: [ top, right, bottom, left] });
var printdata = [{
type: 'pixel',
format: 'html',
flavor: 'plain',
data: data
}];
return qz.print(config, printdata);
}
// notify successful print
function qzsuccess() {
//alert("Success");
}
// exception catch-all
function qzfail(e) {
alert(e);
}
As I said, it worked fine until just an hour ago.