-
-
Save stdclass/1175365 to your computer and use it in GitHub Desktop.
The Comeback of the BLINK-Tag
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
var blinkify = function( el, // DOM-Element | |
rate // Speed (Default: 500 ms) | |
){ | |
setInterval(function(){ // Interval | |
el.style.opacity ^= 1 // change the visibility | |
}, rate || 500 ); |
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
function(a,b){setInterval(function(){a.style.opacity^=1},b||500)} |
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
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
Version 2, December 2004 | |
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE> | |
Everyone is permitted to copy and distribute verbatim or modified | |
copies of this license document, and changing it is allowed as long | |
as the name is changed. | |
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION | |
0. You just DO WHAT THE FUCK YOU WANT TO. |
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
{ | |
"name": "blinkify", | |
"description": "The Comeback of the Blink-Tag", | |
"keywords": [ | |
"blink", | |
"blinktag", | |
"retro" | |
] | |
} |
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
<!doctype html> | |
<html> | |
<head> | |
</head> | |
<body> | |
<b id="test">BLINKY</b><br /> | |
<b id="test2">BLINKY - fast</b> | |
<script> | |
var blinkify = function( el, rate ){ | |
setInterval(function(){ | |
el.style.opacity ^= 1 | |
}, rate || 500 ); | |
} | |
blinkify( document.getElementById( "test" ) ); | |
blinkify( document.getElementById( "test2" ), 100 ); | |
</script> | |
</body> | |
</html> |
or for that matter:
function d(a,b,c){c=a.style.opacity=+!c;setTimeout(d,b||500,a,b,c)}
(67 bytes)
or even:
function d(a,b,c){setTimeout(d,b||500,a,b,a.style.opacity=+!c)}
(63 bytes, assuming you're okay with losing old browsers)
Interesting.
Supporting the current and previous version of each major browser would be nice. No ?
IE8, does not support setTimeout(function,delay,arg1,arg2,...)
, so... 68 ?
i'm happy with 68 (unless we want to dial down the default to 99
for 67).
Oh dear, it's amazing.
And finally i make bitwise trick useful.
function(a,b){setInterval(function(){a.style.opacity^=1},b||500)}
(65 bytes)
whoa, nice! i think that's the first useful XOR assignment i've ever seen here.
I think that's it. There's not much code left to optimize here.
Sorry for the b=...=b?0:1
in my previous comment. That was lazy. It was obvious there was room for improvements.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
well, if you're gonna go down that road...
(68 bytes)