JS calc with eval for YEARS v3

avec boucle for

by toubia95

HTML

<input type="text" name="letters" id="letters" value="mille neuf cent soixante douze" placeholder="Année en toutes lettres">
<button type="button" id="button">=></button>
<input type="text" name="numbers" id="numbers">

CSS

/*
Penser à 7bre 8bre 9bre Xbre,
deux-vingt, trois-vingt, cinq-vingt, six-vingt
septante, octante, nonante, voir http://monsu.desiderio.free.fr/curiosites/septante.html
ûttante, oitante, huitante, vinz, quinze-vingt, onze cent, dix-neuf cent, (1100->1900)



*/
/* voir http://stackoverflow.com/questions/5069464/replace-multiple-strings-at-once */
/* http://stackoverflow.com/questions/2064047/javascript-replace-globally-with-array */

/* voir http://www.regexr.com/  et http://www.w3schools.com/tags/att_input_pattern.asp */

/* voir http://stackoverflow.com/questions/13147289/jslint-eval-is-evil-alternatives */

/* voir http://www.miakinen.net/vrac/nombres */

 #letters {
    width: 200px;
}
#numbers {
    width: 50px;
}

JavaScript

$('#button').click(function () {
    $("#numbers").val(yearLetters($('#letters').val()));
});

// Version 3
var yearLetters = function (str) {
    var array = {
        "deux mil(le(s)?)?": "2000+",
        	"dix(-| )neuf cent(s)?": "1900+",
        	"dix(-| )huit cent(s)?": "1800+",
        	"dix(-| )sept cent(s)?": "1700+",
        	"seize cent(s)?": "1600+",
        	"quinze cent(s)?": "1500+",
        	"quatorze cent(s)?": "1400+",
        	"treize cent(s)?": "1300+",
        	"douze cent(s)?": "1200+",
        	"onze cent(s)?": "1100+",
            "mil(le(s)?)?": "1000+",
            "neuf cent(s)?": "900+",
            "huit cent(s)?": "800+",
            "sept cent(s)?": "700+",
            "six cent(s)?": "600+",
            "cinq cent(s)?": "500+",
            "quatre cent(s)?": "400+",
            "trois cent(s)?": "300+",
            "deux cent(s)?": "200+",
            "cent": "100+",
            "quatre(s)?(-| )vingt(s)?(-| )dix": "90+",
            "quatre(s)?(-| )vingt(s)?": "80+",
            "soixante(s)?(-| )dix": "70+",
            "soixante(s)?": "60+",
            "cinquante(s)?": "50+",
            "quarante(s)?": "40+",
            "trente(s)?": "30+",
            "vingt(s)?": "20+",
            "dix(-| )neuf": "19+",
            "dix(-| )huit": "18+",
            "dix(-| )sept": "17+",
            "seize": "16+",
            "quinze": "15+",
            "quatorze": "14+",
            "treize": "13+",
            "douze": "12+",
            "onze": "11+",
            "dix": "10+",
            "neuf": "9+",
            "huit": "8+",
            "sept": "7+",
            "six": "6+",
            "cinq": "5+",
            "quatre": "4+",
            "trois": "3+",
            "deux": "2+",
            "un": "1+",
            "\\+$": "",
            "[^-()\\d/*+.]": ""
    };
    for (var val in array) {
        str = str.replace(new RegExp(val, "gi"), array[val]);
    }
    var EVAL_IS_DANGEROUS__AVOID_THIS = eval; /* for jslint */
    str =...