better entropy colors and optional callback, thanks Niphlod

This commit is contained in:
mdipierro
2012-09-23 17:00:34 -05:00
parent 3fbd80728d
commit 554fe30288
2 changed files with 2 additions and 3 deletions
+1 -1
View File
@@ -1 +1 @@
Version 2.0.9 (2012-09-23 16:58:06) stable
Version 2.0.9 (2012-09-23 17:00:31) stable
+1 -2
View File
@@ -191,8 +191,7 @@ function web2py_validate_entropy(myfield, req_entropy) {
var v = (web2py_calc_entropy(myfield.val())||0)/req_entropy;
var r=0,g=0,b=0,rs=function(x){return Math.round(x*15).toString(16)};
if(v<=0.5) {r=1.0; g=2.0*v;}
else if(v<1.0) {r=(1.0-2.0*(v-0.5)); g=1.0;}
else {g=Math.max(0,2.0-v); b=1.0;}
else {r=(1.0-2.0*(Math.max(v,0)-0.5)); g=1.0;}
var color = '#'+rs(r)+rs(g)+rs(b);
myfield.css('background-color',color);
entroy_callback = myfield.attr('entroy_callback');