@ -1,10 +1,13 @@
// Rewrite this is a plugin.. is all this JS really 'worth it?'
// Rewrite this is a plugin.. is all this JS really 'worth it?'
// display correct label and messages for minutes or seconds
document . addEventListener ( "DOMContentLoaded" , function ( event ) {
use _seconds _change ( ) ;
} ) ;
window . addEventListener ( 'hashchange' , function ( ) {
window . addEventListener ( 'hashchange' , function ( ) {
var tabs = document . getElementsByClassName ( 'active' ) ;
var tabs = document . getElementsByClassName ( 'active' ) ;
while ( tabs [ 0 ] ) {
while ( tabs [ 0 ] ) {
tabs [ 0 ] . classList . remove ( 'active' )
tabs [ 0 ] . classList . remove ( 'active' ) ;
}
}
set _active _tab ( ) ;
set _active _tab ( ) ;
} , false ) ;
} , false ) ;
@ -37,7 +40,7 @@ function focus_error_tab() {
var tabs = document . querySelectorAll ( '.tabs li a' ) , i ;
var tabs = document . querySelectorAll ( '.tabs li a' ) , i ;
for ( i = 0 ; i < tabs . length ; ++ i ) {
for ( i = 0 ; i < tabs . length ; ++ i ) {
var tab _name = tabs [ i ] . hash . replace ( '#' , '' ) ;
var tab _name = tabs [ i ] . hash . replace ( '#' , '' ) ;
var pane _errors = document . querySelectorAll ( '#' + tab _name + ' .error' )
var pane _errors = document . querySelectorAll ( '#' + tab _name + ' .error' ) ;
if ( pane _errors . length ) {
if ( pane _errors . length ) {
document . location . hash = '#' + tab _name ;
document . location . hash = '#' + tab _name ;
return true ;
return true ;
@ -46,6 +49,38 @@ function focus_error_tab() {
return false ;
return false ;
}
}
function use _seconds _change ( ) {
var isChecked = document . querySelectorAll ( 'input[id="use_seconds"]:checked' ) . length
var labelIntegerField = document . querySelector ( "label[for=minutes_between_check]" ) ;
var msgDefault = document . getElementById ( "minutes-message-default" ) ;
var msgNonDefault = document . getElementById ( "minutes-message-non-default" ) ;
var msgWarning = document . getElementById ( "seconds-warning" ) ;
if ( isChecked ) {
labelIntegerField . innerHTML = "Maximum time in seconds until recheck" ;
try {
msgDefault . style . display = "none" ;
} catch ( error ) {
// continue, won't be present if not default interval
}
try {
msgNonDefault . style . display = "none" ;
} catch ( error ) {
// continue, won't be present if not default interval
}
msgWarning . style . display = "" ;
}
else {
labelIntegerField . innerHTML = "Maximum time in minutes until recheck" ;
try {
msgDefault . style . display = "" ;
} catch ( error ) {
// continue, won't be present if not default interval
}
try {
msgNonDefault . style . display = "" ;
} catch ( error ) {
// continue, won't be present if not default interval
}
msgWarning . style . display = "none" ;
}
}