Skip to content

Commit

Permalink
Update fonctionnelle
Browse files Browse the repository at this point in the history
  • Loading branch information
simonvdfr committed Jun 3, 2021
1 parent dfd2ff4 commit 3f6120a
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 20 deletions.
5 changes: 2 additions & 3 deletions Licence
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pour les sources GreenIT-Analysis
https://github.com/cnumr/GreenIT-Analysis/
Copyright (C) 2019 didierfred@gmail.com / GNU Affero General Public License AGPL v3
GNU Affero General Public License AGPL v3 / Copyright (C) 2019 didierfred@gmail.com


Pour l'algorithme EcoIndex
Expand All @@ -9,8 +9,7 @@ Licence Creative Commons CC-By-NC-ND


Pour le code additionnel pour donner les variables de calcul
MIT License
Copyright (c) 2021 Simon Vandaele - Translucide.net
MIT License / Copyright (c) 2021 Simon Vandaele - Translucide.net

L'autorisation est accordée, gracieusement, à toute personne acquérant une copie
de cette bibliothèque et des fichiers de documentation associés (la "Bibliothèque"),
Expand Down
34 changes: 19 additions & 15 deletions ecoindex.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// ECOINDEX
// http://www.ecoindex.fr/quest-ce-que-ecoindex/
// Lance la mesure de ecoindex quand la page est fini de charger


/*
* Pour plus d'informations sur ecoindex :
Expand Down Expand Up @@ -68,6 +66,9 @@ function computeWaterConsumptionfromEcoIndex(ecoIndex)
}



// Code additionnel pour donner les variables pour le calcul

// Donne le ecoindex
ecoindex = function(dom, resources)
{
Expand Down Expand Up @@ -104,7 +105,7 @@ ecoindex = function(dom, resources)
size = size + size_file;

//console.log(resource);
console.log(req+' : '+size_file+'Ko | '+resource.transferSize+' | '+resource.initiatorType+' | '+resource.name);
//console.log(req+' : '+size_file+'Ko | '+resource.transferSize+' | '+resource.initiatorType+' | '+resource.name);
});


Expand All @@ -114,21 +115,24 @@ ecoindex = function(dom, resources)
var ges = computeGreenhouseGasesEmissionfromEcoIndex(ecoIndex)
var eau = computeWaterConsumptionfromEcoIndex(ecoIndex)

// Log
console.log("ecoIndex: " + ecoIndex);
console.log("EcoIndexGrade: " + EcoIndexGrade);
console.log("ges: " + ges);
console.log("eau: " + eau);
console.log("dom: " + dom);
console.log("req: " + req);
console.log("size: " + size);


// Affichage dans la barre d'admin
var ecotitle = 'ecoIndex: '+ecoIndex+' | GES: '+ges+' gCO2e | eau: '+eau+' cl | Nombre de requêtes: '+req+' | Taille de la page: '+size+' Ko | Taille du DOM: '+dom;
var ecotitle = 'ecoIndex: '+ecoIndex.toFixed(2)+' | GES: '+ges+' gCO2e | eau: '+eau+' cl | Nombre de requêtes: '+req+' | Taille de la page: '+size+' Ko | Taille du DOM: '+dom;

// Style de la gélule d'affichage d'ecoindex
var style = document.createElement('style');
document.head.appendChild(style);
style.sheet.insertRule('#ecoindex { background: #ffffffcc; padding: 5px 8px; border-radius: 10px; position: absolute; z-index: 10; bottom: 10px;}');
style.sheet.insertRule('#ecoindex span { display: inline-block; width: 18px; height: 18px; font-size: 12px; line-height: 18px; margin: 0.1rem 0 0 0.5rem; text-align: center; border-radius: 50%; background-color: #f00; }');
style.sheet.insertRule('#ecoindex span.A { background-color: #349A47; color: #fff; }');
style.sheet.insertRule('#ecoindex span.B { background-color: #51B84B; color: #fff; }');
style.sheet.insertRule('#ecoindex span.C { background-color: #CADB2A; color: black; }');
style.sheet.insertRule('#ecoindex span.D { background-color: #F6EB15; color: black; }');
style.sheet.insertRule('#ecoindex span.E { background-color: #FECD06; color: black; }');
style.sheet.insertRule('#ecoindex span.F { background-color: #F99839; color: #fff; }');
style.sheet.insertRule('#ecoindex span.G { background-color: #ED2124; color: #fff; }');

// Ajout de la note dans la barre d'admin
//<a href="http://www.ecoindex.fr/quest-ce-que-ecoindex/" id="ecoindex" target="_blank" title="'+ecotitle+'">ecoIndex <span class="'+EcoIndexGrade+'">'+EcoIndexGrade+'</span></a>');
document.body.innerHTML = document.body.innerHTML + '<a href="http://www.ecoindex.fr/quest-ce-que-ecoindex/" id="ecoindex" target="_blank" title="'+ecotitle+'">ecoIndex<span class="'+EcoIndexGrade+'">'+EcoIndexGrade+'</span></a>';

}

Expand Down
1 change: 1 addition & 0 deletions ecoindex.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ Pour informer l'utilisateur de l'impact de la page en cours.
## Licences

Les fonctions de calcul viennent de [GreenIT-Analysis](https://github.com/cnumr/GreenIT-Analysis/).
`Copyright (C) 2019 didierfred@gmail.com / GNU Affero General Public License AGPL v3`
`GNU Affero General Public License AGPL v3 / Copyright (C) 2019 didierfred@gmail.com`

L'algorithme [EcoIndex](http://www.ecoindex.fr/quest-ce-que-ecoindex/) est sous [Licence Creative Commons CC-By-NC-ND](https://creativecommons.org/licenses/by-nc-nd/2.0/fr/)

Le code additionnel pour donner les variables pour le calcul est sous licence MIT par Simon Vandaele [Translucide](http://www.translucide.net)
Le code additionnel pour donner les variables pour le calcul est sous `licence MIT` par Simon Vandaele [Translucide](http://www.translucide.net)

0 comments on commit 3f6120a

Please sign in to comment.