Skip to content

Commit 0bb4bb6

Browse files
committed
Fixing JS
1 parent 8ce8adf commit 0bb4bb6

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

3d-guide/README.md

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -71,30 +71,30 @@ Now we have the URL to the manifest we can supply this to a number of IIIF viewe
7171

7272
<div class="row">
7373
<label for="text">Manifest URL:</label>
74-
<input id="text" type="text" placeholder="e.g. https://api.npoint.io/8af5347d219a3cec6039" />
74+
<input id="text" type="text" minlength="50" placeholder="e.g. https://api.npoint.io/8af5347d219a3cec6039" />
7575
</div>
7676

7777
<div class="row" style="margin-top:.75rem;">
7878
<label for="dest">IIIF Viewer</label>
7979
<select id="dest">
8080
<!-- Append as query: ?q=TEXT -->
81-
<option value="https://www.morphosource.org/uv/uv.html#" data-mode="query" data-param="manifest">
81+
<option value="https://www.morphosource.org/uv/uv.html#" data-mode="append" data-param="manifest">
8282
MorphoSource
8383
</option>
8484
<!-- Append as path: /wiki/TEXT -->
85-
<option value="https://smithsonian.github.io/voyager-dev/iiif/iiif_demo" data-mode="query" data-param="document">
85+
<option value="https://smithsonian.github.io/voyager-dev/iiif/iiif_demo" data-mode="append" data-param="document">
8686
Voyager
8787
</option>
8888
<!-- Another path example: /users/TEXT -->
89-
<option value="https://uv-v4.netlify.app/#" data-mode="query" data-param="manifest">
89+
<option value="https://uv-v4.netlify.app/#" data-mode="append" data-param="manifest">
9090
Universal Viewer
9191
</option>
92-
<option value="https://spri-open-resources.s3.us-east-2.amazonaws.com/iiif3dtsg/manifest/index.html#" data-mode="query" data-param="manifest">
92+
<option value="https://spri-open-resources.s3.us-east-2.amazonaws.com/iiif3dtsg/manifest/index.html#" data-mode="append" data-param="manifest">
9393
X3DOM Viewer
9494
</option>
95-
<option value="https://blacklodge.hki.uni-koeln.de/viewer/?locale=en&standalone=true" data-mode="query" data-param="manifest">
95+
<!-- <option value="https://blacklodge.hki.uni-koeln.de/viewer/?locale=en&standalone=true" data-mode="query" data-param="manifest">
9696
Kompakkt Viewer
97-
</option>
97+
</option>-->
9898
</select>
9999

100100
<button id="go" type="button">Open</button>
@@ -108,23 +108,23 @@ Now we have the URL to the manifest we can supply this to a number of IIIF viewe
108108
const sel = $("dest");
109109
const base = sel.value;
110110
const mode = sel.options[sel.selectedIndex].dataset.mode;
111-
const param = sel.options[sel.selectedIndex].dataset.param || "q";
111+
const param = sel.options[sel.selectedIndex].dataset.param;
112112

113113
// Build the final URL
114114
let urlStr;
115115
try {
116-
const u = new URL(base, window.location.href); // supports absolute or relative base
117-
118-
if (mode === "path") {
119-
// Ensure exactly one trailing slash before appending, then encode the segment
120-
const needsSlash = u.pathname.endsWith("/") ? "" : "/";
121-
u.pathname = u.pathname + needsSlash + encodeURIComponent(input);
116+
if (mode === "append") {
117+
urlStr = base + "?" + param + "=" + input;
122118
} else {
123-
// Query mode (e.g., ?q=TEXT). If input empty, we still open base.
124-
if (input) u.searchParams.set(param, input);
119+
const u = new URL(base, window.location.href); // supports absolute or relative base
120+
// Query mode (e.g., ?q=TEXT). If input empty, we still open base.
121+
if (input) {
122+
u.searchParams.set(param, input);
123+
}
124+
125+
urlStr = u.toString();
125126
}
126127

127-
urlStr = u.toString();
128128
} catch (e) {
129129
// Fallback if base isn't a valid URL for some reason
130130
urlStr = base + encodeURIComponent(input);

0 commit comments

Comments
 (0)