Commit 59c5ae39 by Corey Koval

Cleaned up code

parent 48f52161
...@@ -7,7 +7,7 @@ import time ...@@ -7,7 +7,7 @@ import time
import sqlite3 import sqlite3
import threading import threading
import signal import signal
import hashlib # import hashlib
from colorsys import hsv_to_rgb from colorsys import hsv_to_rgb
from optparse import OptionParser from optparse import OptionParser
from os import system, name, kill, getpid from os import system, name, kill, getpid
......
...@@ -4,7 +4,10 @@ ...@@ -4,7 +4,10 @@
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);
// console.log("updateRx Complete");
// console.log(res);
})
} }
// ****************************************************** // ******************************************************
...@@ -89,12 +92,10 @@ function editReceivers(rx_json, id) { ...@@ -89,12 +92,10 @@ function editReceivers(rx_json, id) {
}; };
clearOld(); clearOld();
fetch("/rx_params/" + id, otherParams) fetch("/rx_params/" + id, otherParams)
.then(data => { return data.json() }) .then(res => {
.then(res => { updateRx(showReceivers, id) }) updateRx(showReceivers, id);
.then(res => { loadCzml() }) loadCzml();
//.catch(error=>{console.log(error)}) })
// updateRx(showReceivers, id);
// loadCzml();
} }
} }
...@@ -113,12 +114,10 @@ function makeNewRx(url) { ...@@ -113,12 +114,10 @@ function makeNewRx(url) {
}; };
clearOld(); clearOld();
fetch("/rx_params/new", otherParams) fetch("/rx_params/new", otherParams)
.then(data => { return data.json() }) .then(res => {
.then(res => { updateRx(createReceivers, true) }) updateRx(createReceivers, true);
.then(res => { loadCzml() }) loadCzml();
//.catch(error=>{console.log(error)}) })
//.then(updateRx(createReceivers, true));
// loadCzml();
} }
// ***************************************** // *****************************************
...@@ -144,16 +143,14 @@ function deleteReceiver(uid) { ...@@ -144,16 +143,14 @@ function deleteReceiver(uid) {
}; };
clearOld(); clearOld();
fetch("/rx_params/del", otherParams) fetch("/rx_params/del", otherParams)
.then(data => { return data.json() }) .then(res => {
.then(res => { removerx(uid) }) removerx(uid);
.then(res => { loadCzml() }) loadCzml();
//.catch(error=>{console.log(error)}) })
//.then(updateRx(createReceivers, true));
// loadCzml();
} }
// ******************************************* // *******************************************
// * Fills in Rx UI cards with Rx info // * 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'];
...@@ -206,7 +203,7 @@ function createReceivers(rx_json, id) { ...@@ -206,7 +203,7 @@ function createReceivers(rx_json, id) {
} else { } else {
receivers = rx_json['receivers']; receivers = rx_json['receivers'];
} }
console.log(receivers); // console.log(receivers);
for (let i = 0; i < Object.keys(receivers).length; i++) { for (let i = 0; i < Object.keys(receivers).length; i++) {
const rxcard = document.createElement('div'); const rxcard = document.createElement('div');
...@@ -283,4 +280,4 @@ function refreshRx(rx_json, id) { ...@@ -283,4 +280,4 @@ function refreshRx(rx_json, id) {
// **************************************************** // ****************************************************
function loadRx(action) { function loadRx(action) {
updateRx(action, null); updateRx(action, null);
} }
\ No newline at end of file
...@@ -31,24 +31,27 @@ ...@@ -31,24 +31,27 @@
viewer.zoomTo(loadCzml()); viewer.zoomTo(loadCzml());
function updateParams(parameter) { function updateParams(parameter) {
var xmlHttp = new XMLHttpRequest(); fetch("/update?"+parameter)
xmlHttp.open( "GET", "/update?"+parameter, true ); // false for synchronous request .then(function(response) {
xmlHttp.send( null ); if (response.status == 200) {
xmlHttp.onload = function() { loadRx(refreshRx);
loadRx(refreshRx); clearOld();
clearOld(); loadCzml();
loadCzml(); console.log(response);
} }
})
} }
function loadCzml() { function loadCzml() {
var dataSourcePromise = Cesium.CzmlDataSource.load('/static/output.czml'); var dataSourcePromise = Cesium.CzmlDataSource.load('/static/output.czml');
viewer.dataSources.add(dataSourcePromise); viewer.dataSources.add(dataSourcePromise);
console.log("Loaded CZML");
return dataSourcePromise; return dataSourcePromise;
} }
function clearOld() { function clearOld() {
viewer.dataSources.removeAll(true); viewer.dataSources.removeAll(true);
console.log("Cleared old");
} }
// Add Cesium OSM Buildings, a global 3D buildings layer. // Add Cesium OSM Buildings, a global 3D buildings layer.
......
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