commit 01/10/2025
This commit is contained in:
@@ -11,13 +11,13 @@
|
||||
* List of broadcast zones available
|
||||
* @type {BroadcastZone[]}
|
||||
*/
|
||||
let BroadcastZoneList = [];
|
||||
window.BroadcastZoneList ??= [];
|
||||
|
||||
/**
|
||||
* Currently selected broadcast zone row in the table
|
||||
* @type {JQuery<HTMLElement>|null}
|
||||
*/
|
||||
let selectedBroadcastZoneRow = null;
|
||||
window.selectedBroadcastZoneRow = null;
|
||||
|
||||
/**
|
||||
* Fill broadcast zone table body with values
|
||||
@@ -31,23 +31,23 @@ function fill_broadcastzonetablebody(vv) {
|
||||
<td>${item.index}</td>
|
||||
<td>${item.description}</td>
|
||||
<td>${item.soundChannel}</td>
|
||||
<td>${item.box}</td>
|
||||
<td>${item.relay}</td>
|
||||
<td>${item.id}</td>
|
||||
<td>${item.bp}</td>
|
||||
</tr>`;
|
||||
$('#broadcastzonetablebody').append(row);
|
||||
let $addedrow = $('#broadcastzonetablebody tr:last');
|
||||
$addedrow.click(function () {
|
||||
if (selectedBroadcastZoneRow) {
|
||||
selectedBroadcastZoneRow.find('td').css('background-color', '');
|
||||
if (selectedBroadcastZoneRow.is($(this))) {
|
||||
selectedBroadcastZoneRow = null;
|
||||
if (window.selectedBroadcastZoneRow) {
|
||||
window.selectedBroadcastZoneRow.find('td').css('background-color', '');
|
||||
if (window.selectedBroadcastZoneRow.is($(this))) {
|
||||
window.selectedBroadcastZoneRow = null;
|
||||
$('#btnRemove').prop('disabled', true);
|
||||
$('#btnEdit').prop('disabled', true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
$(this).find('td').css('background-color', '#ffeeba');
|
||||
selectedBroadcastZoneRow = $(this);
|
||||
window.selectedBroadcastZoneRow = $(this);
|
||||
$('#btnRemove').prop('disabled', false);
|
||||
$('#btnEdit').prop('disabled', false);
|
||||
});
|
||||
@@ -60,12 +60,12 @@ function fill_broadcastzonetablebody(vv) {
|
||||
* @param {String} APIURL API URL endpoint (default "BroadcastZones/")
|
||||
*/
|
||||
function reloadBroadcastZones(APIURL = "BroadcastZones/") {
|
||||
BroadcastZoneList = [];
|
||||
window.BroadcastZoneList = [];
|
||||
fetchAPI(APIURL + "List", "GET", {}, null, (okdata) => {
|
||||
if (Array.isArray(okdata)) {
|
||||
//console.log("reloadBroadcastZones : ", okdata)
|
||||
BroadcastZoneList = okdata;
|
||||
fill_broadcastzonetablebody(BroadcastZoneList);
|
||||
window.BroadcastZoneList.push(...okdata);
|
||||
fill_broadcastzonetablebody(window.BroadcastZoneList);
|
||||
} else console.log("reloadBroadcastZones: okdata is not array");
|
||||
}, (errdata) => {
|
||||
alert("Error loading broadcast zones : " + errdata.message);
|
||||
@@ -74,7 +74,7 @@ function reloadBroadcastZones(APIURL = "BroadcastZones/") {
|
||||
|
||||
$(document).ready(function () {
|
||||
console.log("broadcastzones.js loaded successfully");
|
||||
selectedBroadcastZoneRow = null;
|
||||
window.selectedBroadcastZoneRow = null;
|
||||
let $btnClear = $('#btnClear');
|
||||
let $btnAdd = $('#btnAdd');
|
||||
let $btnEdit = $('#btnEdit');
|
||||
@@ -98,12 +98,12 @@ $(document).ready(function () {
|
||||
$findzone.on('input', function () {
|
||||
let searchTerm = $findzone.val().trim().toLowerCase();
|
||||
if (searchTerm.length > 0) {
|
||||
selectedBroadcastZoneRow = null;
|
||||
let filtered = broadcastzonedata.filter(item => item.description.toLowerCase().includes(searchTerm) || item.box.toLowerCase().includes(searchTerm) || item.soundChannel.toLowerCase().includes(searchTerm) || item.relay.toLowerCase().includes(searchTerm));
|
||||
window.selectedBroadcastZoneRow = null;
|
||||
let filtered = window.BroadcastZoneList.filter(item => item.description.toLowerCase().includes(searchTerm) || item.id.toLowerCase().includes(searchTerm) || item.soundChannel.toLowerCase().includes(searchTerm) || item.bp.toLowerCase().includes(searchTerm));
|
||||
fill_broadcastzonetablebody(filtered);
|
||||
} else {
|
||||
selectedBroadcastZoneRow = null;
|
||||
fill_broadcastzonetablebody(broadcastzonedata);
|
||||
window.selectedBroadcastZoneRow = null;
|
||||
fill_broadcastzonetablebody(window.BroadcastZoneList);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -204,8 +204,8 @@ $(document).ready(function () {
|
||||
});
|
||||
|
||||
$btnRemove.click(() => {
|
||||
if (selectedBroadcastZoneRow) {
|
||||
let cells = selectedBroadcastZoneRow.find('td');
|
||||
if (window.selectedBroadcastZoneRow) {
|
||||
let cells = window.selectedBroadcastZoneRow.find('td');
|
||||
/** @type {BroadcastZone} */
|
||||
let bz = {
|
||||
index: cells.eq(0).text(),
|
||||
@@ -226,8 +226,8 @@ $(document).ready(function () {
|
||||
});
|
||||
|
||||
$btnEdit.click(() => {
|
||||
if (selectedBroadcastZoneRow) {
|
||||
let cells = selectedBroadcastZoneRow.find('td');
|
||||
if (window.selectedBroadcastZoneRow) {
|
||||
let cells = window.selectedBroadcastZoneRow.find('td');
|
||||
/** @type {BroadcastZone} */
|
||||
let bz = {
|
||||
index: cells.eq(0).text(),
|
||||
@@ -236,15 +236,15 @@ $(document).ready(function () {
|
||||
Box: cells.eq(3).text(),
|
||||
Relay: cells.eq(4).text()
|
||||
};
|
||||
if (confirm(`Are you sure to edit broadcast zone [${bz.index}] Description=${bz.description} SoundChannel=${bz.SoundChannel} Box=${bz.Box} Relay=${bz.Relay}?`)) {
|
||||
if (confirm(`Are you sure to edit broadcast zone [${bz.index}] Description=${bz.description} SoundChannel=${bz.SoundChannel} Box=${bz.id} Relay=${bz.bp}?`)) {
|
||||
$broadcastzonemodal.modal('show');
|
||||
clearBroadcastZoneModal();
|
||||
$broadcastzoneindex.val(bz.index);
|
||||
$broadcastzonedescription.val(bz.description);
|
||||
$broadcastzonesoundchannel.val(bz.SoundChannel);
|
||||
$broadcastzonebox.val(bz.Box);
|
||||
if (bz.Relay) {
|
||||
bz.Relay.split(';').forEach(relayId => {
|
||||
$broadcastzonebox.val(bz.id);
|
||||
if (bz.bp) {
|
||||
bz.bp.split(';').forEach(relayId => {
|
||||
let id = parseInt(relayId, 10);
|
||||
cbRelay(id).prop('checked', true);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user