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
// get the average color of two hex colors. | |
function avgcolor(color1,color2){ | |
var avg = function(a,b){ return (a+b)/2; }, | |
t16 = function(c){ return parseInt((''+c).replace('#',''),16) }, | |
hex = function(c){ var t = (c>>0).toString(16); | |
return t.length == 2 ? t : '0' + t }, | |
hex1 = t16(color1), | |
hex2 = t16(color2), | |
r = function(hex){ return hex >> 16 & 0xFF}, | |
g = function(hex){ return hex >> 8 & 0xFF}, |
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 retry(isDone, next) { | |
var current_trial = 0, max_retry = 50, interval = 10, is_timeout = false; | |
var id = window.setInterval( | |
function() { | |
if (isDone()) { | |
window.clearInterval(id); | |
next(is_timeout); | |
} | |
if (current_trial++ > max_retry) { | |
window.clearInterval(id); |
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
Code | |
$("button").single_double_click(function () { | |
alert("Try double-clicking me!") | |
}, function () { | |
alert("Double click detected, I'm hiding") | |
$(this).hide() | |
}) | |