Files
rpgzrox/rpg/js/roll.js

42 lines
765 B
JavaScript

let update;
function msg_(status, msg) {
tata.text(status, msg, {
position: "bl",
duration: 3000,
progress: true,
closeBtn: false,
animate: "slide",
});
}
function rollLoad() {
$.ajax({
url: `${window.api}roll`,
type: "GET",
xhrFields: { withCredentials: true },
success(resp) {
let latestLog = null;
resp.Logs.forEach((item) => {
if (update === undefined || item.id > update) {
if (!latestLog || item.id > latestLog.id) {
latestLog = item;
}
}
});
if (latestLog) {
msg_("Rolagem", latestLog.log);
update = latestLog.id;
}
},
});
}
$(document).ready(function () {
setInterval(() => {
rollLoad();
}, 1000);
});