mirror of
https://github.com/wavelog/wavelog.git
synced 2026-03-22 02:14:13 +00:00
Revert "[X-mas cleaning] Found some leftovers"
This commit is contained in:
committed by
GitHub
parent
11af986034
commit
485a14113b
@@ -389,6 +389,31 @@ function stopImpersonate_modal() {
|
||||
<script type="text/javascript" src="<?php echo base_url(); ?>assets/js/buttons.html5.min.js"></script>
|
||||
<script type="text/javascript" src="<?php echo base_url();?>assets/js/selectize.js"></script>
|
||||
|
||||
<?php if ($this->uri->segment(1) == "station") { ?>
|
||||
<script language="javascript" src="<?php echo base_url() ;?>assets/js/HamGridSquare.js"></script>
|
||||
<script src="<?php echo base_url() ;?>assets/js/sections/station_locations.js"></script>
|
||||
<script src="<?php echo base_url() ;?>assets/js/bootstrap-multiselect.js"></script>
|
||||
<script>
|
||||
var position;
|
||||
function getLocation() {
|
||||
if (navigator.geolocation) {
|
||||
navigator.geolocation.getCurrentPosition(showPosition);
|
||||
} else {
|
||||
console.log('Geolocation is not supported by this browser.');
|
||||
}
|
||||
}
|
||||
|
||||
function showPosition(position) {
|
||||
gridsquare = latLonToGridSquare(position.coords.latitude,position.coords.longitude);
|
||||
document.getElementById("stationGridsquareInput").value = gridsquare;
|
||||
}
|
||||
</script>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ($this->uri->segment(1) == "logbooks") { ?>
|
||||
<script src="<?php echo base_url() ;?>assets/js/sections/station_logbooks.js"></script>
|
||||
<?php } ?>
|
||||
|
||||
<?php if ($this->uri->segment(1) == "debug") { ?>
|
||||
<script type="text/javascript">
|
||||
function copyURL(url) {
|
||||
|
||||
127
assets/js/HamGridSquare.js
Normal file
127
assets/js/HamGridSquare.js
Normal file
@@ -0,0 +1,127 @@
|
||||
// HamGridSquare.js
|
||||
// Copyright 2014 Paul Brewer KI6CQ
|
||||
// License: MIT License http://opensource.org/licenses/MIT
|
||||
//
|
||||
// Javascript routines to convert from lat-lon to Maidenhead Grid Squares
|
||||
// typically used in Ham Radio Satellite operations and VHF Contests
|
||||
//
|
||||
// Inspired in part by K6WRU Walter Underwood's python answer
|
||||
// http://ham.stackexchange.com/a/244
|
||||
// to this stack overflow question:
|
||||
// How Can One Convert From Lat/Long to Grid Square
|
||||
// http://ham.stackexchange.com/questions/221/how-can-one-convert-from-lat-long-to-grid-square
|
||||
//
|
||||
|
||||
latLonToGridSquare = function(param1,param2){
|
||||
var lat=-100.0;
|
||||
var lon=0.0;
|
||||
var adjLat,adjLon,GLat,GLon,nLat,nLon,gLat,gLon,rLat,rLon;
|
||||
var U = 'ABCDEFGHIJKLMNOPQRSTUVWX'
|
||||
var L = U.toLowerCase();
|
||||
// support Chris Veness 2002-2012 LatLon library and
|
||||
// other objects with lat/lon properties
|
||||
// properties could be numbers, or strings
|
||||
function toNum(x){
|
||||
if (typeof(x) === 'number') return x;
|
||||
if (typeof(x) === 'string') return parseFloat(x);
|
||||
// dont call a function property here because of binding issue
|
||||
throw "HamGridSquare -- toNum -- can not convert input: "+x;
|
||||
}
|
||||
if (typeof(param1)==='object'){
|
||||
if (param1.length === 2){
|
||||
lat = toNum(param1[0]);
|
||||
lon = toNum(param1[1]);
|
||||
} else if (('lat' in param1) && ('lon' in param1)){
|
||||
lat = (typeof(param1.lat)==='function')? toNum(param1.lat()): toNum(param1.lat);
|
||||
lon = (typeof(param1.lon)==='function')? toNum(param1.lon()): toNum(param1.lon);
|
||||
} else if (('latitude' in param1) && ('longitude' in param1)){
|
||||
lat = (typeof(param1.latitude)==='function')? toNum(param1.latitude()): toNum(param1.latitude);
|
||||
lon = (typeof(param1.longitude)==='function')? toNum(param1.longitude()): toNum(param1.longitude);
|
||||
} else {
|
||||
throw "HamGridSquare -- can not convert object -- "+param1;
|
||||
}
|
||||
} else {
|
||||
lat = toNum(param1);
|
||||
lon = toNum(param2);
|
||||
}
|
||||
if (isNaN(lat)) throw "lat is NaN";
|
||||
if (isNaN(lon)) throw "lon is NaN";
|
||||
if (Math.abs(lat) === 90.0) throw "grid squares invalid at N/S poles";
|
||||
if (Math.abs(lat) > 90) throw "invalid latitude: "+lat;
|
||||
if (Math.abs(lon) > 180) throw "invalid longitude: "+lon;
|
||||
adjLat = lat + 90;
|
||||
adjLon = lon + 180;
|
||||
GLat = U[Math.trunc(adjLat/10)];
|
||||
GLon = U[Math.trunc(adjLon/20)];
|
||||
nLat = ''+Math.trunc(adjLat % 10);
|
||||
nLon = ''+Math.trunc((adjLon/2) % 10);
|
||||
rLat = (adjLat - Math.trunc(adjLat)) * 60;
|
||||
rLon = (adjLon - 2*Math.trunc(adjLon/2)) *60;
|
||||
gLat = L[Math.trunc(rLat/2.5)];
|
||||
gLon = L[Math.trunc(rLon/5)];
|
||||
return GLon+GLat+nLon+nLat+gLon+gLat;
|
||||
}
|
||||
|
||||
gridSquareToLatLon = function(grid, obj){
|
||||
var returnLatLonConstructor = (typeof(LatLon)==='function');
|
||||
var returnObj = (typeof(obj)==='object');
|
||||
var lat=0.0,lon=0.0,aNum="a".charCodeAt(0),numA="A".charCodeAt(0);
|
||||
function lat4(g){
|
||||
return 10*(g.charCodeAt(1)-numA)+parseInt(g.charAt(3))-90;
|
||||
}
|
||||
function lon4(g){
|
||||
return 20*(g.charCodeAt(0)-numA)+2*parseInt(g.charAt(2))-180;
|
||||
}
|
||||
if ((grid.length!=4) && (grid.length!=6)) throw "gridSquareToLatLon: grid must be 4 or 6 chars: "+grid;
|
||||
if (/^[A-X][A-X][0-9][0-9]$/.test(grid)){
|
||||
lat = lat4(grid)+0.5;
|
||||
lon = lon4(grid)+1;
|
||||
} else if (/^[A-X][A-X][0-9][0-9][a-x][a-x]$/.test(grid)){
|
||||
lat = lat4(grid)+(1.0/60.0)*2.5*(grid.charCodeAt(5)-aNum+0.5);
|
||||
lon = lon4(grid)+(1.0/60.0)*5*(grid.charCodeAt(4)-aNum+0.5);
|
||||
} else throw "gridSquareToLatLon: invalid grid: "+grid;
|
||||
if (returnLatLonConstructor) return new LatLon(lat,lon);
|
||||
if (returnObj){
|
||||
obj.lat = lat;
|
||||
obj.lon = lon;
|
||||
return obj;
|
||||
}
|
||||
return [lat,lon];
|
||||
};
|
||||
|
||||
testGridSquare = function(){
|
||||
// First four test examples are from "Conversion Between Geodetic and Grid Locator Systems",
|
||||
// by Edmund T. Tyson N5JTY QST January 1989
|
||||
// original test data in Python / citations by Walter Underwood K6WRU
|
||||
// last test and coding into Javascript from Python by Paul Brewer KI6CQ
|
||||
var testData = [
|
||||
['Munich', [48.14666,11.60833], 'JN58td'],
|
||||
['Montevideo', [[-34.91,-56.21166]], 'GF15vc'],
|
||||
['Washington, DC', [{lat:38.92,lon:-77.065}], 'FM18lw'],
|
||||
['Wellington', [{latitude:-41.28333,longitude:174.745}], 'RE78ir'],
|
||||
['Newington, CT (W1AW)', [41.714775,-72.727260], 'FN31pr'],
|
||||
['Palo Alto (K6WRU)', [[37.413708,-122.1073236]], 'CM87wj'],
|
||||
['Chattanooga (KI6CQ/4)', [{lat:function(){ return "35.0542"; },
|
||||
lon: function(){ return "-85.1142"}}], "EM75kb"]
|
||||
];
|
||||
var i=0,l=testData.length,result='',result2,result3,thisPassed=0,totalPassed=0;
|
||||
for(i=0;i<l;++i){
|
||||
result = latLonToGridSquare.apply({}, testData[i][1]);
|
||||
result2 = gridSquareToLatLon(result);
|
||||
result3 = latLonToGridSquare(result2);
|
||||
thisPassed = (result===testData[i][2]) && (result3===testData[i][2]);
|
||||
console.log("test "+i+": "+testData[i][0]+" "+JSON.stringify(testData[i][1])+
|
||||
" result = "+result+" result2 = "+result2+" result3 = "+result3+" expected= "+testData[i][2]+
|
||||
" passed = "+thisPassed);
|
||||
totalPassed += thisPassed;
|
||||
}
|
||||
console.log(totalPassed+" of "+l+" test passed");
|
||||
return totalPassed===l;
|
||||
};
|
||||
|
||||
HamGridSquare = {
|
||||
toLatLon: gridSquareToLatLon,
|
||||
fromLatLon: latLonToGridSquare,
|
||||
test: testGridSquare
|
||||
};
|
||||
|
||||
141
assets/js/sections/station_locations.js
Normal file
141
assets/js/sections/station_locations.js
Normal file
@@ -0,0 +1,141 @@
|
||||
$(document).ready(function () {
|
||||
function btn_pwd_showhide() {
|
||||
if ($(this).closest('div').find('input[type="password"]').length>0) {
|
||||
$(this).closest('div').find('input[type="password"]').attr('type','text');
|
||||
$(this).closest('div').find('.fa-eye-slash').removeClass('fa-eye-slash').addClass('fa-eye');
|
||||
} else {
|
||||
$(this).closest('div').find('input[type="text"]').attr('type','password');
|
||||
$(this).closest('div').find('.fa-eye').removeClass('fa-eye').addClass('fa-eye-slash');
|
||||
}
|
||||
}
|
||||
$('.btn-pwd-showhide').off('click').on('click', btn_pwd_showhide );
|
||||
|
||||
$("#station_locations_table").DataTable({
|
||||
stateSave: true,
|
||||
language: {
|
||||
url: getDataTablesLanguageUrl(),
|
||||
},
|
||||
});
|
||||
|
||||
$('#dxcc_id').multiselect({
|
||||
// template is needed for bs5 support
|
||||
templates: {
|
||||
button: '<button type="button" style="text-align: left !important;" class="multiselect dropdown-toggle btn btn-secondary w-auto" data-bs-toggle="dropdown" aria-expanded="false"><span class="multiselect-selected-text"></span></button>',
|
||||
},
|
||||
enableFiltering: true,
|
||||
enableFullValueFiltering: false,
|
||||
enableCaseInsensitiveFiltering: true,
|
||||
filterPlaceholder: lang_general_word_search,
|
||||
widthSynchronizationMode: 'always',
|
||||
numberDisplayed: 1,
|
||||
inheritClass: true,
|
||||
buttonWidth: '100%',
|
||||
maxHeight: 600
|
||||
});
|
||||
$('.multiselect-container .multiselect-filter', $('#dxcc_id').parent()).css({
|
||||
'position': 'sticky', 'top': '0px', 'z-index': 1, 'background-color':'inherit', 'width':'100%', 'height':'37px'
|
||||
})
|
||||
|
||||
if (window.location.pathname.indexOf("/station/edit") !== -1 || window.location.pathname.indexOf("/station/create") !== -1 || window.location.pathname.indexOf("/station/copy") !== -1) {
|
||||
|
||||
updateStateDropdown('#dxcc_id', '#stateInputLabel', '#location_us_county', '#stationCntyInputEdit');
|
||||
$('#location_us_county_edit').show();
|
||||
var dxcc = $('#dxcc_id').val();
|
||||
switch (dxcc) {
|
||||
case '6':
|
||||
case '110':
|
||||
case '291':
|
||||
$("#stationCntyInputEdit").prop('disabled', false);
|
||||
selectize_usa_county('#stateDropdown', '#stationCntyInputEdit');
|
||||
break;
|
||||
case '15':
|
||||
case '54':
|
||||
case '61':
|
||||
case '126':
|
||||
case '151':
|
||||
case '288':
|
||||
case '339':
|
||||
case '170':
|
||||
case '21':
|
||||
case '29':
|
||||
case '32':
|
||||
case '281':
|
||||
$("#stationCntyInputEdit").prop('disabled', false);
|
||||
break;
|
||||
default:
|
||||
$("#stationCntyInputEdit").prop('disabled', true);
|
||||
}
|
||||
$("#dxcc_id").change(function () {
|
||||
updateStateDropdown('#dxcc_id', '#stateInputLabel', '#location_us_county', '#stationCntyInputEdit');
|
||||
});
|
||||
|
||||
$('#qrz_apitest_btn').click(function(){
|
||||
|
||||
var apikey = $('#qrzApiKey').val();
|
||||
var msg_div = $('#qrz_apitest_msg');
|
||||
|
||||
msg_div.hide();
|
||||
msg_div.removeClass('alert-success alert-danger')
|
||||
|
||||
$.ajax({
|
||||
url: base_url+'index.php/qrz/qrz_apitest',
|
||||
type: 'POST',
|
||||
data: {
|
||||
'APIKEY': apikey
|
||||
},
|
||||
success: function(res) {
|
||||
if(res.status == 'OK') {
|
||||
msg_div.addClass('alert-success');
|
||||
msg_div.text('Your API Key works. You are good to go!');
|
||||
msg_div.show();
|
||||
} else {
|
||||
msg_div.addClass('alert-danger');
|
||||
msg_div.text('Your API Key failed. Are you sure you have a valid QRZ subsription?');
|
||||
msg_div.show();
|
||||
$('#qrzrealtime').val(-1);
|
||||
}
|
||||
},
|
||||
error: function(res) {
|
||||
msg_div.addClass('alert-danger');
|
||||
msg_div.text('ERROR: Something went wrong on serverside. We\'re sorry..');
|
||||
msg_div.show();
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
$("#stateDropdown").change(function () {
|
||||
var dxcc = $('#dxcc_id').val();
|
||||
var state = $("#stateDropdown.form-select").val();
|
||||
if (state != '') {
|
||||
switch (dxcc) {
|
||||
case '6':
|
||||
case '110':
|
||||
case '291':
|
||||
$("#stationCntyInputEdit").prop('disabled', false);
|
||||
break;
|
||||
case '15':
|
||||
case '54':
|
||||
case '61':
|
||||
case '126':
|
||||
case '151':
|
||||
case '288':
|
||||
case '339':
|
||||
case '170':
|
||||
case '21':
|
||||
case '29':
|
||||
case '32':
|
||||
case '281':
|
||||
$("#stationCntyInputEdit").prop('disabled', false);
|
||||
break;
|
||||
default:
|
||||
$("#stationCntyInputEdit").prop('disabled', true);
|
||||
}
|
||||
} else {
|
||||
$("#stationCntyInputEdit").val('');
|
||||
$("#stationCntyInputEdit").prop('disabled', true);
|
||||
}
|
||||
});
|
||||
|
||||
18
assets/js/sections/station_logbooks.js
Normal file
18
assets/js/sections/station_logbooks.js
Normal file
@@ -0,0 +1,18 @@
|
||||
$(document).ready( function () {
|
||||
$('#station_logbooks_table').DataTable({
|
||||
"stateSave": true,
|
||||
"language": {
|
||||
url: getDataTablesLanguageUrl(),
|
||||
}
|
||||
});
|
||||
} );
|
||||
|
||||
$(document).ready( function () {
|
||||
$('#station_logbooks_linked_table').DataTable({
|
||||
"stateSave": true,
|
||||
"paging": true,
|
||||
"language": {
|
||||
url: getDataTablesLanguageUrl(),
|
||||
}
|
||||
});
|
||||
} );
|
||||
Reference in New Issue
Block a user