includes/clientside/static/pwstrength.js
changeset 363 2220bab5c784
parent 362 02d315d1cc58
child 460 3a1c99845ca8
equal deleted inserted replaced
361:35ed07abc99e 363:2220bab5c784
   179   for ( var i = 0; i < debug.length; i++ )
   179   for ( var i = 0; i < debug.length; i++ )
   180   {
   180   {
   181     debug_txt += debug[i] + "\n";
   181     debug_txt += debug[i] + "\n";
   182   }
   182   }
   183   
   183   
   184   if ( window.console )
   184   // For users that really want to know why their password sucks.
   185     window.console.info(debug_txt);
   185   // Not localized because the feature is really only used for debugging the algorithm.
   186   else if ( document.getElementById('passdebug') )
   186   if ( document.getElementById('passdebug') )
   187     document.getElementById('passdebug').innerHTML = debug_txt;
   187     document.getElementById('passdebug').innerHTML = debug_txt;
   188   
   188   
   189   return score;
   189   return score;
   190 }
   190 }
   191 
   191 
   192 function password_score_draw(score)
   192 function password_score_draw(score)
   193 {
   193 {
       
   194   if ( !$lang )
       
   195   {
       
   196     // $lang isn't initted yet, this happens sometimes on the usercp/emailpassword form.
       
   197     // Try to init it if we have ENANO_LANG_ID and enano_lang; if not, report an error.
       
   198     if ( typeof(enano_lang) == 'object' && typeof(ENANO_LANG_ID) == 'number' )
       
   199     {
       
   200       language_onload();
       
   201     }
       
   202     else
       
   203     {
       
   204       return {
       
   205         color: '#000000',
       
   206         fgcolor: '#666666',
       
   207         str: 'Language init failed',
       
   208       };
       
   209     }
       
   210   }
   194   // some colors are from the Gmail sign-up form
   211   // some colors are from the Gmail sign-up form
   195   if ( score >= 10 )
   212   if ( score >= 10 )
   196   {
   213   {
   197     var color = '#000000';
   214     var color = '#000000';
   198     var fgcolor = '#666666';
   215     var fgcolor = '#666666';
   199     var str = 'Very strong (score: '+score+')';
   216     var str = $lang.get('usercp_pwstrength_score_verystrong', { score: score });
   200   }
   217   }
   201   else if ( score > 3 )
   218   else if ( score > 3 )
   202   {
   219   {
   203     var color = '#008000';
   220     var color = '#008000';
   204     var fgcolor = '#004000';
   221     var fgcolor = '#004000';
   205     var str = 'Strong (score: '+score+')';
   222     var str = $lang.get('usercp_pwstrength_score_strong', { score: score });
   206   }
   223   }
   207   else if ( score >= 1 )
   224   else if ( score >= 1 )
   208   {
   225   {
   209     var color = '#6699cc';
   226     var color = '#6699cc';
   210     var fgcolor = '#4477aa';
   227     var fgcolor = '#4477aa';
   211     var str = 'Good (score: '+score+')';
   228     var str = $lang.get('usercp_pwstrength_score_good', { score: score });
   212   }
   229   }
   213   else if ( score >= -3 )
   230   else if ( score >= -3 )
   214   {
   231   {
   215     var color = '#f5ac00';
   232     var color = '#f5ac00';
   216     var fgcolor = '#ffcc33';
   233     var fgcolor = '#ffcc33';
   217     var str = 'Fair (score: '+score+')';
   234     var str = $lang.get('usercp_pwstrength_score_fair', { score: score });
   218   }
   235   }
   219   else
   236   else
   220   {
   237   {
   221     var color = '#aa0033';
   238     var color = '#aa0033';
   222     var fgcolor = '#FF6060';
   239     var fgcolor = '#FF6060';
   223     var str = 'Weak (score: '+score+')';
   240     var str = $lang.get('usercp_pwstrength_score_weak', { score: score });
   224   }
   241   }
   225   return {
   242   return {
   226     color: color,
   243     color: color,
   227     fgcolor: fgcolor,
   244     fgcolor: fgcolor,
   228     str: str
   245     str: str