aboutsummaryrefslogtreecommitdiff
path: root/html/item_preview.js
diff options
context:
space:
mode:
Diffstat (limited to 'html/item_preview.js')
-rw-r--r--html/item_preview.js15
1 files changed, 11 insertions, 4 deletions
diff --git a/html/item_preview.js b/html/item_preview.js
index 474766c..dccf2d4 100644
--- a/html/item_preview.js
+++ b/html/item_preview.js
@@ -55,6 +55,7 @@ function populate_list(ul, items)
}
}
+/* Link click handler used in make_file_link(). */
async function file_link_clicked(preview_object, file_ref, event)
{
event.preventDefault();
@@ -71,6 +72,10 @@ async function file_link_clicked(preview_object, file_ref, event)
}
}
+/*
+ * The default function to use to create file preview link. Links it creates can
+ * be used to view files from IndexedDB.
+ */
function make_file_link(preview_object, file_ref)
{
const a = document.createElement("a");
@@ -82,7 +87,8 @@ function make_file_link(preview_object, file_ref)
return a;
}
-function resource_preview(resource, preview_object, dialog_context)
+function resource_preview(resource, preview_object, dialog_context,
+ make_link_cb=make_file_link)
{
if (preview_object === undefined)
preview_object = clone_template("resource_preview");
@@ -98,7 +104,7 @@ function resource_preview(resource, preview_object, dialog_context)
[...preview_object.dependencies.childNodes].forEach(n => n.remove());
populate_list(preview_object.dependencies, resource.dependencies);
- const link_maker = file_ref => make_file_link(preview_object, file_ref);
+ const link_maker = file_ref => make_link_cb(preview_object, file_ref);
[...preview_object.scripts.childNodes].forEach(n => n.remove());
populate_list(preview_object.scripts, resource.scripts.map(link_maker));
@@ -113,7 +119,8 @@ function resource_preview(resource, preview_object, dialog_context)
}
#EXPORT resource_preview
-function mapping_preview(mapping, preview_object, dialog_context)
+function mapping_preview(mapping, preview_object, dialog_context,
+ make_link_cb=make_file_link)
{
if (preview_object === undefined)
preview_object = clone_template("mapping_preview");
@@ -138,7 +145,7 @@ function mapping_preview(mapping, preview_object, dialog_context)
}
}
- const link_maker = file_ref => make_file_link(preview_object, file_ref);
+ const link_maker = file_ref => make_link_cb(preview_object, file_ref);
[...preview_object.copyright.childNodes].forEach(n => n.remove());
populate_list(preview_object.copyright,