2016-06-18 23:44:36 +02:00
$ ( document ) . ready ( function ( ) {
2019-07-14 00:41:44 +02:00
function appendLink ( id ) {
2019-07-14 03:38:38 +02:00
$ ( id ) . next ( 'div' ) . find ( '.link' ) . empty ( ) ;
$ ( id ) . next ( 'div' ) . find ( '.link' ) . append ( "<small>Link to this command: <a href='https://amiaopensource.github.io/ffmprovisr/index.html" + id + "'>https://amiaopensource.github.io/ffmprovisr/index.html" + id + "</a></small>" ) ;
2019-07-14 00:41:44 +02:00
}
function moveToRecipe ( id ) {
document . getElementById ( id . substring ( 1 ) ) . checked = true ;
$ ( 'html, body' ) . animate ( { scrollTop : $ ( id ) . offset ( ) . top } , 1000 ) ;
appendLink ( id )
}
2017-10-13 04:14:47 +02:00
// open recipe window if a hash is found in URL
2019-07-14 00:41:44 +02:00
if ( window . location . hash ) {
2017-10-18 23:17:55 +02:00
id = window . location . hash
2019-07-14 00:41:44 +02:00
moveToRecipe ( id )
2016-06-18 23:44:36 +02:00
}
2017-10-13 04:14:47 +02:00
// add hash URL when recipe is opened
2017-10-18 22:02:04 +02:00
$ ( 'label[class="recipe"]' ) . on ( "click" , function ( ) {
id = $ ( this ) . attr ( "for" ) ;
2017-10-19 02:56:35 +02:00
window . location . hash = ( '#' + id )
2019-07-14 00:41:44 +02:00
appendLink ( '#' + id )
} )
2016-06-18 23:44:36 +02:00
2019-07-13 23:52:49 +02:00
// open recipe when clicked
$ ( 'a' ) . on ( "click" , function ( ) {
intralink = $ ( this ) . attr ( "href" )
if ( intralink [ 0 ] == "#" ) {
2019-07-14 00:41:44 +02:00
moveToRecipe ( intralink )
2019-07-13 23:52:49 +02:00
}
} )
// open all windows if button is clicked
2018-04-16 21:22:12 +02:00
$ ( '#open-all' ) . on ( "click" , function ( ) {
$ ( 'input[type=checkbox]' ) . each ( function ( ) {
this . checked = ! this . checked ;
} )
} ) ;
2016-06-18 23:44:36 +02:00
} ) ;