|
|
@ -39,17 +39,18 @@ function getMessages(dataOrigin) {
|
|
|
|
|
|
|
|
|
|
|
|
// make div for all messages, return relevant
|
|
|
|
// make div for all messages, return relevant
|
|
|
|
function buildMessage(responseData, dataOrigin) {
|
|
|
|
function buildMessage(responseData, dataOrigin) {
|
|
|
|
var messages = responseData["messages"];
|
|
|
|
// filter relevan messages
|
|
|
|
var notificationDiv = document.getElementById("notifications")
|
|
|
|
var allMessages = responseData["messages"];
|
|
|
|
|
|
|
|
var messages = allMessages.filter(function(value) {
|
|
|
|
|
|
|
|
return messageTypes[dataOrigin].includes(value["status"])
|
|
|
|
|
|
|
|
}, dataOrigin);
|
|
|
|
|
|
|
|
// build divs
|
|
|
|
|
|
|
|
var notificationDiv = document.getElementById("notifications");
|
|
|
|
var nots = notificationDiv.childElementCount;
|
|
|
|
var nots = notificationDiv.childElementCount;
|
|
|
|
notificationDiv.innerHTML = "";
|
|
|
|
notificationDiv.innerHTML = "";
|
|
|
|
for (let i = 0; i < messages.length; i++) {
|
|
|
|
for (let i = 0; i < messages.length; i++) {
|
|
|
|
var messageData = messages[i];
|
|
|
|
var messageData = messages[i];
|
|
|
|
var messageStatus = messageData["status"];
|
|
|
|
var messageStatus = messageData["status"];
|
|
|
|
if (! messageTypes[dataOrigin].includes(messageStatus)) {
|
|
|
|
|
|
|
|
messages.splice(i);
|
|
|
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
var messageBox = document.createElement("div");
|
|
|
|
var messageBox = document.createElement("div");
|
|
|
|
var title = document.createElement("h3");
|
|
|
|
var title = document.createElement("h3");
|
|
|
|
title.innerHTML = messageData["title"];
|
|
|
|
title.innerHTML = messageData["title"];
|
|
|
@ -63,8 +64,8 @@ function buildMessage(responseData, dataOrigin) {
|
|
|
|
checkDownloadIcons();
|
|
|
|
checkDownloadIcons();
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
// reload on download page when no more notifications
|
|
|
|
// reload page when no more notifications
|
|
|
|
if (nots > 0 && messages.length === 0 && dataOrigin === "download") {
|
|
|
|
if (nots > 0 && messages.length === 0) {
|
|
|
|
location.reload();
|
|
|
|
location.reload();
|
|
|
|
};
|
|
|
|
};
|
|
|
|
return messages
|
|
|
|
return messages
|
|
|
|