$(document).ready(function() { function appendLink(id) { $(id).next('div').find('.link').empty(); $(id).next('div').find('.link').append("Link to this command: https://amiaopensource.github.io/ffmprovisr/index.html" + id + ""); } function moveToRecipe(id) { document.getElementById(id.substring(1)).checked = true; $('html, body').animate({ scrollTop: $(id).offset().top }, 1000); appendLink(id) } // open recipe window if a hash is found in URL if (window.location.hash) { id = window.location.hash moveToRecipe(id) } // add hash URL when recipe is opened $('label[class="recipe"]').on("click", function(){ id = $(this).attr("for"); window.location.hash = ('#' + id) appendLink('#' + id) }) // open recipe when clicked $('a').on("click", function(){ intralink = $(this).attr("href") if (intralink[0] == "#") { moveToRecipe(intralink) } }) // open all windows if button is clicked $('#open-all').on("click", function(){ $('input[type=checkbox]').each(function(){ this.checked = !this.checked; }) }); });