Subversion Repositories ALCASAR

Rev

Rev 2242 | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 2242 Rev 3026
1
/*
1
/*
2
**    Created by: Jeff Todnem (http://www.todnem.com/)
2
**    Created by: Jeff Todnem (http://www.todnem.com/)
3
**    Created on: 2007-08-14
3
**    Created on: 2007-08-14
4
**    Last modified: 2010-05-03
4
**    Last modified: 2010-05-03
5
**
5
**
6
**    License Information:
6
**    License Information:
7
**    -------------------------------------------------------------------------
7
**    -------------------------------------------------------------------------
8
**    Copyright (C) 2007 Jeff Todnem
8
**    Copyright (C) 2007 Jeff Todnem
9
**
9
**
10
**    This program is free software; you can redistribute it and/or modify it
10
**    This program is free software; you can redistribute it and/or modify it
11
**    under the terms of the GNU General Public License as published by the
11
**    under the terms of the GNU General Public License as published by the
12
**    Free Software Foundation; either version 2 of the License, or (at your
12
**    Free Software Foundation; either version 2 of the License, or (at your
13
**    option) any later version.
13
**    option) any later version.
14
**    
14
**    
15
**    This program is distributed in the hope that it will be useful, but
15
**    This program is distributed in the hope that it will be useful, but
16
**    WITHOUT ANY WARRANTY; without even the implied warranty of
16
**    WITHOUT ANY WARRANTY; without even the implied warranty of
17
**    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17
**    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18
**    General Public License for more details.
18
**    General Public License for more details.
19
**    
19
**    
20
**    You should have received a copy of the GNU General Public License along
20
**    You should have received a copy of the GNU General Public License along
21
**    with this program; if not, write to the Free Software Foundation, Inc.,
21
**    with this program; if not, write to the Free Software Foundation, Inc.,
22
**    59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22
**    59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23
**    
23
**    
24
*/
24
*/
25
 
25
 
26
function addLoadEvent(func) {
26
function addLoadEvent(func) {
27
	var oldonload = window.onload;
27
	var oldonload = window.onload;
28
	if (typeof window.onload != "function") {
28
	if (typeof window.onload != "function") {
29
		window.onload = func;
29
		window.onload = func;
30
	}
30
	}
31
	else {
31
	else {
32
		window.onload = function() {
32
		window.onload = function() {
33
			if (oldonload) {
33
			if (oldonload) {
34
				oldonload();
34
				oldonload();
35
			}
35
			}
36
			func();
36
			func();
37
		};
37
		};
38
	}
38
	}
39
}
39
}
40
 
40
 
41
function $() {
41
function $() {
42
	var arrElms = [];
42
	var arrElms = [];
43
	for (var i=0; i < arguments.length; i++) {
43
	for (var i=0; i < arguments.length; i++) {
44
		var elm = arguments[i];
44
		var elm = arguments[i];
45
		if (typeof(elm == "string")) { elm = document.getElementById(elm); }
45
		if (typeof(elm == "string")) { elm = document.getElementById(elm); }
46
		if (arguments.length == 1) { return elm; }
46
		if (arguments.length == 1) { return elm; }
47
		arrElms.push(elm);
47
		arrElms.push(elm);
48
	}
48
	}
49
	return arrElms;
49
	return arrElms;
50
}
50
}
51
 
51
 
52
String.prototype.strReverse = function() {
52
String.prototype.strReverse = function() {
53
	var newstring = "";
53
	var newstring = "";
54
	for (var s=0; s < this.length; s++) {
54
	for (var s=0; s < this.length; s++) {
55
		newstring = this.charAt(s) + newstring;
55
		newstring = this.charAt(s) + newstring;
56
	}
56
	}
57
	return newstring;
57
	return newstring;
58
	//strOrig = ' texttotrim ';
58
	//strOrig = ' texttotrim ';
59
	//strReversed = strOrig.revstring();
59
	//strReversed = strOrig.revstring();
60
};
60
};
61
 
61
 
62
function chkPass(pwd) {
62
function chkPass(pwd) {
63
	var oScorebar = $("scorebar");
-
 
64
	var oScore = $("score");
63
	var oBar = $("pwprogress");
65
	var oComplexity = $("complexity");
-
 
66
	// Simultaneous variable declaration and value assignment aren't supported in IE apparently
64
	// Simultaneous variable declaration and value assignment aren't supported in IE apparently
67
	// so I'm forced to assign the same value individually per var to support a crappy browser *sigh* 
65
	// so I'm forced to assign the same value individually per var to support a crappy browser *sigh* 
68
	var nScore=0, nLength=0, nAlphaUC=0, nAlphaLC=0, nNumber=0, nSymbol=0, nMidChar=0, nRequirements=0, nAlphasOnly=0, nNumbersOnly=0, nUnqChar=0, nRepChar=0, nRepInc=0, nConsecAlphaUC=0, nConsecAlphaLC=0, nConsecNumber=0, nConsecSymbol=0, nConsecCharType=0, nSeqAlpha=0, nSeqNumber=0, nSeqSymbol=0, nSeqChar=0, nReqChar=0, nMultConsecCharType=0;
66
	var nScore=0, nLength=0, nAlphaUC=0, nAlphaLC=0, nNumber=0, nSymbol=0, nMidChar=0, nRequirements=0, nAlphasOnly=0, nNumbersOnly=0, nUnqChar=0, nRepChar=0, nRepInc=0, nConsecAlphaUC=0, nConsecAlphaLC=0, nConsecNumber=0, nConsecSymbol=0, nConsecCharType=0, nSeqAlpha=0, nSeqNumber=0, nSeqSymbol=0, nSeqChar=0, nReqChar=0, nMultConsecCharType=0;
69
	var nMultRepChar=1, nMultConsecSymbol=1;
67
	var nMultRepChar=1, nMultConsecSymbol=1;
70
	var nMultMidChar=2, nMultRequirements=2, nMultConsecAlphaUC=2, nMultConsecAlphaLC=2, nMultConsecNumber=2;
68
	var nMultMidChar=2, nMultRequirements=2, nMultConsecAlphaUC=2, nMultConsecAlphaLC=2, nMultConsecNumber=2;
71
	var nReqCharType=3, nMultAlphaUC=3, nMultAlphaLC=3, nMultSeqAlpha=3, nMultSeqNumber=3, nMultSeqSymbol=3;
69
	var nReqCharType=3, nMultAlphaUC=3, nMultAlphaLC=3, nMultSeqAlpha=3, nMultSeqNumber=3, nMultSeqSymbol=3;
72
	var nMultLength=4, nMultNumber=4;
70
	var nMultLength=4, nMultNumber=4;
73
	var nMultSymbol=6;
71
	var nMultSymbol=6;
74
	var nTmpAlphaUC="", nTmpAlphaLC="", nTmpNumber="", nTmpSymbol="";
72
	var nTmpAlphaUC="", nTmpAlphaLC="", nTmpNumber="", nTmpSymbol="";
75
	var sAlphaUC="0", sAlphaLC="0", sNumber="0", sSymbol="0", sMidChar="0", sRequirements="0", sAlphasOnly="0", sNumbersOnly="0", sRepChar="0", sConsecAlphaUC="0", sConsecAlphaLC="0", sConsecNumber="0", sSeqAlpha="0", sSeqNumber="0", sSeqSymbol="0";
73
	var sAlphaUC="0", sAlphaLC="0", sNumber="0", sSymbol="0", sMidChar="0", sRequirements="0", sAlphasOnly="0", sNumbersOnly="0", sRepChar="0", sConsecAlphaUC="0", sConsecAlphaLC="0", sConsecNumber="0", sSeqAlpha="0", sSeqNumber="0", sSeqSymbol="0";
76
	var sAlphas = "abcdefghijklmnopqrstuvwxyz";
74
	var sAlphas = "abcdefghijklmnopqrstuvwxyz";
77
	var sNumerics = "01234567890";
75
	var sNumerics = "01234567890";
78
	var sSymbols = ")!@#$%^&*()";
76
	var sSymbols = ")!@#$%^&*()";
-
 
77
	var sColor = "";
79
	var sComplexity = "Trop court";
78
	var sComplexity = "Trop court";
80
	var sStandards = "Below";
-
 
81
	var nMinPwdLen = 8;
79
	var nMinPwdLen = 8;
82
	if (document.all) { var nd = 0; } else { var nd = 1; }
80
	if (document.all) { var nd = 0; } else { var nd = 1; }
83
	if (pwd) {
81
	if (pwd) {
84
		nScore = parseInt(pwd.length * nMultLength);
82
		nScore = parseInt(pwd.length * nMultLength);
85
		nLength = pwd.length;
83
		nLength = pwd.length;
86
		var arrPwd = pwd.replace(/\s+/g,"").split(/\s*/);
84
		var arrPwd = pwd.replace(/\s+/g,"").split(/\s*/);
87
		var arrPwdLen = arrPwd.length;
85
		var arrPwdLen = arrPwd.length;
88
		
86
		
89
		/* Loop through password to check for Symbol, Numeric, Lowercase and Uppercase pattern matches */
87
		/* Loop through password to check for Symbol, Numeric, Lowercase and Uppercase pattern matches */
90
		for (var a=0; a < arrPwdLen; a++) {
88
		for (var a=0; a < arrPwdLen; a++) {
91
			if (arrPwd[a].match(/[A-Z]/g)) {
89
			if (arrPwd[a].match(/[A-Z]/g)) {
92
				if (nTmpAlphaUC !== "") { if ((nTmpAlphaUC + 1) == a) { nConsecAlphaUC++; nConsecCharType++; } }
90
				if (nTmpAlphaUC !== "") { if ((nTmpAlphaUC + 1) == a) { nConsecAlphaUC++; nConsecCharType++; } }
93
				nTmpAlphaUC = a;
91
				nTmpAlphaUC = a;
94
				nAlphaUC++;
92
				nAlphaUC++;
95
			}
93
			}
96
			else if (arrPwd[a].match(/[a-z]/g)) { 
94
			else if (arrPwd[a].match(/[a-z]/g)) { 
97
				if (nTmpAlphaLC !== "") { if ((nTmpAlphaLC + 1) == a) { nConsecAlphaLC++; nConsecCharType++; } }
95
				if (nTmpAlphaLC !== "") { if ((nTmpAlphaLC + 1) == a) { nConsecAlphaLC++; nConsecCharType++; } }
98
				nTmpAlphaLC = a;
96
				nTmpAlphaLC = a;
99
				nAlphaLC++;
97
				nAlphaLC++;
100
			}
98
			}
101
			else if (arrPwd[a].match(/[0-9]/g)) { 
99
			else if (arrPwd[a].match(/[0-9]/g)) { 
102
				if (a > 0 && a < (arrPwdLen - 1)) { nMidChar++; }
100
				if (a > 0 && a < (arrPwdLen - 1)) { nMidChar++; }
103
				if (nTmpNumber !== "") { if ((nTmpNumber + 1) == a) { nConsecNumber++; nConsecCharType++; } }
101
				if (nTmpNumber !== "") { if ((nTmpNumber + 1) == a) { nConsecNumber++; nConsecCharType++; } }
104
				nTmpNumber = a;
102
				nTmpNumber = a;
105
				nNumber++;
103
				nNumber++;
106
			}
104
			}
107
			else if (arrPwd[a].match(/[^a-zA-Z0-9_]/g)) { 
105
			else if (arrPwd[a].match(/[^a-zA-Z0-9_]/g)) { 
108
				if (a > 0 && a < (arrPwdLen - 1)) { nMidChar++; }
106
				if (a > 0 && a < (arrPwdLen - 1)) { nMidChar++; }
109
				if (nTmpSymbol !== "") { if ((nTmpSymbol + 1) == a) { nConsecSymbol++; nConsecCharType++; } }
107
				if (nTmpSymbol !== "") { if ((nTmpSymbol + 1) == a) { nConsecSymbol++; nConsecCharType++; } }
110
				nTmpSymbol = a;
108
				nTmpSymbol = a;
111
				nSymbol++;
109
				nSymbol++;
112
			}
110
			}
113
			/* Internal loop through password to check for repeat characters */
111
			/* Internal loop through password to check for repeat characters */
114
			var bCharExists = false;
112
			var bCharExists = false;
115
			for (var b=0; b < arrPwdLen; b++) {
113
			for (var b=0; b < arrPwdLen; b++) {
116
				if (arrPwd[a] == arrPwd[b] && a != b) { /* repeat character exists */
114
				if (arrPwd[a] == arrPwd[b] && a != b) { /* repeat character exists */
117
					bCharExists = true;
115
					bCharExists = true;
118
					/* 
116
					/* 
119
					Calculate icrement deduction based on proximity to identical characters
117
					Calculate icrement deduction based on proximity to identical characters
120
					Deduction is incremented each time a new match is discovered
118
					Deduction is incremented each time a new match is discovered
121
					Deduction amount is based on total password length divided by the
119
					Deduction amount is based on total password length divided by the
122
					difference of distance between currently selected match
120
					difference of distance between currently selected match
123
					*/
121
					*/
124
					nRepInc += Math.abs(arrPwdLen/(b-a));
122
					nRepInc += Math.abs(arrPwdLen/(b-a));
125
				}
123
				}
126
			}
124
			}
127
			if (bCharExists) { 
125
			if (bCharExists) { 
128
				nRepChar++; 
126
				nRepChar++; 
129
				nUnqChar = arrPwdLen-nRepChar;
127
				nUnqChar = arrPwdLen-nRepChar;
130
				nRepInc = (nUnqChar) ? Math.ceil(nRepInc/nUnqChar) : Math.ceil(nRepInc); 
128
				nRepInc = (nUnqChar) ? Math.ceil(nRepInc/nUnqChar) : Math.ceil(nRepInc); 
131
			}
129
			}
132
		}
130
		}
133
		
131
		
134
		/* Check for sequential alpha string patterns (forward and reverse) */
132
		/* Check for sequential alpha string patterns (forward and reverse) */
135
		for (var s=0; s < 23; s++) {
133
		for (var s=0; s < 23; s++) {
136
			var sFwd = sAlphas.substring(s,parseInt(s+3));
134
			var sFwd = sAlphas.substring(s,parseInt(s+3));
137
			var sRev = sFwd.strReverse();
135
			var sRev = sFwd.strReverse();
138
			if (pwd.toLowerCase().indexOf(sFwd) != -1 || pwd.toLowerCase().indexOf(sRev) != -1) { nSeqAlpha++; nSeqChar++;}
136
			if (pwd.toLowerCase().indexOf(sFwd) != -1 || pwd.toLowerCase().indexOf(sRev) != -1) { nSeqAlpha++; nSeqChar++;}
139
		}
137
		}
140
		
138
		
141
		/* Check for sequential numeric string patterns (forward and reverse) */
139
		/* Check for sequential numeric string patterns (forward and reverse) */
142
		for (var s=0; s < 8; s++) {
140
		for (var s=0; s < 8; s++) {
143
			var sFwd = sNumerics.substring(s,parseInt(s+3));
141
			var sFwd = sNumerics.substring(s,parseInt(s+3));
144
			var sRev = sFwd.strReverse();
142
			var sRev = sFwd.strReverse();
145
			if (pwd.toLowerCase().indexOf(sFwd) != -1 || pwd.toLowerCase().indexOf(sRev) != -1) { nSeqNumber++; nSeqChar++;}
143
			if (pwd.toLowerCase().indexOf(sFwd) != -1 || pwd.toLowerCase().indexOf(sRev) != -1) { nSeqNumber++; nSeqChar++;}
146
		}
144
		}
147
		
145
		
148
		/* Check for sequential symbol string patterns (forward and reverse) */
146
		/* Check for sequential symbol string patterns (forward and reverse) */
149
		for (var s=0; s < 8; s++) {
147
		for (var s=0; s < 8; s++) {
150
			var sFwd = sSymbols.substring(s,parseInt(s+3));
148
			var sFwd = sSymbols.substring(s,parseInt(s+3));
151
			var sRev = sFwd.strReverse();
149
			var sRev = sFwd.strReverse();
152
			if (pwd.toLowerCase().indexOf(sFwd) != -1 || pwd.toLowerCase().indexOf(sRev) != -1) { nSeqSymbol++; nSeqChar++;}
150
			if (pwd.toLowerCase().indexOf(sFwd) != -1 || pwd.toLowerCase().indexOf(sRev) != -1) { nSeqSymbol++; nSeqChar++;}
153
		}
151
		}
154
		
152
		
155
	/* Modify overall score value based on usage vs requirements */
153
	/* Modify overall score value based on usage vs requirements */
156
 
154
 
157
		/* General point assignment */
155
		/* General point assignment */
158
		$("nLengthBonus").innerHTML = "+ " + nScore; 
156
		$("nLengthBonus").innerHTML = "+ " + nScore; 
159
		if (nAlphaUC > 0 && nAlphaUC < nLength) {	
157
		if (nAlphaUC > 0 && nAlphaUC < nLength) {	
160
			nScore = parseInt(nScore + ((nLength - nAlphaUC) * 2));
158
			nScore = parseInt(nScore + ((nLength - nAlphaUC) * 2));
161
			sAlphaUC = "+ " + parseInt((nLength - nAlphaUC) * 2); 
159
			sAlphaUC = "+ " + parseInt((nLength - nAlphaUC) * 2); 
162
		}
160
		}
163
		if (nAlphaLC > 0 && nAlphaLC < nLength) {	
161
		if (nAlphaLC > 0 && nAlphaLC < nLength) {	
164
			nScore = parseInt(nScore + ((nLength - nAlphaLC) * 2)); 
162
			nScore = parseInt(nScore + ((nLength - nAlphaLC) * 2)); 
165
			sAlphaLC = "+ " + parseInt((nLength - nAlphaLC) * 2);
163
			sAlphaLC = "+ " + parseInt((nLength - nAlphaLC) * 2);
166
		}
164
		}
167
		if (nNumber > 0 && nNumber < nLength) {	
165
		if (nNumber > 0 && nNumber < nLength) {	
168
			nScore = parseInt(nScore + (nNumber * nMultNumber));
166
			nScore = parseInt(nScore + (nNumber * nMultNumber));
169
			sNumber = "+ " + parseInt(nNumber * nMultNumber);
167
			sNumber = "+ " + parseInt(nNumber * nMultNumber);
170
		}
168
		}
171
		if (nSymbol > 0) {	
169
		if (nSymbol > 0) {	
172
			nScore = parseInt(nScore + (nSymbol * nMultSymbol));
170
			nScore = parseInt(nScore + (nSymbol * nMultSymbol));
173
			sSymbol = "+ " + parseInt(nSymbol * nMultSymbol);
171
			sSymbol = "+ " + parseInt(nSymbol * nMultSymbol);
174
		}
172
		}
175
		if (nMidChar > 0) {	
173
		if (nMidChar > 0) {	
176
			nScore = parseInt(nScore + (nMidChar * nMultMidChar));
174
			nScore = parseInt(nScore + (nMidChar * nMultMidChar));
177
			sMidChar = "+ " + parseInt(nMidChar * nMultMidChar);
175
			sMidChar = "+ " + parseInt(nMidChar * nMultMidChar);
178
		}
176
		}
179
		$("nAlphaUCBonus").innerHTML = sAlphaUC; 
177
		$("nAlphaUCBonus").innerHTML = sAlphaUC; 
180
		$("nAlphaLCBonus").innerHTML = sAlphaLC;
178
		$("nAlphaLCBonus").innerHTML = sAlphaLC;
181
		$("nNumberBonus").innerHTML = sNumber;
179
		$("nNumberBonus").innerHTML = sNumber;
182
		$("nSymbolBonus").innerHTML = sSymbol;
180
		$("nSymbolBonus").innerHTML = sSymbol;
183
		$("nMidCharBonus").innerHTML = sMidChar;
181
		$("nMidCharBonus").innerHTML = sMidChar;
184
		
182
		
185
		/* Point deductions for poor practices */
183
		/* Point deductions for poor practices */
186
		if ((nAlphaLC > 0 || nAlphaUC > 0) && nSymbol === 0 && nNumber === 0) {  // Only Letters
184
		if ((nAlphaLC > 0 || nAlphaUC > 0) && nSymbol === 0 && nNumber === 0) {  // Only Letters
187
			nScore = parseInt(nScore - nLength);
185
			nScore = parseInt(nScore - nLength);
188
			nAlphasOnly = nLength;
186
			nAlphasOnly = nLength;
189
			sAlphasOnly = "- " + nLength;
187
			sAlphasOnly = "- " + nLength;
190
		}
188
		}
191
		if (nAlphaLC === 0 && nAlphaUC === 0 && nSymbol === 0 && nNumber > 0) {  // Only Numbers
189
		if (nAlphaLC === 0 && nAlphaUC === 0 && nSymbol === 0 && nNumber > 0) {  // Only Numbers
192
			nScore = parseInt(nScore - nLength); 
190
			nScore = parseInt(nScore - nLength); 
193
			nNumbersOnly = nLength;
191
			nNumbersOnly = nLength;
194
			sNumbersOnly = "- " + nLength;
192
			sNumbersOnly = "- " + nLength;
195
		}
193
		}
196
		if (nRepChar > 0) {  // Same character exists more than once
194
		if (nRepChar > 0) {  // Same character exists more than once
197
			nScore = parseInt(nScore - nRepInc);
195
			nScore = parseInt(nScore - nRepInc);
198
			sRepChar = "- " + nRepInc;
196
			sRepChar = "- " + nRepInc;
199
		}
197
		}
200
		if (nConsecAlphaUC > 0) {  // Consecutive Uppercase Letters exist
198
		if (nConsecAlphaUC > 0) {  // Consecutive Uppercase Letters exist
201
			nScore = parseInt(nScore - (nConsecAlphaUC * nMultConsecAlphaUC)); 
199
			nScore = parseInt(nScore - (nConsecAlphaUC * nMultConsecAlphaUC)); 
202
			sConsecAlphaUC = "- " + parseInt(nConsecAlphaUC * nMultConsecAlphaUC);
200
			sConsecAlphaUC = "- " + parseInt(nConsecAlphaUC * nMultConsecAlphaUC);
203
		}
201
		}
204
		if (nConsecAlphaLC > 0) {  // Consecutive Lowercase Letters exist
202
		if (nConsecAlphaLC > 0) {  // Consecutive Lowercase Letters exist
205
			nScore = parseInt(nScore - (nConsecAlphaLC * nMultConsecAlphaLC)); 
203
			nScore = parseInt(nScore - (nConsecAlphaLC * nMultConsecAlphaLC)); 
206
			sConsecAlphaLC = "- " + parseInt(nConsecAlphaLC * nMultConsecAlphaLC);
204
			sConsecAlphaLC = "- " + parseInt(nConsecAlphaLC * nMultConsecAlphaLC);
207
		}
205
		}
208
		if (nConsecNumber > 0) {  // Consecutive Numbers exist
206
		if (nConsecNumber > 0) {  // Consecutive Numbers exist
209
			nScore = parseInt(nScore - (nConsecNumber * nMultConsecNumber));  
207
			nScore = parseInt(nScore - (nConsecNumber * nMultConsecNumber));  
210
			sConsecNumber = "- " + parseInt(nConsecNumber * nMultConsecNumber);
208
			sConsecNumber = "- " + parseInt(nConsecNumber * nMultConsecNumber);
211
		}
209
		}
212
		if (nSeqAlpha > 0) {  // Sequential alpha strings exist (3 characters or more)
210
		if (nSeqAlpha > 0) {  // Sequential alpha strings exist (3 characters or more)
213
			nScore = parseInt(nScore - (nSeqAlpha * nMultSeqAlpha)); 
211
			nScore = parseInt(nScore - (nSeqAlpha * nMultSeqAlpha)); 
214
			sSeqAlpha = "- " + parseInt(nSeqAlpha * nMultSeqAlpha);
212
			sSeqAlpha = "- " + parseInt(nSeqAlpha * nMultSeqAlpha);
215
		}
213
		}
216
		if (nSeqNumber > 0) {  // Sequential numeric strings exist (3 characters or more)
214
		if (nSeqNumber > 0) {  // Sequential numeric strings exist (3 characters or more)
217
			nScore = parseInt(nScore - (nSeqNumber * nMultSeqNumber)); 
215
			nScore = parseInt(nScore - (nSeqNumber * nMultSeqNumber)); 
218
			sSeqNumber = "- " + parseInt(nSeqNumber * nMultSeqNumber);
216
			sSeqNumber = "- " + parseInt(nSeqNumber * nMultSeqNumber);
219
		}
217
		}
220
		if (nSeqSymbol > 0) {  // Sequential symbol strings exist (3 characters or more)
218
		if (nSeqSymbol > 0) {  // Sequential symbol strings exist (3 characters or more)
221
			nScore = parseInt(nScore - (nSeqSymbol * nMultSeqSymbol)); 
219
			nScore = parseInt(nScore - (nSeqSymbol * nMultSeqSymbol)); 
222
			sSeqSymbol = "- " + parseInt(nSeqSymbol * nMultSeqSymbol);
220
			sSeqSymbol = "- " + parseInt(nSeqSymbol * nMultSeqSymbol);
223
		}
221
		}
224
		$("nAlphasOnlyBonus").innerHTML = sAlphasOnly; 
222
		$("nAlphasOnlyBonus").innerHTML = sAlphasOnly; 
225
		$("nNumbersOnlyBonus").innerHTML = sNumbersOnly; 
223
		$("nNumbersOnlyBonus").innerHTML = sNumbersOnly; 
226
		$("nRepCharBonus").innerHTML = sRepChar; 
224
		$("nRepCharBonus").innerHTML = sRepChar; 
227
		$("nConsecAlphaUCBonus").innerHTML = sConsecAlphaUC; 
225
		$("nConsecAlphaUCBonus").innerHTML = sConsecAlphaUC; 
228
		$("nConsecAlphaLCBonus").innerHTML = sConsecAlphaLC; 
226
		$("nConsecAlphaLCBonus").innerHTML = sConsecAlphaLC; 
229
		$("nConsecNumberBonus").innerHTML = sConsecNumber;
227
		$("nConsecNumberBonus").innerHTML = sConsecNumber;
230
		$("nSeqAlphaBonus").innerHTML = sSeqAlpha; 
228
		$("nSeqAlphaBonus").innerHTML = sSeqAlpha; 
231
		$("nSeqNumberBonus").innerHTML = sSeqNumber; 
229
		$("nSeqNumberBonus").innerHTML = sSeqNumber; 
232
		$("nSeqSymbolBonus").innerHTML = sSeqSymbol; 
230
		$("nSeqSymbolBonus").innerHTML = sSeqSymbol; 
233
 
231
 
234
		/* Determine if mandatory requirements have been met and set image indicators accordingly */
232
		/* Determine if mandatory requirements have been met and set image indicators accordingly */
235
		var arrChars = [nLength,nAlphaUC,nAlphaLC,nNumber,nSymbol];
233
		var arrChars = [nLength,nAlphaUC,nAlphaLC,nNumber,nSymbol];
236
		var arrCharsIds = ["nLength","nAlphaUC","nAlphaLC","nNumber","nSymbol"];
234
		var arrCharsIds = ["nLength","nAlphaUC","nAlphaLC","nNumber","nSymbol"];
237
		var arrCharsLen = arrChars.length;
235
		var arrCharsLen = arrChars.length;
238
		for (var c=0; c < arrCharsLen; c++) {
236
		for (var c=0; c < arrCharsLen; c++) {
239
			var oImg = $('div_' + arrCharsIds[c]);
237
			var oImg = $('div_' + arrCharsIds[c]);
240
			var oBonus = $(arrCharsIds[c] + 'Bonus');
238
			var oBonus = $(arrCharsIds[c] + 'Bonus');
241
			$(arrCharsIds[c]).innerHTML = arrChars[c];
239
			$(arrCharsIds[c]).innerHTML = arrChars[c];
242
			if (arrCharsIds[c] == "nLength") { var minVal = parseInt(nMinPwdLen - 1); } else { var minVal = 0; }
240
			if (arrCharsIds[c] == "nLength") { var minVal = parseInt(nMinPwdLen - 1); } else { var minVal = 0; }
243
			if (arrChars[c] == parseInt(minVal + 1)) { nReqChar++; oImg.className = "pass"; oBonus.parentNode.className = "pass"; }
241
			if (arrChars[c] == parseInt(minVal + 1)) { nReqChar++; oImg.className = "pass"; oBonus.parentNode.className = "pass"; }
244
			else if (arrChars[c] > parseInt(minVal + 1)) { nReqChar++; oImg.className = "exceed"; oBonus.parentNode.className = "exceed"; }
242
			else if (arrChars[c] > parseInt(minVal + 1)) { nReqChar++; oImg.className = "exceed"; oBonus.parentNode.className = "exceed"; }
245
			else { oImg.className = "fail"; oBonus.parentNode.className = "fail"; }
243
			else { oImg.className = "fail"; oBonus.parentNode.className = "fail"; }
246
		}
244
		}
247
		nRequirements = nReqChar;
245
		nRequirements = nReqChar;
248
		if (pwd.length >= nMinPwdLen) { var nMinReqChars = 3; } else { var nMinReqChars = 4; }
246
		if (pwd.length >= nMinPwdLen) { var nMinReqChars = 3; } else { var nMinReqChars = 4; }
249
		if (nRequirements > nMinReqChars) {  // One or more required characters exist
247
		if (nRequirements > nMinReqChars) {  // One or more required characters exist
250
			nScore = parseInt(nScore + (nRequirements * 2)); 
248
			nScore = parseInt(nScore + (nRequirements * 2)); 
251
			sRequirements = "+ " + parseInt(nRequirements * 2);
249
			sRequirements = "+ " + parseInt(nRequirements * 2);
252
		}
250
		}
253
		$("nRequirementsBonus").innerHTML = sRequirements;
251
		$("nRequirementsBonus").innerHTML = sRequirements;
254
 
252
 
255
		/* Determine if additional bonuses need to be applied and set image indicators accordingly */
253
		/* Determine if additional bonuses need to be applied and set image indicators accordingly */
256
		var arrChars = [nMidChar,nRequirements];
254
		var arrChars = [nMidChar,nRequirements];
257
		var arrCharsIds = ["nMidChar","nRequirements"];
255
		var arrCharsIds = ["nMidChar","nRequirements"];
258
		var arrCharsLen = arrChars.length;
256
		var arrCharsLen = arrChars.length;
259
		for (var c=0; c < arrCharsLen; c++) {
257
		for (var c=0; c < arrCharsLen; c++) {
260
			var oImg = $('div_' + arrCharsIds[c]);
258
			var oImg = $('div_' + arrCharsIds[c]);
261
			var oBonus = $(arrCharsIds[c] + 'Bonus');
259
			var oBonus = $(arrCharsIds[c] + 'Bonus');
262
			$(arrCharsIds[c]).innerHTML = arrChars[c];
260
			$(arrCharsIds[c]).innerHTML = arrChars[c];
263
			if (arrCharsIds[c] == "nRequirements") { var minVal = nMinReqChars; } else { var minVal = 0; }
261
			if (arrCharsIds[c] == "nRequirements") { var minVal = nMinReqChars; } else { var minVal = 0; }
264
			if (arrChars[c] == parseInt(minVal + 1)) { oImg.className = "pass"; oBonus.parentNode.className = "pass"; }
262
			if (arrChars[c] == parseInt(minVal + 1)) { oImg.className = "pass"; oBonus.parentNode.className = "pass"; }
265
			else if (arrChars[c] > parseInt(minVal + 1)) { oImg.className = "exceed"; oBonus.parentNode.className = "exceed"; }
263
			else if (arrChars[c] > parseInt(minVal + 1)) { oImg.className = "exceed"; oBonus.parentNode.className = "exceed"; }
266
			else { oImg.className = "fail"; oBonus.parentNode.className = "fail"; }
264
			else { oImg.className = "fail"; oBonus.parentNode.className = "fail"; }
267
		}
265
		}
268
 
266
 
269
		/* Determine if suggested requirements have been met and set image indicators accordingly */
267
		/* Determine if suggested requirements have been met and set image indicators accordingly */
270
		var arrChars = [nAlphasOnly,nNumbersOnly,nRepChar,nConsecAlphaUC,nConsecAlphaLC,nConsecNumber,nSeqAlpha,nSeqNumber,nSeqSymbol];
268
		var arrChars = [nAlphasOnly,nNumbersOnly,nRepChar,nConsecAlphaUC,nConsecAlphaLC,nConsecNumber,nSeqAlpha,nSeqNumber,nSeqSymbol];
271
		var arrCharsIds = ["nAlphasOnly","nNumbersOnly","nRepChar","nConsecAlphaUC","nConsecAlphaLC","nConsecNumber","nSeqAlpha","nSeqNumber","nSeqSymbol"];
269
		var arrCharsIds = ["nAlphasOnly","nNumbersOnly","nRepChar","nConsecAlphaUC","nConsecAlphaLC","nConsecNumber","nSeqAlpha","nSeqNumber","nSeqSymbol"];
272
		var arrCharsLen = arrChars.length;
270
		var arrCharsLen = arrChars.length;
273
		for (var c=0; c < arrCharsLen; c++) {
271
		for (var c=0; c < arrCharsLen; c++) {
274
			var oImg = $('div_' + arrCharsIds[c]);
272
			var oImg = $('div_' + arrCharsIds[c]);
275
			var oBonus = $(arrCharsIds[c] + 'Bonus');
273
			var oBonus = $(arrCharsIds[c] + 'Bonus');
276
			$(arrCharsIds[c]).innerHTML = arrChars[c];
274
			$(arrCharsIds[c]).innerHTML = arrChars[c];
277
			if (arrChars[c] > 0) { oImg.className = "warn"; oBonus.parentNode.className = "warn"; }
275
			if (arrChars[c] > 0) { oImg.className = "warn"; oBonus.parentNode.className = "warn"; }
278
			else { oImg.className = "pass"; oBonus.parentNode.className = "pass"; }
276
			else { oImg.className = "pass"; oBonus.parentNode.className = "pass"; }
279
		}
277
		}
280
		
278
		
281
		/* Determine complexity based on overall score */
279
		/* Determine complexity based on overall score */
282
		if (nScore > 100) { nScore = 100; } else if (nScore < 0) { nScore = 0; }
280
		if (nScore > 100) { nScore = 100; } else if (nScore < 0) { nScore = 0; }
-
 
281
		if(nScore < 0){}
-
 
282
		else if (nScore < 20) {
-
 
283
			sColor = "bg-dark";
283
		if (nScore >= 0 && nScore < 20) { sComplexity = "Tr&egrave;s Faible"; }
284
			sComplexity = "Tr&egrave;s Faible";
-
 
285
		}
-
 
286
		else if (nScore < 40) {
-
 
287
			sColor = "bg-danger";
284
		else if (nScore >= 20 && nScore < 40) { sComplexity = "Faible"; }
288
			sComplexity = "Faible"; }
-
 
289
		else if (nScore < 60) {
-
 
290
			sColor = "bg-warning";
285
		else if (nScore >= 40 && nScore < 60) { sComplexity = "Moyen"; }
291
			sComplexity = "Moyen"; }
-
 
292
		else if (nScore < 80) {
-
 
293
			sColor = "bg-info";
-
 
294
			sComplexity = "Bon";
-
 
295
		}
286
		else if (nScore >= 60 && nScore < 80) { sComplexity = "Bon"; }
296
		else if (nScore <= 100) {
-
 
297
			sColor = "bg-success";
287
		else if (nScore >= 80 && nScore <= 100) { sComplexity = "Tr&egrave;s bon"; }
298
			sComplexity = "Tr&egrave;s bon";
-
 
299
		}
288
		
300
		
289
		/* Display updated score criteria to client */
301
		/* Display updated score criteria to client */
290
		oScorebar.style.backgroundPosition = "-" + parseInt(nScore * 4) + "px";
302
		oBar.innerHTML = nScore + "% / "+sComplexity;
291
		oScore.innerHTML = nScore + "%";
303
		oBar.style.width = nScore + "%";
292
		oComplexity.innerHTML = sComplexity;
304
		oBar.className = "progress-bar " + sColor;
293
	}
305
	}
294
	else {
306
	else {
295
		/* Display default score criteria to client */
307
		/* Display default score criteria to client */
296
		initPwdChk();
308
		initPwdChk();
297
		oScore.innerHTML = nScore + "%";
309
		oBar.innerHTML = nScore + "%"+sComplexity;
298
		oComplexity.innerHTML = sComplexity;
310
		oBar.style.width = nScore + "%";
-
 
311
		oBar.className = "progress-bar";
299
	}
312
	}
300
}
313
}
301
 
