mirror of
https://github.com/soulaklabs/bitoduc.fr.git
synced 2025-12-08 17:13:23 +00:00
Meilleure francisation du code
Ajout de sansAccents dans les prototypes de Chaine Renommage des fonctions à l'infinitif
This commit is contained in:
@@ -7,7 +7,7 @@
|
|||||||
<link rel="stylesheet" type="text/css" href="bitoduc.css" />
|
<link rel="stylesheet" type="text/css" href="bitoduc.css" />
|
||||||
|
|
||||||
<script type="text/javascript" src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
|
<script type="text/javascript" src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
|
||||||
<script type="text/javascript" src="js/fr.js" charset="utf-8"></script>
|
<script type="text/javascript" src="js/prototypes-fr.js" charset="utf-8"></script>
|
||||||
<script type="text/javascript" src="js/principal.js" charset="utf-8"></script>
|
<script type="text/javascript" src="js/principal.js" charset="utf-8"></script>
|
||||||
<script type="text/javascript" src="js/gogol-analytique.js"></script>
|
<script type="text/javascript" src="js/gogol-analytique.js"></script>
|
||||||
</head>
|
</head>
|
||||||
@@ -31,7 +31,7 @@
|
|||||||
|
|
||||||
<br/><br/>
|
<br/><br/>
|
||||||
<div>
|
<div>
|
||||||
<a id="lienChange" href="#" ></a>
|
<a id="lienInversion" href="#" ></a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
28
js/fr.js
28
js/fr.js
@@ -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
|
|
||||||
@@ -3,16 +3,16 @@
|
|||||||
var reciproque = {'anglais': 'francais', 'francais': 'anglais'};
|
var reciproque = {'anglais': 'francais', 'francais': 'anglais'};
|
||||||
var embelli = {'francais': 'Français', 'anglais': 'Anglais'};
|
var embelli = {'francais': 'Français', 'anglais': 'Anglais'};
|
||||||
|
|
||||||
function changeDeSens(traductions) {
|
function inverser(traductions) {
|
||||||
var langue = $( "#mots" ).attr("data-langue");
|
var langue = $( "#mots" ).attr("data-langue");
|
||||||
$( "#mots" ).attr("data-langue", reciproque[langue]);
|
$( "#mots" ).attr("data-langue", reciproque[langue]);
|
||||||
construitListe(traductions);
|
construitListe(traductions);
|
||||||
}
|
}
|
||||||
|
|
||||||
function metAJourLienChange(langue) {
|
function mettreAJourLienInversion(langue) {
|
||||||
var langueSource = langue;
|
var langueSource = langue;
|
||||||
var langueDestination = reciproque[langue];
|
var langueDestination = reciproque[langue];
|
||||||
$( "#lienChange" )
|
$( "#lienInversion" )
|
||||||
.html(
|
.html(
|
||||||
'<span class="mot-' + langueSource + '">'
|
'<span class="mot-' + langueSource + '">'
|
||||||
+ embelli[langueSource]
|
+ 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){
|
function htmlifier(mot, langue){
|
||||||
var res = '<span class="mot-' + langue + '">' + mot[langue] + '</span>';
|
var res = '<span class="mot-' + langue + '">' + mot[langue] + '</span>';
|
||||||
if (langue == "francais") {
|
if (langue == "francais") {
|
||||||
@@ -70,13 +50,13 @@ function htmlifier(mot, langue){
|
|||||||
function construitListe(traductions) {
|
function construitListe(traductions) {
|
||||||
var langue = $( "#mots" ).attr("data-langue");
|
var langue = $( "#mots" ).attr("data-langue");
|
||||||
|
|
||||||
metAJourLienChange(langue);
|
mettreAJourLienInversion(langue);
|
||||||
|
|
||||||
traductions = traductions["vrais mots"].concat(traductions["faux mots"]);
|
traductions = traductions["vrais mots"].concat(traductions["faux mots"]);
|
||||||
// tri par ordre alphabétique de la langue de départ
|
// trier par ordre alphabétique de la langue de départ
|
||||||
traductions.tri(function(traduction1, traduction2){
|
traductions.trier(function(traduction1, traduction2){
|
||||||
var s1 = sansAccents(traduction1[langue]);
|
var s1 = traduction1[langue].enMinuscules().sansAccents();
|
||||||
var s2 = sansAccents(traduction2[langue]);
|
var s2 = traduction2[langue].enMinuscules().sansAccents();
|
||||||
if (s1 > s2) {
|
if (s1 > s2) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@@ -92,7 +72,7 @@ function construitListe(traductions) {
|
|||||||
var l = '';
|
var l = '';
|
||||||
for (var i=0; i < traductions.longueur(); i++) {
|
for (var i=0; i < traductions.longueur(); i++) {
|
||||||
var mot = traductions[i];
|
var mot = traductions[i];
|
||||||
var c = sansAccents(mot[langue]).caractereA(0).enMajuscules();
|
var c = mot[langue].caractereA(0).enMajuscules().sansAccents();
|
||||||
|
|
||||||
|
|
||||||
if (c != l) {
|
if (c != l) {
|
||||||
@@ -129,7 +109,7 @@ function construitListe(traductions) {
|
|||||||
$(function() {
|
$(function() {
|
||||||
$.recupererJSON( "traductions.json", function( traductions ) {
|
$.recupererJSON( "traductions.json", function( traductions ) {
|
||||||
construitListe(traductions);
|
construitListe(traductions);
|
||||||
$( "#lienChange" ).clic( function() {changeDeSens(traductions);} );
|
$( "#lienInversion" ).clic( function() {inverser(traductions);} );
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
59
js/prototypes-fr.js
vendored
Normal file
59
js/prototypes-fr.js
vendored
Normal file
@@ -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
|
||||||
Reference in New Issue
Block a user