isite 2022.3.2 → 2022.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/apps/client-side/app.js
CHANGED
|
@@ -191,4 +191,11 @@ module.exports = function (site) {
|
|
|
191
191
|
site.get({ name: '/api/file/:category/:name', public: true }, (req, res) => {
|
|
192
192
|
res.download(site.dir + '/../../uploads/' + req.params.category + '/files/' + req.params.name);
|
|
193
193
|
});
|
|
194
|
+
|
|
195
|
+
site.onPOST('/x-api/convert', (req, res) => {
|
|
196
|
+
res.json({
|
|
197
|
+
done: true,
|
|
198
|
+
value: Buffer.from(req.data.text, 'utf8').toString('hex'),
|
|
199
|
+
});
|
|
200
|
+
});
|
|
194
201
|
};
|
|
@@ -1103,12 +1103,46 @@
|
|
|
1103
1103
|
}
|
|
1104
1104
|
};
|
|
1105
1105
|
|
|
1106
|
+
site.hex = function (txt) {
|
|
1107
|
+
if (typeof txt == 'string') {
|
|
1108
|
+
const encoder = new TextEncoder();
|
|
1109
|
+
return Array.from(encoder.encode(txt))
|
|
1110
|
+
.map((b) => b.toString(16).padStart(2, '0'))
|
|
1111
|
+
.join('');
|
|
1112
|
+
} else if (typeof txt == 'number') {
|
|
1113
|
+
let value = txt.toString(16);
|
|
1114
|
+
if (value.length == 1) {
|
|
1115
|
+
value = '0' + value;
|
|
1116
|
+
}
|
|
1117
|
+
return value;
|
|
1118
|
+
}
|
|
1119
|
+
};
|
|
1120
|
+
site.zakat = function (obj) {
|
|
1121
|
+
let value = '';
|
|
1122
|
+
if (obj.name) {
|
|
1123
|
+
value += '01' + site.hex(obj.name.length) + site.hex(obj.name);
|
|
1124
|
+
}
|
|
1125
|
+
if (obj.vat_number) {
|
|
1126
|
+
value += '02' + site.hex(obj.vat_number.length) + site.hex(obj.vat_number);
|
|
1127
|
+
}
|
|
1128
|
+
if (obj.time) {
|
|
1129
|
+
value += '03' + site.hex(obj.time.length) + site.hex(obj.time);
|
|
1130
|
+
}
|
|
1131
|
+
if (obj.total) {
|
|
1132
|
+
value += '04' + site.hex(obj.total.length) + site.hex(obj.total);
|
|
1133
|
+
}
|
|
1134
|
+
if (obj.vat_total) {
|
|
1135
|
+
value += '05' + site.hex(obj.vat_total.length) + site.hex(obj.vat_total);
|
|
1136
|
+
}
|
|
1137
|
+
return site.toBase64(value);
|
|
1138
|
+
};
|
|
1139
|
+
|
|
1106
1140
|
site.barcode = function (options) {
|
|
1107
1141
|
if (!options || !options.selector || !options.text) {
|
|
1108
1142
|
console.error('qrcode need {selector , text}');
|
|
1109
1143
|
return;
|
|
1110
1144
|
}
|
|
1111
|
-
return JsBarcode(options.selector, options.selector
|
|
1145
|
+
return JsBarcode(options.selector, options.selector, options.options);
|
|
1112
1146
|
};
|
|
1113
1147
|
site.qrcode = function (options) {
|
|
1114
1148
|
if (!options || !options.selector || !options.text) {
|