aboutsummaryrefslogtreecommitdiffstats
path: root/op25/gr-op25_repeater/www/www-static/main.js
blob: dd0706d845c29f28decf9f23e111b062c27adb6c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
// Copyright 2017, 2018 Max H. Parke KA1RBI
// 
// This file is part of OP25
// 
// OP25 is free software; you can redistribute it and/or modify it
// under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3, or (at your option)
// any later version.
// 
// OP25 is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
// License for more details.
// 
// You should have received a copy of the GNU General Public License
// along with OP25; see the file COPYING. If not, write to the Free
// Software Foundation, Inc., 51 Franklin Street, Boston, MA
// 02110-1301, USA.

var d_debug = 1;

var http_req = new XMLHttpRequest();
var counter1 = 0;
var error_val = null;
var current_tgid = null;
var send_busy = 0;
var send_qfull = 0;
var send_queue = [];
var req_cb_count = 0;
var request_count = 0;
var nfinal_count = 0;
var n200_count = 0;
var r200_count = 0;
var SEND_QLIMIT = 5;

function find_parent(ele, tagname) {
    while (ele) {
        if (ele.nodeName == tagname)
            return (ele);
        else if (ele.nodeName == "HTML")
            return null;
        ele = ele.parentNode;
    }
    return null;
}

function f_command(ele, command) {
    var myrow = find_parent(ele, "TR");
    var mytbl = find_parent(ele, "TABLE");
    amend_d(myrow, mytbl, command);
}

function edit_freq(freq, to_ui) {
	var MHZ = 1000000.0;
	if (to_ui) {
		var f = (freq / MHZ) + "";
		if (f.indexOf(".") == -1)
			f += ".0";
		return f;
	} else {
		var f = parseFloat(freq);
		if (freq.indexOf("."))
			f *= MHZ;
		return Math.round(f);
	}
}

function edit_d(d, to_ui) {
	var new_d = {};
	var hexints = {"nac":1};
	var ints = {"if_rate":1, "ppm":1, "rate":1, "offset":1, "nac":1, "logfile-workers":1, "decim-amt":1, "seek":1, "hamlib-model":1 };
	var bools = {"active":1, "trunked":1, "rate":1, "offset":1, "phase2_tdma": 1, "phase2-tdma":1, "wireshark":1, "udp-player":1, "audio-if":1, "tone-detect":1, "vocoder":1, "audio":1, "pause":1 };
	var floats = {"costas-alpha":1, "gain-mu":1, "calibration":1, "fine-tune":1, "gain":1, "excess-bw":1, "offset":1}
	var lists = {"blacklist":1, "whitelist":1, "cclist":1};
	var freqs = {"frequency":1, "cclist":1};


	for (var k in d) {
		if (!to_ui) {
			if (d[k] == "None")
				new_d[k] = null;
			else
				new_d[k] = d[k];
			if (k == "plot" && !d[k].length)
				new_d[k] = null;
			if (k in ints) {
				new_d[k] = parseInt(new_d[k]);
			} else if (k in floats) {
				new_d[k] = parseFloat(new_d[k]);
			} else if (k in lists) {
				var l = new_d[k].split(",");
				if (k in freqs) {
					var new_l = [];
					for (var i in l)
						new_l.push(edit_freq(l[i], to_ui));
					new_d[k] = new_l;
				} else {
					new_d[k] = l;
				}
			} else if (k in freqs) {
				new_d[k] = edit_freq(new_d[k], to_ui);
			}
		} else {
			if (k in hexints) {
				new_d[k] = "0x" + d[k].toString(16);
			} else if (k in ints) {
				if (d[k] == null)
					new_d[k] = "";
				else
					new_d[k] = d[k].toString(10);
			} else if (k in lists) {
				if (k in freqs) {
					var new_l = [];
					for (var i in d[k]) {
						new_l.push(edit_freq(d[k][i], to_ui));
					}
					new_d[k] = new_l.join(",");
				} else {
					new_d[k] = d[k].join(",");
				}
			} else if (k in freqs) {
				new_d[k] = edit_freq(d[k], to_ui);
			} else {
				new_d[k] = d[k];
			}
		}
	}
	return new_d;
}

function edit_l(cfg, to_ui) {
	var new_d = {"devices": [], "channels": []};
	for (var device in cfg['devices'])
		new_d["devices"].push(edit_d(cfg['devices'][device], to_ui));
	for (var channel in cfg['channels'])
		new_d["channels"].push(edit_d(cfg['channels'][channel], to_ui));
	new_d["backend-rx"] = edit_d(cfg['backend-rx'], to_ui);
	return new_d;
}

