1window.TastyRecipes = window.TastyRecipes || {}; 2window.TastyRecipes.cookMode = { 3 wakeLockApi: false, 4 wakeLock: false, 5 cookModeSelector: '.tasty-recipes-cook-mode', 6 init() { 7 if ("wakeLock" in navigator && "request" in navigator.wakeLock) { 8 this.wakeLockApi = navigator.wakeLock; 9 } 10 11 const cookModes = document.querySelectorAll(this.cookModeSelector); 12 13 if (cookModes.length > 0) { 14 for (const cookMode of cookModes) { 15 if (this.wakeLockApi) { 16 cookMode.querySelector('input[type="checkbox"]').addEventListener("change", event => { 17 this.checkboxChange(event.target); 18 }, false); 19 } else { 20 cookMode.style.display = "none"; 21 } 22 } 23 } 24 }, 25 checkboxChange(checkbox) { 26 if (checkbox.checked) { 27 this.lock(); 28 } else { 29 this.unlock(); 30 } 31 }, 32 setCheckboxesState(state) { 33 const checkboxes = document.querySelectorAll(this.cookModeSelector + ' input[type="checkbox"]'); 34 for (const checkbox of checkboxes) { 35 checkbox.checked = state; 36 } 37 }, 38 async lock() { 39 try { 40 this.wakeLock = await this.wakeLockApi.request("screen"); 41 this.wakeLock.addEventListener("release", () => { 42 this.wakeLock = false; 43 this.setCheckboxesState(false); 44 }); 45 this.setCheckboxesState(true); 46 } catch (error) { 47 this.setCheckboxesState(false); 48 } 49 }, 50 unlock() { 51 if (this.wakeLock) { 52 this.wakeLock.release(); 53 this.wakeLock = false; 54 } 55 this.setCheckboxesState(false); 56 } 57}; 58 59(function(callback) { 60 if (document.readyState !== "loading") { 61 callback(); 62 } else { 63 document.addEventListener("DOMContentLoaded", callback); 64 } 65})(() => { 66 window.TastyRecipes.cookMode.init(); 67});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.