qz, auto-table control, auto-git pull, etc

This commit is contained in:
2026-02-12 16:18:43 +07:00
parent eb62ba5ee1
commit 71e587a8ca
10 changed files with 724 additions and 565 deletions
+31 -18
View File
@@ -4,7 +4,7 @@
Desc. : JS - Fonia Custom Class v3
Created By : Siau Pheng ([email protected]).
Created Date : June 19th, 2009.
Last Modified : January 26th, 2026.
Last Modified : February 10th, 2026.
(c) 2009 - 2026, 3FONIA Software; WWW.3FONIA.COM.
@@ -13,7 +13,7 @@
'use strict';
var FoniaJS = {
version: "3.1.1",
version: "3.1.2",
APP_ID: 0,
APP_SID: "",
WEB_HOST: "",
@@ -336,18 +336,14 @@ var FoniaJS = {
$('.option-tags').each((i, el) => {
const elm = $(el);
if (!jQuery.isFunction(jQuery.fn.select2)) return;
var _opts = {tags: false, dropdownAutoWidth: true, width: 'auto', theme: 'bootstrap-5'};
var _opts = {tags: false, dropdownAutoWidth: true, width: 'auto', theme: 'bootstrap-5', language: 'id'};
var _dmodal = elm.closest('div.modal');
if ($(_dmodal).hasClass('modal')) _opts.dropdownParent = _dmodal;
if (_dmodal.length) _opts.dropdownParent = _dmodal;
var _sel2 = elm.select2(_opts);
if (elm.prop('required')) elm.removeAttr('required');
//_sel2.on('select2:close', (e) =>{ $(e.target).valid(); });
});
$('[data-toggle="tooltip"]').tooltip();
/*$('.colorpic').each((i, el) => {
$(el).prop('background-color', $(el).val());
});*/
if('function' == typeof jQuery.fn.datepicker){
$('.pickdate').datepicker({
format: 'dd-mm-yyyy',
@@ -364,13 +360,21 @@ var FoniaJS = {
RequestParam: function(aparam) {
var tmp_hasil = [];
var tmp_array = aparam;
$('input').each((i, el) => {
/*if (el.id.indexOf('_db')!==-1){
/*$('input').each((i, el) => {
if (el.id.indexOf('_db')!==-1){
tmp_array.push(el.id);
}*/
if (el.id.indexOf('_cbox')!==-1){
tmp_array.push(el.id + '=' + el.value);
}
});*/
var tmp_cblist = {};
$('tbody input[id*="cbox"][type="checkbox"]:checked').map((i, b) => {
const arr = b.id.split('_');
if (!tmp_cblist[arr[0]]) tmp_cblist[arr[0]] = [];
tmp_cblist[arr[0]].push(arr[2]);
// for compatible only
tmp_array.push(b.id + '=' + b.value);
});
$.each(tmp_cblist, (i, b) => {
tmp_array.push('List_CB_' + i + '=' + b.join());
});
tmp_array.map(nilai => {
if (typeof nilai === "string") {
@@ -594,6 +598,11 @@ var FoniaJS = {
}
$(elm).nextAll('div.bootstrap-autocomplete').remove();
$(elm).off();
//fixed hidden on modal
var _dbody = $(elm).closest('div.modal-body');
var _dcont = $(elm).closest('div.modal-content');
if (_dbody.length) $(_dbody).css('overflow', 'visible');
if (_dcont.length) $(_dcont).css('overflow', 'visible');
new AutoComplete(elm, objComp);
},
getAppID: function() {
@@ -786,11 +795,15 @@ class _Request_JSONF extends _Request {
var json = {}, jsono = {'draw':0,'recordsTotal':0,'recordsFiltered':0,'data':[]};
try {
json = jQuery.parseJSON(data);
if (!jQuery.isEmptyObject(json) && json[0].draw){
jsono.draw = json[0].draw;
jsono.recordsTotal = json[0].recordsTotal;
jsono.recordsFiltered = json[0].recordsFiltered;
jsono.data = json[0].data;
if (!jQuery.isEmptyObject(json) && json.length > 0){
$(json).each((i, lini) => {
if (lini.type == 'table-live' && lini.id == ini.id) {
jsono.draw = lini.config.draw;
jsono.recordsTotal = lini.config.recordsTotal;
jsono.recordsFiltered = lini.config.recordsFiltered;
jsono.data = lini.data;
}
});
}
} catch (e){
console.log(e);
+27 -17
View File
@@ -4,16 +4,25 @@
Desc. : JS Setup QZ Connection
Created By : Siau Pheng (siaupheng@3fonia.com).
Created Date : May 27th, 2007.
Last Modified : January 9th, 2021.
Last Modified : February 8th, 2026.
(c) 2008 - 2021, 3FONIA Software; WWW.3FONIA.COM.
(c) 2008 - 2026, 3FONIA Software; WWW.3FONIA.COM.
*******************************************************************/
function startConnection() {
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 });
}
}
function startConnection(config) {
config = config ? config : {};
if (!qz.websocket.isActive()) {
_updateState('Waiting');
qz.websocket.connect().then(function() {
qz.websocket.connect(config).then(() => {
_updateState('Active');
_findDefaultPrinter();
});
@@ -24,7 +33,7 @@ function startConnection() {
function endConnection(){
if (qz.websocket.isActive()) {
qz.websocket.disconnect().then(function() {
qz.websocket.disconnect().then(() => {
_updateState('Inactive');
});
} else {
@@ -33,7 +42,7 @@ function endConnection(){
}
function _findDefaultPrinter(){
qz.printers.getDefault().then(function(data) {
qz.printers.getDefault().then((data) => {
var _printer = data;
if (typeof data === 'object' && data.name == undefined) {
if (data.file != undefined) _printer = "FILE: " + data.file;
@@ -44,35 +53,36 @@ function _findDefaultPrinter(){
}
FoniaJS._def_printer = data;
FoniaJS._def_printname = _printer;
$(_divStatus).html($(_divStatus).html() + ' // ' + _printer);
setTimeout(() => $(_divStatus).html($(_divStatus).html() + ' // ' + _printer), 2000);
});
}
function _updateState(text){
$(_divStatus).html(text);
$(_divStatus).html(text).removeClass('border-success border-warning text-success');
if (text == "Active") {
$(_divStatus).css("background-color", "#AAFFAA");
$(_divStatus).addClass('border-success text-success');
} else {
$(_divStatus).css("background-color", "#FFFFC0");
$(_divStatus).addClass('border-warning');
}
}
var _divStatus = '#divQZStatus';
const _divStatus = '#divQZStatus';
if (typeof qz !== 'undefined') {
qz.security.setCertificatePromise(function(resolve, reject) {
jQuery.ajax({ url:FoniaJS.WEB_PATH+'assets/signing/cert.pem', cache:false, dataType:'text' }).then(resolve, reject);
qz.security.setSignatureAlgorithm("SHA512");
qz.security.setCertificatePromise((resolve, reject) => {
jQuery.ajax({url:FoniaJS.WEB_PATH+'assets/signing/cert.pem', cache:false, dataType:'text'}).then(resolve, reject);
});
qz.security.setSignaturePromise(function(toSign) {
return function(resolve, reject) {
qz.security.setSignaturePromise((toSign) => {
return (resolve, reject) => {
jQuery.post(FoniaJS.WEB_PATH+"assets/signing/sign.php?req="+toSign).then(resolve, reject);
};
});
qz.websocket.setClosedCallbacks(function(evt) {
qz.websocket.setClosedCallbacks((evt) => {
_updateState('Inactive');
if (evt.reason) console.info("Connection closed: " + evt.reason);
});
qz.websocket.setErrorCallbacks(function(evt){
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";
+467 -352
View File
File diff suppressed because it is too large Load Diff
+26 -2
View File
File diff suppressed because one or more lines are too long