function amend_d(myrow, mytbl, command) {
    var trunk_row = null;
    if (mytbl.id == "chtable")
        trunk_row = find_next(myrow, "TR");
    if (command == "delete") {
        var ok = confirm ("Confirm delete");
        if (ok) {
            myrow.parentNode.removeChild(myrow);
            if (mytbl.id == "chtable")
                trunk_row.parentNode.removeChild(trunk_row);
        }
    } else if (command == "clone") {
        var newrow = myrow.cloneNode(true);
	newrow.id = find_free_id("id_");
        if (mytbl.id == "chtable") {
            var newrow2 = trunk_row.cloneNode(true);
	    newrow2.id = "tr_" + newrow.id.substring(3);
            if (trunk_row.nextSibling) {
                myrow.parentNode.insertBefore(newrow2, trunk_row.nextSibling);
                myrow.parentNode.insertBefore(newrow, trunk_row.nextSibling);
            } else {
                myrow.parentNode.appendChild(newrow);
                myrow.parentNode.appendChild(newrow2);
            }
        } else {
            if (myrow.nextSibling)
                myrow.parentNode.insertBefore(newrow, myrow.nextSibling);
            else
                myrow.parentNode.appendChild(newrow);
        }
    } else if (command == "new") {
        var newrow = null;
        var parent = null;
        if (mytbl.id == "chtable") {
            newrow = document.getElementById("chrow").cloneNode(true);
            parent = document.getElementById("chrow").parentNode;
        } else if (mytbl.id == "devtable") {
            newrow = document.getElementById("devrow").cloneNode(true);
            parent = document.getElementById("devrow").parentNode;
        } else {
            return null;
        }
        newrow.style['display'] = '';
	newrow.id = find_free_id("id_");
        parent.appendChild(newrow);
        if (mytbl.id == "chtable") {
            var newrow2 = document.getElementById("trrow").cloneNode(true);
	    newrow2.id = "tr_" + newrow.id.substring(3);
            parent.appendChild(newrow2);
        }
        return newrow.id;
    }
}

function nav_update(command) {
	var names = ["b1", "b2", "b3", "b4", "b5"];
	var bmap = { "status": "b1", "plot": "b2", "settings": "b3", "rx": "b4", "about": "b5" };
	var id = bmap[command];
	for (var id1 in names) {
		b = document.getElementById(names[id1]);
		if (names[id1] == id) {
			b.className = "nav-button-active";
		} else {
			b.className = "nav-button";
		}
	}
}

function f_select(command) {
    var div_list = ["status", "plot", "settings", "rx", "about"];
    for (var i=0; i<div_list.length; i++) {
        var ele = document.getElementById("div_" + div_list[i]);
        if (command == div_list[i])
            ele.style['display'] = "";
        else
            ele.style['display'] = "none";
    }
    var ctl = document.getElementById("controls");
    if (command == "status")
        ctl.style['display'] = "";
    else
        ctl.style['display'] = "none";
    nav_update(command);
    if (command == "settings")
        f_list();
}

function is_digit(s) {
    if (s >= "0" && s <= "9")
        return true;
    else
        return false;
}

function rx_update(d) {
    if (d["files"].length > 0) {
        for (var i=0; i<d["files"].length; i++) {
            var img = document.getElementById("img" + i);
            if (img['src'] != d["files"][i]) {
                img['src'] = d["files"][i];
                img.style["display"] = "";
            }
        }
    }
    error_val = d["error"];
}

// frequency, system, and talkgroup display

function change_freq(d) {
    var html = "<span class=\"label\">Frequency: </span><span class=\"value\">" + d['freq'] / 1000000.0;
    html += "</span> <span class=\"systgid\"> &nbsp;" + d['system'] + " </span> ";
    if (d['tgid'] != null) {
        html += "<span class=\"label\">Talkgroup ID: </span><span class=\"value\"> " + d['tgid'];
        html += "</span> <span class=\"systgid\"> &nbsp;" + d['tag'] + " </span>";
    }
    html += "<br>";
    var div_s2 = document.getElementById("div_s2");
    div_s2.innerHTML = html;
    div_s2.style["display"] = "";
    if (d['tgid'] != null)
        current_tgid = d['tgid'];
    if (current_tgid != null) {
        var div_s3 = document.getElementById("div_s3");
        div_s3.style["display"] = "";
    }
}

// adjacent sites table

function adjacent_data(d) {
    if (Object.keys(d).length < 1) {
        var html = "</div>";
        return html;
    }
    var html = "<div class=\"adjacent\">";
    html += "<table border=1 borderwidth=0 cellpadding=0 cellspacing=0 width=100%>";
    html += "<tr><th colspan=99 style=\"align: center\">Adjacent Sites</th></tr>";
    html += "<tr><th>Frequency</th><th>Sys ID</th><th>RFSS</th><th>Site</th><th>Uplink</th></tr>";
    var ct = 0;
    for (var freq in d) {
        var color = "#d0d0d0";
        if ((ct & 1) == 0)
            color = "#c0c0c0";
        ct += 1;
        html += "<tr style=\"background-color: " + color + ";\"><td>" + freq / 1000000.0 + "</td><td>" + d[freq]['sysid'].toString(16) + "</td><td>" + d[freq]["rfid"] + "</td><td>" + d[freq]["stid"] + "</td><td>" + (d[freq]["uplink"] / 1000000.0) + "</td></tr>";
    }
    html += "</table></div></div><br><br>";

// end adjacent sites table

    return html;
}

// additional system info: wacn, sysID, rfss, site id, secondary control channels, freq error

function trunk_update(d) {
    var do_hex = {"syid":0, "sysid":0, "wacn": 0};
    var do_float = {"rxchan":0, "txchan":0};
    var html = "";
    for (var nac in d) {
        if (!is_digit(nac.charAt(0)))
            continue;
        html += "<span class=\"nac\">";
        html += "NAC " + "0x" + parseInt(nac).toString(16) + " ";
        html += d[nac]['rxchan'] / 1000000.0;
        html += " / ";
        html += d[nac]['txchan'] / 1000000.0;
        html += " tsbks " + d[nac]['tsbks'];
        html += "</span><br>";

        html += "<span class=\"label\">WACN: </span>" + "<span class=\"value\">0x" + parseInt(d[nac]['wacn']).toString(16) + " </span>";
        html += "<span class=\"label\">System ID: </span>" + "<span class=\"value\">0x" + parseInt(d[nac]['sysid']).toString(16) + " </span>";
        html += "<span class=\"label\">RFSS ID: </span><span class=\"value\">" + d[nac]['rfid'] + " </span>";
        html += "<span class=\"label\">Site ID: </span><span class=\"value\">" + d[nac]['stid'] + "</span><br>";
        if (d[nac]["secondary"].length) {
            html += "<span class=\"label\">Secondary control channel(s): </span><span class=\"value\"> ";
            for (i=0; i<d[nac]["secondary"].length; i++) {
                html += d[nac]["secondary"][i] / 1000000.0;
                html += " ";
            }
            html += "</span><br>";
        }
        if (error_val != null) {
            html += "<span class=\"label\">Frequency error: </span><span class=\"value\">" + error_val + " Hz. (approx) </span><br>";
        }

// system frequencies table

        html += "<p><div class=\"info\"><div class=\"system\">";
        html += "<table border=1 borderwidth=0 cellpadding=0 cellspacing=0 width=100%>"; // was width=350
        html += "<tr><th colspan=99 style=\"align: center\">System Frequencies</th></tr>";
        html += "<tr><th>Frequency</th><th>Last Seen</th><th colspan=2>Talkgoup ID</th><th>Count</th></tr>";
        var ct = 0;
        for (var freq in d[nac]['frequency_data']) {
            tg2 = d[nac]['frequency_data'][freq]['tgids'][1];
            if (tg2 == null)
                tg2 = "&nbsp;";
            var color = "#d0d0d0";
            if ((ct & 1) == 0)
                color = "#c0c0c0";
            ct += 1;
            html += "<tr style=\"background-color: " + color + ";\"><td>" + parseInt(freq) / 1000000.0 + "</td><td>" + d[nac]['frequency_data'][freq]['last_activity'] + "</td><td>" + d[nac]['frequency_data'][freq]['tgids'][0] + "</td><td>" + tg2 + "</td><td>" + d[nac]['frequency_data'][freq]['counter'] + "</td></tr>";
        }
        html += "</table></div>";

// end system freqencies table

        html += adjacent_data(d[nac]['adjacent_data']);
    }
    var div_s1 = document.getElementById("div_s1");
    div_s1.innerHTML = html;
}

function config_list(d) {
    var html = "";
    html += "<select id=\"config_select\" name=\"cfg-list\" size=5>";
    for (var file in d["data"]) {
        html += "<option value=\"" + d["data"][file] + "\">" + d["data"][file] + "</option>";
    }
    html += "<option value=\"New Configuration\">New Configuration</option>";
    html += "</select>";
    document.getElementById("cfg_list_area").innerHTML = html;
}

