Commit afacb3cd by UsakoSenpai

Add descriptive comments to JS code.

parent e6ceb796
// *************************************************
// * Gets Rx data from backend
// *************************************************
function updateRx(callBack, id) { function updateRx(callBack, id) {
fetch("/rx_params") fetch("/rx_params")
.then(data=>{return data.json()}) .then(data=>{return data.json()})
.then(res=>{callBack(res, id)}) .then(res=>{callBack(res, id)})
} }
// ******************************************************
// * Makes Changes to Receiver, Saves, & Refreshes Cards
// ******************************************************
function editReceivers(rx_json, id) { function editReceivers(rx_json, id) {
const receivers = rx_json['receivers']; const receivers = rx_json['receivers'];
var stationUrlHtml = var stationUrlHtml =
...@@ -92,6 +98,9 @@ function editReceivers(rx_json, id) { ...@@ -92,6 +98,9 @@ function editReceivers(rx_json, id) {
} }
} }
// ****************************************************
// * Sends Rx station URL to backend and refreshes map
// ****************************************************
function makeNewRx(url) { function makeNewRx(url) {
const new_rx = {"station_url":url}; const new_rx = {"station_url":url};
// console.log(new_rx); // console.log(new_rx);
...@@ -112,11 +121,17 @@ function makeNewRx(url) { ...@@ -112,11 +121,17 @@ function makeNewRx(url) {
// loadCzml(); // loadCzml();
} }
// *****************************************
// * Removes the Rx UI Card
// *****************************************
function removerx(uid) { function removerx(uid) {
const rxcard = document.getElementById("rx-" + uid); const rxcard = document.getElementById("rx-" + uid);
rxcard.remove(); rxcard.remove();
} }
// *******************************************
// * Removes Rx from Backend and Reloads Map
// *******************************************
function deleteReceiver(uid) { function deleteReceiver(uid) {
const del_rx = {"uid":uid}; const del_rx = {"uid":uid};
// console.log(new_rx); // console.log(new_rx);
...@@ -137,6 +152,9 @@ function deleteReceiver(uid) { ...@@ -137,6 +152,9 @@ function deleteReceiver(uid) {
// loadCzml(); // loadCzml();
} }
// *******************************************
// * Fills in Rx UI cards with Rx info
// *******************************************
function showReceivers(rx_json, id) { function showReceivers(rx_json, id) {
const receivers = rx_json['receivers']; const receivers = rx_json['receivers'];
...@@ -177,6 +195,10 @@ function showReceivers(rx_json, id) { ...@@ -177,6 +195,10 @@ function showReceivers(rx_json, id) {
} }
// ****************************************************
// * Creates cards on UI for Receiver information.
// * Iterates through Rx objects on page load/Rx add.
// ****************************************************
function createReceivers(rx_json, id) { function createReceivers(rx_json, id) {
var receivers var receivers
if (id == true) { if (id == true) {
...@@ -246,6 +268,9 @@ function createReceivers(rx_json, id) { ...@@ -246,6 +268,9 @@ function createReceivers(rx_json, id) {
} }
} }
// ****************************************************
// * Refreshes info on Rx UI Cards (Refresh button)
// ****************************************************
function refreshRx(rx_json, id) { function refreshRx(rx_json, id) {
const receivers = rx_json['receivers']; const receivers = rx_json['receivers'];
for (let i = 0; i < Object.keys(receivers).length; i++) { for (let i = 0; i < Object.keys(receivers).length; i++) {
...@@ -253,6 +278,9 @@ function refreshRx(rx_json, id) { ...@@ -253,6 +278,9 @@ function refreshRx(rx_json, id) {
} }
} }
// ****************************************************
// * Main function - Loads all Receivers
// ****************************************************
function loadRx(action) { function loadRx(action) {
updateRx(action, null); updateRx(action, null);
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment