diff --git a/creuille.js b/creuille.js index 2819fdc..1bd403a 100644 --- a/creuille.js +++ b/creuille.js @@ -27,26 +27,26 @@ function sansAccents(mot) { // accentuées du français. // https://fr.wikipedia.org/wiki/Diacritiques_utilisés_en_français return mot - .toLowerCase() - .replace("à", "a") - .replace("â", "a") - .replace("ç", "c") - .replace("é", "e") - .replace("è", "e") - .replace("ê", "e") - .replace("ë", "e") - .replace("î", "i") - .replace("ï", "i") - .replace("ô", "o") - .replace("ù", "u") - .replace("ü", "u"); + .enMinuscules() + .remplacer("à", "a") + .remplacer("â", "a") + .remplacer("ç", "c") + .remplacer("é", "e") + .remplacer("è", "e") + .remplacer("ê", "e") + .remplacer("ë", "e") + .remplacer("î", "i") + .remplacer("ï", "i") + .remplacer("ô", "o") + .remplacer("ù", "u") + .remplacer("ü", "u"); } function htmlifier(mot, langue){ var res = '' + mot[langue] + ''; if (langue == "francais") { if ("genre" in mot){ - var genre = 'N' + mot["genre"].toUpperCase(); + var genre = 'N' + mot["genre"].enMajuscules(); res += ' ' + genre + ''; } if ("classe" in mot){ @@ -72,7 +72,7 @@ function construitListe(traductions) { traductions = traductions["vrais mots"].concat(traductions["faux mots"]); // tri par ordre alphabétique de la langue de départ - traductions.sort(function(traduction1, traduction2){ + traductions.tri(function(traduction1, traduction2){ var s1 = sansAccents(traduction1[langue]); var s2 = sansAccents(traduction2[langue]); if (s1 > s2) { @@ -88,18 +88,19 @@ function construitListe(traductions) { $( "#index" ).html(""); var l = ''; - for (var i=0; i < traductions.length; i++) { + for (var i=0; i < traductions.longueur(); i++) { var mot = traductions[i]; - var c = sansAccents(mot[langue]).charAt(0).toUpperCase(); + var c = sansAccents(mot[langue]).caractereA(0).enMajuscules(); + if (c != l) { l = c; - $( "#index" ).append( + $( "#index" ).ajouter( $("") .attr("href", "#" + l) .html(l) ); - $( "#mots" ).append( + $( "#mots" ).ajouter( $("
") .attr("class", "groupe-lettre") .append($("").attr("name", l)) @@ -108,9 +109,9 @@ function construitListe(traductions) { } $( "#mots" ) - .children() - .last() - .append( + .enfants() + .dernier() + .ajouter( $("") .attr("class", "definition") .html( diff --git a/fr.js b/fr.js new file mode 100644 index 0000000..6ddf219 --- /dev/null +++ b/fr.js @@ -0,0 +1,26 @@ +Objet = Object +Objet.creer = Objet.create + +Chaine = String +Chaine.prototype.enMinuscules = Chaine.prototype.toLowerCase +Chaine.prototype.enMajuscules = Chaine.prototype.toUpperCase +Chaine.prototype.remplacer = Chaine.prototype.replace +Chaine.prototype.caractereA = Chaine.prototype.charAt + +Tableau = Array +Tableau.prototype.tri = Tableau.prototype.sort +Tableau.prototype.longueur = function () { return this.length; } +Tableau.prototype.pousser = Tableau.prototype.push + +document.creerElement = document.createElement +document.recupererElementParNomDEtiquette = document.getElementsByTagName; +document.localisation = document.location; +document.localisation.protocole = document.localisation.protocole; + +jQuery.fn.extend({ + clic: function (x) { return this.click(x); }, + enfants: function () { return this.children(); }, + dernier: function () { return this.last(); }, + ajouter: function (x) { return this.append(x); } +}); +$.recupererJSON = $.getJSON diff --git a/index.html b/index.html index d48c232..718e6c6 100644 --- a/index.html +++ b/index.html @@ -7,12 +7,13 @@ - + + @@ -21,13 +22,13 @@