@@ -24,6 +24,10 @@ let config = {
2424var qsinceload = 0 ;
2525var sectionsloaded = false ;
2626var stationcookieexists = false ;
27+ var thispage = location . href . split ( "/" ) . slice ( - 1 ) ;
28+
29+ if ( thispage == "handkey.html" )
30+ var isHandKey = true ;
2731
2832// load configuration from JSON files
2933function getConfig ( configType ) {
@@ -34,25 +38,20 @@ function getConfig(configType){
3438 var a = JSON . parse ( this . responseText ) ;
3539 switch ( configType ) {
3640 case "general" :
37- console . log ( "get config general" ) ;
3841 config . general = a ;
39- console . log ( "set config general" ) ;
4042 setGeneralConfig ( ) ;
4143 break ;
4244 case "bands" :
43- console . log ( "get config bands" ) ;
4445 config . bands = a ;
4546 refreshBandList ( config . bands . band ) ;
4647 setStationDataFromCookie ( ) ;
4748 break ;
4849 case "modes" :
49- console . log ( "get config modes" ) ;
5050 config . modes = a ;
5151 refreshModeList ( config . modes . modes ) ;
5252 setStationDataFromCookie ( ) ;
5353 break ;
5454 case "sections" :
55- console . log ( "get config sections" ) ;
5655 config . sections = a ;
5756 sectionsloaded = true ;
5857 break ;
@@ -91,10 +90,14 @@ window.addEventListener("load", function(){
9190 getConfig ( "bands" ) ;
9291 getConfig ( "modes" ) ;
9392 getConfig ( "sections" ) ;
94- setGeneralConfig ( ) ;
95- updateLogTime ( ) ;
96- setInterval ( updateLogTime , 1000 ) ;
97- setInterval ( testCookieExists , 1000 ) ;
93+
94+ // Only things for the main form at index.html
95+ if ( thispage == "index.html" || thispage == "" ) {
96+ setGeneralConfig ( ) ;
97+ updateLogTime ( ) ;
98+ setInterval ( updateLogTime , 1000 ) ;
99+ setInterval ( testCookieExists , 1000 ) ;
100+ }
98101} ) ;
99102
100103//
@@ -135,6 +138,8 @@ var submitOkCall = false;
135138var submitOkClass = false ;
136139var submitOkSection = false ;
137140var submitOkDupe = false ;
141+ var submitOkLogClockDate = false ;
142+ var submitOkLogClockTime = false ;
138143
139144//
140145// QSO Call Validation - is callsign well-formed
@@ -301,12 +306,21 @@ function resetSubmitOkStatus() {
301306 submitOkClass = false ;
302307 submitOkSection = false ;
303308 submitOkDupe = false ;
309+ submitOkLogClockDate = false ;
310+ submitOkLogClockTime = false ;
304311 toggleLogButton ( false ) ;
305312}
306313
307314// check if it's ready to submit
308315function checkSubmitOkStatus ( ) {
309- if ( submitOkCall && submitOkClass && submitOkSection ) { // && submitOkDupe )
316+ if ( submitOkCall && submitOkClass && submitOkSection ) {
317+ if ( isHandKey ) {
318+ if ( submitOkLogClockDate && submitOkLogClockTime ) {
319+ return true ;
320+ } else {
321+ return false ;
322+ }
323+ }
310324 return true ;
311325 } else {
312326 return false ;
@@ -331,7 +345,9 @@ function logSubmit() {
331345 lform . method = "POST" ;
332346 lform . action = "#" ;
333347
334- // Generate and store the qkey hash
348+ // If this is the handkey.html version the date/time needs to be parsed out
349+ if ( isHandKey )
350+ handkeyDateTime ( ) ;
335351
336352 // I have no idea whyu these can't be directly assigned by value.... Javascript is annoying
337353 var opcallsign = document . getElementById ( "callsign" ) . value ;
@@ -367,7 +383,8 @@ function logSubmit() {
367383 }
368384
369385 // update the display and clear the entry
370- updateDisplayLog ( ) ;
386+ if ( ! isHandKey )
387+ updateDisplayLog ( ) ;
371388 logReset ( ) ;
372389 } ,
373390 failure : function ( msg ) {
@@ -380,13 +397,92 @@ function logSubmit() {
380397
381398// reset the log form
382399function logReset ( ) {
383- clearStatusMsg ( ) ;
400+ // clearStatusMsg();
384401 resetSubmitOkStatus ( ) ;
402+
403+ // save the date for handkeying
404+ if ( isHandKey )
405+ var lcd = document . getElementById ( "logclockdate" ) . value ;
406+
385407 document . getElementById ( "log" ) . reset ( ) ;
408+
386409 $ ( '#log input' ) . parent ( ) . find ( 'input' ) . removeClass ( "is-invalid" ) . removeClass ( "is-valid" ) ;
387- document . getElementById ( "call" ) . focus ( ) ;
410+
411+ if ( isHandKey ) {
412+ document . getElementById ( "logclockdate" ) . value = lcd ;
413+ document . getElementById ( "logclocktime" ) . focus ( ) ;
414+ } else {
415+ document . getElementById ( "call" ) . focus ( ) ;
416+ }
388417} ;
389418
419+ // handkey.html variant support
420+ function handkeyDateTime ( ) {
421+ var lcd = document . getElementById ( "logclockdate" ) . value ;
422+ var lct = document . getElementById ( "logclocktime" ) . value ;
423+ var logclock = lcd . concat ( " " , lct . slice ( 0 , 2 ) , ":" , lct . slice ( 2 , 4 ) , ":" , "00" ) ;
424+ document . getElementById ( "logclock" ) . value = logclock ;
425+ } ;
426+
427+ $ ( '#logclockdate' ) . focusout ( function ( ) {
428+ var input = $ ( this ) ;
429+ var re = / ^ [ 0 - 9 ] { 4 } \- [ 0 - 9 ] { 2 } \- [ 0 - 9 ] { 2 } $ / ;
430+ var is_valid = true ;
431+ var dt = input . val ( ) ;
432+
433+ if ( re . test ( input . val ( ) ) ) {
434+ var y = dt . slice ( 0 , 4 ) ;
435+ var m = dt . slice ( 5 , 7 ) ;
436+ var d = dt . slice ( 8 , 12 ) ;
437+
438+ // Y2K1 problem!
439+ if ( y < 2000 || y > 2100 ) is_valid = false ;
440+ if ( m < 1 || m > 12 ) is_valid = false ;
441+ if ( d < 1 || d > 31 ) is_valid = false ;
442+
443+ } else {
444+ is_valid = false ;
445+ }
446+
447+ if ( is_valid ) {
448+ input . removeClass ( "is-invalid" ) . addClass ( "is-valid" ) ;
449+ submitOkLogClockDate = true ;
450+ } else {
451+ input . removeClass ( "is-valid" ) . addClass ( "is-invalid" ) ;
452+ submitOkLogClockDate = false ;
453+ }
454+ } ) ;
455+
456+ $ ( '#logclocktime' ) . focusout ( function ( ) {
457+ var input = $ ( this ) ;
458+ var re = / ^ [ 0 - 9 ] { 3 , 4 } $ / ;
459+ var is_valid = true ;
460+ var t = input . val ( ) ;
461+
462+ if ( re . test ( input . val ( ) ) ) {
463+ if ( t . length == 3 )
464+ t = "0" . concat ( t ) ;
465+ document . getElementById ( "logclocktime" ) . value = t ;
466+ var hh = t . slice ( 0 , 2 ) ;
467+ var mm = t . slice ( 2 , 4 ) ;
468+
469+ if ( hh < 0 || hh > 23 ) is_valid = false ;
470+ if ( mm < 0 || mm > 59 ) is_valid = false ;
471+
472+ } else {
473+ is_valid = false ;
474+ }
475+
476+ if ( is_valid ) {
477+ input . removeClass ( "is-invalid" ) . addClass ( "is-valid" ) ;
478+ submitOkLogClockTime = true ;
479+ } else {
480+ input . removeClass ( "is-valid" ) . addClass ( "is-invalid" ) ;
481+ submitOkLogClockTime = false ;
482+ }
483+ } ) ;
484+
485+
390486//
391487// Manage QSOs
392488//
@@ -395,7 +491,7 @@ function editQSO(qkey){
395491}
396492
397493function delQSO ( qkey , qcall ) {
398- if ( confirm ( "Are you sue your want to delete QSO with " + qcall + "?\n(QSO ID# " + qkey + ")" ) ) {
494+ if ( confirm ( "Are you sure your want to delete QSO with " + qcall + "?\n(QSO ID# " + qkey + ")" ) ) {
399495 $ . ajax ( {
400496 type : "GET" ,
401497 url : "api/delqso.php?qkey=" + qkey ,
@@ -572,4 +668,4 @@ function testCookieExists(){
572668 stationcookieexists = false ;
573669 }
574670 }
575- }
671+ }
0 commit comments