Created
April 30, 2019 19:03
-
-
Save zprima/bff4e44e70768cda96b60a5b634c31be to your computer and use it in GitHub Desktop.
medium_p5_c2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const FRESHNESS_UI = 'freshness_ui'; | |
// add freeshness_ui class to body | |
var bodyEle = document.body; | |
bodyEle.classList.add(FRESHNESS_UI); | |
// toggle freshness ui class on the body element | |
function toggleFreshness() { | |
var status = bodyEle.classList.toggle(FRESHNESS_UI); | |
// console.log("toggle status", status); | |
return status; | |
} | |
// keyboard shortcut for toggle | |
function handleToggle(event) { | |
// cmd + j | |
if (event.metaKey && event.which == 74) { | |
toggleFreshness(); | |
event.preventDefault(); | |
} | |
} | |
window.addEventListener('keydown', handleToggle, false); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment