summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorDavid Thompson <dthompson@vistahigherlearning.com>2022-02-17 08:48:57 -0500
committerDavid Thompson <dthompson@vistahigherlearning.com>2022-02-17 08:48:57 -0500
commit1466f38f0bd71980e1079cf6fcc642dc36034214 (patch)
treeb5784da9aa83df2eadac8c1e71c003c851629db0 /js
parent8a802faa389d70678ab5bf8685d17004fc04d956 (diff)
Don't show references header if there are no references.
Diffstat (limited to 'js')
-rw-r--r--js/garden.js34
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");