vidhimudaliar commited on
Commit
68356dc
·
verified ·
1 Parent(s): 4e5f3a0

Update assets/js/codebook.js

Browse files
Files changed (1) hide show
  1. assets/js/codebook.js +7 -2
assets/js/codebook.js CHANGED
@@ -334,7 +334,13 @@ function renderVideos(examples) {
334
  wrapper.className = "video-item";
335
 
336
  const video = document.createElement("video");
337
- video.src = ex.src;
 
 
 
 
 
 
338
  video.controls = true;
339
  video.loop = true;
340
  video.muted = true;
@@ -408,4 +414,3 @@ if (document.readyState === 'loading') {
408
  renderSidebar();
409
  updateActiveCategory();
410
  }
411
-
 
334
  wrapper.className = "video-item";
335
 
336
  const video = document.createElement("video");
337
+ // Resolve example src against the current page URL so it works when hosted
338
+ // from a subpath or static host.
339
+ try {
340
+ video.src = new URL(ex.src, window.location.href).href;
341
+ } catch (e) {
342
+ video.src = ex.src;
343
+ }
344
  video.controls = true;
345
  video.loop = true;
346
  video.muted = true;
 
414
  renderSidebar();
415
  updateActiveCategory();
416
  }