Video yükleniyor...
Video Yüklenemedi
Time for a new mind-bending project! #QLOCK — A JavaScript Quine Clock It displays the current time in a seven-segment style, embedded within its own JavaScript source code. 🕔 🕝 🕢 🕤 🕑 🕜 (321 bytes)
338,613 görüntüleme • 2 yıl önce •via X (Twitter)
10 Yorum

Make sure to view the source! Here is a slightly shortened version without the setTimeout for the animation:

for(j=o="\n",y=5;y--;document.body.innerHTML="<pre>&lt"+(S="script>\n")+o+"\n\n&lt/"+S)for(x=-1;x++<63;o+=`(r=${r})()`[j++].fontcolor(c?'#0F0':"#444"))c=x/2%4<3&&[31599,19812,14479,31207,23524,29411,29679,30866,31727,31719,1040][(D=Date()[16+(x/8|0)])<10?D:10]&1<<(x/2|0)%4+3*y

The 3x5 bitmap for every digit was encoded into a number. By converting the pixels into binary data and later to an integer we were able to save some space. Here is #7 for example: ⚪️⚪️⚪️ ⚫️⚫️⚪️ ⚫️⚪️⚫️ ⚫️⚪️⚫️ ⚫️⚪️⚫️ => 111 001 010 010 010 => 29330

Many thanks to Cole ( who was able to cut off the ugly dangling paren in my code. He "ended up going down a golfing rabbit hole" and improved the bitmap encoding by using parseInt with base 36. That shaved ~10 bytes and gave room for the layout fix.

Proud to see #QLOCK being featured in "JavaScript Weekly": "Martin really captures the joy and expressiveness of JavaScript and the Web with his collection of projects, whether it’s [JSFuck], a spinning globe [...], and many more such experiments." 💌

Lovely idea! (reminds me this meme)

Lol 🤣

too good

That’s great! I have a flipdot display that’s controlled by node… here it is being a clock (it usually shows details of passing aircraft). Sound up for the mechanical goodness.

Ohh, I love these mechanical flipdot displays! 🔊 ⚫️⚪️

