554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
|
function suggLesLa (sWord) {
if (_oSpellChecker.getMorph(sWord).some(s => s.includes(":p"))) {
return "les|la";
}
return "la";
}
function formatNumber (s) {
let nLen = s.length;
if (nLen < 4 ) {
return s;
}
let sRes = "";
// nombre ordinaire
let nEnd = nLen;
while (nEnd > 0) {
let nStart = Math.max(nEnd-3, 0);
sRes = sRes ? s.slice(nStart, nEnd) + " " + sRes : sRes = s.slice(nStart, nEnd);
nEnd = nEnd - 3;
}
// binaire
if (/^[01]+$/.test(s)) {
nEnd = nLen;
let sBin = "";
while (nEnd > 0) {
let nStart = Math.max(nEnd-4, 0);
sBin = sBin ? s.slice(nStart, nEnd) + " " + sBin : sBin = s.slice(nStart, nEnd);
nEnd = nEnd - 4;
}
sRes += "|" + sBin;
}
// numéros de téléphone
if (nLen == 10) {
if (s.startsWith("0")) {
sRes += "|" + s.slice(0,2) + " " + s.slice(2,4) + " " + s.slice(4,6) + " " + s.slice(6,8) + " " + s.slice(8); // téléphone français
if (s[1] == "4" && (s[2]=="7" || s[2]=="8" || s[2]=="9")) {
sRes += "|" + s.slice(0,4) + " " + s.slice(4,6) + " " + s.slice(6,8) + " " + s.slice(8); // mobile belge
}
sRes += "|" + s.slice(0,3) + " " + s.slice(3,6) + " " + s.slice(6,8) + " " + s.slice(8); // téléphone suisse
}
sRes += "|" + s.slice(0,4) + " " + s.slice(4,7) + "-" + s.slice(7); // téléphone canadien ou américain
} else if (nLen == 9 && s.startsWith("0")) {
sRes += "|" + s.slice(0,3) + " " + s.slice(3,5) + " " + s.slice(5,7) + " " + s.slice(7,9); // fixe belge 1
sRes += "|" + s.slice(0,2) + " " + s.slice(2,5) + " " + s.slice(5,7) + " " + s.slice(7,9); // fixe belge 2
}
return sRes;
}
function formatNF (s) {
try {
let m = /NF[ -]?(C|E|P|Q|S|X|Z|EN(?:[ -]ISO|))[ -]?([0-9]+(?:[\/‑-][0-9]+|))/i.exec(s);
|
|
|
|
>
|
|
<
<
<
<
<
|
|
>
>
|
|
<
|
>
>
|
>
|
|
>
>
|
>
|
>
|
<
<
<
<
|
>
|
<
>
|
|
>
>
>
|
>
|
<
>
|
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
|
function suggLesLa (sWord) {
if (_oSpellChecker.getMorph(sWord).some(s => s.includes(":p"))) {
return "les|la";
}
return "la";
}
function formatNumber (sNumber) {
let nLen = sNumber.length;
if (nLen < 4 ) {
return sNumber;
}
let sRes = "";
if (!sNumber.includes(",")) {
// Nombre entier
sRes = _formatNumber(sNumber, 3);
// binaire
if (/^[01]+$/.test(sNumber)) {
sRes += "|" + _formatNumber(sNumber, 4);
}
// numéros de téléphone
if (nLen == 10) {
if (sNumber.startsWith("0")) {
sRes += "|" + _formatNumber(sNumber, 2); // téléphone français
if (sNumber[1] == "4" && (sNumber[2]=="7" || sNumber[2]=="8" || sNumber[2]=="9")) {
sRes += "|" + sNumber.slice(0,4) + " " + sNumber.slice(4,6) + " " + sNumber.slice(6,8) + " " + sNumber.slice(8); // mobile belge
}
sRes += "|" + sNumber.slice(0,3) + " " + sNumber.slice(3,6) + " " + sNumber.slice(6,8) + " " + sNumber.slice(8); // téléphone suisse
}
sRes += "|" + sNumber.slice(0,4) + " " + sNumber.slice(4,7) + "-" + sNumber.slice(7); // téléphone canadien ou américain
} else if (nLen == 9 && sNumber.startsWith("0")) {
sRes += "|" + sNumber.slice(0,3) + " " + sNumber.slice(3,5) + " " + sNumber.slice(5,7) + " " + sNumber.slice(7,9); // fixe belge 1
sRes += "|" + sNumber.slice(0,2) + " " + sNumber.slice(2,5) + " " + sNumber.slice(5,7) + " " + sNumber.slice(7,9); // fixe belge 2
}
} else {
// Nombre réel
let [sInt, sFloat] = sNumber.split(",", 2);
sRes = _formatNumber(sInt, 3) + "," + sFloat;
}
return sRes;
}
function _formatNumber (sNumber, nGroup=3) {
let sRes = "";
let nEnd = sNumber.length;
while (nEnd > 0) {
let nStart = Math.max(nEnd-nGroup, 0);
sRes = sRes ? sNumber.slice(nStart, nEnd) + " " + sRes : sRes = sNumber.slice(nStart, nEnd);
nEnd = nEnd - nGroup;
}
return sRes;
}
function formatNF (s) {
try {
let m = /NF[ -]?(C|E|P|Q|S|X|Z|EN(?:[ -]ISO|))[ -]?([0-9]+(?:[\/‑-][0-9]+|))/i.exec(s);
|