summaryrefslogtreecommitdiff
path: root/html
diff options
context:
space:
mode:
Diffstat (limited to 'html')
-rw-r--r--html/install.js10
-rw-r--r--html/item_preview.js8
2 files changed, 11 insertions, 7 deletions
diff --git a/html/install.js b/html/install.js
index 68033bc..df63626 100644
--- a/html/install.js
+++ b/html/install.js
@@ -211,15 +211,15 @@ function InstallView(tab_id, on_view_show, on_view_hide) {
delete response.json.api_schema_version;
delete response.json.api_schema_revision;
- const files = response.json.source_copyright
- .concat(item_type === "resource" ? response.json.scripts : []);
+ const scripts = item_type === "resource" && response.json.scripts;
+ const files = response.json.source_copyright.concat(scripts || []);
if (item_type === "mapping") {
- for (const res_ref of Object.values(response.json.payloads))
+ for (const res_ref of Object.values(response.json.payloads || {}))
process_item(work, "resource", res_ref.identifier);
} else {
- for (const res_id of (response.json.dependencies || []))
- process_item(work, "resource", res_id);
+ for (const res_ref of (response.json.dependencies || []))
+ process_item(work, "resource", res_ref.identifier);
}
/*
diff --git a/html/item_preview.js b/html/item_preview.js
index bd4fd68..1da9492 100644
--- a/html/item_preview.js
+++ b/html/item_preview.js
@@ -82,7 +82,10 @@ function resource_preview(resource, preview_object, link_cb=make_file_link) {
preview_object.source_name.innerText = resource.source_name;
[...preview_object.dependencies.childNodes].forEach(n => n.remove());
- populate_list(preview_object.dependencies, resource.dependencies);
+
+ const deps_refs = resource.dependencies || [];
+ populate_list(preview_object.dependencies,
+ deps_refs.map(res_ref => res_ref.identifier));
const link_maker = file_ref => link_cb(preview_object, file_ref);
@@ -109,7 +112,8 @@ function mapping_preview(mapping, preview_object, link_cb=make_file_link) {
preview_object.source_name.innerText = mapping.source_name;
[...preview_object.payloads.childNodes].forEach(n => n.remove());
- for (const [pattern, payload] of Object.entries(mapping.payloads).sort()) {
+ const payload_entries = Object.entries(mapping.payloads || {}).sort();
+ for (const [pattern, payload] of payload_entries) {
/* We use a non-breaking space because normal space would be ignored. */
const [nbsp, rarrow] = [160, 0x2192].map(n => String.fromCodePoint(n));
const texts = [`${pattern}${nbsp}`, `${rarrow} ${payload.identifier}`];