Last active
January 24, 2021 12:38
-
-
Save Nadeeshyama/5209824 to your computer and use it in GitHub Desktop.
[Set Debug Mode] Set the URL hash in the format '#debug-ddmmyyyy' to set a global variable __DEBUG__ #URL #Hash
This file contains 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
/** | |
* Set the URL hash in the format '#debug-ddmmyyyy' to set a global | |
* variable __DEBUG__ so that it can be used across all scritps to | |
* do console outputs, legacy alerts, etc. | |
*/ | |
var __DEBUG__ = (function() { | |
var pad = function (s) {return (s.length == 1 ? '0' + s : s)}, // to pad numbers with leading 0s | |
t = new Date(), | |
y = t.getFullYear().toString(), | |
m = pad((t.getMonth() + 1).toString()), // month is index returned in JS :) | |
d = pad(t.getDate().toString()), | |
hash = window.location.hash.replace('#', ''); // hash with cross browser compatibility | |
return ((d + m + y) === hash.replace('debug-', '')); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment