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