Nettoyage du javascript

- Renommage de creuille.js en principal.js (plus soutenu et surtout plus
  bitoduc)
- Utilisation de "'use strict';"
- Code de gogol analytique mis dans un fichier dédié
This commit is contained in:
Christophe-Marie Duquesne
2015-12-13 13:17:31 +01:00
parent ba6daefa35
commit a51a67a567
4 changed files with 36 additions and 24 deletions

8
fr.js
View File

@@ -1,13 +1,15 @@
Objet = Object 'use strict';
var Objet = Object
Objet.creer = Objet.create Objet.creer = Objet.create
Chaine = String var Chaine = String
Chaine.prototype.enMinuscules = Chaine.prototype.toLowerCase Chaine.prototype.enMinuscules = Chaine.prototype.toLowerCase
Chaine.prototype.enMajuscules = Chaine.prototype.toUpperCase Chaine.prototype.enMajuscules = Chaine.prototype.toUpperCase
Chaine.prototype.remplacer = Chaine.prototype.replace Chaine.prototype.remplacer = Chaine.prototype.replace
Chaine.prototype.caractereA = Chaine.prototype.charAt Chaine.prototype.caractereA = Chaine.prototype.charAt
Tableau = Array var Tableau = Array
Tableau.prototype.tri = Tableau.prototype.sort Tableau.prototype.tri = Tableau.prototype.sort
Tableau.prototype.longueur = function () { return this.length; } Tableau.prototype.longueur = function () { return this.length; }
Tableau.prototype.pousser = Tableau.prototype.push Tableau.prototype.pousser = Tableau.prototype.push

19
gogol-analytique.js Normal file
View File

@@ -0,0 +1,19 @@
'use strict';
$(function() {
var _gaq = _gaq || [];
_gaq.pousser(['_setAccount', 'UA-42609030-1']);
_gaq.pousser(['_trackPageview']);
(function() {
var ga = document.creerElement('script');
ga.type = 'text/javascript';
ga.async = true;
ga.src =
('https:' == document.localisation.protocole ?
'https://ssl' : 'http://www')
+ '.google-analytics.com/ga.js';
var s = document.recupererElementParNomDEtiquette('script')[0];
s.parentNode.insertBefore(ga, s);
})();
});

View File

@@ -8,29 +8,10 @@
<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="fr.js" charset="utf-8"></script> <script type="text/javascript" src="fr.js" charset="utf-8"></script>
<script type="text/javascript" src="creuille.js" charset="utf-8"></script> <script type="text/javascript" src="principal.js" charset="utf-8"></script>
<script> <script type="text/javascript" src="gogol-analytique.js"></script>
$( function() {
$.recupererJSON( "traductions.json", function( traductions ) {
construitListe(traductions);
$( "#lienChange" ).clic( function() {changeDeSens(traductions);} );
});
});
</script>
</head> </head>
<body> <body>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.pousser(['_setAccount', 'UA-42609030-1']);
_gaq.pousser(['_trackPageview']);
(function() {
var ga = document.creerElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.localisation.protocole ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.recupererElementParNomDEtiquette('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
<div id="tout"> <div id="tout">
<h1>Bitoduc.fr : termes informatiques en français</h1> <h1>Bitoduc.fr : termes informatiques en français</h1>

View File

@@ -1,3 +1,5 @@
'use strict';
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'};
@@ -123,3 +125,11 @@ function construitListe(traductions) {
); );
} }
} }
$(function() {
$.recupererJSON( "traductions.json", function( traductions ) {
construitListe(traductions);
$( "#lienChange" ).clic( function() {changeDeSens(traductions);} );
});
});