This repository has been archived by the owner on Feb 18, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
m.html
777 lines (690 loc) · 22.3 KB
/
m.html
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
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
<!DOCTYPE HTML>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1">
<title>VHF Goonhilly WebSDR - Mobile</title>
<meta name="description" content="VHF Goonhilly WebSDR - by AMSAT-UK & BATC">
<meta name="author" content="AMSAT-UK & BATC">
<link rel="shortcut icon" href="/favicon.ico">
<style>
button { height:45px }
body {
font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";
}
.freqbar {
box-sizing: border-box; -webkit-box-sizing: border-box; -moz-box-sizing: border-box;
background-color: black; color:yellow; text-align:center;
vertical-align:middle;
height:45px;
font-size:35px;
}
@media (max-width:319px) { .freqbar { font-size:30px; } }
@media (max-width:279px) { .freqbar { font-size:25px; } }
@media (max-width:239px) { .freqbar { font-size:20px; } }
@media (max-width:199px) { .freqbar { font-size:16px; } }
.relbutton3, .relbutton4, .relbutton5, .relbutton6, .relbuttona {
text-align:center; vertical-align:middle;
box-sizing: border-box; -webkit-box-sizing: border-box; -moz-box-sizing: border-box;
margin:2px;
}
.relbutton3 { width:30%; width:calc(33.33333% - 4px); }
.relbutton4 { width:22%; width:calc(25% - 4px); }
.relbutton5 { width:18%; width:calc(20% - 4px); }
.relbutton6 { width:15%; width:calc(16.66666% - 4px); }
.relbuttona { min-width:76px; }
.upsidedown {
-moz-transform: scaleY(-1);
-o-transform: scaleY(-1);
-webkit-transform: scaleY(-1);
transform: scaleY(-1);
-ms-filter: "FlipV";
}
.onesetting { display:table-cell; min-width:50%; height:45px; vertical-align:middle; }
div.freqinfo1 {
display:none;
position:absolute;
}
input.freqbar:focus + div.freqinfo1 {
display:block;
}
div.freqinfo2 {
background-color:#ffffc0;
position:relative;
border: 3px solid #c0c000;
padding:2px;
z-index:2;
}
.warning {
color:red; font-weight:bold; border:2px; border-style:solid; border-color:black; background-color:white; margin:8px; padding:4px; display:none;
}
#mobile_audio_start_btn {
display: none;
}
#mobile_audio_start_btn > button {
width:100%;
color:red;
font-weight: bold;
font-size: 1em;
box-sizing: border-box; -webkit-box-sizing: border-box; -moz-box-sizing: border-box;
border-color: black;
margin:2px;
}
</style>
</head>
<body onload=bodyonload()>
<h2>VHF Goonhilly WebSDR</h2>
<p>
Tuning is different from the normal WebSDR: Drag the waterfall, not the yellow filter curve.
</p>
<hr>
<div id="browserwarning" class="warning">
Your browser is not supported; if it does not work, please try again with Firefox on Android, or Safari version 6 or later on iOS.</div>
</div>
<form name="freqform" action="#" onsubmit="freqsubmit(this); return false;"
>
<script>
var sup_android=false;
var sup_iOS=false;
try {
var n=navigator.userAgent.toLowerCase();
if (n.indexOf('android')!=-1) sup_android=true;
if (n.indexOf('iphone')!=-1) sup_iOS=true;
if (n.indexOf('ipad')!=-1) sup_iOS=true;
if (n.indexOf('ipod')!=-1) sup_iOS=true;
if (n.indexOf('ios')!=-1) sup_iOS=true;
} catch (e) {};
</script>
<input type="number" name="frequency" step="any" onFocus="freqfocus=true; this.value=''" onBlur="freqfocus=false;" class="freqbar" style="display:inline-block; width:60%;" /
><div class="freqinfo1"><div class="freqinfo2" id="freqinfo"></div></div
><select class="freqbar" style="display:inline-block; width:40%" id="modesel" onchange="setmode_sel(this)">
<option value="USB">USB</option>
<option value="LSB">LSB</option>
<option value="CW">CW</option>
<option value="AM">AM</option>
<option value="FM">FM</option>
</select
></form
><div style="font-size:0px"><canvas id="ax" height="21px"></canvas></div><div id="wfdiv" class="upsidedown"></div
><div id="smeter" style="display:none">
<div style="display:inline-block;position:relative;width:100%;height:33px;background-color:black;">
<div id="smeterpeak" style="width:100px;height:4px;background-color:#ff8000;position:absolute;top:10px;left:0px"></div>
<div id="smeterbar" style="width:100px;height:4px;background-color:#00ff00;position:absolute;top:10px;left:0px"></div>
<div style="position:absolute; color:#00ff00; top:0px; left:240px; height:16px;overflow:hidden"><span id="numericalsmeter">?</span> dBm</div>
<div style="position:absolute; color:#ff8000; top:15px; left:240px; height:16px;overflow:hidden"><span id="numericalsmeterpeak">?</span> dBm peak</div>
<img src="smeter1.png" alt="[scale]" style="position:absolute; top:23px; left:0px">
</div>
</div
>
<div id="mobile_audio_start_btn"><button onclick="start_audio();">Tap to start audio!</button><br></div>
<button class="relbutton6" onclick="freqstep(-3)"><<<</button
><button class="relbutton6" onclick="freqstep(-2)"><<</button
><button class="relbutton6" onclick="freqstep(-1)"><</button
><button class="relbutton6" onclick="freqstep(+1)">></button
><button class="relbutton6" onclick="freqstep(+2)">>></button
><button class="relbutton6" onclick="freqstep(+3)">>>></button
><br
><button class="relbutton4" id="mutebutton" name="mute" onclick="togglemute()">mute</button
><button class="relbutton4" id="squelchbutton" name="mute" onclick="togglesquelch()">squelch</button
><button class="relbutton4" name="zoom out" onclick="waterfallapplet[0].setzoom(-1,waterfallapplet[0].width/2)">zoom out</button
><button class="relbutton4" name="zoom in" onclick="waterfallapplet[0].setzoom(-2,waterfallapplet[0].width/2)">zoom in</button
><hr
><b>Memories:</b><br
><button class="relbutton3" onclick="mem_store()">store</button
><button class="relbutton3" id="deletebutton" onclick="mem_deletebutton()">delete</button
><button class="relbutton3" id="labelbutton" onclick="mem_labelbutton()">label</button
><br
><div id="memories"></div>
<hr>
<b>Settings:</b>
<br>
<label class="onesetting" for="stopwaterfallcheckbox">
<input id="stopwaterfallcheckbox" type="checkbox" value="" onclick="waterfallapplet[0].startstop(!this.checked)">
Stop waterfall (reduces network and processor load)
</label>
<div></div>
<label class="onesetting" for="showsmetercheckbox">
<input id="showsmetercheckbox" type="checkbox" value=""
onclick="if (this.checked) { document.getElementById('smeter').style.display='block'; interval_updatesmeter = setInterval('updatesmeter()',200); }
else {document.getElementById('smeter').style.display='none'; clearInterval(interval_updatesmeter); }">
Show S-meter
</label>
<div></div>
<label class="onesetting" for="extrabuffer1checkbox">
<input id="extrabuffer1checkbox" type="checkbox" value="" onclick="set_buffer1(this.checked)">
More playback buffering
</label>
<div></div>
<script>
document.getElementById('stopwaterfallcheckbox').checked=false;
document.getElementById('showsmetercheckbox').checked=false;
document.getElementById('extrabuffer1checkbox').checked=false;
</script>
<br>
<hr>
<div id="soundappletdiv"></div>
<hr>
<footer class="my-4 pt-1 text-muted text-center text-small">
<p class="mb-1">© 2019 VHF Goonhilly WebSDR Project, provided by AMSAT-UK & BATC, hosted by Goonhilly Earth Station.</p>
</footer>
<script src="tmp/bandinfo.js" type="text/javascript"></script>
<script>
//----------------------------------------------------------------------------------------
// WebSDR, client side for mobile devices
// Copyright 2007-2014, Pieter-Tjerk de Boer, [email protected]
var isTouchDev=true;
var freq=ini_freq;
var mode=ini_mode.toUpperCase();
var hi=3.5;
var lo=-3.5;
var band=0;
var soundapplet=null;
var smeter;
var mute=0;
var started=0;
var reqanim=1;
var memories;
try { memories=JSON.parse(localStorage.getItem('memories')); } catch (e) {};
if (!memories) memories=[];
else mem_show();
var wvw=document.body.offsetWidth || window.innerWidth;
if (wvw>1024) wvw=1024;
var nwaterfalls=1;
var waterfallapplet = [
{ div:"wfdiv", id:0, band:band, maxzoom:bandinfo[band].maxzoom, width:wvw }
];
var i;
for (i=0;i<nbands;i++) bandinfo[i].zoom=0;
document.getElementById("ax").width=wvw;
var wvw0=wvw;
document.getElementById('modesel').value=mode;
setmode_sel(document.getElementById('modesel'));
{
var i;
var s="";
for (i=0;i<nbands;i++) {
var bi=bandinfo[i];
s+=(i?"<br>":"")+bi.name+": "+(bi.centerfreq-bi.samplerate/2).toFixed(0)+" - "+(bi.centerfreq+bi.samplerate/2).toFixed(0)+" kHz";
}
document.getElementById("freqinfo").innerHTML=s;
}
// ----- initialization stuff: -------------------------------
function start_audio()
{
if(sup_iOS)
{
// Safari on iOS only plays webaudio after it has been started by clicking a button, so this function must be called from a button's onclick handler
if (!document.ct) document.ct = new webkitAudioContext();
var s = document.ct.createBufferSource();
s.connect(document.ct.destination);
try { s.start(0); } catch(e) { s.noteOn(0); };
}
else
{
document['ct'].resume();
}
setTimeout(function() {
if(document['ct'].state != 'suspended')
{
document.getElementById("mobile_audio_start_btn").style.display = "none";
}
else
{
alert("Audio playback doesn't appear to be working, please refresh or contact project team if the problem persists.");
}
}, 50);
}
var serveravailable=-1; // -1 means yet to be tested, 0 and 1 mean false and true
function test_serverbusy()
{
serveravailable=soundapplet.getid();
if (serveravailable<0) setTimeout('test_serverbusy()',100);
if (serveravailable==0) {
document.body.innerHTML="Sorry, the WebSDR server is too busy right now; please try again later.\n";
}
}
function soundappletstarted()
{
started++;
serveravailable=-1;
setTimeout('test_serverbusy()',100);
if (started==2) setfreq(freq);
}
function waterfallappletstarted()
{
waterfallapplet[0].setslow(8);
bandinfo[band].zoom=1;
centerwaterfall();
started++;
if (started==2) setfreq(freq);
}
function browsersupporterror()
{
document.getElementById("browserwarning").style.display= "block";
}
// ----- zooming & tuning: -------------------------------
// this function is called when the scrollwheel is moved to change the zoom
function zoomchange(id,zoom,start)
{
var e=bandinfo[band];
if (zoom==e.zoom && start==e.start) return;
var oldzoom=e.zoom;
e.kHzperpx = e.samplerate/(1<<zoom)/1024;
e.px0freq = e.centerfreq - e.samplerate/2 + (start*(e.samplerate/(1<<e.maxzoom))/1024);
e.zoom=zoom;
e.start=start;
drawaxis();
var newfreq=e.px0freq+e.kHzperpx*waterfallapplet[0].width/2;
if (Math.abs(freq-newfreq)>4*e.kHzperpx || zoom==oldzoom) {
freq=newfreq;
document.freqform.frequency.value=nominalfreq().toFixed(2);
send_soundsettings_to_server();
}
}
function iscw()
{
return hi-lo < 1.0;
}
function nominalfreq()
{
if (iscw()) return freq+(hi+lo)/2;
return freq;
}
function send_soundsettings_to_server()
{
var m=mode;
if (m=="USB") m=0;
else if (m=="LSB") m=0;
else if (m=="CW") m=0;
else if (m=="AM") m=1;
else if (m=="FM") m=4;
if(soundapplet != null)
{
soundapplet.setparam(
"f="+freq
+"&band="+band
+"&lo="+lo
+"&hi="+hi
+"&mode="+m
+"&name=mobile"+(sup_iOS?"/iOS":sup_android?"/Android":"")
);
}
}
function centerwaterfall()
{
var e=bandinfo[band];
var zoom=e.zoom;
e.kHzperpx = e.samplerate/(1<<zoom)/1024;
e.kHzperpxmax = e.samplerate/(1<<e.maxzoom)/1024;
e.px0freq = freq-e.kHzperpx*waterfallapplet[0].width/2;
var start = ( e.px0freq - e.centerfreq + e.samplerate/2 ) / e.kHzperpxmax;
waterfallapplet[0].setzoom(zoom, start);
}
var freqfocus=false;
function setband(b)
{
if (b<0 || b>=nbands) return;
band=b;
var e=bandinfo[b];
waterfallapplet[0].setband(b, e.maxzoom, e.zoom, e.start);
drawaxis();
}
function setfreq(f)
{
freq=f;
f=nominalfreq();
var e=bandinfo[band];
if (f<e.centerfreq-e.samplerate/2-4 || f>e.centerfreq+e.samplerate/2+4) {
// new frequency is not in the current band: then search through all bands until we find the right one (if any)
for (i=0;i<nbands;i++) {
e=bandinfo[i];
c=e.centerfreq;
w=e.samplerate/2+4;
if (f>c-w && f<c+w) { setband(i); break; }
}
}
if (!freqfocus) document.freqform.frequency.value=nominalfreq().toFixed(2);
send_soundsettings_to_server();
centerwaterfall();
}
function setmode_sel(sel)
{
mode=sel.options[sel.selectedIndex].value;
switch (mode) {
case "AM": lo=-3.5; hi=3.5; break;
case "FM": lo=-7; hi=7; break;
case "CW": lo=0.55; hi=0.95; break;
case "USB": lo=0.3; hi=2.7; break;
case "LSB": lo=-2.7; hi=-0.3; break;
}
document.freqform.frequency.value=nominalfreq().toFixed(2); // because modechange might change nominalfrequency
send_soundsettings_to_server();
drawaxis(); // to update the passband indicator
}
function freqstep(st)
// do a frequency step, suitable for the current mode
{
var steps_ssb= [bandinfo[band].tuningstep, 0.5, 2.5 ];
var steps_am5= [0.1, 1, 5];
var steps_am9= [0.1, 1, 9];
var steps_fm= [1, 5, 12.5 ];
var steps=steps_ssb;
var grid=false;
var i=Math.abs(st)-1;
if (mode=="AM") {
if (freq<1800) steps=steps_am9; else steps=steps_am5;
if (i>=1) grid=true;
}
if (mode=="FM") {
steps=steps_fm;
if (i>=1) grid=true;
}
var d=steps[i];
var f=(st>0)?freq:-freq;
if (!grid) f=f+d;
else f=d*Math.ceil(f/d+0.1);
f=(st>0)?f:-f;
setfreq(f);
}
function freqsubmit(fo)
{
var f=fo.frequency.value;
if (iscw()) f-=(hi+lo)/2;
if (!(f>0)) f=freq;
setTimeout("setfreq("+f+");",0);
//fo.modesel.focus();
}
// ----- other controls: -------------------------------
var muted=0;
function togglemute()
{
muted=1-muted;
document.getElementById("mutebutton").style.backgroundColor = muted ? "darkgrey" : "";
// document.getElementById("mutebutton").innerHTML = muted ? "unmute" : "mute";
soundapplet.setparam("mute="+muted);
}
var squelched=0;
function togglesquelch()
{
squelched=1-squelched;
document.getElementById("squelchbutton").style.backgroundColor = squelched ? "darkgrey" : "";
soundapplet.setparam("squelch="+squelched);
}
var wfhidden=0;
function togglewfhide()
{
wfhidden=1-wfhidden;
document.getElementById("wfhidebutton").style.backgroundColor = wfhidden ? "darkgrey" : "";
if (wfhidden) {
waterfallapplet[0].destroy();
} else {
waterfallapplet = [ { div:"wfdiv", id:0, band:0, maxzoom:bandinfo[band].maxzoom, width:wvw } ];
prep_html5waterfalls();
}
}
var wfhidden=0;
function setwfhide(h)
{
wfhidden=h;
if (wfhidden) {
waterfallapplet[0].destroy();
} else {
waterfallapplet = [ { div:"wfdiv", id:0, band:0, maxzoom:bandinfo[band].maxzoom, width:wvw } ];
prep_html5waterfalls();
}
}
function set_buffer1(toggle)
{
if (toggle) soundapplet.setdelay1(4000);
else soundapplet.setdelay1(1000);
}
var smeterpeaktimer=2;
var smeterpeak=0;
var interval_updatesmeter;
function updatesmeter()
{
try {
var s=soundapplet.smeter();
} catch (e) { s=0; };
var c=''+(s/100.0-127).toFixed(1);
if (c.length<6) c=' '+c;
document.getElementById('numericalsmeter').innerHTML = c;
if (s>=0) document.getElementById('smeterbar').style.width= s*0.0191667+"px";
else document.getElementById('smeterbar').style.width="0px";
smeterpeaktimer--;
if ((smeterpeak<s-0.1) || (smeterpeaktimer<=0)) {
smeterpeak=s;
smeterpeaktimer=5;
if (smeterpeak>=0) document.getElementById('smeterpeak').style.width= smeterpeak*0.0191667 +"px";
else document.getElementById('smeterpeak').style.width="0px";
var c=''+(s/100.0-127).toFixed(1);
if (c.length<6) c=' '+c;
document.getElementById('numericalsmeterpeak').innerHTML = c;
}
}
// ----- drawing the frequency axis -------------------------------
var needdrawaxis=0;
function drawaxis_do()
{
var ax=document.getElementById("ax");
var ctx=ax.getContext("2d");
var vw=ax.width;
needdrawaxis=0;
// erase canvas
ctx.fillStyle="black";
ctx.fillRect(0,0,vw,ax.height);
// draw major tics
ctx.strokeStyle="white";
ctx.beginPath();
ctx.font="18px Verdana";
ctx.fillStyle="white";
ctx.textAlign="center";
ctx.lineWidth=2;
var i;
var b=bandinfo[band];
var fmin=b.px0freq;
if (fmin<b.centerfreq-b.samplerate/2) fmin=b.centerfreq-b.samplerate/2;
var fmax=b.px0freq+b.kHzperpx*vw;
if (fmax>b.centerfreq+b.samplerate/2) fmax=b.centerfreq+b.samplerate/2;
var grid=9;
var mgrid=1;
if (fmin>1600) grid=10;
if (b.kHzperpx>0.15) { grid=20; mgrid=grid/10; }
if (b.kHzperpx>0.3) { grid=50; mgrid=grid/10; }
if (b.kHzperpx>0.6) { grid=100; mgrid=grid/10; }
if (b.kHzperpx>1.5) { grid=200; mgrid=grid/10; }
if (b.kHzperpx>3) { grid=500; mgrid=grid/10; }
if (b.kHzperpx>6) { grid=1000; mgrid=grid/10; }
if (b.kHzperpx>15) { grid=2000; mgrid=grid/10; }
if (b.kHzperpx>30) { grid=5000; mgrid=grid/10; }
if (b.kHzperpx>60) { grid=10000; mgrid=grid/10; }
var f=Math.ceil(fmin/grid)*grid;
// major ticks
while (f<fmax) {
var x=0.5+(f-b.px0freq)/b.kHzperpx;
ctx.moveTo(x,21);
ctx.lineTo(x,15);
ctx.fillText(""+f,x,14);
f+=grid;
}
// minor ticks
grid=1;
var f=Math.ceil(fmin/grid)*grid;
while (f<fmax) {
var x=0.5+(f-b.px0freq)/b.kHzperpx;
ctx.moveTo(x,21); ctx.lineTo(x,19);
f+=mgrid;
}
ctx.stroke();
// draw tuning indicator
ctx.strokeStyle="yellow";
ctx.beginPath();
ctx.moveTo(vw/2+.5,3);
ctx.lineTo(vw/2+.5,19);
var x=vw/2+lo/b.kHzperpx;
ctx.moveTo(x-10,19);
ctx.lineTo(x-5,19);
ctx.lineTo(x,5);
var x=vw/2+hi/b.kHzperpx;
ctx.lineTo(x,5);
ctx.lineTo(x+5,17);
ctx.lineTo(x+10,17);
ctx.stroke();
}
function drawaxis()
{
if (reqanim) {
if (needdrawaxis) return;
needdrawaxis=1;
requestAnimationFrame(drawaxis_do);
}
else drawaxis_do();
}
window.onresize=function(ev)
{
wvw=document.body.offsetWidth || window.innerWidth;
if (wvw>1024) wvw=1024;
document.getElementById("ax").width=wvw;
waterfallapplet[0].setSize(wvw,waterfallapplet[0].height);
centerwaterfall();
drawaxis();
}
//----------------------------------------------------------------------------------------
// things related to interaction with the mouse (clicking & dragging on the frequency axes)
var dragging=false;
var dragorigX;
var dragorigval;
var touchingLower=false;
// from http://www.switchonthecode.com/tutorials/javascript-tutorial-the-scroll-wheel
function cancelEvent(e)
{
e = e ? e : window.event;
if(e.stopPropagation) e.stopPropagation();
if(e.preventDefault) e.preventDefault();
e.cancelBubble = true;
e.cancel = true;
e.returnValue = false;
return false;
}
function getMouseXY(e)
{
e = e || window.event;
if (e.pageX || e.pageY) return {x:e.pageX, y:e.pageY};
return {
x:e.clientX + document.body.scrollLeft - document.body.clientLeft,
y:e.clientY + document.body.scrollTop - document.body.clientTop
};
// from: http://www.webreference.com/programming/javascript/mk/column2/
}
function mouseup(e)
{
if (dragging) {
dragging=false;
document.onmousemove(e);
document.onmousemove = null;
}
}
document.onmouseup = mouseup;
// ----- handling memories -------------------------------
var mem_mode=0; // 0 for recall, 1 for erase, 2 for edit
function mem_recall(i)
{
mode=memories[i].mode;
document.getElementById('modesel').value=mode;
lo=memories[i].lo;
hi=memories[i].hi;
setfreq(memories[i].freq);
drawaxis(); // to update the passband indicator
}
function mem_erase(i)
{
var b=memories[i].band;
memories.splice(i,1);
mem_show();
try { localStorage.setItem('memories',JSON.stringify(memories)); } catch (e) {};
}
function mem_label(i)
{
var label=prompt("Label? ","");
if (!label) return;
memories[i].label=label;
mem_show();
try { localStorage.setItem('memories',JSON.stringify(memories)); } catch (e) {};
}
function mem_store()
{
var nomf=nominalfreq();
var l;
try { l=memories[i].label;} catch(e){ l=''; };
i=memories.length;
memories[i]={freq:freq, nomfreq:nomf, band:band, mode:mode, lo:lo, hi:hi, label:'' };
mem_show();
try { localStorage.setItem('memories',JSON.stringify(memories)); } catch (e) {};
}
function mem_click(i)
{
// called when clicking on a memory button
switch (mem_mode) {
case 0: mem_recall(i); break;
case 1: mem_erase(i); mem_set_mode(0); break;
case 2: mem_label(i); mem_set_mode(0); break;
}
}
function mem_set_mode(m)
{
mem_mode=m;
document.getElementById("deletebutton").style.backgroundColor = (mem_mode==1) ? "darkgrey" : "";
document.getElementById("labelbutton").style.backgroundColor = (mem_mode==2) ? "darkgrey" : "";
document.getElementById('memories').style.backgroundColor= (mem_mode>=1) ? "darkgrey" : "";
}
function mem_deletebutton()
{
var m=1;
if (mem_mode==1) m=0;
mem_set_mode(m);
}
function mem_labelbutton()
{
var m=2;
if (mem_mode==2) m=0;
mem_set_mode(m);
}
function mem_show()
{
var i;
var s="";
for (i=0;i<memories.length;i++) {
var m="";
m=memories[i].mode;
s+='<button class="relbuttona" onclick="mem_click('+i+')">'+memories[i].nomfreq.toFixed(2)+' '+m+
'<br>'+memories[i].label+'</button>';
}
document.getElementById('memories').innerHTML=s;
}
// Safari on iOS only plays webaudio after it has been started by clicking a button, so this function must be called from a button's onclick handler
function bodyonload()
{
if (!document.ct) document.ct= new webkitAudioContext();
var s = document.ct.createBufferSource();
s.connect(document.ct.destination);
try { s.start(0); } catch(e) { s.noteOn(0); }
if(document['ct'].state == 'suspended')
{
document.getElementById("mobile_audio_start_btn").style.display="inline";
}
}
//----------------------------------------------------------------------------------------
</script>
<script src="websdr-sound.js" type="text/javascript"></script>
<script src="websdr-waterfall.js" type="text/javascript"></script>
<script>
const ping_interval = 10*1000;
function ping() {
var request = new XMLHttpRequest();
request.open('GET', 'https://eshail.batc.org.uk/a.gif?f='+f+'&m='+mode, true);
request.send();
request = null;
setTimeout(ping, ping_interval);
}
setTimeout(ping, ping_interval);
</script>
</body>