314
 
302
function initPwdChk(restart) {
315
function initPwdChk(restart) {
303
	/* Reset all form values to their default */
316
	/* Reset all form values to their default */
304
	var arrZeros = ["nLength","nAlphaUC","nAlphaLC","nNumber","nSymbol","nMidChar","nRequirements","nAlphasOnly","nNumbersOnly","nRepChar","nConsecAlphaUC","nConsecAlphaLC","nConsecNumber","nSeqAlpha","nSeqNumber","nSeqSymbol","nLengthBonus","nAlphaUCBonus","nAlphaLCBonus","nNumberBonus","nSymbolBonus","nMidCharBonus","nRequirementsBonus","nAlphasOnlyBonus","nNumbersOnlyBonus","nRepCharBonus","nConsecAlphaUCBonus","nConsecAlphaLCBonus","nConsecNumberBonus","nSeqAlphaBonus","nSeqNumberBonus","nSeqSymbolBonus"];
317
	var arrZeros = ["nLength","nAlphaUC","nAlphaLC","nNumber","nSymbol","nMidChar","nRequirements","nAlphasOnly","nNumbersOnly","nRepChar","nConsecAlphaUC","nConsecAlphaLC","nConsecNumber","nSeqAlpha","nSeqNumber","nSeqSymbol","nLengthBonus","nAlphaUCBonus","nAlphaLCBonus","nNumberBonus","nSymbolBonus","nMidCharBonus","nRequirementsBonus","nAlphasOnlyBonus","nNumbersOnlyBonus","nRepCharBonus","nConsecAlphaUCBonus","nConsecAlphaLCBonus","nConsecNumberBonus","nSeqAlphaBonus","nSeqNumberBonus","nSeqSymbolBonus"];
305
	var arrPassPars = ["nAlphasOnlyBonus","nNumbersOnlyBonus","nRepCharBonus","nConsecAlphaUCBonus","nConsecAlphaLCBonus","nConsecNumberBonus","nSeqAlphaBonus","nSeqNumberBonus","nSeqSymbolBonus"];
318
	var arrPassPars = ["nAlphasOnlyBonus","nNumbersOnlyBonus","nRepCharBonus","nConsecAlphaUCBonus","nConsecAlphaLCBonus","nConsecNumberBonus","nSeqAlphaBonus","nSeqNumberBonus","nSeqSymbolBonus"];
306
	var arrPassDivs = ["div_nAlphasOnly","div_nNumbersOnly","div_nRepChar","div_nConsecAlphaUC","div_nConsecAlphaLC","div_nConsecNumber","div_nSeqAlpha","div_nSeqNumber","div_nSeqSymbol"];
319
	var arrPassDivs = ["div_nAlphasOnly","div_nNumbersOnly","div_nRepChar","div_nConsecAlphaUC","div_nConsecAlphaLC","div_nConsecNumber","div_nSeqAlpha","div_nSeqNumber","div_nSeqSymbol"];
307
	var arrFailPars = ["nLengthBonus","nAlphaUCBonus","nAlphaLCBonus","nNumberBonus","nSymbolBonus","nMidCharBonus","nRequirementsBonus"];
320
	var arrFailPars = ["nLengthBonus","nAlphaUCBonus","nAlphaLCBonus","nNumberBonus","nSymbolBonus","nMidCharBonus","nRequirementsBonus"];
308
	var arrFailDivs = ["div_nLength","div_nAlphaUC","div_nAlphaLC","div_nNumber","div_nSymbol","div_nMidChar","div_nRequirements"];
321
	var arrFailDivs = ["div_nLength","div_nAlphaUC","div_nAlphaLC","div_nNumber","div_nSymbol","div_nMidChar","div_nRequirements"];
309
	for (var i in arrZeros) { $(arrZeros[i]).innerHTML = "0"; }
322
	for (var i in arrZeros) { $(arrZeros[i]).innerHTML = "0"; }
310
	for (var i in arrPassPars) { $(arrPassPars[i]).parentNode.className = "pass"; }
323
	for (var i in arrPassPars) { $(arrPassPars[i]).parentNode.className = "pass"; }
311
	for (var i in arrPassDivs) { $(arrPassDivs[i]).className = "pass"; }
324
	for (var i in arrPassDivs) { $(arrPassDivs[i]).className = "pass"; }
312
	for (var i in arrFailPars) { $(arrFailPars[i]).parentNode.className = "fail"; }
325
	for (var i in arrFailPars) { $(arrFailPars[i]).parentNode.className = "fail"; }
313
	for (var i in arrFailDivs) { $(arrFailDivs[i]).className = "fail"; }
326
	for (var i in arrFailDivs) { $(arrFailDivs[i]).className = "fail"; }
314
	$("passwordPwd").value = "";
327
	$("passwordPwd").value = "";
315
	$("passwordTxt").value = "";
328
	$("passwordTxt").value = "";
316
	$("scorebar").style.backgroundPosition = "0";
329
	$("scorebar").style.backgroundPosition = "0";
317
	if (restart) {
330
	if (restart) {
318
		$("passwordPwd").className = "";
331
		$("passwordPwd").className = "";
319
		$("passwordTxt").className = "hide";
332
		$("passwordTxt").className = "hide";
320
	}
333
	}
321
}
334
}
322
 
335
 
323
addLoadEvent(function() { initPwdChk(1); });
336
addLoadEvent(function() { initPwdChk(1); });
324
 
337
 
325
 
338