Skip to content

Commit

Permalink
Merge pull request #2674 from rsammelson/fix-pota-regex
Browse files Browse the repository at this point in the history
Fix POTA regex
  • Loading branch information
magicbug authored Nov 11, 2023
2 parents c5f9809 + 7ebf909 commit ba171a5
Showing 1 changed file with 120 additions and 83 deletions.
203 changes: 120 additions & 83 deletions assets/js/sections/simplefle.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,25 @@ var callsign = "";
var errors = [];
var qsoList = [];

$('#simpleFleInfoButton').click(function (event) {
var awardInfoLines = [
lang_qso_simplefle_info_ln2,
lang_qso_simplefle_info_ln3,
lang_qso_simplefle_info_ln4
];
var simpleFleInfo = "";
awardInfoLines.forEach(function (line) {
simpleFleInfo += line + "<br><br>";
});
BootstrapDialog.alert({
title: "<h4>"+lang_qso_simplefle_info_ln1+"</h4>",
message: simpleFleInfo,
});
$("#simpleFleInfoButton").click(function (event) {
var awardInfoLines = [
lang_qso_simplefle_info_ln2,
lang_qso_simplefle_info_ln3,
lang_qso_simplefle_info_ln4,
];
var simpleFleInfo = "";
awardInfoLines.forEach(function (line) {
simpleFleInfo += line + "<br><br>";
});
BootstrapDialog.alert({
title: "<h4>" + lang_qso_simplefle_info_ln1 + "</h4>",
message: simpleFleInfo,
});
});

$('#js-syntax').click(function (event) {
$('#js-syntax').prop("disabled", false);
$.ajax({
$("#js-syntax").click(function (event) {
$("#js-syntax").prop("disabled", false);
$.ajax({
url: base_url + "index.php/simplefle/displaySyntax",
type: "post",
success: function (html) {
Expand Down Expand Up @@ -133,13 +133,15 @@ function handleInput() {
var originalDate = new Date(extraQsoDate);
originalDate.setDate(originalDate.getDate() + plusCount);
extraQsoDate = originalDate.toISOString().split("T")[0];
} else if (item.match(/^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$/)) {
extraQsoDate = item;
} else if (
item.match(/^[0-2][0-9][0-5][0-9]$/)
item.match(/^\d{4}-(0[1-9]|1[0-2])-(0[1-9]|[12][0-9]|3[01])$/)
) {
extraQsoDate = item;
} else if (item.match(/^[0-2][0-9][0-5][0-9]$/)) {
qsotime = item;
} else if (item.match(/^CW$|^SSB$|^LSB$|^USB$|^FM$|^AM$|^PSK$|^FT8$/i)) {
} else if (
item.match(/^CW$|^SSB$|^LSB$|^USB$|^FM$|^AM$|^PSK$|^FT8$/i)
) {
mode = item.toUpperCase();
} else if (
item.match(/^[0-9]{1,4}(?:m|cm|mm)$/) ||
Expand All @@ -164,13 +166,13 @@ function handleInput() {
qsotime = qsotime.slice(0, -2) + item;
} else if (
item.match(
/^[A-Z0-9]{1,3}\/[A-Z]{2}-\d{3}|[AENOS]*[FNSUACA]-\d{3}|(?!.*FF)[A-Z0-9]{1,3}-\d{4}|[A-Z0-9]{1,3}[F]{2}-\d{4}$/i
/^[A-Z0-9]{1,3}\/[A-Z]{2}-\d{3}|[AENOS]*[FNSUACA]-\d{3}|(?!.*FF)[A-Z0-9]{1,3}-\d{4,5}|[A-Z0-9]{1,3}[F]{2}-\d{4}$/i,
)
) {
sotaWwff = item.toUpperCase();
} else if (
item.match(
/([a-zA-Z0-9]{1,3}[0123456789][a-zA-Z0-9]{0,3}[a-zA-Z])|.*\/([a-zA-Z0-9]{1,3}[0123456789][a-zA-Z0-9]{0,3}[a-zA-Z])|([a-zA-Z0-9]{1,3}[0123456789][a-zA-Z0-9]{0,3}[a-zA-Z])\/.*/
/([a-zA-Z0-9]{1,3}[0-9][a-zA-Z0-9]{0,3}[a-zA-Z])|.*\/([a-zA-Z0-9]{1,3}[0-9][a-zA-Z0-9]{0,3}[a-zA-Z])|([a-zA-Z0-9]{1,3}[0-9][a-zA-Z0-9]{0,3}[a-zA-Z])\/.*/,
)
) {
callsign = item.toUpperCase();
Expand Down Expand Up @@ -206,7 +208,9 @@ function handleInput() {
}

if (isValidDate(extraQsoDate) === false) {
addErrorMessage(lang_qso_simplefle_error_date + " " + extraQsoDate);
addErrorMessage(
lang_qso_simplefle_error_date + " " + extraQsoDate,
);
extraQsoDate = qsodate;
}

Expand Down Expand Up @@ -251,14 +255,38 @@ function handleInput() {

$("#qsoTable > tbody:last-child").append(tableRow);

localStorage.setItem(`user_${user_id}_tabledata`, $("#qsoTable").html());
localStorage.setItem(`user_${user_id}_my-call`, $("#station-call").val());
localStorage.setItem(`user_${user_id}_operator`, $("#operator").val());
localStorage.setItem(`user_${user_id}_my-sota-wwff`, $("#my-sota-wwff").val());
localStorage.setItem(`user_${user_id}_qso-area`, $(".qso-area").val());
localStorage.setItem(`user_${user_id}_qsodate`, $("#qsodate").val());
localStorage.setItem(`user_${user_id}_my-power`, $("#my-power").val());
localStorage.setItem(`user_${user_id}_my-grid`, $("#my-grid").val());
localStorage.setItem(
`user_${user_id}_tabledata`,
$("#qsoTable").html(),
);
localStorage.setItem(
`user_${user_id}_my-call`,
$("#station-call").val(),
);
localStorage.setItem(
`user_${user_id}_operator`,
$("#operator").val(),
);
localStorage.setItem(
`user_${user_id}_my-sota-wwff`,
$("#my-sota-wwff").val(),
);
localStorage.setItem(
`user_${user_id}_qso-area`,
$(".qso-area").val(),
);
localStorage.setItem(
`user_${user_id}_qsodate`,
$("#qsodate").val(),
);
localStorage.setItem(
`user_${user_id}_my-power`,
$("#my-power").val(),
);
localStorage.setItem(
`user_${user_id}_my-grid`,
$("#my-grid").val(),
);

callsign = "";
sotaWwff = "";
Expand All @@ -272,7 +300,14 @@ function handleInput() {

var qsoCount = qsoList.length;
if (qsoCount) {
$(".js-qso-count").html("<strong>" + lang_qso_simplefle_qso_list_total + ":</strong> " + qsoCount + " " + lang_gen_hamradio_qso);
$(".js-qso-count").html(
"<strong>" +
lang_qso_simplefle_qso_list_total +
":</strong> " +
qsoCount +
" " +
lang_gen_hamradio_qso,
);
} else {
$(".js-qso-count").html("");
}
Expand All @@ -283,31 +318,31 @@ function handleInput() {
}

function checkMainFieldsErrors() {
if ($("#station-call").val() === '-') {
$('#warningStationCall').show();
$('#station-call').css('border', '2px solid rgb(217, 83, 79)');
$('#warningStationCall').text(lang_qso_simplefle_error_stationcall);
if ($("#station-call").val() === "-") {
$("#warningStationCall").show();
$("#station-call").css("border", "2px solid rgb(217, 83, 79)");
$("#warningStationCall").text(lang_qso_simplefle_error_stationcall);
} else {
$('#station-call').css('border', '');
$('#warningStationCall').hide();
}
$("#station-call").css("border", "");
$("#warningStationCall").hide();
}

if ($("#operator").val() === "") {
$('#warningOperatorField').show();
$('#operator').css('border', '2px solid rgb(217, 83, 79)');
$('#warningOperatorField').text(lang_qso_simplefle_error_operator);
}else {
$('#operator').css('border', '');
$('#warningOperatorField').hide();
}
$("#warningOperatorField").show();
$("#operator").css("border", "2px solid rgb(217, 83, 79)");
$("#warningOperatorField").text(lang_qso_simplefle_error_operator);
} else {
$("#operator").css("border", "");
$("#warningOperatorField").hide();
}
if ($("textarea").val() === "") {
$('#textarea').css('border', '2px solid rgb(217, 83, 79)');
setTimeout(function() {
$('#textarea').css('border', '');
}, 2000);
}else {
$('#textarea').css('border', '');
}
$("#textarea").css("border", "2px solid rgb(217, 83, 79)");
setTimeout(function () {
$("#textarea").css("border", "");
}, 2000);
} else {
$("#textarea").css("border", "");
}
}

$textarea.keydown(function (event) {
Expand Down Expand Up @@ -382,7 +417,6 @@ $(".js-download-qso").click(function () {
handleInput();
});


function getBandFromFreq(freq) {
if (freq > 1.7 && freq < 2) {
return "160m";
Expand Down Expand Up @@ -421,14 +455,18 @@ function getFreqFromBand(band, mode) {
var bandData = Bands[settingsBand];

if (bandData) {
return bandData[settingsMode] / 1000000;
}


return bandData[settingsMode] / 1000000;
}
}

function getSettingsMode(mode) {
if (mode === "AM" || mode === "FM" || mode === "SSB" || mode === "LSB" || mode === "USB") {
if (
mode === "AM" ||
mode === "FM" ||
mode === "SSB" ||
mode === "LSB" ||
mode === "USB"
) {
return "SSB";
}

Expand All @@ -451,23 +489,23 @@ for (const [key, value] of Object.entries(Bands)) {
<div class="form-group">
<label for="${key.slice(1)}CW">CW</label>
<input type="text" class="form-control text-uppercase" id="${key.slice(
1
1,
)}CW" value="${value.cw}">
</div>
</div>
<div class="col-3">
<div class="form-group">
<label for="${key.slice(1)}SSB">SSB</label>
<input type="text" class="form-control text-uppercase" id="${key.slice(
1
1,
)}SSB" value="${value.ssb}">
</div>
</div>
<div class="col-3">
<div class="form-group">
<label for="${key.slice(1)}DIGI">DIGI</label>
<input type="text" class="form-control text-uppercase" id="${key.slice(
1
1,
)}DIGI" value="${value.digi}">
</div>
</div>
Expand Down Expand Up @@ -503,10 +541,8 @@ function isExampleDataEntered() {
let isExampleData = false;
if (textarea.value.startsWith("*example-data*")) {
isExampleData = true;

};
}
return isExampleData;

}

function getAdifTag(tagName, value) {
Expand Down Expand Up @@ -559,7 +595,7 @@ function isIOTA(value) {
}

function isPOTA(value) {
if (value.match(/^(?!.*FF)[A-Z0-9]{1,3}-\d{4}$/)) {
if (value.match(/^(?!.*FF)[A-Z0-9]{1,3}-\d{4,5}$/)) {
return true;
}
}
Expand All @@ -572,7 +608,6 @@ function isWWFF(value) {
return false;
}


$(document).ready(function () {
setInterval(updateUTCTime, 1000);
updateUTCTime();
Expand Down Expand Up @@ -621,10 +656,10 @@ $(document).ready(function () {

$(".js-save-to-log").click(function () {
if ($("textarea").val() === "") {
$('#textarea').css('border', '2px solid rgb(217, 83, 79)');
setTimeout(function() {
$('#textarea').css('border', '');
}, 2000);
$("#textarea").css("border", "2px solid rgb(217, 83, 79)");
setTimeout(function () {
$("#textarea").css("border", "");
}, 2000);
return false;
}
if (false === isBandModeEntered()) {
Expand Down Expand Up @@ -659,13 +694,11 @@ $(".js-save-to-log").click(function () {
btnOKClass: "btn-warning",
});
return false;
}
else {
} else {
handleInput();
BootstrapDialog.confirm({
title: lang_general_word_attention,
message:
lang_qso_simplefle_confirm_save_to_log,
message: lang_qso_simplefle_confirm_save_to_log,
type: BootstrapDialog.TYPE_INFO,
btnCancelLabel: lang_general_word_cancel,
btnOKLabel: lang_general_word_ok,
Expand All @@ -686,15 +719,20 @@ $(".js-save-to-log").click(function () {
var rst_rcvd = item[7];
var rst_sent = item[6];
var start_date = item[0];
var start_time = item[1][0] + item[1][1] + ":" + item[1][2] + item[1][3];
var start_time =
item[1][0] +
item[1][1] +
":" +
item[1][2] +
item[1][3];
var band = item[4];
var mode = item[5];
var freq_display = item[3] * 1000000;
var station_profile = $(".station_id").val();
var sota_ref = '';
var iota_ref = '';
var pota_ref = '';
var wwff_ref = '';
var sota_ref = "";
var iota_ref = "";
var pota_ref = "";
var wwff_ref = "";
if (isSOTA(item[8])) {
sota_ref = item[8];
} else if (isIOTA(item[8])) {
Expand Down Expand Up @@ -730,8 +768,7 @@ $(".js-save-to-log").click(function () {
clearSession();
BootstrapDialog.alert({
title: lang_qso_simplefle_success_save_to_log_header,
message:
lang_qso_simplefle_success_save_to_log,
message: lang_qso_simplefle_success_save_to_log,
});
}
},
Expand Down

0 comments on commit ba171a5

Please sign in to comment.