better entropy colors and optional callback, thanks Niphlod
This commit is contained in:
@@ -1 +1 @@
|
||||
Version 2.0.9 (2012-09-23 16:58:06) stable
|
||||
Version 2.0.9 (2012-09-23 17:00:31) stable
|
||||
|
||||
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user