|
|
|
|
@@ -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();
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
});
|