diff --git a/ui/general/mavlink.js b/ui/general/mavlink.js index c5d3d30..9e5513c 100644 --- a/ui/general/mavlink.js +++ b/ui/general/mavlink.js @@ -32,26 +32,26 @@ enabled = true; // Runs the initPage when the document is loaded document.onload = InitPage(); // Save file button -document.getElementById("save").addEventListener("click", SaveSettings); +document.getElementById("save").addEventListener("click", saveSettings); // This attempts to read the conf file, if it exists, then it will parse it and fill out the table // if it fails then the values are loaded with defaults. function InitPage() { cockpit.script(scriptLocation + "cockpitScript.sh -v") .then((content) => version.innerHTML=content) - .catch(error => Fail(error)); + .catch(error => displayFail(error)); cockpit.script(scriptLocation + "cockpitScript.sh -u") .then(function(content) { ipsubnet1.innerHTML=content; ipsubnet2.innerHTML=content; }) - .catch(error => Fail(error)); + .catch(error => displayFail(error)); file_location.innerHTML = confLocation + "main.conf"; cockpit.file(confLocation + "main.conf") .read().then((content, tag) => SuccessReadFile(content)) - .catch(error => FailureReadFile(error)); + .catch(error => failureReadFile(error)); } function getValueByKey(text, sectionName, sectionLength, key) { @@ -158,7 +158,7 @@ function SuccessReadFile(content) { var currentbaudRate = getValueByKey(content, "[UartEndpoint alpha]", 2, "Baud"); cockpit.script(scriptLocation + "cockpitScript.sh -s") .then((content) => AddDropDown(fmuDevice, content.split("\n"), currentfmuDevice)) - .catch(error => Fail(error)); + .catch(error => displayFail(error)); AddDropDown(baudrate, baudRateArray, currentbaudRate); //UDP Telemetry @@ -225,7 +225,7 @@ function SuccessReadFile(content) { } } catch(e) { - FailureReadFile(e); + failureReadFile(e); } } @@ -249,11 +249,11 @@ function AddDropDown(box, theArray, defaultValue) { } } catch(e) { - Fail(e) + displayFail(e) } } -function FailureReadFile(error) { +function failureReadFile(error) { // Display error message console.log("Error : " + error.message); output.innerHTML = "Error : " + error.message; @@ -267,7 +267,7 @@ function FailureReadFile(error) { } -function SaveSettings() { +function saveSettings() { //lets do some validation @@ -306,7 +306,7 @@ function SaveSettings() { //open the file for writing, and callback function for modification cockpit.file(confLocation + "main.conf") .read().then((content, tag) => SuccessReadforSaveFile(content)) - .catch(error => FailureReadFile(error)); + .catch(error => failureReadFile(error)); } function SuccessReadforSaveFile(content) { @@ -335,23 +335,23 @@ function SuccessReadforSaveFile(content) { content = setValueByKey(content, "[UartEndpoint alpha]",2, "Baud", baudrate.value ) cockpit.file(confLocation + "main.conf", { superuser : "try" }).replace(content) - .then(Success) - .catch(Fail); + .then(displaySuccess) + .catch(displayFail); cockpit.spawn(["systemctl", "restart", "mavlink-router"], { superuser : "try" }); } catch(e) { - FailureReadFile(e); + failureReadFile(e); } } -function Success() { +function displaySuccess() { result.style.color = "green"; result.innerHTML = "Success, mavlink-router restarting..."; setTimeout(() => result.innerHTML = "", 5000); } -function Fail(error) { +function displayFail(error) { result.style.color = "red"; result.innerHTML = error.message; } diff --git a/ui/general/spirilink.html b/ui/general/spirilink.html index 891072f..1b2f2ee 100644 --- a/ui/general/spirilink.html +++ b/ui/general/spirilink.html @@ -5,7 +5,7 @@