add execute input box
This commit is contained in:
@@ -342,9 +342,20 @@ if (count($_POST) > 0) {
|
|||||||
|
|
||||||
//javascript constants for use in the selection option group
|
//javascript constants for use in the selection option group
|
||||||
echo "<script>\n";
|
echo "<script>\n";
|
||||||
|
echo "window.permission_execute = " . (permission_exists('phrase_execute') ? 'true' : 'false') . ";\n";
|
||||||
echo "window.phrase_label_sounds = '" . ($text['label-sounds'] ?? 'Sounds') . "';\n";
|
echo "window.phrase_label_sounds = '" . ($text['label-sounds'] ?? 'Sounds') . "';\n";
|
||||||
echo "window.phrase_label_recordings = '" . ($text['label-recordings'] ?? 'Recordings') . "';\n";
|
echo "window.phrase_label_recordings = '" . ($text['label-recordings'] ?? 'Recordings') . "';\n";
|
||||||
echo "window.phrase_commands = " . json_encode([$text['label-play'] ?? 'Play', $text['label-pause'] ?? 'Pause', $text['label-execute'] ?? 'Execute'], true) . ";\n";
|
//only include permissive actions
|
||||||
|
$phrase_commands = [];
|
||||||
|
if (permission_exists('phrase_play')) {
|
||||||
|
$phrase_commands[] = $text['label-play'] ?? 'Play';
|
||||||
|
$phrase_commands[] = $text['label-pause'] ?? 'Pause';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (permission_exists('phrase_execute')) {
|
||||||
|
$phrase_commands[] = $text['label-execute'] ?? 'Execute';
|
||||||
|
}
|
||||||
|
echo "window.phrase_commands = " . json_encode($phrase_commands, true) . ";\n";
|
||||||
|
|
||||||
//existing details
|
//existing details
|
||||||
if (!empty($phrase_details)) {
|
if (!empty($phrase_details)) {
|
||||||
|
|||||||
@@ -31,6 +31,44 @@ document.addEventListener("DOMContentLoaded", function () {
|
|||||||
add_draggable_rows();
|
add_draggable_rows();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//
|
||||||
|
// Switch to a text input box when 'Execute' is selected instead of dropdown
|
||||||
|
//
|
||||||
|
function add_switch_to_text_input(select_action) {
|
||||||
|
if (window.permission_execute) {
|
||||||
|
const row = select_action.parentNode.parentNode;
|
||||||
|
const row_index = document.getElementById('structure').rows.length;
|
||||||
|
//get the select boxes
|
||||||
|
const select_list = row.querySelectorAll('td select'); //action and recording select dropdown boxes
|
||||||
|
const select_data = select_list[1];
|
||||||
|
|
||||||
|
// Create a new text input to replace the select when execute is chosen
|
||||||
|
const textInput = document.createElement('input');
|
||||||
|
textInput.type = 'text';
|
||||||
|
textInput.className = 'formfld';
|
||||||
|
textInput.id = 'phrase_detail_data_input[' + row_index + ']';
|
||||||
|
textInput.name = 'phrase_detail_data_input[' + row_index + ']';
|
||||||
|
//match style
|
||||||
|
textInput.style.width = select_data.style.width;
|
||||||
|
textInput.style.height = select_data.style.height;
|
||||||
|
//set to hide
|
||||||
|
textInput.style.display = 'none';
|
||||||
|
select_data.parentNode.appendChild(textInput);
|
||||||
|
|
||||||
|
select_action.addEventListener('change', function () {
|
||||||
|
if (select_action.value === 'execute') {
|
||||||
|
//show text box
|
||||||
|
select_data.style.display = 'none';
|
||||||
|
textInput.style.display = 'block';
|
||||||
|
} else {
|
||||||
|
//hide text box
|
||||||
|
select_data.style.display = 'block';
|
||||||
|
textInput.style.display = 'none';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// Inserts all existing records before the empty one
|
// Inserts all existing records before the empty one
|
||||||
//
|
//
|
||||||
@@ -47,7 +85,8 @@ function add_existing() {
|
|||||||
const select_list = newRow.querySelectorAll('td select'); //action and recording select dropdown boxes
|
const select_list = newRow.querySelectorAll('td select'); //action and recording select dropdown boxes
|
||||||
//play, pause, execute select box
|
//play, pause, execute select box
|
||||||
const select_action = select_list[0];
|
const select_action = select_list[0];
|
||||||
select_by_text(select_action, 'Play');
|
add_switch_to_text_input(select_action);
|
||||||
|
select_by_value(select_action, 'play-file');
|
||||||
|
|
||||||
//recording select box
|
//recording select box
|
||||||
const select_recording = select_list[1];
|
const select_recording = select_list[1];
|
||||||
@@ -181,10 +220,19 @@ function add_row() {
|
|||||||
|
|
||||||
//reset id
|
//reset id
|
||||||
newRow.id = 'row_' + index;
|
newRow.id = 'row_' + index;
|
||||||
|
|
||||||
//reset 'name' attribute
|
//reset 'name' attribute
|
||||||
newRow.setAttribute('name', 'recording_' + index);
|
newRow.setAttribute('name', 'recording_' + index);
|
||||||
|
|
||||||
|
//get the select boxes
|
||||||
|
const select_list = newRow.querySelectorAll('td select'); //action and recording select dropdown boxes
|
||||||
|
//play, pause, execute select box
|
||||||
|
const select_action = select_list[0];
|
||||||
|
//recording select box
|
||||||
|
const select_recording = select_list[1];
|
||||||
|
|
||||||
|
//add switchable select box to text input box
|
||||||
|
add_switch_to_text_input(select_action);
|
||||||
|
|
||||||
//add the row to the table body
|
//add the row to the table body
|
||||||
tbody.appendChild(newRow);
|
tbody.appendChild(newRow);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user