reorganize class name

This commit is contained in:
2026-10-06 14:05:52 +07:00
parent 8a758e5875
commit 17188f6134
13 changed files with 417 additions and 309 deletions
+85
View File
@@ -0,0 +1,85 @@
/*******************************************************************
Module : /assets/js/download.js
Desc. : Fungsi-fungsi download data & laporan
Created By : Siau Pheng ([email protected]).
Created Date : April 1st, 2011.
Last Modified : October 2nd, 2026.
(c) 3FONIA Software; WWW.3FONIA.COM.
*******************************************************************/
var Download = function(options) {
var _options = {
'url': '',
'filename': 'file.bin',
'title': '',
'text': 'share dari aplikasi'
};
var _params = [];
this.construct = function(options){
if (typeof options == 'object') {
$.extend(_options, options);
} else _options.url = options;
};
this.set_url = function (url){
_options.url = url;
};
this.add_param = function(par_id, par_val) {
var _getvalue = (par_val) ? par_id + '=' + encodeURIComponent(par_val) : par_id;
_params.push(_getvalue);
};
this._exec = async function(is_share) {
if (!_options.url) {
console.warn('cek url !');
return false;
}
try {
const blob = await $.ajax({
type: 'POST',
url: _options.url,
data: FoniaJS.RequestParam(_params),
xhrFields: {
responseType: 'blob'
},
success: async function (data, status, xhr) {
const disposition = xhr.getResponseHeader('Content-Disposition');
if (disposition && disposition.indexOf('attachment') !== -1) {
const filenameRegex = /filename[^;=\n]*=((['"]).*?\2|[^;\n]*)/;
const matches = filenameRegex.exec(disposition);
if (matches != null && matches[1]) {
_options.filename = matches[1].replace(/['"]/g, '');
}
}
}
});
const file = new File([blob], _options.filename, { type: blob.type });
if (is_share === true && navigator.canShare && navigator.canShare({ files: [file] })) {
await navigator.share({
files: [file],
title: _options.title ?? _options.filename,
text: _options.text
});
} else {
const link = document.createElement('a');
link.href = URL.createObjectURL(blob);
link.download = _options.filename;
link.click();
}
} catch (error) {
console.error('Download / sharing gagal :', error);
};
return this;
};
this.share = async function() {
await this._exec(true);
};
this.download = async function() {
await this._exec(false);
};
this.construct(options);
};
-63
View File
@@ -1,63 +0,0 @@
/*******************************************************************
Module : /assets/js/export.js
Desc. : Fungsi-fungsi export data & laporan
Created By : Siau Pheng ([email protected]).
Created Date : April 1st, 2011.
Last Modified : January 19th, 2026.
(c) 3FONIA Software; WWW.3FONIA.COM.
*******************************************************************/
var cEXPORT = function(url, options){
var _options = {
'url': '',
'filename': ''
};
var _params = [];
this.construct = function(url, options){
if (typeof url == 'object') {
$.extend(_options, url);
} else {
$.extend(_options, options);
_options.url = url;
}
};
this.set_url = function (url){
_options.url = url;
};
this.add_param = function (par_id, par_val){
var _getvalue = (par_val) ? par_id + "=" + escape(par_val) : par_id;
_params.push(_getvalue);
},
this.download = async function(){
if (!_options.url) {
console.warn('cek url !');
return false;
}
var _pro = (window.location.protocol=='https:') ? 'https://' : 'http://';
var _src = _pro+FoniaJS.WEB_HOST + _options.url + '?' + $.param(FoniaJS.RequestParam(_params));
try {
const response = await fetch(_src)
.then(response => {
const cDispo = response.headers.get('Content-Disposition');
if (cDispo && cDispo.indexOf('filename=') !== -1) {
_options.filename = cDispo.split('filename=')[1].split(';')[0].replace(/"/g, '');
}
return response;
})
const blob = await response.blob();
const link = document.createElement('a');
link.href = URL.createObjectURL(blob);
link.download = _options.filename;
link.click();
} catch (error) {
console.error('Download gagal:', error);
}
return this;
};
this.construct(url, options);
};
+6 -5
View File
@@ -10,15 +10,16 @@
*******************************************************************/
var cPDF = function(url, options){
var Pdf = function(options){
var vars = {
'url': '',
'zoom': 80,
'param': []
};
this.construct = function(url, options){
$.extend(vars, options);
vars.url = url;
this.construct = function(options){
if (typeof options == 'object') {
$.extend(vars, options);
} else vars.url = options;
};
this.set_url = function (url){
vars.url = url;
@@ -61,5 +62,5 @@ var cPDF = function(url, options){
$(this).remove();
}).modal('show');
};
this.construct(url, options);
this.construct(options);
};
+1 -1
View File
@@ -9,7 +9,7 @@
*******************************************************************/
var cPOLEDISPLAY = function(port, options){
var PoleDisplay = function(port, options){
var _cd_port = '';
var _cd_pole = '';
var _options = {
+12 -10
View File
@@ -10,15 +10,16 @@
*******************************************************************/
var cPRINTER = function(url, options){
var Printer = function(options){
var vars = {
'url': '',
'zoom': 90,
'param': []
};
this.construct = function(url, options){
$.extend(vars, options);
vars.url = url;
this.construct = function(options){
if (typeof options == 'object') {
$.extend(vars, options);
} else vars.url = options;
};
this.set_url = function (url){
vars.url = url;
@@ -87,10 +88,10 @@ var cPRINTER = function(url, options){
error: (typeof vars.onFailure === "function") ? vars.onFailure : null,
});
};
this.construct(url, options);
this.construct(options);
};
var cPRINTERPOS = function(url, options) {
var PrinterPos = function(options) {
var b_default = false;
var _options = {
'url': '',
@@ -103,9 +104,10 @@ var cPRINTERPOS = function(url, options) {
'chr_sbold': "\x1B\x21\x31",
'chr_uline': "\x1B\x21\x80"
};
this.construct = function(url, options) {
$.extend(_options, options);
_options.url = url;
this.construct = function(options) {
if (typeof options == 'object') {
$.extend(_options, options);
} else _options.url = options;
if (FoniaJS._def_printer) _options.printer = FoniaJS._def_printer;
};
this.detectPrinter = function() {
@@ -230,5 +232,5 @@ var cPRINTERPOS = function(url, options) {
}
return notaout;
};
this.construct(url, options);
this.construct(options);
};
-73
View File
@@ -1,73 +0,0 @@
/*******************************************************************
Module : /assets/js/share.js
Desc. : JS Class Share File Cross Browser
Created By : Siau Pheng ([email protected]).
Created Date : May 27th, 2007.
Last Modified : January 19th, 2026.
(c) 3FONIA Software; WWW.3FONIA.COM.
*******************************************************************/
var cSHARE = function(url, options) {
var _options = {
'url': '',
'filename': '',
'title': '',
'text': 'share dari aplikasi'
};
var _params = [];
this.construct = function(url, options){
if (typeof url == 'object') {
$.extend(_options, url);
} else {
$.extend(_options, options);
_options.url = url;
}
};
this.set_url = function (url){
_options.url = url;
};
this.add_param = function(par_id, par_val) {
var _getvalue = (par_val) ? par_id + '=' + escape(par_val) : par_id;
_params.push(_getvalue);
};
this.share = async function() {
if (!_options.url) {
console.warn('cek url !');
return false;
}
var _pro = (window.location.protocol=='https:') ? 'https://' : 'http://';
var _src = _pro+FoniaJS.WEB_HOST + _options.url + '?' + $.param(FoniaJS.RequestParam(_params));
try {
const response = await fetch(_src)
.then(response => {
const cDispo = response.headers.get('Content-Disposition');
if (cDispo && cDispo.indexOf('filename=') !== -1) {
_options.filename = cDispo.split('filename=')[1].split(';')[0].replace(/"/g, '');
}
return response;
});
const blob = await response.blob();
const file = new File([blob], _options.filename, { type: blob.type });
if (navigator.canShare && navigator.canShare({ files: [file] })) {
await navigator.share({
files: [file],
title: _options.title ?? _options.filename,
text: _options.text
});
} else {
const link = document.createElement('a');
link.href = URL.createObjectURL(blob);
link.download = _options.filename;
link.click();
}
} catch (error) {
console.error('Sharing gagal:', error);
}
};
this.construct(url, options);
};
+6 -5
View File
@@ -10,14 +10,15 @@
*******************************************************************/
var cSIMULATOR = function(url, options){
var Simulator = function(options){
var vars = {
'url': '',
'param': []
};
this.construct = function(url, options){
$.extend(vars, options);
vars.url = url;
this.construct = function(options){
if (typeof options == 'object') {
$.extend(vars, options);
} else vars.url = options;
};
this.set_url = function (url){
vars.url = url;
@@ -79,5 +80,5 @@ var cSIMULATOR = function(url, options){
dataType: 'json'
});
};
this.construct(url, options);
this.construct(options);
};