fix: Add links on account page

This commit is contained in:
Joachim Van Herwegen 2023-09-27 11:36:37 +02:00
parent 307dba3219
commit 3bfd9e3298

View File

@ -93,16 +93,23 @@
})();
// Adds account info to the UI
function showAccountInfo(rootElement, data, addLink, addDel, confirmMsg, finishMsg) {
function showAccountInfo(rootElement, data, addUpdate, addDel, confirmMsg, finishMsg) {
for (const [ key, url ] of Object.entries(data)) {
const li = document.createElement('li');
if (addLink) {
li.insertAdjacentHTML('beforeend', `<a href="${url}">${key}</a>`);
// I didn't want to add another parameter to the function to indicate if the key should be a link
if (/^https?:\/\//.test(key)) {
li.insertAdjacentHTML('beforeend', `<a href="${key}">${key}</a>`);
} else {
li.append(key);
}
if (addUpdate) {
li.insertAdjacentHTML('beforeend', ` <a href="${url}">(update)</a>`);
}
if (addDel) {
const del = createUrlDeleteElement(li, url, { method: 'DELETE' }, confirmMsg, finishMsg);
li.append(' ');