function config_data(d) {
    var cfg = edit_l(d['data'], true);
    open_editor();
    var chtable = document.getElementById("chtable");
    var devtable = document.getElementById("devtable");
    var chrow = document.getElementById("chrow");
    var devrow = document.getElementById("devrow");
    for (var device in cfg['devices'])
        rollup_row("dev", document.getElementById(amend_d(devrow, devtable, "new")), cfg['devices'][device]);
    for (var channel in cfg['channels'])
        rollup_row("ch", document.getElementById(amend_d(chrow, chtable, "new")), cfg['channels'][channel]);
    rollup_rx_rows(cfg['backend-rx']);
}

function open_editor() {
    document.getElementById("edit_settings").style["display"] = "";
    var rows = document.querySelectorAll(".dynrow");
    var ct = 0;
    for (var r in rows) {
        var row = rows[r];
        ct += 1;
        if (row.id && (row.id.substring(0,3) == "id_" || row.id.substring(0,3) == "tr_")) {
            row.parentNode.removeChild(row);
        }
    }
    var oldtbl = document.getElementById("rt_1");
    if (oldtbl)
        oldtbl.parentNode.removeChild(oldtbl);
    var tbl = document.getElementById("rxopt-table");
    var newtbl = tbl.cloneNode(true);
    newtbl.id = "rt_1";
    newtbl.style["display"] = "";
    var rxrow = newtbl.querySelector(".rxrow");
    var advrow = newtbl.querySelector(".advrow");
    rxrow.id = "rx_1";
    advrow.id = "rx_2";
    if (tbl.nextSibling)
        tbl.parentNode.insertBefore(newtbl, tbl.nextSibling);
    else
        tbl.parentNode.appendChild(newtbl);
}

function http_req_cb() {
    req_cb_count += 1;
    s = http_req.readyState;
    if (s != 4) {
        nfinal_count += 1;
        return;
    }
    if (http_req.status != 200) {
        n200_count += 1;
        return;
    }
    r200_count += 1;
    var dl = JSON.parse(http_req.responseText);
    var dispatch = {'trunk_update': trunk_update, 'change_freq': change_freq, 'rx_update': rx_update, 'config_data': config_data, 'config_list': config_list}
    for (var i=0; i<dl.length; i++) {
        var d = dl[i];
        if (!("json_type" in d))
            continue;
        if (!(d["json_type"] in dispatch))
            continue;
        dispatch[d["json_type"]](d);
    }
}

function do_onload() {
    var ele = document.getElementById("div_status");
    ele.style["display"] = "";
    setInterval(do_update, 1000);
    b = document.getElementById("b1");
    b.className = "nav-button-active";
}

function do_update() {
    send_command("update", 0);
    f_debug();
}

function send_command(command, data) {
    var d = {"command": command, "data": data};
    send(d);
}

function send(d) {
    request_count += 1;
    if (send_queue.length >= SEND_QLIMIT) {
        send_qfull += 1;
        send_queue.unshift();
    }
    send_queue.push( d );
    send_process();
}

function send_process() {
    s = http_req.readyState;
    if (s != 0 && s != 4) {
        send_busy += 1;
        return;
    }
    http_req.open("POST", "/");
    http_req.onreadystatechange = http_req_cb;
    http_req.setRequestHeader("Content-type", "application/json");
    cmd = JSON.stringify( send_queue );
    send_queue = [];
    http_req.send(cmd);
}

function f_scan_button(command) {
    if (current_tgid == null)
        send_command(command, -1);
    else
        send_command(command, current_tgid);
}

function f_debug() {
	if (!d_debug) return;
	var html = "busy " + send_busy;
	html += " qfull " + send_qfull;
	html += " sendq size " + send_queue.length;
	html += " requests " + request_count;
	html += "<br>callbacks:";
	html += " total=" + req_cb_count;
	html += " incomplete=" + nfinal_count;
	html += " error=" + n200_count;
	html += " OK=" + r200_count;
	html += "<br>";
	var div_debug = document.getElementById("div_debug");
	div_debug.innerHTML = html;
}

function find_next(e, tag) {
	var n = e.nextSibling;
	for (var i=0; i<25; i++) {
		if (n == null)
			return null;
		if (n.nodeName == tag)
			return n;
		n = n.nextSibling;
	}
	return null;
}

function find_free_id(pfx) {
	for (var seq = 1; seq < 5000; seq++) {
		var test_id = pfx + seq;
		var ele = document.getElementById(test_id);
		if (!ele)
			return test_id;
	}
	return null;
}

function f_trunked(e) {
	var row = find_parent(e, "TR");
	var trrow = document.getElementById("tr_" + row.id.substring(3));
	trrow['style']["display"] = (e.checked) ? "" : "none";
}

function read_write_sel(sel_node, def) {
	var result = [];
	var elist = sel_node.querySelectorAll("option");
	for (var e in elist) {
		var ele = elist[e];
		if (def) {
			if (!def[sel_node.name])
				return;
			var options = def[sel_node.name].split(",");
			var opts = {};
			for (var o in options)
				opts[options[o]] = 1;
			if (ele.value in opts)
				ele.selected = true;
			else
				ele.selected = false;
		} else {
			if (ele.selected)
				result.push(ele.value);
		}
	}
	if (!def)
		return result.join();
}

function read_write(elist, def) {
	var result = {};
	var s = "len: " + elist.length + "; ";
	for (var e in elist) {
		s += elist[e].tagName + "; ";
	}
	for (var e in elist) {
		var ele = elist[e];
		if (ele.nodeName == 'INPUT') {
			if (ele.type == 'text')
				if (def) {
					ele.value = def[ele.name];
					s += ele.name + "=" + ele.value + "; ";
				} else
					result[ele.name] = ele.value;
			else if (ele.type == 'checkbox')
				if (def) {
					ele.checked = def[ele.name];
					s += "checkbox " + ele.name + "; ";
				}
				else
					result[ele.name] = ele.checked;
		} else if (ele.nodeName == 'SELECT') {
			if (def) {
				read_write_sel(ele, def);
				s += "select " + ele.name + "; ";
			}
			else
				result[ele.name] = read_write_sel(ele, def);
		}
		
	}
	if (!def)
		return result;
}

function rollup_row(which, row, def) {
	var elements = Array.from(row.querySelectorAll("input,select"));
	if (which == "ch") {
		var trrow = document.getElementById("tr_" + row.id.substring(3));
		elements = elements.concat(Array.from(trrow.querySelectorAll("input,select")));
	}
	else if (which == "rx") {
		var advrow = document.getElementById("rx_2");
		elements = elements.concat(Array.from(advrow.querySelectorAll("input,select")));
	}
	if (def && which == "ch")
		trrow.style["display"] = (def["trunked"]) ? "" : "none";
	var result = read_write(elements, def);
	if (!def)
		return result;
}

function rollup(which, def) {
	var result = [];
	var mytbl = document.getElementById(which + "table");
	var elements = mytbl.querySelectorAll(".dynrow");
	for (var e in elements) {
		var row = elements[e];
		if (row.id != null && row.id.substring(0,3) == "id_")
			result.push(rollup_row(which, row));
	}
	if (!def)
		return result;
}

function rollup_rx_rows(def) {
	return rollup_row("rx", document.getElementById("rx_1"), def);
}

function f_save() {
	var name = document.getElementById("config_name");
	if (!name.value) {
		alert("Name is required");
		name.focus();
		return;
	}
	if (name.value == "New Configuration") {
		alert ("'" + name.value + "' is a reserved name, please retry");
		name.value = "";
		name.focus();
		return;
	}
	var cfg = { "devices": rollup("dev", null), "channels": rollup("ch", null), "backend-rx": rollup_rx_rows(null) };
	cfg = edit_l(cfg, false);
	var request = {"name": name.value, "value": cfg};
	send_command("config-save", request);
	f_list();
}

function f_list() {
	var inp = document.getElementById("include_tsv");
	send_command("config-list", (inp.checked) ? "tsv" : "");
}

function f_start() {
	var sel = document.getElementById("config_select");
	if (!sel) return;
	var val = read_write_sel(sel, null);
	if ((!val) || val == "New Configuration") {
		alert ("You must select a valid configuration to start");
		return;
	}
	if (val.indexOf("[TSV]") >= 0) {
		alert ("TSV files not supported. First, invoke \"Edit\"; inspect the resulting configuration; then click \"Save\".");
		return;
	}
	send_command("rx-start", val);
}

function f_load() {
	var sel = document.getElementById("config_select");
	if (!sel) return;
	var val = read_write_sel(sel, null);
	if (!val) {
		alert ("You must select a configuration to edit");
		return;
	}
	if (val == "New Configuration") {
		open_editor();
	} else {
		send_command('config-load', val);
		var ele = document.getElementById("config_name");
		ele.value = val;
	}
}

function show_advanced(o) {
    var tbl = find_parent(o, "TABLE");
    var row = tbl.querySelector(".advrow");
    if (o.value == "Show") {
        o.value = "Hide";
        row.style["display"] = "";
    } else {
        o.value = "Show";
        row.style["display"] = "none";
    }
}