Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add mechanism for entering custom configurations in examples view. #1062

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,16 @@ <h2 class="controls-title">Annotations</h2>
</button>
</div>
</div>

<div class="controls-group">
<h2 class="controls-title">Custom Configuration</h2>
<textarea id="customConfig" rows="5" class="w-full"></textarea>
<div class="mt-2">
<button id="setConfigButton" class="controls-button">
Apply Configurations
</button>
</div>
</div>
</div>

<div id="youTubeTab" class="hidden controls-tab-content">
Expand Down Expand Up @@ -292,6 +302,8 @@ <h2 class="controls-title">Duration</h2>
var $clearAnnotationsButton = document.getElementById(
"clearAnnotationsButton"
);
var $customConfig = document.getElementById("customConfig");
var $setConfigButton = document.getElementById("setConfigButton");
var $setYouTubeVideoIdButton = document.getElementById(
"setYouTubeVideoIdButton"
);
Expand Down Expand Up @@ -420,6 +432,10 @@ <h2 class="controls-title">Duration</h2>
});
}

function setConfig() {
// The configs are loaded as part of the IIIF initialization.
activateIIIFTab();
}
$iiifManifestIdSelect.onchange = function() {
var $selectedOption = document.querySelector(
"#iiifManifestIdSelect option:checked"
Expand Down Expand Up @@ -483,6 +499,9 @@ <h2 class="controls-title">Duration</h2>
setAnnotations();
};

$setConfigButton.onclick = function() {
setConfig();
};
$mutedCheckbox.onclick = function(e) {
muted = e.target.checked;
uv.set({
Expand Down Expand Up @@ -627,6 +646,18 @@ <h2 class="controls-title">Duration</h2>
});
});

// apply custom configs from the form
uv.on("configure", function({ config, cb}) {
try {
if ($customConfig.value.length > 0) {
var customConfig = JSON.parse($customConfig.value);
cb(customConfig);
}
} catch (e) {
console.error("Could not process user-provided JSON configuration.");
}
});

uv.on("targetChange", function(target) {
$target.value = target;
});
Expand Down