Skip to content

Commit

Permalink
autopush
Browse files Browse the repository at this point in the history
  • Loading branch information
winnieoursbrun committed May 30, 2018
1 parent a3c3727 commit 53c384f
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 14 deletions.
6 changes: 2 additions & 4 deletions ctrl/don.ctrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class DonCtrl
mettreDansIndex(don)
{
// console.log(don);
// console.log("Index : "+don.indexHeure);
console.log("Index : "+don.indexHeure);
let index = don.indexHeure;
if(this.dons[index] == undefined)
{
Expand All @@ -51,7 +51,7 @@ class DonCtrl
}
this.donsId[don.id] = index;

// console.log("Ajout dans l'index du don #"+don.id);
console.log("Ajout dans l'index du don #"+don.id);
// console.log(this.dons);
}

Expand Down Expand Up @@ -79,9 +79,7 @@ class DonCtrl
delete this.donsId[id];

console.log("Retrait de l'index #"+id);
console.log(don);
console.log("------------------------");
console.log(this.dons);
}

addDon(don)
Expand Down
4 changes: 4 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@
<h1>Interface</h1>
</header>
<!-- <webview id="foo" src="https://www.helloasso.com/" style="display:inline-flex; width:640px; height:480px"></webview> -->
<a href="http://localhost:8080">HOME</a>
<a href="http://localhost:8080/compteur.html">COMPTEUR</a>
<a href="http://localhost:8080/timer.html#timer=1&format=hm">TIMER1</a>
<a href="http://localhost:8080/timer.html#timer=2&format=hm">TIMER2</a>
<script type="application/javascript" src="./index.js"></script>
</body>
</html>
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ document.body.appendChild(totalDonLigne);
function majDon(totalDon)
{
let totalDonLigne = document.getElementById('totalDonParagraphe');
if(!!totalDonLigne)
if(totalDonLigne)
{
totalDonLigne.innerHTML = "Total des dons actuels : " + totalDon.toLocaleString("fr-FR", { style: 'currency', currency: 'EUR' });
document.body.appendChild(totalDonLigne);
Expand Down
25 changes: 19 additions & 6 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,11 @@ function recupererTwitch() {
}
},
function (error, response, body) {
var data = JSON.parse(body)
if (body == null || body[0] != '{') {
console.log("body", body);
return ;
} else
var data = JSON.parse(body)
if (data.stream != null)
twitchDesertbus = data.stream.viewers
majTwitch()
Expand All @@ -244,7 +248,11 @@ function recupererTwitch() {
}
},
function (error, response, body) {
var data = JSON.parse(body)
if (body == null || body[0] != '{') {
console.log("body", body);
return ;
} else
var data = JSON.parse(body)
if (data.stream != null)
twitchJvtv = data.stream.viewers
majTwitch()
Expand Down Expand Up @@ -290,8 +298,13 @@ function recupererDonsHelloAsso() {
}
},
function (error, response, body) {
let data = JSON.parse(body);
traiterHelloAsso(data);
if (body == null || body[0] != '{') {
console.log("body", body);
return ;
} else {
var data = JSON.parse(body);
traiterHelloAsso(data);
}

for (let i = 2; i <= data.pagination.max_page; i++) {
request({
Expand All @@ -301,7 +314,7 @@ function recupererDonsHelloAsso() {
}
},
function (error, response, body) {
if (body[0] != '{') {
if (body == null || body[0] != '{') {
console.log("body", body);
i--
} else {
Expand Down Expand Up @@ -392,7 +405,7 @@ webserver.on('request', function (request) {
connexion.on("message", function (event) {
// console.log(event);
let data = JSON.parse(event.utf8Data);
// console.log(data);
console.log(data);
if (!!data.tag) {
let tag = data.tag;
console.log("Tag : " + tag);
Expand Down
8 changes: 5 additions & 3 deletions www/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ let etatCompteur = {bloque: false, vraieValeur: 0, valeurCourante: 0};
function majTwitch(infos)
{
let totalViewers = document.getElementById('totalViewers');
totalViewers.innerHTML = infos.desertbus + infos.jvtv;
if (infos.desertbus && infos.jvtv)
totalViewers.innerHTML = infos.desertbus + infos.jvtv;
}

function majDon(infos)
Expand Down Expand Up @@ -169,7 +170,7 @@ function listeDonMaj(liste)
let td;

td = document.createElement('td');
td.innerHTML = "#"+i;
td.innerHTML = "#"+item.id;
tr.appendChild(td);

td = document.createElement('td');
Expand All @@ -191,7 +192,7 @@ function listeDonMaj(liste)
td.innerHTML =
"<a onclick=\"listeDonInfos("+index+");\" style=\"cursor: pointer; text-decoration: underline\">Voir informations</a> - " +
"<a onclick=\"ajoutDonInitModif("+index+");\" style=\"cursor: pointer; text-decoration: underline\">Modifier</a> - " +
"<a onclick=\"supprimerDon("+index+");\" style=\"cursor: pointer; text-decoration: underline\">Supprimer</a>";
"<a onclick=\"supprimerDon("+item.id+");\" style=\"cursor: pointer; text-decoration: underline\">Supprimer</a>";
tr.appendChild(td);

table.appendChild(tr);
Expand Down Expand Up @@ -478,6 +479,7 @@ function listeDonInfos(index)
if(cle != 'cle')
text += cle+" : "+item.infos[cle]+"\n";
}
text += "id: " + item.id + "\n"
alert(text);
}

Expand Down

0 comments on commit 53c384f

Please sign in to comment.