From 4fa91c8fbec0c4d05e7f0ca5fca7d5d15bed59e5 Mon Sep 17 00:00:00 2001 From: Conrad Chan Date: Fri, 4 Jun 2021 14:42:26 -0700 Subject: [PATCH] chore: Add support for collections for start:dev (#1397) --- src/index.html | 85 ++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 69 insertions(+), 16 deletions(-) diff --git a/src/index.html b/src/index.html index 1aa871485..f11be064b 100644 --- a/src/index.html +++ b/src/index.html @@ -9,17 +9,18 @@
-
-
Token:
- - +
+
+
Token:
+ + +
+ +
+
File ID:
+ + +
+ +
+ +
-
-
File ID:
- - -
- -
- +
+
+
Collection:
+ + + +
Enter 2+ comma separated list of file ids
+
@@ -67,6 +103,14 @@ /* global Box */ preview = new Box.Preview(); + function clearProperty(selector) { + var inputEl = document.getElementById(selector + '-set'); + var displayEl = document.getElementById(selector + '-display'); + inputEl.value = ''; + displayEl.textContent = ''; + localStorage.setItem(selector, ''); + } + function setProperty(selector) { // Get new value, fallback to local storage var inputValue = document.querySelector('#' + selector + '-set'); @@ -87,12 +131,20 @@ function loadPreview(options) { var token = localStorage.getItem('token'); var fileid = localStorage.getItem('fileid'); + var fileidList = localStorage.getItem('collection') || ''; if (!token || !fileid) { return; } + var collection = + fileidList && + fileidList.split(',').map(function(fileid) { + return fileid.trim(); + }); + var previewOptions = options || { + collection, enableThumbnailsSidebar: true, showAnnotations: true, showDownload: true, @@ -105,6 +157,7 @@ // Try to load all properties from storage on page load setProperty('token'); setProperty('fileid'); + setProperty('collection'); loadPreview();