1var gmap; 2var geocoder; 3var pos1; 4var pos2; 5 6function setLanguage(lng) { 7 console.log("before set cookie: "+lng); 8 document.cookie = "hamqthlang="+lng+";expires=Wed, 1 Jan 2100 12:00:00 UTC; path=/"; 9 return true; 10} 11 12function prepareGoogleMap() { 13 console.log(gmap); 14 if (typeof gmap === 'undefined'){ 15 var myOptions = { 16 zoom: 13, 17 center: new google.maps.LatLng(0,0), 18 mapTypeId: google.maps.MapTypeId.ROADMAP 19 }; 20 21 gmap = new google.maps.Map(document.getElementById("mapdata"), myOptions); 22 geocoder = new google.maps.Geocoder(); 23 }; 24} 25 26function loadGoogleMapScript() { 27 var script = document.createElement('script'); 28 script.type = 'text/javascript'; 29 script.src = 'https://maps.googleapis.com/maps/api/js?v=3.exp&key=AIzaSyDWMrEJEYqqIBIelfW9dXBWpPvIsWSx8RU&' + 30 ''; 31 document.body.appendChild(script); 32} 33 34function findLatLongFromAddress(myAddress, myLat, myLng, hisAddress, hisLat, hisLng, callhash) { 35 var hisLoc; 36 var myLoc; 37 38 console.log("myAddress:",myAddress); 39 if (myAddress!=="") { 40 geocoder.geocode( { 'address': myAddress}, function(results, status) { 41 if (status === google.maps.GeocoderStatus.OK) { 42 myLoc = results[0].geometry.location; 43 console.log(myLoc); 44 var marker1 = new google.maps.Marker({ 45 map: gmap, 46 position: myLoc 47 }); 48 } 49 else { 50 console.log("Geocode was not successful for the following reason: " + status); 51 } 52 }); 53 } 54 55 console.log("hisLat"+hisLat.toString()); 56 console.log("hisLng"+hisLng.toString()); 57 console.log("hisAddress"+hisAddress); 58 if (hisLat===0 && hisLng===0) { 59 geocoder.geocode( { 'address': hisAddress}, function(results, status) { 60 if (status === google.maps.GeocoderStatus.OK) { 61 hisLoc = results[0].geometry.location; 62 var marker = new google.maps.Marker({ 63 map: gmap, 64 position: hisLoc 65 }); 66 console.log("hisLoc"+hisLoc); 67 console.log("myLoc"+myLoc); 68 69 console.log(hisLoc.lat()); 70 console.log(hisLoc.lng()); 71 72 73 var grid = latLonToGridSquare(hisLoc.lat(),hisLoc.lng()); 74 console.log(grid); 75 //console.log("http://www.hamqth.com/updategrid.php?id="+callhash+"&grid="+grid); 76 xmlHttp = new XMLHttpRequest(); 77 xmlHttp.open("GET","https://www.hamqth.com/updategrid.php?id="+callhash+"&grid="+grid, false ); 78 xmlHttp.send( null ); 79 80 if (document.getElementById('grid').textContent ==="") { 81 document.getElementById('grid').textContent = grid; 82 } 83 84 if (typeof myLoc !== 'undefined') { 85 var mapPath = [myLoc,hisLoc]; 86 87 var geodesicOptions = { 88 path : mapPath, 89 strokeColor: '#CC0099', 90 strokeOpacity: 1.0, 91 strokeWeight: 3, 92 geodesic: true, 93 map: gmap 94 }; 95 geodesicPoly = new google.maps.Polyline(geodesicOptions); 96 } 97 gmap.setCenter(results[0].geometry.location); 98 99 } 100 else { 101 console.log("Geocode was not successful for the following reason: " + status); 102 } 103 }); 104 } 105 else { 106 console.log("hisLat && hisLong <> 0"); 107 hisLoc = new google.maps.LatLng(hisLat,hisLng); 108 console.log("hisLoc"+hisLoc); 109 gmap.setCenter(hisLoc); 110 var marker = new google.maps.Marker({ 111 map: gmap, 112 position: hisLoc 113 }); 114 } 115 116} 117 118function updateGrid(hisAddress) { 119 geocoder = new google.maps.Geocoder(); 120 geocoder.geocode( { 'address': hisAddress}, function(results, status) { 121 if (status === google.maps.GeocoderStatus.OK) { 122 hisLoc = results[0].geometry.location; 123 var marker = new google.maps.Marker({ 124 map: gmap, 125 position: hisLoc 126 }); 127 console.log("hisLoc"+hisLoc); 128 129 console.log(hisLoc.lat()); 130 console.log(hisLoc.lng()); 131 132 var grid = latLonToGridSquare(hisLoc.lat(),hisLoc.lng()); 133 console.log(grid); 134 //xmlHttp = new XMLHttpRequest(); 135 //xmlHttp.open( "GET","http://hamqth.com/dxcc.php?callsign=N:"+adif.toString(), false ); 136 //xmlHttp.send( null ); 137 } 138 }); 139} 140 141function onChangeCountry() { 142 var adif = document.getElementById('frm-adif').value; 143 var xmlHttp = null; 144 xmlHttp = new XMLHttpRequest(); 145 xmlHttp.open( "GET","https://www.hamqth.com/dxcc.php?callsign=N:"+adif.toString(), false ); 146 xmlHttp.send( null ); 147 var data = xmlHttp.responseText; 148 if (data.indexOf("ERROR") === -1) 149 { 150 var arra = data.split("|"); 151 document.getElementById('itu').value = arra[0]; 152 document.getElementById('cq').value = arra[1]; 153 document.getElementById('frm-continent').value = arra[2]; 154 document.getElementById('gmt_offset').value = arra[3]; 155 document.getElementById('latitude').value = arra[4]; 156 document.getElementById('longitude').value = arra[5]; 157 } 158 return true; 159} 160
161$('#searchSpot').click(function (event){ 162 event.preventDefault(); 163 var callsign = $('#spotCallsign').val(); 164 console.log(callsign); 165 $('#spot_search').fadeOut('slow').load('/spot_search.php?callsign='+callsign).fadeIn("slow"); 166}); 167 168function setCookie(key, value) { 169 var expires = new Date(); 170 expires.setTime(expires.getTime() + 31536000000); //1 year 171 document.cookie = key + '=' + value + ';expires=' + expires.toUTCString(); 172} 173 174function getCookie(key) { 175 var keyValue = document.cookie.match('(^|;) ?' + key + '=([^;]*)(;|$)'); 176 return keyValue ? keyValue[2] : null; 177} 178 179// HamGridSquare.js 180// Copyright 2014 Paul Brewer KI6CQ 181// License: MIT License http://opensource.org/licenses/MIT or CC-BY-SA 182// 183// Javascript routines to convert from lat-lon to Maidenhead Grid Squares 184// typically used in Ham Radio Satellite operations and VHF Contests 185// 186// Inspired in part by K6WRU Walter Underwood's python answer 187// http://ham.stackexchange.com/a/244 188// to this stack overflow question: 189// How Can One Convert From Lat/Long to Grid Square 190// http://ham.stackexchange.com/questions/221/how-can-one-convert-from-lat-long-to-grid-square 191// 192 193latLonToGridSquare = function(param1,param2){ 194 var lat=-100.0; 195 var lon=0.0; 196 var adjLat,adjLon,GLat,GLon,nLat,nLon,gLat,gLon,rLat,rLon; 197 var U = 'ABCDEFGHIJKLMNOPQRSTUVWX'; 198 var L = U.toLowerCase(); 199 // support Chris Veness 2002-2012 LatLon library and 200 // other objects with lat/lon properties 201 // properties could be getter functions, numbers, or strings 202 function toNum(x){ 203 if (typeof(x) === 'number') return x; 204 if (typeof(x) === 'string') return parseFloat(x); 205 if (typeof(x) === 'function') return parseFloat(x()); 206 throw "HamGridSquare -- toNum -- can not convert input: "+x; 207 } 208 if (typeof(param1)==='object'){ 209 if (param1.length === 2){ 210 lat = toNum(param1[0]); 211 lon = toNum(param1[1]); 212 } else if (('lat' in param1) && ('lon' in param1)){ 213 lat = toNum(param1.lat); 214 lon = toNum(param1.lon); 215 } else if (('latitude' in param1) && ('longitude' in param1)){ 216 lat = toNum(param1.latitude); 217 lon = toNum(param1.longitude); 218 } else { 219 throw "HamGridSquare -- can not convert object -- "+param1; 220 } 221 } else { 222 lat = toNum(param1); 223 lon = toNum(param2); 224 } 225 if (isNaN(lat)) throw "lat is NaN"; 226 if (isNaN(lon)) throw "lon is NaN"; 227 if (Math.abs(lat) === 90.0) throw "grid squares invalid at N/S poles"; 228 if (Math.abs(lat) > 90) throw "invalid latitude: "+lat; 229 if (Math.abs(lon) > 180) throw "invalid longitude: "+lon; 230 adjLat = lat + 90; 231 adjLon = lon + 180; 232 GLat = U[Math.trunc(adjLat/10)]; 233 GLon = U[Math.trunc(adjLon/20)]; 234 nLat = ''+Math.trunc(adjLat % 10); 235 nLon = ''+Math.trunc((adjLon/2) % 10); 236 rLat = (adjLat - Math.trunc(adjLat)) * 60; 237 rLon = (adjLon - 2*Math.trunc(adjLon/2)) *60; 238 gLat = L[Math.trunc(rLat/2.5)]; 239 gLon = L[Math.trunc(rLon/5)]; 240 return GLon+GLat+nLon+nLat+gLon+gLat; 241} 242 243testGridSquare = function(){ 244 // First four test examples are from "Conversion Between Geodetic and Grid Locator Systems", 245 // by Edmund T. Tyson N5JTY QST January 1989 246 // original test data / citations by Walter Underwood K6WRU 247 // last test and coding into Javascript from Python by Paul Brewer KI6CQ 248 var testData = [ 249 ['Munich', [48.14666,11.60833], 'JN58td'], 250 ['Montevideo', [[-34.91,-56.21166]], 'GF15vc'], 251 ['Washington, DC', [{lat:38.92,lon:-77.065}], 'FM18lw'], 252 ['Wellington', [{latitude:-41.28333,longitude:174.745}], 'RE78ir'], 253 ['Newington, CT (W1AW)', [41.714775,-72.727260], 'FN31pr'], 254 ['Palo Alto (K6WRU)', [[37.413708,-122.1073236]], 'CM87wj'], 255 ['Chattanooga (KI6CQ/4)', [{lat:function(){ return "35.0542"; }, 256 lon: function(){ return "-85.1142"}}], "EM75kb"] 257 ]; 258 var i=0,l=testData.length,result='',thisPassed=0,totalPassed=0; 259 for(i=0;i<l;++i){ 260 result = latLonToGridSquare.apply({}, testData[i][1]); 261 thisPassed = result===testData[i][2]; 262 console.log("test "+i+": "+testData[i][0]+" "+JSON.stringify(testData[i][1])+ 263 " result = "+result+" expected= "+testData[i][2]+ 264 " passed = "+thisPassed); 265 totalPassed += thisPassed; 266 } 267 console.log(totalPassed+" of "+l+" test passed"); 268 return totalPassed===l; 269} 270
271$('#btnSendSpot').click(function(event){ 272 event.preventDefault(); 273 var freq = $('#edtFreq').val(); 274 var dxCall = $('#edtDxCall').val(); 275 var note = $('#edtNote').val(); 276 277 $.ajax({ 278 type: "POST", 279 url: "/sendspot.php", 280 dataType: 'text', 281 data: { 282 freq : freq, 283 dxcall : dxCall, 284 note : note 285 }, 286 complete : function() { 287 $('#newspot').modal('hide'); 288 $('#edtFreq').val(null); 289 $('#edtDxCall').val(null); 290 $('#edtNote').val(null); 291 } 292 }); 293}); 294 295$('#newspot').on('shown.bs.modal', function () { 296 $('#edtFreq').focus(); 297}); 298 299$('[data-dismiss=modal]').on('click', function (e) { 300 var $t = $(this), 301 target = $t[0].href || $t.data("target") || $t.parents('.modal') || []; 302 303 $(target) 304 .find("input,textarea,select") 305 .val('') 306 .end() 307 .find("input[type=checkbox], input[type=radio]") 308 .prop("checked", "") 309 .end(); 310}); 311 312$('#rbn-reload').click(function (e) { 313 e.preventDefault(); 314 315 var request = new XMLHttpRequest(); 316 317 var address = getRbnAddress(); 318 console.log(address); 319 request.open("GET", address, true); 320 321 request.onreadystatechange = function() { 322 if (request.readyState == 4 && request.status == 200) { 323 var spots = JSON.parse(request.responseText); 324 show_spots(spots); 325 }; 326 } 327 request.send(null); 328 329}); 330 331function show_spots(spots) { 332 var table = '<table class="table table-condensed table-striped"><thead><tr><th>Freq</th><th>Mode</th><th>Callsign</th><th>Age</th><th>Source</th></tr></thead>'; 333 table += '<tbody>'; 334 335 $.each(spots, function(i, item){ 336 if (item.age < 20) { 337 table += '<tr class="danger">'; 338 } 339 else if (item.age < 50) { 340 table += '<tr class="success">'; 341 } 342 else { 343 table += '<tr class="active">'; 344 } 345 table += '<td class="text-right">'+item.freq+'</td>'; 346 table += '<td class="text-center">'+item.mode+'</td>'; 347 table += '<td><a href="https://www.hamqth.com/'+item.dxcall+'">'+item.dxcall+'</a></td>'; 348 table += '<td class="text-right">'+item.age+'</td>'; 349 350 table += '<td>'; 351 var a = item.lsn; 352 var rcvd = ''; 353 var i = 1; 354 var more = ''; 355 $.each(a, function(y,s){ 356 if (i>13) { 357 more += y+'('+s+')'+"\n"; 358 } 359 else { 360 var style = ' class="rbn'; 361 if (s>40) { 362 style += '40'; 363 } 364 else if (s>30) { 365 style += '30'; 366 367 } 368 else if (s>20) { 369 style += '20'; 370 371 } 372 else if (s>10) { 373 style += '10'; 374 375 } 376 else { 377 style += '00'; 378 } 379 style +='" '; 380 rcvd += '<span title="'+s+'" '+style+'>'+y+'</span> '; 381 } 382 i++; 383 }); 384 if (more!=='') { 385 rcvd += '<span title="'+more+'"><strong>...</strong></span>'; 386 } 387 table += rcvd; 388 table += '</td>'; 389 390 391 table += '</tr>'; 392 }); 393 table += '</tbody></table>Spots are reloaded ever 10 seconds'; 394 //console.log(table); 395 396 $('#rbn-result').html(table); 397} 398 399 400function getRbnAddress() { 401 402 var bands = checkboxesToString('bands'); 403 var fromcont = checkboxesToString('fromcont'); 404 fromcont = fromcont.replace(/frm/g,''); 405 var mode = checkboxesToString("mode"); 406 var cont = checkboxesToString("cont"); 407 var waz = $('#waz').val(); 408 var itu = $('#itu').val(); 409 var age = radioToString('maxage'); 410 age = age.replace(/max/g,''); 411 412 var sort = 3; 413 if ($('#sort-freq').prop('checked')) { 414 sort = 1; 415 } 416 else if ($('#sort-call').prop('checked')) { 417 sort = 2; 418 } 419 420 setCookie('band',bands);
421 setCookie('mode',mode); 422 setCookie('fromcont',fromcont); 423 setCookie('cont',cont); 424 setCookie('waz',waz); 425 setCookie('itu',itu); 426 setCookie('sortby',sort); 427 setCookie('age',age); 428 429 if (bands!=='') { 430 bands = '&band='+bands; 431 } 432 433 if (fromcont!=='') { 434 fromcont = '&fromcont='+fromcont; 435 } 436 437 if (mode!=='') { 438 mode = '&mode='+mode; 439 } 440 441 if (cont!=='') { 442 cont = '&cont='+cont; 443 } 444 445 if (waz!=='') { 446 waz = '&waz='+waz; 447 } 448 449 if (itu!=='') { 450 itu = '&itu='+itu; 451 } 452 453 return '/rbn_data.php?data=1'+bands+fromcont+mode+cont+waz+itu+'&age='+age+'&order='+sort; 454} 455 456function checkboxesToString(chkName) { 457 var tmp = ''; 458 $('#'+chkName+' :checkbox').each(function(){ 459 var id = $(this).attr('id'); 460 if ($('#'+id).prop('checked')) { 461 tmp = tmp + id + ','; 462 } 463 }); 464 return tmp.substr(0,tmp.length-1); 465} 466 467function radioToString(chkName) { 468 var tmp = ''; 469 $('#'+chkName+' :radio').each(function(){ 470 var id = $(this).attr('id'); 471 if ($('#'+id).prop('checked')) { 472 tmp = tmp + id + ','; 473 } 474 }); 475 return tmp.substr(0,tmp.length-1); 476} 477 478function filter_changed() { 479 $('#rbn-reload').click(); 480} 481 482 483$('#allItu').click(function (e) { 484 e.preventDefault(); 485 $('#itu').val('*'); 486 $('#rbn-reload').click(); 487}); 488 489$('#allWaz').click(function (e) { 490 e.preventDefault(); 491 $('#waz').val('*'); 492 $('#rbn-reload').click(); 493}); 494 495$('#btn-rbnfilter').click(function () { 496 $('#rbnfilter').toggle(); 497 498 if ($("#rbnfilter").is(':hidden')) { 499 $(this).text('Show filter'); 500 } 501 else { 502 $(this).text('Hide filter'); 503 } 504}); 505 506// cluster //////////////////////////////////////////////////////////////////////////////////////////////////////////// 507 508$('#btn-dxcfilter').click(function () { 509 $('#dxcfilter').toggle(); 510 511 if ($("#dxcfilter").is(':hidden')) { 512 $(this).text('Show filter'); 513 } 514 else { 515 $(this).text('Hide filter'); 516 } 517}); 518 519$('#allDxcItu').click(function (e) { 520 e.preventDefault(); 521 $('#dxcItu').val('*'); 522 $('#dxc-reload').click(); 523}); 524 525$('#allDxcWaz').click(function (e) { 526 e.preventDefault(); 527 $('#dxcWaz').val('*'); 528 $('#dxc-reload').click(); 529}); 530 531function dxc_filter_changed() { 532 $('#dxc-reload').click(); 533} 534 535function getDxcAddress() { 536 537 var bands = checkboxesToString('dxcBands'); 538 bands = bands.replace(/dxc/g,''); 539 var fromcont = checkboxesToString('dxcFromcont'); 540 fromcont = fromcont.replace(/dxcFrm/g,''); 541 var mode = checkboxesToString("dxcMode"); 542 mode = mode.replace(/dxc/g,''); 543 var cont = checkboxesToString("dxcCont"); 544 cont = cont.replace(/dxc/g,''); 545 var waz = $('#dxcWaz').val(); 546 waz = waz.replace(/dxc/g,''); 547 var itu = $('#dxcItu').val(); 548 itu = itu.replace(/dxc/g,''); 549 550 var lotw = 0; 551 if ($('#dxcLoTW').prop('checked')) { 552 lotw = 1; 553 } 554 555 var eqsl = 0; 556 if ($('#dxceQSL').prop('checked')) { 557 eqsl = 1; 558 } 559 560 setCookie('dxcBand',bands);
561 setCookie('dxcMode',mode); 562 setCookie('dxcFromcont',fromcont); 563 setCookie('dxcCont',cont); 564 setCookie('dxcWaz',waz); 565 setCookie('dxcItu',itu); 566 setCookie('dxcLoTW',lotw); 567 setCookie('dxceQSL',eqsl); 568 569 /* 570 console.log('set :'+bands); 571 console.log('set :'+mode); 572 console.log('set :'+fromcont); 573 console.log('set :'+cont); 574 console.log('set :'+waz); 575 console.log('set :'+itu); 576 console.log('set :'+lotw); 577 console.log('set :'+eqsl); 578 */ 579 580 if (bands!=='') { 581 bands = '&band='+bands; 582 } 583 584 if (fromcont!=='') { 585 fromcont = '&fromcont='+fromcont; 586 } 587 588 if (mode!=='') { 589 mode = '&mode='+mode; 590 } 591 592 if (cont!=='') { 593 cont = '&cont='+cont; 594 } 595 596 if (waz!=='') { 597 waz = '&waz='+waz; 598 } 599 600 if (itu!=='') { 601 itu = '&itu='+itu; 602 } 603 604 if (lotw) { 605 lotw = '&lotw=1'; 606 } 607 else { 608 lotw = ''; 609 } 610 611 if (eqsl) { 612 eqsl = '&eqsl=1'; 613 } 614 else { 615 eqsl = ''; 616 } 617 618 return '/dxc_json.php?data=1'+bands+fromcont+mode+cont+waz+itu+lotw+eqsl; 619} 620 621$('#dxc-reload').click(function (e) { 622 e.preventDefault(); 623 624 var request = new XMLHttpRequest(); 625 626 var address = getDxcAddress(); 627 //console.log(address); 628 request.open("GET", address, true); 629 630 request.onreadystatechange = function() { 631 if (request.readyState == 4 && request.status == 200) { 632 var spots = JSON.parse(request.responseText); 633 //console.log(spots); 634 show_dxc_spots(spots); 635 }; 636 } 637 request.send(null); 638 639}); 640 641$('#allDxcBands').click(function (e) { 642 $('#dxcBands :checkbox').each(function(){ 643 var id = $(this).attr('id'); 644 ($('#'+id).prop('checked', true)); 645 }); 646}); 647 648$('#nilDxcBands').click(function (e) { 649 $('#dxcBands :checkbox').each(function(){ 650 var id = $(this).attr('id'); 651 ($('#'+id).prop('checked', false)); 652 }); 653}); 654 655function loadClusterFilter() { 656 var band = getCookie("dxcBand"); 657 if ((band === null) || (band==='')) { 658 $('#dxcBands :checkbox').prop('checked', true); 659 } 660 else { 661 band = band.split(','); 662 for(var i=0;i<band.length;i++) { 663 $('#dxc'+band[i]).prop('checked', true); 664 } 665 } 666 667 var fromcont = getCookie('dxcFromcont'); 668 if ((fromcont === null) || (fromcont==='')){ 669 $('#dxcFrmEU').prop('checked', true); 670 $('#dxcFrmNA').prop('checked', true); 671 $('#dxcFrmSA').prop('checked', true); 672 $('#dxcFrmOC').prop('checked', true); 673 $('#dxcFrmAN').prop('checked', true); 674 $('#dxcFrmAF').prop('checked', true); 675 $('#dxcFrmAS').prop('checked', true); 676 } 677 else { 678 fromcont = fromcont.split(','); 679 for(var i=0;i<fromcont.length;i++) { 680 $('#dxcFrm'+fromcont[i]).prop('checked', true); 681 } 682 } 683 684 var mode = getCookie('dxcMode'); 685 if ((mode === null) || (mode==='')) { 686 $('#dxcMode :checkbox').prop('checked', true); 687 } 688 else { 689 //console.log(mode); 690 mode = mode.split(','); 691 for(var i=0;i<mode.length;i++) { 692 $('#dxc'+mode[i]).prop('checked', true); 693 } 694 } 695 696 var waz = getCookie('dxcWaz'); 697 if ((waz === null) || (waz==='')) { 698 $('#dxcWaz').val('*'); 699 } 700 else { 701 $('#dxcWaz').val(waz); 702 } 703 704 var itu = getCookie('dxcItu'); 705 if ((itu === null) || (itu==='')) { 706 $('#dxcItu').val('*'); 707 } 708 else { 709 $('#dxcItu').val(itu); 710 } 711 712 var cont = getCookie('dxcCont'); 713 if ((cont === null) || (cont==='')){ 714 $('#dxcCont :checkbox').prop('checked', true); 715 } 716 else { 717 cont = cont.split(','); 718 for(var i=0;i<cont.length;i++) { 719 $('#dxc'+cont[i]).prop('checked', true); 720 } 721 } 722 723 var lotw = getCookie('dxcLoTW'); 724 //console.log('get dxcLoTW:'+lotw); 725 if ((lotw === null) || (lotw === '' || (lotw === '0'))){ 726 $('#dxcLoTW').prop('checked', false); 727 } 728 else { 729 $('#dxcLoTW').prop('checked', true); 730 } 731 732 var eqsl = getCookie('dxceQSL'); 733 //console.log('get dxceQSL:'+eqsl); 734 if ((eqsl === null) || (eqsl === '') || (eqsl === '0')){ 735 $('#dxceQSL').prop('checked', false); 736 } 737 else { 738 $('#dxceQSL').prop('checked', true); 739 } 740 741} 742 743 744function show_dxc_spots(spots) { 745 var table = '<table class="table table-condensed table-striped"><thead>'; 746 table += '<tr><th>Spotter</th><th>Freq</th><th>DX call</th><th>Comment</th><th class="text-center">Spot date</th><th>LoTW</th><th>eQSL</th><th>Country</th></tr></thead>'; 747 table += '<tbody>'; 748 var lotw = ' '; 749 var eqsl = ' '; 750 var active = ''; 751 $.each(spots, function(i, item){ 752 if (item.lotw === 1) {
753 lotw = 'L'; 754 } 755 else { 756 lotw = ' '; 757 } 758 759 if (item.eqsl === 1) { 760 eqsl = 'E'; 761 } 762 else { 763 eqsl = ' ' 764 } 765 766 item.comment = item.comment.replace('<','<'); 767 item.comment = item.comment.replace('>','>'); 768 769 if ((i % 2) > 0) { 770 active = 'class="active"'; 771 } 772 else { 773 active = ''; 774 } 775 776 table += '<tr style="color:'+item.color+'" '+active+'>'; 777 table += '<td><a href="https://www.hamqth.com/'+item.spotter+'" style="color:'+item.color+'" id="callsignLink">'+item.spotter+'</a></td>' 778 table += '<td class="text-right">'+item.freq+'</td>'; 779 table += '<td><a href="https://www.hamqth.com/'+item.dxcall+'" style="color:'+item.color+'" id="callsignLink">'+item.dxcall+'</a></td>'; 780 table += '<td>'+item.comment+'</td>'; 781 table += '<td class="text-center">'+item.spottime+'</td>'; 782 783 table += '<td>'+lotw+'</td>'; 784 table += '<td>'+eqsl+'</td>'; 785 table += '<td>'+item.country+'</td>'; 786 table += '</tr>'; 787 }); 788 table += '</tbody></table>Spots are reloaded ever 10 seconds'; 789 table += ' '; 790 table += '<script type="text/javascript">'; 791 table += 'var _gaq = _gaq || [];'; 792 table += '_gaq.push(["_setAccount", "UA-24185932-1"]);'; 793 table += '_gaq.push(["_trackPageview"]);'; 794 table += ' (function() {'; 795 table += ' var ga = document.createElement("script"); ga.type = "text/javascript"; ga.async = true;'; 796 table += ' ga.src = ("https:" == document.location.protocol ? "https://ssl" : "http://www") + ".google-analytics.com/ga.js";'; 797 table += ' var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(ga, s);'; 798 table += ' })();'; 799 table += '</script>'; 800 801 $('#spot_data').html(table); 802} 803 804function date_time(id) 805{ 806 date = new Date; 807 year = date.getUTCFullYear();
808 month = date.getUTCMonth(); 809 months = new Array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'); 810 d = date.getUTCDate(); 811 day = date.getUTCDay(); 812 h = date.getUTCHours(); 813 if(h<10) 814 { 815 h = "0"+h; 816 } 817 m = date.getUTCMinutes(); 818 if(m<10) 819 { 820 m = "0"+m; 821 } 822 s = date.getUTCSeconds(); 823 if(s<10) 824 { 825 s = "0"+s; 826 } 827 result = d+' '+months[month]+' '+year+' '+h+':'+m+':'+s+' UTC'; 828 document.getElementById(id).innerHTML = result; 829 830 // date = new Date; 831 // var h = date.getUTCHours(); 832 // if(h<10) 833 // { 834 // h = "0"+h; 835 // } 836 // var m = date.getUTCMinutes(); 837 // if(m<10) 838 // { 839 // m = "0"+m; 840 // } 841 // var s = date.getUTCSeconds(); 842 // if(s<10) 843 // { 844 // s = "0"+s; 845 // } 846 // result = h+':'+m+':'+s+' UTC'; 847 // document.getElementById(id).innerHTML = result; 848 setTimeout('date_time("'+id+'");','1000'); 849 return true; 850} 851 852if ($('#frm-oqrsurl').length) { 853 if ($('#frm-oqrstype-0').is(':checked') || $('#frm-oqrstype-1').is(':checked') || $('#frm-oqrstype-2').is(':checked')) { 854 $('#frm-oqrsurl').css('visibility', 'hidden'); 855 } 856} 857 858$('#frm-oqrstype-0').click(function (event) { 859 $('#frm-oqrsurl').css('visibility', 'hidden'); 860}); 861$('#frm-oqrstype-1').click(function (event) { 862 $('#frm-oqrsurl').css('visibility', 'hidden'); 863}); 864$('#frm-oqrstype-2').click(function (event) { 865 $('#frm-oqrsurl').css('visibility', 'hidden'); 866}); 867$('#frm-oqrstype-3').click(function (event) { 868 $('#frm-oqrsurl').css('visibility', 'visible'); 869}); 870 871$(document).ready(function() { 872 var root = "https://blockchain.info/"; 873 var buttons = $('.blockchain-btn'); 874 875 buttons.find('.blockchain').hide(); 876 buttons.find('.stage-begin').trigger('show').show(); 877 878 buttons.each(function(index) { 879 var _button = $(this); 880 881 (function() { 882 var button = _button; 883 884 button.click(function() { 885 var receivers_address = $(this).data('address'); 886 var test = $(this).data('test'); 887 888 button.find('.blockchain').hide(); 889 890 button.find('.stage-loading').trigger('show').show(); 891 892 button.find('.qr-code').empty(); 893 894 function checkBalance() { 895 $.ajax({ 896 type: "GET", 897 url: root + 'q/getreceivedbyaddress/'+receivers_address+ 898 '?start_time='+(new Date).getTime(), 899 data : {format : 'plain'}, 900 success: function(response) { 901 if (!response) return; 902 903 var value = parseInt(response); 904 905 if (value > 0 || test) { 906 button.find('.blockchain').hide(); 907 button.find('.stage-paid').trigger('show').show().html(button.find('.stage-paid').html().replace('[[value]]', value / 100000000)); 908 } else { 909 setTimeout(checkBalance, 5000); 910 } 911 } 912 }); 913 } 914 915 try { 916 ws = new WebSocket('wss://ws.blockchain.info/inv'); 917 918 if (!ws) return; 919 920 ws.onmessage = function(e) { 921 try { 922 var obj = $.parseJSON(e.data); 923 924 if (obj.op == 'utx') { 925 var tx = obj.x; 926 927 var result = 0; 928 for (var i = 0; i < tx.out.length; i++) { 929 var output = tx.out[i]; 930 931 if (output.addr == receivers_address) { 932 result += parseInt(output.value); 933 } 934 } 935 } 936 937 button.find('.blockchain').hide(); 938 button.find('.stage-paid').trigger('show').show().html(button.find('.stage-paid').html().replace('[[value]]', result / 100000000)); 939 940 ws.close(); 941 } catch(e) { 942 console.log(e); 943 944 console.log(e.data); 945 } 946 }; 947 948 ws.onopen = function() { 949 ws.send('{"op":"addr_sub", "addr":"'+ receivers_address +'"}'); 950 }; 951 } catch (e) { 952 console.log(e); 953 } 954 955 button.find('.stage-ready').trigger('show').show().html(button.find('.stage-ready').html().replace('[[address]]', receivers_address)); 956 957 button.find('.qr-code').html('<img style="margin:5px" src="'+root+'qr?data='+receivers_address+'&size=125">'); 958 959 button.unbind(); 960 961 ///Check for incoming payment 962 setTimeout(checkBalance, 5000); 963 }); 964 })(); 965 }); 966});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.