Add feature to jump to marker (#471)

* Add options for setting marker and jumping to marker
* Correct "mute" to "muted"
This commit is contained in:
jacobcolbert
2019-05-06 00:41:16 -04:00
committed by Ilya Grigorik
parent e91b4c9cdb
commit d8965f644c
3 changed files with 30 additions and 9 deletions

View File

@@ -102,6 +102,9 @@ function updateCustomShortcutInputText(inputItem, keyCode) {
inputItem.keyCode = keyCode;
}
// List of custom actions for which customValue should be disabled
var customActionsNoValues=["pause","muted","mark","jump"];
function add_shortcut() {
var html = `<select class="customDo">
<option value="slower">Decrease speed</option>
@@ -112,6 +115,8 @@ function add_shortcut() {
<option value="fast">Preferred speed</option>
<option value="muted">Mute</option>
<option value="pause">Pause</option>
<option value="mark">Set marker</option>
<option value="jump">Jump to marker</option>
</select>
<input class="customKey" type="text" placeholder="press a key"/>
<input class="customValue" type="text" placeholder="value (0.10)"/>
@@ -192,7 +197,7 @@ function restore_options() {
const dom = document.querySelector(".customs:last-of-type")
dom.querySelector(".customDo").value = item["action"];
if (item["action"] === "pause" || item["action"] === "muted")
if (customActionsNoValues.includes(item["action"]))
dom.querySelector(".customValue").disabled = true;
updateCustomShortcutInputText(dom.querySelector(".customKey"), item["key"]);
@@ -262,14 +267,11 @@ document.addEventListener('DOMContentLoaded', function () {
});
document.addEventListener('change', (event) => {
eventCaller(event, "customDo", function () {
switch (event.target.value) {
case "muted":
case "pause":
event.target.nextElementSibling.nextElementSibling.disabled = true;
event.target.nextElementSibling.nextElementSibling.value = 0;
break;
default:
event.target.nextElementSibling.nextElementSibling.disabled = false;
if (customActionsNoValues.includes(event.target.value)) {
event.target.nextElementSibling.nextElementSibling.disabled = true;
event.target.nextElementSibling.nextElementSibling.value = 0;
} else {
event.target.nextElementSibling.nextElementSibling.disabled = false;
}
})
});