overhaul of displaying at '/'
This commit is contained in:
parent
ed9194ff9e
commit
4b3181f1b8
@ -199,6 +199,11 @@ app.get('/', async (_, res) => {
|
||||
</div>
|
||||
{<script dangerouslySetInnerHTML={{__html:`
|
||||
let intervalIds = [];
|
||||
fetch('http://localhost:3000/code')
|
||||
.then(function(response) {
|
||||
return response.json();
|
||||
})
|
||||
.then(function(data) {
|
||||
function runIntervals() {
|
||||
setInterval(function() {
|
||||
intervalIds.forEach(clearInterval);
|
||||
@ -208,37 +213,30 @@ app.get('/', async (_, res) => {
|
||||
let max = 5;
|
||||
let perso = Math.floor(Math.random() * (max - min + 1) + min);
|
||||
let imgElement = document.getElementById(perso);
|
||||
// let base = base[perso]
|
||||
// console.log(base)
|
||||
if (imgElement){
|
||||
intervalIds.push(setInterval(function() {
|
||||
fetch('http://localhost:3000/code')
|
||||
.then(function(response) {
|
||||
return response.json();
|
||||
})
|
||||
.then(function(data) {
|
||||
// let min = 1;
|
||||
// let max = 5;
|
||||
let anim = n++;
|
||||
|
||||
let gg = (data[perso][anim])
|
||||
if(gg === undefined){
|
||||
anim = 0
|
||||
}
|
||||
let imgElement = document.getElementById(perso);
|
||||
imgElement.src = (data[perso][n]);
|
||||
if(imgElement.src === undefined){
|
||||
imgElement.src = data[perso][0];
|
||||
imgElement.src = (data[perso][anim]);
|
||||
console.log(gg)
|
||||
|
||||
}, 5000));
|
||||
}
|
||||
setTimeout(function(){
|
||||
imgElement.src = data[perso][0];
|
||||
}, 4000);
|
||||
});
|
||||
}, 1000));
|
||||
}
|
||||
}, 5000);
|
||||
imgElement.src = (data[perso][0])
|
||||
}, 29000);
|
||||
}, 30000);
|
||||
}
|
||||
function stopIntervals() {
|
||||
intervalIds.forEach(clearInterval);
|
||||
intervalIds = [];
|
||||
}
|
||||
runIntervals();
|
||||
});
|
||||
`}}></script> }
|
||||
</div>
|
||||
</>
|
||||
|
30
test.js
30
test.js
@ -1,29 +1 @@
|
||||
let intervalIds = [];
|
||||
function runIntervals() {
|
||||
intervalIds.push(setInterval(function() {
|
||||
let min = 0;
|
||||
let max = 5;
|
||||
let perso = Math.floor(Math.random() * (max - min + 1) + min);
|
||||
let imgElement = document.getElementById(perso);
|
||||
if (imgElement){
|
||||
intervalIds.push(setInterval(function() {
|
||||
fetch('http://localhost:3000/code')
|
||||
then(function(response) {
|
||||
return response.json();
|
||||
})
|
||||
.then(function(data) {
|
||||
let perso = Math.floor(Math.random() * (max - min + 1) + min);
|
||||
let imgElement = document.getElementById(perso);
|
||||
imgElement.src = (data[1][0]);
|
||||
});
|
||||
}, 1000));
|
||||
}
|
||||
|
||||
}, 5000));
|
||||
}
|
||||
|
||||
function stopIntervals() {
|
||||
intervalIds.forEach(clearInterval);
|
||||
intervalIds = [];
|
||||
}
|
||||
runIntervals();
|
||||
setTimeout((imgElement.src = (data[perso][0])), 9000);
|
Loading…
x
Reference in New Issue
Block a user