diff --git a/js/lib/genericFunctions.js b/js/lib/genericFunctions.js index a20e00d..e6c4ad9 100644 --- a/js/lib/genericFunctions.js +++ b/js/lib/genericFunctions.js @@ -130,4 +130,7 @@ String.prototype.hashCode = function(){ var uri = (document.location.pathname + document.location.search); return uri.indexOf(s) >= 0; } - \ No newline at end of file + +function debug (m) { + console.log(`Location: ${window.location} Message: ${m}`); +} \ No newline at end of file diff --git a/js/lib/poolImprovements.js b/js/lib/poolImprovements.js index 29c847b..b3d2d68 100644 --- a/js/lib/poolImprovements.js +++ b/js/lib/poolImprovements.js @@ -4,50 +4,87 @@ * **************************************************************************/ -function improvePoolList(){ +async function getURL(url){ - var poolStatuses = {} - var oldMessage = $(parent.top.document).find("div#message div#messagetype div#messagetext").text(); - - // Check when the loading screen for pools has disappears and then show a member statuses. - var statusInterval = setInterval(function(){ - if(!$(parent.top.document).find("div#message").is(":visible")){ - $(parent.top.document).find("div#message div#messagetype div#messagetext").text("Loading member statuses..."); - $(parent.top.document).find("div#message").show(); - clearInterval(statusInterval); - } - } , 100); - - $.ajax({ + return new Promise((resolve, reject) => { + $.ajax({ + + url: url, + type: "GET", + success: response => resolve(response), + error: e => reject(e) + }) + }) + +} + +// Check when the loading screen for pools has disappears and then show a member statuses. +async function showLoadingMessage(message){ + + let messageDiv = $(parent.top.document).find("div#message"); + + return new Promise((resolve, reject) => { + var statusInterval = setInterval(function(){ - url: "https://" + window.location.host + "/tmui/Control/jspmap/tmui/locallb/pool/stats.jsp?SearchString=*&", - type: "GET", - success: function(response) { - - $(response).find("tbody#list_body tr") - .filter(function() { - return this.id.match(/\/.+\//); - }) - .each(function(){ - - var poolName = this.id.replace(/_member_row_[0-9]+$/i, ""); - - if(!(poolName in poolStatuses)){ - poolStatuses[poolName] = {}; - } - - var memberName = $(this).find("td").eq(3).text().trim(); - var statusIcon = $(this).find("td").eq(1).find("img").attr("src"); - var title = $(this).find("td").eq(1).find("img").attr("title"); - - poolStatuses[poolName][memberName] = { "icon": statusIcon, "title": title }; - - }); + if(!(messageDiv.is(":visible"))){ + console.log(messageDiv); + messageDiv.html(` +
Member | Status |
Member | Status | |
" + member + " | " + memberStatuses[member].title + " | |
${member} | ${memberStatuses[member].title} |