diff --git a/index.html b/index.html
index fca3d80..62893bb 100644
--- a/index.html
+++ b/index.html
@@ -7,7 +7,7 @@
-
+
@@ -31,7 +31,7 @@
diff --git a/js/fr.js b/js/fr.js
deleted file mode 100644
index 576032a..0000000
--- a/js/fr.js
+++ /dev/null
@@ -1,28 +0,0 @@
-'use strict';
-
-var Objet = Object
-Objet.creer = Objet.create
-
-var 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
-
-var 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/js/principal.js b/js/principal.js
index a3287a4..afeb067 100644
--- a/js/principal.js
+++ b/js/principal.js
@@ -3,16 +3,16 @@
var reciproque = {'anglais': 'francais', 'francais': 'anglais'};
var embelli = {'francais': 'Français', 'anglais': 'Anglais'};
-function changeDeSens(traductions) {
+function inverser(traductions) {
var langue = $( "#mots" ).attr("data-langue");
$( "#mots" ).attr("data-langue", reciproque[langue]);
construitListe(traductions);
}
-function metAJourLienChange(langue) {
+function mettreAJourLienInversion(langue) {
var langueSource = langue;
var langueDestination = reciproque[langue];
- $( "#lienChange" )
+ $( "#lienInversion" )
.html(
''
+ embelli[langueSource]
@@ -24,26 +24,6 @@ function metAJourLienChange(langue) {
);
}
-function sansAccents(mot) {
- // Faute d'une bibliotheque unidecode, nous nous limitons aux lettres
- // accentuées du français.
- // https://fr.wikipedia.org/wiki/Diacritiques_utilisés_en_français
- return mot
- .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") {
@@ -70,13 +50,13 @@ function htmlifier(mot, langue){
function construitListe(traductions) {
var langue = $( "#mots" ).attr("data-langue");
- metAJourLienChange(langue);
+ mettreAJourLienInversion(langue);
traductions = traductions["vrais mots"].concat(traductions["faux mots"]);
- // tri par ordre alphabétique de la langue de départ
- traductions.tri(function(traduction1, traduction2){
- var s1 = sansAccents(traduction1[langue]);
- var s2 = sansAccents(traduction2[langue]);
+ // trier par ordre alphabétique de la langue de départ
+ traductions.trier(function(traduction1, traduction2){
+ var s1 = traduction1[langue].enMinuscules().sansAccents();
+ var s2 = traduction2[langue].enMinuscules().sansAccents();
if (s1 > s2) {
return 1;
}
@@ -92,7 +72,7 @@ function construitListe(traductions) {
var l = '';
for (var i=0; i < traductions.longueur(); i++) {
var mot = traductions[i];
- var c = sansAccents(mot[langue]).caractereA(0).enMajuscules();
+ var c = mot[langue].caractereA(0).enMajuscules().sansAccents();
if (c != l) {
@@ -129,7 +109,7 @@ function construitListe(traductions) {
$(function() {
$.recupererJSON( "traductions.json", function( traductions ) {
construitListe(traductions);
- $( "#lienChange" ).clic( function() {changeDeSens(traductions);} );
+ $( "#lienInversion" ).clic( function() {inverser(traductions);} );
});
});
diff --git a/js/prototypes-fr.js b/js/prototypes-fr.js
new file mode 100644
index 0000000..6ab5bd8
--- /dev/null
+++ b/js/prototypes-fr.js
@@ -0,0 +1,59 @@
+'use strict';
+
+var Objet = Object
+Objet.creer = Objet.create
+
+var 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
+Chaine.prototype.sansAccents = function () {
+ // Faute d'une bibliotheque unidecode, nous nous limitons aux lettres
+ // accentuées du français.
+ // https://fr.wikipedia.org/wiki/Diacritiques_utilisés_en_français
+ return this
+ .remplacer("à", "a")
+ .remplacer("â", "a")
+ .remplacer("ç", "c")
+ .remplacer("é", "e")
+ .remplacer("è", "e")
+ .remplacer("ê", "e")
+ .remplacer("ë", "e")
+ .remplacer("î", "i")
+ .remplacer("ï", "i")
+ .remplacer("ô", "o")
+ .remplacer("ù", "u")
+ .remplacer("ü", "u")
+ .remplacer("À", "A")
+ .remplacer("Â", "A")
+ .remplacer("Ç", "C")
+ .remplacer("É", "E")
+ .remplacer("È", "E")
+ .remplacer("Ê", "E")
+ .remplacer("Ë", "E")
+ .remplacer("Î", "I")
+ .remplacer("Ï", "I")
+ .remplacer("Ô", "O")
+ .remplacer("Ù", "U")
+ .remplacer("Ü", "U");
+}
+
+
+var Tableau = Array
+Tableau.prototype.trier = 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