-4
I’m making a script in JS but I’m having a little difficulty.
I wanted to make my Loop() function be called again only when my Fatown() function has already been fully executed, today when I run Script the Loop() function is called before the Fatown() function is fully executed
Follow the code excerpt
(function loop() {
var rand = Math.round(Math.random() * (minutoMax - minutoMin)) + minutoMin;
console.log(new Date().toLocaleString());
setTimeout(function() {
FaTown();
loop();
}, rand);
}());
function FaTown() {
setTimeout(function() {
uw.FarmTown.openFarm();
setTimeout(function() {
try {
$('.checkbox.selcionar_tudo').click();
} catch (e) {
//
}
setTimeout(function() {
document.getElementById("pegar_button").click()
setTimeout(function() {
$('.btn_confirmar_sim').click();
setTimeout(function() {
var janelas = GPWindowMgr.getOpenedClosableWindows();
for (var i = 0; i < janelas.length; i++) {
if (janelas[i].type === 589) {
janelas[i].close();
break;
}
}
}, timeOpen)
}, time1)
}, time2)
}, time3)
}, time4)
}
I don’t understand anything. Explain better and in more detail what you have tried.
– Cmte Cardeal
I’m doing the question Edit
– Jeferson Martins