سامانه صدور فاکتور و حسابداری
Mirrored from https://github.com/davoodmehraban89/Factor-easy.git
Synced Dec 3, 17:00 UTC
refactor: share safe print-only text node digit normalization with purchase print
davoodmehraban89 committed
Oct 11, 2026 at 16:33 UTC
eff6463418f9b324c5836c43968b1b88bbb944bf
1 file changed
+8
-4
js/print.js
+8
-4
@@ -18,10 +18,9 @@ function getInvoicePrintSpec(inv){
18
return {paper:'A4',orientation:'landscape',widthMm:297,heightMm:210,marginMm:5};
19
}
20
// Print-only display normalization: stored serials, API identifiers and numeric values stay unchanged.
21
-function localizePrintHtmlDigits(html){
22
- const template=document.createElement('template');
23
- template.innerHTML=String(html??'');
24
- const walker=document.createTreeWalker(template.content,NodeFilter.SHOW_TEXT);
21
+function localizePrintTextNodes(root){
22
+ if(!root)return;
23
+ const walker=document.createTreeWalker(root,NodeFilter.SHOW_TEXT);
24
const latin='0123456789',arabic='٠١٢٣٤٥٦٧٨٩',persian='۰۱۲۳۴۵۶۷۸۹';
25
let node;
26
while((node=walker.nextNode())){
@@ -31,6 +30,11 @@ function localizePrintHtmlDigits(html){
30
return n<0?ch:persian[n];
31
});
32
}
33
+}
34
+function localizePrintHtmlDigits(html){
35
+ const template=document.createElement('template');
36
+ template.innerHTML=String(html??'');
37
+ localizePrintTextNodes(template.content);
38
return template.innerHTML;
39
}
40
function buildIsolatedPrintDocument(content,spec){