From b24c153615f3232952debf43d2e332c59d607c69 Mon Sep 17 00:00:00 2001 From: rdkartono Date: Thu, 6 Nov 2025 11:31:02 +0700 Subject: [PATCH] commit 06/11/2025 --- html/semiauto/assets/css/style.css | 10 + html/semiauto/assets/js/custom.js | 320 +++++++++++++++++++++----- html/semiauto/index.html | 18 +- html/webpage/overview.html | 2 +- libs/linux-aarch64/libbassenc_mp3.so | Bin 0 -> 134280 bytes libs/linux-aarch64/libbassenc_ogg.so | Bin 0 -> 773816 bytes libs/linux-aarch64/libbassenc_opus.so | Bin 0 -> 217624 bytes libs/linux-armhf/libbassenc_mp3.so | Bin 0 -> 126932 bytes libs/linux-armhf/libbassenc_ogg.so | Bin 0 -> 657348 bytes libs/linux-armhf/libbassenc_opus.so | Bin 0 -> 228088 bytes libs/linux-x86-64/libbassenc_mp3.so | Bin 0 -> 140856 bytes libs/linux-x86-64/libbassenc_ogg.so | Bin 0 -> 816440 bytes libs/linux-x86-64/libbassenc_opus.so | Bin 0 -> 229512 bytes libs/linux-x86/libbassenc_mp3.so | Bin 0 -> 149820 bytes libs/linux-x86/libbassenc_ogg.so | Bin 0 -> 692800 bytes libs/linux-x86/libbassenc_opus.so | Bin 0 -> 234264 bytes libs/win32-arm64/bass.dll | Bin 265264 -> 0 bytes libs/win32-arm64/bassenc.dll | Bin 62512 -> 0 bytes libs/win32-x86-64/bassenc_mp3.dll | Bin 0 -> 92216 bytes libs/win32-x86-64/bassenc_ogg.dll | Bin 0 -> 183664 bytes libs/win32-x86-64/bassenc_opus.dll | Bin 0 -> 166496 bytes libs/win32-x86/bassenc_mp3.dll | Bin 0 -> 79784 bytes libs/win32-x86/bassenc_ogg.dll | Bin 0 -> 172768 bytes libs/win32-x86/bassenc_opus.dll | Bin 0 -> 148432 bytes src/MainExtension01.kt | 2 +- src/audio/AudioPlayer.kt | 8 +- src/audio/BassEnc.java | 6 +- src/audio/BassEncMP3.java | 13 ++ src/audio/BassEncOGG.java | 15 ++ src/audio/BassEncOpus.java | 18 ++ src/audio/Mp3Encoder.kt | 126 ++++++++++ src/audio/OpusEncoder.kt | 127 ++++++++++ src/barix/BarixConnection.kt | 50 ++-- src/web/WebApp.kt | 178 ++++++++------ 34 files changed, 719 insertions(+), 174 deletions(-) create mode 100644 libs/linux-aarch64/libbassenc_mp3.so create mode 100644 libs/linux-aarch64/libbassenc_ogg.so create mode 100644 libs/linux-aarch64/libbassenc_opus.so create mode 100644 libs/linux-armhf/libbassenc_mp3.so create mode 100644 libs/linux-armhf/libbassenc_ogg.so create mode 100644 libs/linux-armhf/libbassenc_opus.so create mode 100644 libs/linux-x86-64/libbassenc_mp3.so create mode 100644 libs/linux-x86-64/libbassenc_ogg.so create mode 100644 libs/linux-x86-64/libbassenc_opus.so create mode 100644 libs/linux-x86/libbassenc_mp3.so create mode 100644 libs/linux-x86/libbassenc_ogg.so create mode 100644 libs/linux-x86/libbassenc_opus.so delete mode 100644 libs/win32-arm64/bass.dll delete mode 100644 libs/win32-arm64/bassenc.dll create mode 100644 libs/win32-x86-64/bassenc_mp3.dll create mode 100644 libs/win32-x86-64/bassenc_ogg.dll create mode 100644 libs/win32-x86-64/bassenc_opus.dll create mode 100644 libs/win32-x86/bassenc_mp3.dll create mode 100644 libs/win32-x86/bassenc_ogg.dll create mode 100644 libs/win32-x86/bassenc_opus.dll create mode 100644 src/audio/BassEncMP3.java create mode 100644 src/audio/BassEncOGG.java create mode 100644 src/audio/BassEncOpus.java create mode 100644 src/audio/Mp3Encoder.kt create mode 100644 src/audio/OpusEncoder.kt diff --git a/html/semiauto/assets/css/style.css b/html/semiauto/assets/css/style.css index 933b7d3..4fdee9a 100644 --- a/html/semiauto/assets/css/style.css +++ b/html/semiauto/assets/css/style.css @@ -344,6 +344,16 @@ th, td { color: #fff; } +.btn-disable { + color: white; + background-color: var(--bs-red); +} + +.btn-enable { + color: white; + background-color: #36d636; +} + .btn-logout { background-color: #4280ab; color: #fff; diff --git a/html/semiauto/assets/js/custom.js b/html/semiauto/assets/js/custom.js index f24c080..3ae64f0 100644 --- a/html/semiauto/assets/js/custom.js +++ b/html/semiauto/assets/js/custom.js @@ -28,8 +28,7 @@ let $input_gatenumber = null; let $input_flightnumber = null; let $input_licenseplate = null; let $input_conveyorbelt = null; -let $input_hours = null; -let $input_minutes = null; +let $input_etad = null; let $row_airplane = null; let $row_city = null; @@ -42,6 +41,11 @@ let $col_conveyorbelt = null; let $col_procedure = null; let $col_licenseplate = null; +/** + * @type {message[]} + */ +let selected_messages = []; + /** * @typedef {Object} message * @property {number} id - The ID of the message @@ -438,8 +442,8 @@ function reload_database() { }); } -function empty_preview(){ - $preview_arabic.empty(); +function empty_preview() { + $preview_arabic.empty(); $preview_chinese.empty(); $preview_english.empty(); $preview_indonesia.empty(); @@ -455,7 +459,7 @@ function empty_preview(){ } -function enable_disable_fields(){ +function enable_disable_fields() { $row_airplane.hide(); $row_city.hide(); $row_gatenumber.hide(); @@ -469,10 +473,10 @@ function enable_disable_fields(){ // show airplane row if English preview contains the placeholder const text = $preview_english.text() || ""; - if (text.indexOf('[CITY]') !== -1) $row_city.show(); - if (text.indexOf('[AIRPLANE_NAME]') !== -1) $row_airplane.show(); - if (text.indexOf('[FLIGHT_NUMBER]') !== -1) $row_airplane.show(); - if (text.indexOf('[GATENUMBER]') !== -1) $row_gatenumber.show(); + if (text.indexOf('[CITY]') !== -1) $row_city.show(); + if (text.indexOf('[AIRPLANE_NAME]') !== -1) $row_airplane.show(); + if (text.indexOf('[FLIGHT_NUMBER]') !== -1) $row_airplane.show(); + if (text.indexOf('[GATENUMBER]') !== -1) $row_gatenumber.show(); if (text.indexOf('[ETAD]') !== -1) $row_time.show(); if (text.indexOf('[REASON]') !== -1) $col_reason.show(); if (text.indexOf('[PLACES]') !== -1) $col_places.show(); @@ -482,76 +486,140 @@ function enable_disable_fields(){ if (text.indexOf('[PLATNOMOR]') !== -1) $col_licenseplate.show(); } -function update_preview(language){ +function ValidString(str) { + return (str != null && typeof str === 'string' && str.trim().length > 0); +} + +function update_preview(language) { let text = ""; let $preview = null; if (language === "indonesia") { $preview = $preview_indonesia; + text = selected_messages.find(m => (m.language || "").toLowerCase() === "indonesia")?.message_details || ""; } else if (language === "english") { $preview = $preview_english; + text = selected_messages.find(m => (m.language || "").toLowerCase() === "english")?.message_details || ""; } else if (language === "chinese") { $preview = $preview_chinese; + text = selected_messages.find(m => (m.language || "").toLowerCase() === "chinese")?.message_details || ""; } else if (language === "japanese") { $preview = $preview_japanese; + text = selected_messages.find(m => (m.language || "").toLowerCase() === "japanese")?.message_details || ""; } else if (language === "arabic") { $preview = $preview_arabic; + text = selected_messages.find(m => (m.language || "").toLowerCase() === "arabic")?.message_details || ""; } else if (language === "local") { $preview = $preview_local; + text = selected_messages.find(m => (m.language || "").toLowerCase() === "local")?.message_details || ""; } - if ($preview) { - text = $preview.text(); - } + if (text.indexOf('[CITY]') !== -1) { let cities = $select_city.val(); - if (Array.isArray(cities)) { - text = text.replace(/\[CITY\]/g, cities.join(", ")); - } else { - text = text.replace(/\[CITY\]/g, cities || ""); + if (Array.isArray(cities) && cities.length > 0) { + let citiesNames = []; + for (let cityTag of cities) { + let ct = window.semiautodata.cities.find(c => c.tag === cityTag); + if (ct) { + citiesNames.push(ct.value); + } + } + if (citiesNames.length > 0) { + text = text.replace(/\[CITY\]/g, citiesNames.join(", ")); + } } } if (text.indexOf('[AIRPLANE_NAME]') !== -1) { - let airlineTag = $select_airline.val() || ""; - let airlineObj = window.semiautodata.airlines.find(a => a.tag === airlineTag); - let airlineName = airlineObj ? airlineObj.value : ""; - text = text.replace(/\[AIRPLANE_NAME\]/g, airlineName); + let airlineTag = $select_airline.val(); + if (ValidString(airlineTag)) { + let airlineObj = window.semiautodata.airlines.find(a => a.tag === airlineTag); + let airlineName = airlineObj ? airlineObj.value : ""; + if (airlineName.length > 0) { + text = text.replace(/\[AIRPLANE_NAME\]/g, airlineName); + } + } } if (text.indexOf('[FLIGHT_NUMBER]') !== -1) { - let flightNumber = $input_flightnumber.val() || ""; - text = text.replace(/\[FLIGHT_NUMBER\]/g, flightNumber); + let airlineTag = $select_airline.val(); + let flightNumber = $input_flightnumber.val(); + if (ValidString(airlineTag) && ValidString(flightNumber)) { + text = text.replace(/\[FLIGHT_NUMBER\]/g, `${airlineTag} ${flightNumber}`); + } } if (text.indexOf('[GATENUMBER]') !== -1) { - let gateNumber = $input_gatenumber.val() || ""; - text = text.replace(/\[GATENUMBER\]/g, gateNumber); + let gateNumber = $input_gatenumber.val(); + if (ValidString(gateNumber)) { + text = text.replace(/\[GATENUMBER\]/g, gateNumber); + } } if (text.indexOf('[ETAD]') !== -1) { - let etad = $input_etad.val() || ""; - text = text.replace(/\[ETAD\]/g, etad); + let etad = $input_etad.val(); + if (ValidString(etad)) { + text = text.replace(/\[ETAD\]/g, etad); + } } if (text.indexOf('[REASON]') !== -1) { - let reason = $select_reason.val() || ""; - text = text.replace(/\[REASON\]/g, reason); + let reason = $select_reason.val(); + if (ValidString(reason)) { + let reasonobj = window.semiautodata.reasons.find(r => r.tag === reason); + let reasontext = reasonobj ? reasonobj.value : ""; + if (ValidString(reasontext)) { + text = text.replace(/\[REASON\]/g, reasontext); + } + } } if (text.indexOf('[PLACES]') !== -1) { - let placeTag = $select_places.val() || ""; - text = text.replace(/\[PLACES\]/g, placeTag); + let placeTag = $select_places.val(); + if (ValidString(placeTag)) { + let placeobj = window.semiautodata.places.find(p => p.tag === placeTag); + let placetext = placeobj ? placeobj.value : ""; + if (ValidString(placetext)) { + text = text.replace(/\[PLACES\]/g, placetext); + } + } } if (text.indexOf('[SHALAT]') !== -1) { - let shalatTag = $select_shalat.val() || ""; - text = text.replace(/\[SHALAT\]/g, shalatTag); + let shalatTag = $select_shalat.val(); + if (ValidString(shalatTag)) { + let shalatobj = window.semiautodata.shalat.find(s => s.tag === shalatTag); + let shalattext = shalatobj ? shalatobj.value : ""; + if (ValidString(shalattext)) { + text = text.replace(/\[SHALAT\]/g, shalattext); + } + } } if (text.indexOf('[BCB]') !== -1) { - let bcbTag = $select_bcb.val() || ""; - text = text.replace(/\[BCB\]/g, bcbTag); + let bcbTag = $select_bcb.val(); + if (ValidString(bcbTag)) { + text = text.replace(/\[BCB\]/g, bcbTag); + } } if (text.indexOf('[PROCEDURE]') !== -1) { - let procedureTag = $select_procedure.val() || ""; - text = text.replace(/\[PROCEDURE\]/g, procedureTag); + let procedureTag = $select_procedure.val(); + if (ValidString(procedureTag)) { + let procedureobj = window.semiautodata.procedures.find(p => p.tag === procedureTag); + let proceduretext = procedureobj ? procedureobj.value : ""; + if (ValidString(proceduretext)) { + text = text.replace(/\[PROCEDURE\]/g, proceduretext); + } + } } if (text.indexOf('[PLATNOMOR]') !== -1) { - let platNomorTag = $select_licenseplate.val() || ""; - text = text.replace(/\[PLATNOMOR\]/g, platNomorTag); + let platNomorTag = $select_licenseplate.val(); + if (ValidString(platNomorTag)) { + text = text.replace(/\[PLATNOMOR\]/g, platNomorTag); + } + } + if (text.indexOf('[SEQUENCE]') !== -1) { + let sequenceTag = $select_sequence.val(); + if (ValidString(sequenceTag)) { + let sequenceobj = window.semiautodata.sequences.find(s => s.tag === sequenceTag); + let sequencetext = sequenceobj ? sequenceobj.value : ""; + if (ValidString(sequencetext)) { + text = text.replace(/\[SEQUENCE\]/g, sequencetext); + } + } } if ($preview) { @@ -559,13 +627,45 @@ function update_preview(language){ } } -function update_all_previews(){ +function isComplete(chkbox, preview) { + if (chkbox.is(":checked")) { + const text = preview.text(); + if (text.indexOf('[') !== -1) { + return false; + } + if (text.indexOf(']') !== -1) { + return false; + } + } + return true; +} + +function check_complete_message() { + let complete = true; + if (!isComplete($enable_indonesia, $preview_indonesia)) complete = false; + if (!isComplete($enable_english, $preview_english)) complete = false; + if (!isComplete($enable_chinese, $preview_chinese)) complete = false; + if (!isComplete($enable_japanese, $preview_japanese)) complete = false; + if (!isComplete($enable_arabic, $preview_arabic)) complete = false; + if (!isComplete($enable_local, $preview_local)) complete = false; + + if (complete) { + $("#send_broadcast").removeClass("btn-disable").addClass("btn-enable"); + } else { + $("#send_broadcast").removeClass("btn-enable").addClass("btn-disable"); + } + +} + +function update_all_previews() { update_preview("indonesia"); update_preview("english"); update_preview("chinese"); update_preview("japanese"); update_preview("arabic"); update_preview("local"); + + check_complete_message(); } function fill_items() { @@ -584,8 +684,7 @@ function fill_items() { $input_flightnumber.empty(); $input_licenseplate.empty(); $input_conveyorbelt.empty(); - $input_hours.empty(); - $input_minutes.empty(); + $input_etad.empty(); empty_preview(); @@ -623,17 +722,17 @@ function fill_items() { $enable_indonesia.prop("checked", !!checked); return true; } - if (l.startsWith("english") ) { + if (l.startsWith("english")) { if (checked) $preview_english.text(value); else $preview_english.empty(); $enable_english.prop("checked", !!checked); return true; } - if (l.startsWith("chinese") ) { + if (l.startsWith("chinese")) { if (checked) $preview_chinese.text(value); else $preview_chinese.empty(); $enable_chinese.prop("checked", !!checked); return true; } - if (l.startsWith("japanese") ) { + if (l.startsWith("japanese")) { if (checked) $preview_japanese.text(value); else $preview_japanese.empty(); $enable_japanese.prop("checked", !!checked); return true; @@ -660,6 +759,7 @@ function fill_items() { } } + selected_messages = []; if (willSelect) { // unselect other selected rows and clear their previews $tbody_message.find("tr.table-active").each(function () { @@ -676,8 +776,10 @@ function fill_items() { const sameMsgs = window.semiautodata.messages.filter(m => Number(m.id) === Number(groupId)); for (let m of sameMsgs) { applyLang(m.language, m.message_details, true); + selected_messages.push(m); } enable_disable_fields(); + update_all_previews(); } } else { // deselect this row and clear its previews @@ -711,7 +813,7 @@ function fill_items() { multiple: false }); $select_airline.val(null).trigger("change"); - + $select_airline.on('change', function () { update_all_previews(); }); @@ -742,21 +844,21 @@ function fill_items() { placeholder: "Select a place", width: '100%', multiple: false, - data: window.semiautodata.places.map(p => ({ id: p.tag, text: p.value })) + data: window.semiautodata.places.map(p => ({ id: p.tag, text: p.value + " [" + p.tag + "]" })) }); - + $select_places.val(null).trigger("change"); $select_places.on('change', function () { update_all_previews(); }); } if (window.semiautodata.shalat !== null && Array.isArray(window.semiautodata.shalat) && window.semiautodata.shalat.length > 0) { - + $select_shalat.select2({ placeholder: "Select shalat time", width: '100%', multiple: false, - data: window.semiautodata.shalat.map(s => ({ id: s.tag, text: s.value })) + data: window.semiautodata.shalat.map(s => ({ id: s.tag, text: s.value + " [" + s.tag + "]" })) }); $select_shalat.val(null).trigger("change"); } @@ -765,20 +867,20 @@ function fill_items() { placeholder: "Select a reason", width: '100%', multiple: false, - data: window.semiautodata.reasons.map(r => ({ id: r.tag, text: r.value })) + data: window.semiautodata.reasons.map(r => ({ id: r.tag, text: r.value + " [" + r.tag + "]" })) }); $select_reason.val(null).trigger("change"); $select_reason.on('change', function () { update_all_previews(); }); } - + if (window.semiautodata.compensation !== null && Array.isArray(window.semiautodata.compensation) && window.semiautodata.compensation.length > 0) { $select_compensation.select2({ placeholder: "Select compensation", width: '100%', multiple: false, - data: window.semiautodata.compensation.map(c => ({ id: c.tag, text: c.value })) + data: window.semiautodata.compensation.map(c => ({ id: c.tag, text: c.value + " [" + c.tag + "]" })) }); $select_compensation.val(null).trigger("change"); $select_compensation.on('change', function () { @@ -790,7 +892,7 @@ function fill_items() { placeholder: "Select procedure", width: '100%', multiple: false, - data: window.semiautodata.procedures.map(p => ({ id: p.tag, text: p.value })) + data: window.semiautodata.procedures.map(p => ({ id: p.tag, text: p.value + " [" + p.tag + "]" })) }); $select_procedure.val(null).trigger("change"); $select_procedure.on('change', function () { @@ -813,11 +915,112 @@ function fill_items() { $input_licenseplate.on('input', function () { update_all_previews(); }); - + + $input_etad.on('input', function () { + update_all_previews(); + }); + + + } } +function send_broadcast_message() { + console.log("send_broadcast_message"); + if ($("#send_broadcast").hasClass("btn-disable")) { + alert("Cannot send broadcast message. Please complete all required fields."); + return; + } + // get all checked broadcast zones from tbody_broadcastzones + let selected_zones = []; + $tbody_broadcastzones.find("input[type='checkbox']").each(function () { + const $checkbox = $(this); + if ($checkbox.is(":checked")) { + selected_zones.push($checkbox.val()); + } + }); + + if (selected_zones.length === 0) { + alert("Please select at least one broadcast zone."); + return; + } + + let languages = []; + if ($enable_indonesia.is(":checked")) languages.push("INDONESIA"); + if ($enable_english.is(":checked")) languages.push("ENGLISH"); + if ($enable_chinese.is(":checked")) languages.push("CHINESE"); + if ($enable_japanese.is(":checked")) languages.push("JAPANESE"); + if ($enable_arabic.is(":checked")) languages.push("ARABIC"); + if ($enable_local.is(":checked")) languages.push("LOCAL"); + + if (languages.length === 0) { + alert("Please select at least one language to send."); + return; + } + + let description = selected_messages.length > 0 ? selected_messages[0].description : ""; + if (!ValidString(description)) { + alert("Message not selected"); + return; + } + + let tags = []; + let msg = selected_messages[0]; + tags.push("ANN_ID:"+msg.id); + if (msg.message_details.indexOf('[CITY]') !== -1) { + let cities = $select_city.val(); + if (Array.isArray(cities) && cities.length > 0) { + tags.push("CITY:" + cities.join(";")); + } + } + if (msg.message_details.indexOf('[AIRPLANE_NAME]') !== -1) { + tags.push("AL:" + $select_airline.val()); + } + if (msg.message_details.indexOf('[FLIGHT_NUMBER]') !== -1) { + tags.push("FLNUM:" + $input_flightnumber.val()); + } + if (msg.message_details.indexOf('[PLATNOMOR]') !== -1) { + tags.push("PLATNOMOR:" + $input_licenseplate.val()); + } + if (msg.message_details.indexOf('[PLACES]') !== -1) { + tags.push("PLACES:" + $select_places.val()); + } + if (msg.message_details.indexOf('[ETAD]') !== -1) { + tags.push("ETAD:" + $input_etad.val()); + } + if (msg.message_details.indexOf('[SHALAT]') !== -1) { + tags.push("SHALAT:" + $select_shalat.val()); + } + if (msg.message_details.indexOf('[BCB]') !== -1) { + tags.push("BCB:" + $input_conveyorbelt.val()); + } + if (msg.message_details.indexOf('[GATENUMBER]') !== -1) { + tags.push("GATECODE:" + $input_gatenumber.val()); + } + if (msg.message_details.indexOf('[REASON]') !== -1) { + tags.push("REASON:" + $select_reason.val()); + } + if (msg.message_details.indexOf('[PROCEDURE]') !== -1) { + tags.push("PROCEDURE:" + $select_procedure.val()); + } + + let payload = { + description: description, + languages: languages.join(";"), + tags: tags.join(" "), + broadcastzones: selected_zones.join(";") + } + console.log("Payload:", payload); + fetchAPI("SemiAuto", "POST", {}, payload, (data) => { + alert("Broadcast message sent successfully."); + }, (error) => { + console.error("Error:", error); + alert("Error sending broadcast message: " + error); + }); + +} + // App start here $(document).ready(function () { console.log("javascript loaded"); @@ -846,8 +1049,7 @@ $(document).ready(function () { $input_flightnumber = $("#input_flightnumber"); $input_licenseplate = $("#input_licenseplate"); $input_conveyorbelt = $("#input_conveyorbelt"); - $input_hours = $("#input_hours"); - $input_minutes = $("#input_minutes"); + $input_etad = $("#input_etad"); $row_airplane = $("#row_airplane"); $row_city = $("#row_city"); $row_gatenumber = $("#row_gatenumber"); @@ -864,5 +1066,9 @@ $(document).ready(function () { reload_database(); }); + $("#send_broadcast").off("click").on("click", function () { + send_broadcast_message(); + }); + }); \ No newline at end of file diff --git a/html/semiauto/index.html b/html/semiauto/index.html index 559d47d..9fc0744 100644 --- a/html/semiauto/index.html +++ b/html/semiauto/index.html @@ -110,7 +110,7 @@
-
+
@@ -123,18 +123,8 @@
-
-
-
-
-
-
-
-
-
-
-
-
+
+
@@ -236,7 +226,7 @@  Reload Database
-
-