Skip to content

Commit 15c1b59

Browse files
authored
Merge pull request #101 from andriumon/quick-fix
Added missing multiple-source implementation for dimensions web table
2 parents 8fc4aed + 234e4a1 commit 15c1b59

File tree

1 file changed

+25
-15
lines changed

1 file changed

+25
-15
lines changed

website/dimensions.html

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -233,30 +233,40 @@ <h2>Research Software Quality Dimensions</h2>
233233
row.appendChild(descriptionCell);
234234

235235
const sourceCell = document.createElement("td");
236-
if (data.source && typeof data.source === "object") {
237-
let href = null;
238-
239-
if (data.source.url) {
240-
href = data.source.url;
241-
} else if (data.source['@id']) {
242-
href = data.source['@id'];
243-
} else if (data.source.identifier) {
244-
href = data.source.identifier;
245-
}
236+
function appendSourceLink(src, cell, addSeparator = false) {
237+
let href = src.url || src['@id'] || src.identifier;
238+
let label = src.name || href;
246239

247240
if (href) {
248241
const link = document.createElement("a");
249242
link.href = href;
250-
link.textContent = data.source.name || href;
243+
link.textContent = label;
251244
link.target = "_blank";
252245
link.style.color = "#1E90FF";
253246
link.style.display = "block";
254-
sourceCell.appendChild(link);
255-
} else {
256-
sourceCell.textContent = "";
247+
link.style.marginBottom = "6px";
248+
cell.appendChild(link);
249+
}
250+
251+
if (addSeparator) {
252+
const separator = document.createElement("hr");
253+
separator.style.borderTop = "1px dashed #444";
254+
separator.style.margin = "6px 0";
255+
cell.appendChild(separator);
257256
}
257+
}
258+
259+
if (Array.isArray(data.source)) {
260+
data.source.forEach((src, index) => {
261+
appendSourceLink(src, sourceCell, index < data.source.length - 1);
262+
});
263+
} else if (data.source && typeof data.source === "object") {
264+
appendSourceLink(data.source, sourceCell);
258265
} else {
259-
sourceCell.textContent = "";
266+
const noSource = document.createElement("span");
267+
noSource.textContent = "no source available";
268+
noSource.style.color = "#999";
269+
sourceCell.appendChild(noSource);
260270
}
261271
row.appendChild(sourceCell);
262272

0 commit comments

Comments
 (0)