From 66914b9adfc5b04e2d37c506e3ee1779d53f1c2f Mon Sep 17 00:00:00 2001 From: Basil Crow Date: Mon, 8 May 2023 20:34:16 -0700 Subject: [PATCH] Replace Prototype.js with native JavaScript --- src/main/webapp/js/warning.js | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/src/main/webapp/js/warning.js b/src/main/webapp/js/warning.js index 8bb1198dd..d3123bc38 100644 --- a/src/main/webapp/js/warning.js +++ b/src/main/webapp/js/warning.js @@ -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;