PageSourceSearch

https://static.gruppenkonto.spiegel.de/js/common/passwordcheckerembedded-58173f6874d9abc23c1d446cfce0354f.js

js spiegel.de collected 2026-10-09 22:25:11 UTC 3,549 bytes, 113 lines download raw bytes

1var config = null;
2var registeredPasswordField = null;
3var passwordCheckerComponent = null;
4
5/**
6 * Initializes the embedded passwordchecker-component. The following is part of the initialization:
7 * 1.) Remember the configuration and the HTML-Components for later use.
8 * 2.) Add requirement list to the content of the page.
9 * 3.) Add listeners to the password field.
10 * @param passwordFieldId
11 * @param configuration
12 * @returns
13 */
14function initPasswordChecker(passwordFieldId, configuration){
15	
16	// 1.) Remember the configuration and the HTML-Components
17	config = configuration;
18	registeredPasswordField = $("#" + passwordFieldId);
19	passwordCheckerComponent = $("#passwordCheckerComponent");
20
21	// 2.) Add requirement list to the HTML page
22	var requirementList = $("#requirements");
23	for (var i = 0; i < config.requirements.length; i++){
24		requirementList.append('<li data-requirement="' + config.requirements[i].id + '">'
25			+ '	<svg width="10" height="10" viewBox="0 0 10 10" fill="none" xmlns="http://www.w3.org/2000/svg">'
26			+ '		<path class="passed" d="M8.33334 1.66666L3.66668 7.66666L1.66668 4.99999" stroke-width="1.8" stroke-linecap="round"/>'
27			+ '		<path class="failed" d="M9 9.00002L1.00002 1M9 1L1.00002 9.00002" stroke-linecap="round"/>'
28			+ '	</svg>'
29			+ 	config.requirements[i].label
30			+ '</li>');
31	}
32	
33	// 3.) Add listeners to the password field
34	registeredPasswordField.keyup(function() {
35		setupPasswordStrength();
36	});
37	registeredPasswordField.on("input", function() {
38		showPasswordStrength();
39	});
40	registeredPasswordField.blur(function() {
41		// Passwort-Sicherheit soll nach initialem einblenden nicht mehr ausgeblendet werden
42		// hidePasswordStrength();
43		updateStrengthList(requirementList);
44	});
45	
46	document.addEventListener('submit', function(e) {
47		  updateStrengthList(requirementList);	
48		  if (calculateStrength() < config.requirements.length) {
49			  showPasswordStrength();
50			  e.preventDefault();
51		  }
52		});
53	
54}
55
56function updateStrengthList(requirementList){
57	  if (calculateStrength() < config.requirements.length)  {
58		  registeredPasswordField.addClass("cms-error-input");
59		  requirementList.addClass("cms-psw-checker-invalid");
60	  } else {
61		  registeredPasswordField.removeClass("cms-error-input");
62	  }
63}
64
65function setupPasswordStrength() {
66	var password = registeredPasswordField.val();
67	var strength = calculateStrength();
68	var ptext = $("#pwdStrengthText");
69	if (password.length == 0 || strength < 1) {
70		ptext.text(config.strengths[0]);
71	} else if (strength < config.requirements.length) {
72		ptext.text(config.strengths[1]);
73	} else {
74		if (password.length < 10) {
75			ptext.text(config.strengths[2]);
76		} else {
77			ptext.text(config.strengths[3]);
78		}
79		registeredPasswordField.removeClass("cms-error-input");
80
81	}
82}
83
84function calculateStrength() {
85	var password = registeredPasswordField.val();
86	var strength = 0;
87	for (var i = 0; i < config.requirements.length; i++){
88		if (checkRequirement(config.requirements[i])) {
89			strength++;
90		}
91	}
92	return strength;
93}
94
95function checkRequirement(requirement) {
96	var password = registeredPasswordField.val();
97	var isRequirementOk = (new RegExp(requirement.regex)).test(password);
98	if (isRequirementOk) {
99		$("[data-requirement=" + requirement.id + "]").removeClass("failed");
100	} else {
101		$("[data-requirement=" + requirement.id + "]").addClass("failed");
102	}
103	return isRequirementOk;
104}
105 
106function hidePasswordStrength(){
107	passwordCheckerComponent.hide();
108}
109
110function showPasswordStrength(){
111	setupPasswordStrength();
112	passwordCheckerComponent.show();
113}

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.