Skip to content

Commit

Permalink
Merge pull request #349 from basil/remove-prototype
Browse files Browse the repository at this point in the history
Replace Prototype.js with native JavaScript
  • Loading branch information
KostyaSha committed May 9, 2023
2 parents 47b623a + 66914b9 commit 96567a0
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions src/main/webapp/js/warning.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,27 @@ var InlineWarning = (function () {

exports.start = function () {
// Ignore when GH trigger unchecked
if (!$$(options.input).first().checked) {
if (!document.querySelector(options.input).checked) {
return;
}
new Ajax.PeriodicalUpdater(
options.id,
options.url,
{
method: 'get',
frequency: 10,
decay: 2
}
);
var frequency = 10;
var decay = 2;
var lastResponseText;
var fetchData = function () {
fetch(options.url).then((rsp) => {
rsp.text().then((responseText) => {
if (responseText !== lastResponseText) {
document.getElementById(options.id).innerHTML = responseText;
lastResponseText = responseText;
frequency = 10;
} else {
frequency *= decay;
}
setTimeout(fetchData, frequency * 1000);
});
});
};
fetchData();
};

return exports;
Expand Down

0 comments on commit 96567a0

Please sign in to comment.