From 148b4b31ac4bee578e463f6004e82803ef953610 Mon Sep 17 00:00:00 2001 From: Revertron Date: Thu, 6 May 2021 22:53:38 +0200 Subject: [PATCH] Fixed dropdown menu behavior. Added loading of domain info and contacts on edit. --- src/webview/scripts.js | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/webview/scripts.js b/src/webview/scripts.js index 48e6fad..371d773 100644 --- a/src/webview/scripts.js +++ b/src/webview/scripts.js @@ -9,11 +9,13 @@ document.addEventListener('click', function (event) { closeDropdowns(); }); -function closeDropdowns() { +function closeDropdowns(except) { // Get all elements with class="dropdowns" and hide them var dropdowns = document.getElementsByClassName("dropdown is-active"); for (i = 0; i < dropdowns.length; i++) { - dropdowns[i].classList.remove('is-active'); + if (dropdowns[i] != except) { + dropdowns[i].classList.remove('is-active'); + } } } @@ -120,7 +122,7 @@ function addMyDomain(name, timestamp, data) { } function refreshMyDomains() { - var card = '

{title}

{tags}
'; + var card = '

{title}

{tags}
'; var tag = '{domain}'; var cards = ""; myDomains.forEach(function(value, index, array) { @@ -147,7 +149,7 @@ function refreshMyDomains() { document.getElementById("my_domains").innerHTML = cards; } -function editDomain(domain) { +function editDomain(domain, event) { myDomains.forEach(function(value, index, array) { if (domain != value.name) { return; @@ -161,7 +163,13 @@ function editDomain(domain) { }); } document.getElementById("new_domain").value = title.replace("." + domain_data.zone, ""); - changeZone(domain_data.zone); + if (typeof domain_data.info !== 'undefined') { + document.getElementById("info_text").value = domain_data.info; + } + if (typeof domain_data.contacts !== 'undefined') { + document.getElementById("contacts_text").value = domain_data.contacts.join("\n"); + } + changeZone(domain_data.zone, event); refreshRecordsList(); showNewDomainDialog(); }); @@ -199,7 +207,7 @@ function openTab(element, tabName) { function toggle(element, event) { event.stopPropagation(); - closeDropdowns(); + closeDropdowns(element); element.classList.toggle('is-active'); }