Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
df-aggregator
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Oleksandr Barabash
df-aggregator
Commits
8b6692e2
Commit
8b6692e2
authored
Apr 09, 2021
by
Corey Koval
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
JS Cleanup
parent
06bc08ee
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
63 additions
and
113 deletions
+63
-113
receiver_configurator.js
static/receiver_configurator.js
+63
-113
No files found.
static/receiver_configurator.js
View file @
8b6692e2
...
...
@@ -40,60 +40,50 @@ function editReceivers(rx_json, id) {
if
(
receivers
[
id
].
single
)
isSingle
=
"checked"
;
var
stationIDhtml
=
"Station ID: <a href=
\"
"
+
receivers
[
id
].
station_url
+
"
\"
target=
\"
_blank
\"
>"
+
receivers
[
id
].
station_id
+
"</a>"
;
`Station ID: <a href="
${
receivers
[
id
].
station_url
}
" target="_blank">
${
receivers
[
id
].
station_id
}
</a>`
;
// var manualInfo =
// "<input type=\"hidden\" id=\"manual_toggle_" + receivers[id].uid + "\"/>";
var
singleModeHtml
=
` Single Receiver Mode: <input
${
isSingle
}
id="singlerx_toggle_
${
id
}
" type="checkbox" />`
;
var
singleModeHtml
=
" Single Receiver Mode: <input "
+
isSingle
+
" id=
\"
singlerx_toggle_"
+
id
+
"
\"
type=
\"
checkbox
\"
/>"
;
var
locationHtml
=
`Location:
${
receivers
[
id
].
latitude
}
°,
${
receivers
[
id
].
longitude
}
°`
;
var
locationHtml
=
"Location: "
+
receivers
[
id
].
latitude
+
"°, "
+
receivers
[
id
].
longitude
+
"°"
;
var
heading
=
"Heading: "
+
receivers
[
id
].
heading
+
"°"
;
var
heading
=
`Heading:
${
receivers
[
id
].
heading
}
°`
;
var
freqHtml
=
"Tuned to "
+
receivers
[
id
].
frequency
+
" MHz"
;
var
freqHtml
=
`Tuned to
${
receivers
[
id
].
frequency
}
MHz`
;
var
edit_stationIDhtml
=
"Station ID:<input style=
\"
width: 105px;
\"
type=
\"
text
\"
value=
\"
"
+
receivers
[
id
].
station_id
+
"
\"
name=
\"
station_id_"
+
id
+
"
\"
/>"
;
// var edit_manualInfo =
// "Manually input receiver info: <input id=\"manual_toggle_" + id + "\" type=\"checkbox\" />";
`Station ID:<input style="width: 105px;" type="text" value="
${
receivers
[
id
].
station_id
}
" name="station_id_
${
id
}
" />`
;
var
edit_locationHtml
=
"Latitude:<input style=
\"
width: 105px;
\"
type=
\"
text
\"
value=
\"
"
+
receivers
[
id
].
latitude
+
"
\"
name=
\"
station_lat_"
+
id
+
"
\"
/>"
+
" Longitude:<input style=
\"
width: 105px;
\"
type=
\"
text
\"
value=
\"
"
+
receivers
[
id
].
longitude
+
"
\"
name=
\"
station_lon_"
+
id
+
"
\"
/>"
;
`Latitude:<input style="width: 105px;" type="text" value="
${
receivers
[
id
].
latitude
}
" name="station_lat_
${
id
}
" />
Longitude:<input style="width: 105px;" type="text" value="
${
receivers
[
id
].
longitude
}
" name="station_lon_
${
id
}
" />`
;
var
edit_heading
=
"Heading:<input style=
\"
width: 105px;
\"
type=
\"
text
\"
value=
\"
"
+
receivers
[
id
].
heading
+
"
\"
name=
\"
station_heading_"
+
id
+
"
\"
/>"
;
`Heading:<input style="width: 105px;" type="text" value="
${
receivers
[
id
].
heading
}
" name="station_heading_
${
id
}
" />`
;
var
edit_freqHtml
=
"Frequency:<input style=
\"
width: 105px;
\"
type=
\"
text
\"
value=
\"
"
+
receivers
[
id
].
frequency
+
"
\"
name=
\"
frequency_"
+
id
+
"
\"
/>"
;
`Frequency:<input style="width: 105px;" type="text" value="
${
receivers
[
id
].
frequency
}
" name="frequency_
${
id
}
" />`
;
const
mobilespan
=
document
.
getElementById
(
id
+
"-mobile"
);
const
singlespan
=
document
.
getElementById
(
id
+
"-single"
);
// var mobile = id + "-mobile";
const
mobilespan
=
document
.
getElementById
(
`
${
id
}
-mobile`
);
const
singlespan
=
document
.
getElementById
(
`
${
id
}
-single`
);
var
isMobileCheck
;
var
isInvertedCheck
;
var
isSingleCheck
;
var
editButton
=
document
.
getElementById
(
id
+
"-edit"
);
var
editButton
=
document
.
getElementById
(
`
${
id
}
-edit`
);
if
(
editButton
.
checked
)
{
clearInterval
(
autoRefresh
);
let
isMobile
=
""
;
if
(
receivers
[
id
].
mobile
)
isMobile
=
"checked"
;
let
isInverted
=
""
;
if
(
receivers
[
id
].
inverted
)
isInverted
=
"checked"
;
document
.
getElementById
(
id
+
"-editicon"
).
innerHTML
=
"save"
;
document
.
getElementById
(
`
${
id
}
-editicon`
).
innerHTML
=
"save"
;
mobilespan
.
innerHTML
=
"Mobile Receiver: <input "
+
isMobile
+
" id=
\"
mobilerx_toggle_"
+
id
+
"
\"
type=
\"
checkbox
\"
/>"
;
document
.
getElementById
(
id
+
"-invert"
).
innerHTML
=
"Inverted DOA: <input "
+
isInverted
+
" id=
\"
invert_toggle_"
+
id
+
"
\"
type=
\"
checkbox
\"
/>"
;
isInvertedCheck
=
document
.
getElementById
(
"invert_toggle_"
+
id
);
`Mobile Receiver: <input
${
isMobile
}
id="mobilerx_toggle_
${
id
}
" type="checkbox" />`
;
document
.
getElementById
(
`
${
id
}
-invert`
).
innerHTML
=
`Inverted DOA: <input
${
isInverted
}
id="invert_toggle_
${
id
}
" type="checkbox" />`
;
isInvertedCheck
=
document
.
getElementById
(
`invert_toggle_
${
id
}
`
);
isInvertedCheck
.
setAttribute
(
"title"
,
"KerberosSDR users keep this checked."
);
isMobileCheck
=
document
.
getElementById
(
"mobilerx_toggle_"
+
id
);
isMobileCheck
=
document
.
getElementById
(
`mobilerx_toggle_
${
id
}
`
);
if
(
isMobileCheck
.
checked
)
{
if
(
isMobileCheck
.
checked
)
{
singlespan
.
innerHTML
=
singleModeHtml
;
...
...
@@ -106,31 +96,16 @@ function editReceivers(rx_json, id) {
singlespan
.
innerHTML
=
""
;
}
}
// document.getElementById(id + "-manual").innerHTML = edit_manualInfo;
// // document.getElementById(id + "-url").innerHTML = edit_stationUrlHtml;
// document.getElementById("manual_toggle_" + id).onchange = function() {
// if (document.getElementById("manual_toggle_" + id).checked) {
// document.getElementById(id + "-id").innerHTML = edit_stationIDhtml;
// document.getElementById(id + "-location").innerHTML = edit_locationHtml;
// document.getElementById(id + "-heading").innerHTML = edit_heading;
// document.getElementById(id + "-freq").innerHTML = edit_freqHtml;
// } else {
// document.getElementById(id + "-id").innerHTML = stationIDhtml;
// document.getElementById(id + "-location").innerHTML = locationHtml;
// document.getElementById(id + "-heading").innerHTML = heading;
// document.getElementById(id + "-freq").innerHTML = freqHtml;
// }
// }
}
else
{
autoRefresh
=
setInterval
(
function
()
{
reloadRX
();
},
refreshrate
);
isMobileCheck
=
document
.
getElementById
(
"mobilerx_toggle_"
+
id
);
isMobileCheck
=
document
.
getElementById
(
`mobilerx_toggle_
${
id
}
`
);
if
(
isMobileCheck
.
checked
)
{
receivers
[
id
].
mobile
=
true
;
}
else
{
receivers
[
id
].
mobile
=
false
;
}
isInvertedCheck
=
document
.
getElementById
(
"invert_toggle_"
+
id
);
isInvertedCheck
=
document
.
getElementById
(
`invert_toggle_
${
id
}
`
);
if
(
isInvertedCheck
.
checked
)
{
receivers
[
id
].
inverted
=
true
;
}
else
{
...
...
@@ -138,7 +113,7 @@ function editReceivers(rx_json, id) {
}
try
{
isSingleCheck
=
document
.
getElementById
(
"singlerx_toggle_"
+
id
);
isSingleCheck
=
document
.
getElementById
(
`singlerx_toggle_
${
id
}
`
);
if
(
isSingleCheck
.
checked
)
{
receivers
[
id
].
single
=
true
;
}
else
{
...
...
@@ -156,7 +131,7 @@ function editReceivers(rx_json, id) {
method
:
"PUT"
};
// clearOld();
fetch
(
"/rx_params/"
+
id
,
otherParams
)
fetch
(
`/rx_params/
${
id
}
`
,
otherParams
)
.
then
(
res
=>
{
updateRx
(
showReceivers
,
id
);
reloadRX
();
...
...
@@ -189,7 +164,7 @@ function makeNewRx(url) {
// * Removes the Rx UI Card
// *****************************************
function
removerx
(
uid
)
{
const
rxcard
=
document
.
getElementById
(
"rx-"
+
uid
);
const
rxcard
=
document
.
getElementById
(
`rx-
${
uid
}
`
);
rxcard
.
remove
();
}
...
...
@@ -248,57 +223,47 @@ function activateReceiver(uid, state) {
function
showReceivers
(
rx_json
,
id
)
{
const
receivers
=
rx_json
[
'receivers'
];
// var stationUrlHtml =
// "<input type=\"hidden\" id=\"url_" + id + "\"/>";
var
stationIDhtml
=
"Station ID: <a href=
\"
"
+
receivers
[
id
].
station_url
+
"
\"
target=
\"
_blank
\"
>"
+
receivers
[
id
].
station_id
+
"</a>"
;
// var manualInfo =
// "<input type=\"hidden\" id=\"manual_toggle_" + receivers[id].uid + "\"/>";
`Station ID: <a href="
${
receivers
[
id
].
station_url
}
" target="_blank">
${
receivers
[
id
].
station_id
}
</a>`
;
var
locationHtml
=
"Location: "
+
receivers
[
id
].
latitude
+
"°, "
+
receivers
[
id
].
longitude
+
"°"
;
`Location:
${
receivers
[
id
].
latitude
}
°,
${
receivers
[
id
].
longitude
}
°`
;
var
heading
=
"Heading: "
+
receivers
[
id
].
heading
+
"°"
;
`Heading:
${
receivers
[
id
].
heading
}
°`
;
var
freqHtml
=
"Tuned to "
+
receivers
[
id
].
frequency
+
" MHz"
;
const
urlspan
=
document
.
getElementById
(
id
+
"-url"
);
const
mobilespan
=
document
.
getElementById
(
id
+
"-mobile"
);
const
invertspan
=
document
.
getElementById
(
id
+
"-invert"
);
const
singlespan
=
document
.
getElementById
(
id
+
"-single"
);
// const manualspan = document.getElementById(id + "-manual");
const
idspan
=
document
.
getElementById
(
id
+
"-id"
);
const
locationspan
=
document
.
getElementById
(
id
+
"-location"
);
const
headingspan
=
document
.
getElementById
(
id
+
"-heading"
);
const
freqspan
=
document
.
getElementById
(
id
+
"-freq"
);
document
.
getElementById
(
id
+
"-activate"
)
.
setAttribute
(
'onclick'
,
"activateReceiver("
+
receivers
[
id
].
uid
+
", "
+
!
receivers
[
id
].
active
+
")"
);
`Tuned to
${
receivers
[
id
].
frequency
}
MHz`
;
const
urlspan
=
document
.
getElementById
(
`
${
id
}
-url`
);
const
mobilespan
=
document
.
getElementById
(
`
${
id
}
-mobile`
);
const
invertspan
=
document
.
getElementById
(
`
${
id
}
-invert`
);
const
singlespan
=
document
.
getElementById
(
`
${
id
}
-single`
);
const
idspan
=
document
.
getElementById
(
`
${
id
}
-id`
);
const
locationspan
=
document
.
getElementById
(
`
${
id
}
-location`
);
const
headingspan
=
document
.
getElementById
(
`
${
id
}
-heading`
);
const
freqspan
=
document
.
getElementById
(
`
${
id
}
-freq`
);
document
.
getElementById
(
`
${
id
}
-activate`
)
.
setAttribute
(
'onclick'
,
`activateReceiver(
${
receivers
[
id
].
uid
}
,
${
!
receivers
[
id
].
active
}
)`
);
if
(
receivers
[
id
].
active
==
true
)
{
document
.
getElementById
(
id
+
"-activate"
)
document
.
getElementById
(
`
${
id
}
-activate`
)
.
setAttribute
(
"title"
,
"Click to disable this receiver."
);
document
.
getElementById
(
id
+
"-activateicon"
).
style
.
color
=
"black"
;
document
.
getElementById
(
`
${
id
}
-activateicon`
).
style
.
color
=
"black"
;
}
else
{
document
.
getElementById
(
id
+
"-activateicon"
).
style
.
color
=
"red"
;
document
.
getElementById
(
id
+
"-activate"
)
document
.
getElementById
(
`
${
id
}
-activateicon`
).
style
.
color
=
"red"
;
document
.
getElementById
(
`
${
id
}
-activate`
)
.
setAttribute
(
"title"
,
"Click to enable this receiver."
);
}
// document.getElementById(id + "-mobile").innerHTML = "";
mobilespan
.
innerHTML
=
""
;
invertspan
.
innerHTML
=
""
;
singlespan
.
innerHTML
=
""
;
document
.
getElementById
(
id
+
"-editicon"
).
innerHTML
=
"edit"
;
// document.getElementById(id + "-manual").innerHTML = manualInfo;
// document.getElementById(id + "-url").innerHTML = stationUrlHtml;
document
.
getElementById
(
id
+
"-id"
).
innerHTML
=
stationIDhtml
;
document
.
getElementById
(
id
+
"-location"
).
innerHTML
=
locationHtml
;
document
.
getElementById
(
id
+
"-heading"
).
innerHTML
=
heading
;
document
.
getElementById
(
id
+
"-freq"
).
innerHTML
=
freqHtml
;
document
.
getElementById
(
`
${
id
}
-editicon`
).
innerHTML
=
"edit"
;
document
.
getElementById
(
`
${
id
}
-id`
).
innerHTML
=
stationIDhtml
;
document
.
getElementById
(
`
${
id
}
-location`
).
innerHTML
=
locationHtml
;
document
.
getElementById
(
`
${
id
}
-heading`
).
innerHTML
=
heading
;
document
.
getElementById
(
`
${
id
}
-freq`
).
innerHTML
=
freqHtml
;
}
...
...
@@ -314,13 +279,11 @@ function createReceivers(rx_json, id) {
const
rxcard
=
document
.
createElement
(
'div'
);
rxcard
.
className
=
"receiver"
;
rxcard
.
id
=
"rx-"
+
receivers
[
i
].
uid
;
rxcard
.
id
=
`rx-
${
receivers
[
i
].
uid
}
`
;
// const urlspan = document.createElement('span');
const
mobilespan
=
document
.
createElement
(
'span'
);
const
invertspan
=
document
.
createElement
(
'span'
);
const
singlespan
=
document
.
createElement
(
'span'
);
// const manualspan = document.createElement('span');
const
idspan
=
document
.
createElement
(
'span'
);
const
locationspan
=
document
.
createElement
(
'span'
);
const
headingspan
=
document
.
createElement
(
'span'
);
...
...
@@ -329,13 +292,13 @@ function createReceivers(rx_json, id) {
const
editiconspan
=
document
.
createElement
(
'span'
);
editiconspan
.
classList
.
add
(
"material-icons"
,
"edit-icon"
,
"no-select"
);
editiconspan
.
innerHTML
=
"edit"
;
editiconspan
.
id
=
receivers
[
i
].
uid
+
"-editicon"
;
editiconspan
.
id
=
`
${
receivers
[
i
].
uid
}
-editicon`
;
const
editcheck
=
document
.
createElement
(
'input'
);
editcheck
.
classList
.
add
(
"edit-checkbox"
,
"edit-icon"
);
editcheck
.
type
=
'checkbox'
;
editcheck
.
id
=
receivers
[
i
].
uid
+
"-edit"
;
editcheck
.
setAttribute
(
'onclick'
,
"updateRx(editReceivers, "
+
receivers
[
i
].
uid
+
")"
);
editcheck
.
id
=
`
${
receivers
[
i
].
uid
}
-edit`
;
editcheck
.
setAttribute
(
'onclick'
,
`updateRx(editReceivers,
${
receivers
[
i
].
uid
}
)`
);
const
deleteiconspan
=
document
.
createElement
(
'span'
);
deleteiconspan
.
classList
.
add
(
"material-icons"
,
"delete-icon"
,
"no-select"
);
...
...
@@ -344,38 +307,25 @@ function createReceivers(rx_json, id) {
const
deletecheck
=
document
.
createElement
(
'input'
);
deletecheck
.
classList
.
add
(
"edit-checkbox"
,
"delete-icon"
);
deletecheck
.
type
=
'checkbox'
;
deletecheck
.
id
=
receivers
[
i
].
uid
+
"-delete"
;
deletecheck
.
setAttribute
(
'onclick'
,
"deleteReceiver("
+
receivers
[
i
].
uid
+
")"
);
deletecheck
.
id
=
`
${
receivers
[
i
].
uid
}
-delete`
;
deletecheck
.
setAttribute
(
'onclick'
,
`deleteReceiver(
${
receivers
[
i
].
uid
}
)`
);
const
activateiconspan
=
document
.
createElement
(
'span'
);
activateiconspan
.
classList
.
add
(
"material-icons"
,
"activate-icon"
,
"no-select"
);
activateiconspan
.
innerHTML
=
"power_settings_new"
;
activateiconspan
.
id
=
receivers
[
i
].
uid
+
"-activateicon"
;
activateiconspan
.
id
=
`
${
receivers
[
i
].
uid
}
-activateicon`
;
const
activatecheck
=
document
.
createElement
(
'input'
);
activatecheck
.
classList
.
add
(
"edit-checkbox"
,
"activate-icon"
);
activatecheck
.
type
=
'checkbox'
;
activatecheck
.
id
=
receivers
[
i
].
uid
+
"-activate"
;
// const addnewiconspan = document.createElement('span');
// addnewiconspan.classList.add("material-icons", "add-icon", "no-select");
// addnewiconspan.innerHTML = "add_circle_outline"
// addnewiconspan.id="add_station_icon"
//
// const addnewcheck = document.createElement('input');
// addnewcheck.type = 'checkbox';
// addnewcheck.id="add_station";
// addnewcheck.classList.add("edit-checkbox", "add-icon")
// urlspan.id = receivers[i].uid + "-url";
mobilespan
.
id
=
receivers
[
i
].
uid
+
"-mobile"
;
invertspan
.
id
=
receivers
[
i
].
uid
+
"-invert"
;
singlespan
.
id
=
receivers
[
i
].
uid
+
"-single"
;
// manualspan.id = receivers[i].uid + "-manual";
idspan
.
id
=
receivers
[
i
].
uid
+
"-id"
;
locationspan
.
id
=
receivers
[
i
].
uid
+
"-location"
;
headingspan
.
id
=
receivers
[
i
].
uid
+
"-heading"
;
freqspan
.
id
=
receivers
[
i
].
uid
+
"-freq"
;
activatecheck
.
id
=
`
${
receivers
[
i
].
uid
}
-activate`
;
mobilespan
.
id
=
`
${
receivers
[
i
].
uid
}
-mobile`
;
invertspan
.
id
=
`
${
receivers
[
i
].
uid
}
-invert`
;
singlespan
.
id
=
`
${
receivers
[
i
].
uid
}
-single`
;
idspan
.
id
=
`
${
receivers
[
i
].
uid
}
-id`
;
locationspan
.
id
=
`
${
receivers
[
i
].
uid
}
-location`
;
headingspan
.
id
=
`
${
receivers
[
i
].
uid
}
-heading`
;
freqspan
.
id
=
`
${
receivers
[
i
].
uid
}
-freq`
;
document
.
getElementById
(
"rxcards"
).
insertBefore
(
rxcard
,
document
.
getElementById
(
"add_station"
));
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment