use labels
This commit is contained in:
parent
870ab765ca
commit
b14e8f20c8
|
|
@ -342,7 +342,9 @@ 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.phrase_commands = " . json_encode(['Play', 'Pause', 'Execute'], true) . ";\n";
|
echo "window.phrase_label_sounds = '" . ($text['label-sounds'] ?? 'Sounds') . "';\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";
|
||||||
|
|
||||||
//existing details
|
//existing details
|
||||||
if (!empty($phrase_details)) {
|
if (!empty($phrase_details)) {
|
||||||
|
|
|
||||||
|
|
@ -8,14 +8,14 @@ document.addEventListener("DOMContentLoaded", function () {
|
||||||
select.appendChild(new Option('', ''));
|
select.appendChild(new Option('', ''));
|
||||||
|
|
||||||
// Add recordings
|
// Add recordings
|
||||||
grp_rec.label = 'Recordings';
|
grp_rec.label = window.phrase_label_recordings;
|
||||||
for (let i = 0; i < window.phrase_recordings.length; i++) {
|
for (let i = 0; i < window.phrase_recordings.length; i++) {
|
||||||
grp_rec.appendChild(new Option(window.phrase_recordings[i].recording_name, window.phrase_recordings[i].recording_uuid));
|
grp_rec.appendChild(new Option(window.phrase_recordings[i].recording_name, window.phrase_recordings[i].recording_uuid));
|
||||||
}
|
}
|
||||||
select.appendChild(grp_rec);
|
select.appendChild(grp_rec);
|
||||||
|
|
||||||
// Add sounds
|
// Add sounds
|
||||||
grp_snd.label = 'Sounds';
|
grp_snd.label = window.phrase_label_sounds;
|
||||||
for (let i = 0; i < window.phrase_sounds.length; i++) {
|
for (let i = 0; i < window.phrase_sounds.length; i++) {
|
||||||
grp_snd.appendChild(new Option(window.phrase_sounds[i], window.phrase_sounds[i]));
|
grp_snd.appendChild(new Option(window.phrase_sounds[i], window.phrase_sounds[i]));
|
||||||
}
|
}
|
||||||
|
|
@ -31,7 +31,9 @@ document.addEventListener("DOMContentLoaded", function () {
|
||||||
add_draggable_rows();
|
add_draggable_rows();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//
|
||||||
// Inserts all existing records before the empty one
|
// Inserts all existing records before the empty one
|
||||||
|
//
|
||||||
function add_existing() {
|
function add_existing() {
|
||||||
const tbody = document.getElementById('structure');
|
const tbody = document.getElementById('structure');
|
||||||
|
|
||||||
|
|
@ -62,6 +64,9 @@ function add_existing() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Set the selected index on a dropdown box based on the value (key)
|
||||||
|
//
|
||||||
function select_by_value(selectElement, valueToFind) {
|
function select_by_value(selectElement, valueToFind) {
|
||||||
// Loop through the options of the select element
|
// Loop through the options of the select element
|
||||||
for (let i = 0; i < selectElement.options.length; i++) {
|
for (let i = 0; i < selectElement.options.length; i++) {
|
||||||
|
|
@ -73,6 +78,9 @@ function select_by_value(selectElement, valueToFind) {
|
||||||
console.warn('Value not found in select options');
|
console.warn('Value not found in select options');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Set the selected index on a dropdown box based on the text
|
||||||
|
//
|
||||||
function select_by_text(selectElement, textToFind) {
|
function select_by_text(selectElement, textToFind) {
|
||||||
for (let i = 0; i < selectElement.options.length; i++) {
|
for (let i = 0; i < selectElement.options.length; i++) {
|
||||||
if (selectElement.options[i].text === textToFind) {
|
if (selectElement.options[i].text === textToFind) {
|
||||||
|
|
@ -83,7 +91,9 @@ function select_by_text(selectElement, textToFind) {
|
||||||
console.warn('Text not found in select options');
|
console.warn('Text not found in select options');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
// Add draggable functionality to rows
|
// Add draggable functionality to rows
|
||||||
|
//
|
||||||
function add_draggable_rows() {
|
function add_draggable_rows() {
|
||||||
const tableBody = document.getElementById('structure');
|
const tableBody = document.getElementById('structure');
|
||||||
let draggedRow = null;
|
let draggedRow = null;
|
||||||
|
|
@ -115,7 +125,9 @@ function add_draggable_rows() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
// Function to update the 'name' attribute based on row numbers
|
// Function to update the 'name' attribute based on row numbers
|
||||||
|
//
|
||||||
function update_order() {
|
function update_order() {
|
||||||
const tableBody = document.getElementById('structure');
|
const tableBody = document.getElementById('structure');
|
||||||
const rows = tableBody.querySelectorAll('tr');
|
const rows = tableBody.querySelectorAll('tr');
|
||||||
|
|
@ -144,6 +156,9 @@ function update_order() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Ensure the order is updated when submitting the form
|
||||||
|
//
|
||||||
function submit_phrase() {
|
function submit_phrase() {
|
||||||
//ensure order is updated before submitting form
|
//ensure order is updated before submitting form
|
||||||
update_order();
|
update_order();
|
||||||
|
|
@ -151,7 +166,9 @@ function submit_phrase() {
|
||||||
const form = document.getElementById('frm').submit();
|
const form = document.getElementById('frm').submit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
// Add a new row to the table
|
// Add a new row to the table
|
||||||
|
//
|
||||||
function add_row() {
|
function add_row() {
|
||||||
const tbody = document.getElementById('structure');
|
const tbody = document.getElementById('structure');
|
||||||
const newRow = document.getElementById('empty_row').cloneNode(true);
|
const newRow = document.getElementById('empty_row').cloneNode(true);
|
||||||
|
|
@ -175,7 +192,9 @@ function add_row() {
|
||||||
add_draggable_rows();
|
add_draggable_rows();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
// Remove the last row in the table
|
// Remove the last row in the table
|
||||||
|
//
|
||||||
function remove_row() {
|
function remove_row() {
|
||||||
const tbody = document.getElementById('structure');
|
const tbody = document.getElementById('structure');
|
||||||
if (tbody && tbody.rows.length > 1) {
|
if (tbody && tbody.rows.length > 1) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue