Last active
May 11, 2021 10:53
-
-
Save housamz/6044416304403a735eefb65bd8b7814a to your computer and use it in GitHub Desktop.
Knowledge is power
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
Knowledge is power | |
------------------ | |
A [Pen](https://codepen.io/housamz/pen/rggZJr) by [Housamz](https://codepen.io/housamz) on [CodePen](https://codepen.io). | |
[License](https://codepen.io/housamz/pen/rggZJr/license). |
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 numberWithCommas = x => | |
x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); | |
const formatNumber = number => | |
Math.floor(number) < 10 ? "0" + Math.floor(number) : Math.floor(number); | |
const shfrt = str => | |
str.split('').map(x => String.fromCharCode(x.charCodeAt(0) ^ 123)).reduce((a,b) => a+b); // bitwise XOR with any number, e.g. 123 | |
const first = new Date(shfrt(": [HW[IKJO[JKAKKAKK")).getTime(); | |
const second = new Date(shfrt(": [NW[IKJB[JMANKAKK")).getTime(); | |
document.body.innerHTML = shfrt("G[FYA@VA @[ VAJKK@YEGE0[[ GTEG [ FYYEG EG[FYYEGTEG EG[FYYEGTEG EG[FYYEGTEGTE"); | |
const calcAndDisplay = (dateData, displayBlock) => { | |
dateData = new Date().getTime() - dateData; | |
const days = formatNumber(dateData / (1000 * 60 * 60 * 24)); | |
const hours = formatNumber((dateData % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); | |
const minutes = formatNumber((dateData % (1000 * 60 * 60)) / (1000 * 60)); | |
const seconds = formatNumber((dateData % (1000 * 60)) / 1000); | |
document.getElementById(displayBlock).innerHTML = days + "d " + hours + "h " + minutes + "m " + seconds + "s "; | |
document.getElementById("all").innerHTML = numberWithCommas(dateData); | |
return false; | |
}; | |
setInterval(() => { | |
calcAndDisplay(first, "countup"); | |
calcAndDisplay(second, "timesince"); | |
}, Math.floor(Math.random() * 100) + 10); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment