Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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