upgrade all with dice compatible

This commit is contained in:
2026-08-22 12:53:04 +07:00
parent 27ebdca49b
commit e7bb9a6c90
34 changed files with 546 additions and 486 deletions
+37 -35
View File
@@ -1,19 +1,43 @@
/*******************************************************************
Module : /js/qz/qz-start.js
Desc. : JS Setup QZ Connection
Module : /assets/js/qz/qz-start.js
Desc. : Setup QZ Connection
Created By : Siau Pheng ([email protected]).
Created Date : May 27th, 2007.
Last Modified : February 8th, 2026.
Last Modified : August 22nd, 2026.
(c) 2008 - 2026, 3FONIA Software; WWW.3FONIA.COM.
(c) 3FONIA Software; WWW.3FONIA.COM.
*******************************************************************/
function launchQZ() {
const _divStatus = '#divQZStatus';
if (typeof qz !== 'undefined') {
qz.security.setSignatureAlgorithm("SHA512");
qz.security.setCertificatePromise((resolve, reject) => {
jQuery.ajax({url:'qz/cert', cache:false, dataType:'text'}).then(resolve, reject);
});
qz.security.setSignaturePromise((toSign) => {
return (resolve, reject) => {
jQuery.ajax('qz/sign/'+toSign).then(resolve, reject);
};
});
qz.websocket.setClosedCallbacks((evt) => {
_updateState('Inactive');
if (evt.reason) console.info("Connection closed: " + evt.reason);
});
qz.websocket.setErrorCallbacks((evt) => {
_updateState('Error');
if (evt.target != undefined) {
var err = (evt.target.readyState >= 2) ? "Connection to QZ Tray was closed" : "A connection error occurred, check log for details";
console.info(err)
}
});
}
function launchQZ() {
if (!qz.websocket.isActive()) {
window.location.assign("qz:launch");
//Retry 5 times, pausing 1 second between each attempt
startConnection({ retries: 5, delay: 1 });
}
}
@@ -22,10 +46,10 @@ function startConnection(config) {
config = config ? config : {};
if (!qz.websocket.isActive()) {
_updateState('Waiting');
qz.websocket.connect(config).then(() => {
qz.websocket.connect({...config, host: 'localhost'}).then(() => {
_updateState('Active');
_findDefaultPrinter();
});
}).catch(() => _updateState('Error'));
} else {
console.info('An active connection with QZ already exists.');
}
@@ -35,7 +59,7 @@ function endConnection(){
if (qz.websocket.isActive()) {
qz.websocket.disconnect().then(() => {
_updateState('Inactive');
});
}).catch(() => _updateState('Error'));
} else {
console.info('No active connection with QZ exists.');
}
@@ -64,30 +88,8 @@ function _updateState(text){
} else {
$(_divStatus).addClass('border-warning');
}
}
const _divStatus = '#divQZStatus';
if (typeof qz !== 'undefined') {
qz.security.setSignatureAlgorithm("SHA512");
qz.security.setCertificatePromise((resolve, reject) => {
jQuery.ajax({url:'qz/cert', cache:false, dataType:'text'}).then(resolve, reject);
});
qz.security.setSignaturePromise((toSign) => {
return (resolve, reject) => {
jQuery.ajax('qz/sign/'+toSign).then(resolve, reject);
};
});
qz.websocket.setClosedCallbacks((evt) => {
_updateState('Inactive');
if (evt.reason) console.info("Connection closed: " + evt.reason);
});
qz.websocket.setErrorCallbacks((evt) => {
_updateState('Error');
if (evt.target != undefined) {
var err = (evt.target.readyState >= 2) ? "Connection to QZ Tray was closed" : "A connection error occurred, check log for details";
console.info(err)
}
});
startConnection();
$('li#qzL, li#qzS, li#qzZ').removeClass('d-none');
if (text !== "Error") {
$('li#qzL').addClass('d-none');
} else $('li#qzS, li#qzZ').addClass('d-none');
}