|
|
@ -1,35 +1,86 @@
|
|
|
|
import { tempsExport } from "./scriptChrono.js";
|
|
|
|
import { tempsExport } from "./scriptChrono.js";
|
|
|
|
|
|
|
|
$(document).ready(async function() {
|
|
|
|
$(document).ready(function() {
|
|
|
|
var timerId, percent1, percent2;
|
|
|
|
var timerId, percent;
|
|
|
|
percent1 = 0;
|
|
|
|
percent = 0;
|
|
|
|
percent2 = 0;
|
|
|
|
var isPaused = false;
|
|
|
|
var isPaused = false;
|
|
|
|
|
|
|
|
await fetch('js/updateProgressBar.php?idplayer=1&playertime='+percent1);
|
|
|
|
|
|
|
|
await fetch('js/updateProgressBar.php?idplayer=54&playertime='+percent2);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// reset progress bars
|
|
|
|
|
|
|
|
percent1 = 0;
|
|
|
|
|
|
|
|
percent2 = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
initProgressBar('#load1', '#rocket1');
|
|
|
|
|
|
|
|
initProgressBar('#load2', '#rocket2');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function initProgressBar(loadId, rocketId){
|
|
|
|
|
|
|
|
$(loadId).css('width', '0px');
|
|
|
|
|
|
|
|
$(loadId).addClass('progress-bar-striped active');
|
|
|
|
|
|
|
|
$(rocketId).show();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function updateProgressBar(percent, loadId, rocketId) {
|
|
|
|
|
|
|
|
$(loadId).css('width', percent + '%');
|
|
|
|
|
|
|
|
$(loadId).html(percent + '%');
|
|
|
|
|
|
|
|
$(rocketId).css('left', 'calc('+percent+'% - 19px');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function resetProgressBar(loadId) {
|
|
|
|
|
|
|
|
$(loadId).css('width', '0px');
|
|
|
|
|
|
|
|
$(loadId).addClass('progress-bar-striped active');
|
|
|
|
|
|
|
|
$(loadId).removeClass('bg-danger');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function finishBar(loadId, rocketId, buttonId) {
|
|
|
|
|
|
|
|
$(loadId).addClass('bg-danger');
|
|
|
|
|
|
|
|
$(buttonId).attr('disabled', true);
|
|
|
|
|
|
|
|
$(loadId).html('Finish');
|
|
|
|
|
|
|
|
$(rocketId).hide();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
async function fetchDataAndUpdate() {
|
|
|
|
|
|
|
|
if (!isPaused) {
|
|
|
|
|
|
|
|
// increment progress bars
|
|
|
|
|
|
|
|
let response = (await fetch('js/progressBar.php'));
|
|
|
|
|
|
|
|
let result = await response.text();
|
|
|
|
|
|
|
|
let jsonData = JSON.parse(result);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let idplayer1 = jsonData[0].idplayer;
|
|
|
|
|
|
|
|
percent1 = parseInt(jsonData[0].playertime) + 2;
|
|
|
|
|
|
|
|
|
|
|
|
// reset progress bar
|
|
|
|
await fetch('js/updateProgressBar.php?idplayer='+idplayer1+'&playertime='+percent1);
|
|
|
|
percent = 0;
|
|
|
|
console.log('js/updateProgressBar.php?idplayer='+idplayer1+'&playertime='+percent1);
|
|
|
|
//$('#test').attr('disabled', true);
|
|
|
|
|
|
|
|
$('#load').css('width', '0px');
|
|
|
|
updateProgressBar(percent1, '#load1', '#rocket1');
|
|
|
|
$('#load').addClass('progress-bar-striped active');
|
|
|
|
|
|
|
|
$('#rocket').show();
|
|
|
|
// Increment second progress bar
|
|
|
|
|
|
|
|
response = (await fetch('js/progressBar.php'));
|
|
|
|
timerId = setInterval(function() {
|
|
|
|
result = await response.text();
|
|
|
|
if(!isPaused){
|
|
|
|
jsonData = JSON.parse(result);
|
|
|
|
// increment progress bar
|
|
|
|
|
|
|
|
percent += 1/12;
|
|
|
|
let idplayer2 = jsonData[1].idplayer;
|
|
|
|
$('#load').css('width', percent + '%');
|
|
|
|
percent2 = parseInt(jsonData[1].playertime) + 2;
|
|
|
|
$('#load').html(percent + '%');
|
|
|
|
|
|
|
|
$('#rocket').css('left','calc('+percent+'% - 19px');
|
|
|
|
await fetch('js/updateProgressBar.php?idplayer='+idplayer2+'&playertime='+percent2);
|
|
|
|
|
|
|
|
console.log('js/updateProgressBar.php?idplayer='+idplayer2+'&playertime='+percent2);
|
|
|
|
if(percent>= 100){
|
|
|
|
|
|
|
|
|
|
|
|
updateProgressBar(percent2, '#load2', '#rocket2');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (percent1 >= 100 && percent2 >= 100) {
|
|
|
|
clearInterval(timerId);
|
|
|
|
clearInterval(timerId);
|
|
|
|
$('#load').removeClass('progress-bar-striped active');
|
|
|
|
resetProgressBar('#load1');
|
|
|
|
$('#load').addClass('bg-danger');
|
|
|
|
finishBar('#load1', '#rocket1', '#repondbien1');
|
|
|
|
$('#repondbien').attr('disabled', true);
|
|
|
|
|
|
|
|
$('#load').html('Finish');
|
|
|
|
resetProgressBar('#load2');
|
|
|
|
$('#rocket').hide();
|
|
|
|
finishBar('#load2', '#rocket2', '#repondbien2');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, 250);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
timerId = setInterval(fetchDataAndUpdate, 2000);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function wait(ms){
|
|
|
|
function wait(ms){
|
|
|
|
var start = new Date().getTime();
|
|
|
|
var start = new Date().getTime();
|
|
|
@ -39,7 +90,51 @@ $(document).ready(function() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$('#repondbien').click(function() {
|
|
|
|
$('#repondbien1').click(async function() {
|
|
|
|
|
|
|
|
let response = (await fetch('js/progressBar.php'));
|
|
|
|
|
|
|
|
let result = await response.text();
|
|
|
|
|
|
|
|
let jsonData = JSON.parse(result);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let idplayer = jsonData[0].idplayer;
|
|
|
|
|
|
|
|
percent1 = parseInt(jsonData[0].playertime) + 20;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await fetch('js/updateProgressBar.php?idplayer='+idplayer+'&playertime='+percent1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$('#repondbien1').attr('disabled', false);
|
|
|
|
|
|
|
|
resetProgressBar('#load1');
|
|
|
|
|
|
|
|
updateProgressBar(percent1, '#load1', '#rocket1');
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$('#repondbien2').click(async function() {
|
|
|
|
|
|
|
|
let response = (await fetch('js/progressBar.php'));
|
|
|
|
|
|
|
|
let result = await response.text();
|
|
|
|
|
|
|
|
let jsonData = JSON.parse(result);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let idplayer = jsonData[1].idplayer;
|
|
|
|
|
|
|
|
percent2 = parseInt(jsonData[1].playertime) + 20;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
await fetch('js/updateProgressBar.php?idplayer='+idplayer+'&playertime='+percent2);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$('#repondbien2').attr('disabled', false);
|
|
|
|
|
|
|
|
resetProgressBar('#load2');
|
|
|
|
|
|
|
|
updateProgressBar(percent2, '#load2', '#rocket2');
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$('#repondmal').click(function() {
|
|
|
|
|
|
|
|
isPaused = true;
|
|
|
|
|
|
|
|
$('#repondmal').attr('disabled', false);
|
|
|
|
|
|
|
|
resetProgressBar('#load1');
|
|
|
|
|
|
|
|
resetProgressBar('#load2');
|
|
|
|
|
|
|
|
wait(3000);
|
|
|
|
|
|
|
|
console.log("test");
|
|
|
|
|
|
|
|
isPaused = false;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
if (tempsExport <= 6000) {
|
|
|
|
if (tempsExport <= 6000) {
|
|
|
|
percent += 12;
|
|
|
|
percent += 12;
|
|
|
|
} else if (tempsExport > 6000 && tempsExport <= 12000) {
|
|
|
|
} else if (tempsExport > 6000 && tempsExport <= 12000) {
|
|
|
@ -51,23 +146,4 @@ $(document).ready(function() {
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
percent += 8;
|
|
|
|
percent += 8;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$('#repondbien').attr('disabled', false);
|
|
|
|
*/
|
|
|
|
$('#load').css('width', '0px');
|
|
|
|
|
|
|
|
$('#load').addClass('progress-bar-striped active');
|
|
|
|
|
|
|
|
$('#load').removeClass('bg-danger');
|
|
|
|
|
|
|
|
$('#load').css('width', percent + '%');
|
|
|
|
|
|
|
|
$('#load').html(percent + '%');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$('#repondmal').click(function() {
|
|
|
|
|
|
|
|
isPaused = true;
|
|
|
|
|
|
|
|
$('#repondmal').attr('disabled', false);
|
|
|
|
|
|
|
|
//$('#load').css('width', percent+'px');
|
|
|
|
|
|
|
|
$('#load').addClass('progress-bar-striped active');
|
|
|
|
|
|
|
|
$('#load').removeClass('bg-danger');
|
|
|
|
|
|
|
|
wait(3000);
|
|
|
|
|
|
|
|
console.log("test");
|
|
|
|
|
|
|
|
isPaused = false;
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
})
|
|
|
|
|