diff options
-rw-r--r-- | js/garden.js | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/js/garden.js b/js/garden.js index fe3b952..046943a 100644 --- a/js/garden.js +++ b/js/garden.js @@ -569,22 +569,24 @@ function viewCropDetails(crop) { } function addReferences() { - const div = document.createElement("div"); - const title = document.createElement("span"); - const list = document.createElement("ul"); - title.appendChild(document.createTextNode("References")); - div.appendChild(title); - crop.references.forEach(ref => { - const li = document.createElement("li"); - const link = document.createElement("a"); - link.appendChild(document.createTextNode(ref.title)); - link.href = ref.url; - link.target = "_blank"; // open in new tab. - li.appendChild(link); - list.appendChild(li); - }); - div.appendChild(list); - modal.appendChild(div); + if(crop.references.length > 0) { + const div = document.createElement("div"); + const title = document.createElement("span"); + const list = document.createElement("ul"); + title.appendChild(document.createTextNode("References")); + div.appendChild(title); + crop.references.forEach(ref => { + const li = document.createElement("li"); + const link = document.createElement("a"); + link.appendChild(document.createTextNode(ref.title)); + link.href = ref.url; + link.target = "_blank"; // open in new tab. + li.appendChild(link); + list.appendChild(li); + }); + div.appendChild(list); + modal.appendChild(div); + } } const container = document.getElementById("container"); |