1function protectPassword(validationOptions) { 2 var minStrenghtValue = ( $(':input[data-event="password-strenght"][data-ps-min-value]').length && (typeof $(':input[data-event="password-strenght"][data-ps-min-value]').attr('data-ps-min-value') != 'undefined') )? $(':input[data-event="password-strenght"][data-ps-min-value]').attr('data-ps-min-value') : 4 ; 3 4 if (minStrenghtValue == 0) { 5 return false; 6 } 7 var minStrenghtValueLabel = translation['pwd_value_label_'+ minStrenghtValue]; 8 9 if ( !validationOptions ) { 10 validationOptions = { 11 'string_length': 8, // digit (numero min di caratteri) 12 'lower_upper_case': 0, // boolean (0/1) 13 'alphanumeric_characters': 1, // boolean (0/1) 14 'special_characters': 0, // boolean (0/1) 15 'avoid_spaces': 1, // boolean (0/1) 16 'pwd_complexity': 1 // boolean (0/1) 17 }; 18 } 19 20 var pwdStringLength = validationOptions['string_length']; 21 var pwdStringLowUppCase = validationOptions['lower_upper_case']; 22 var pwdStringAlpNum = validationOptions['alphanumeric_characters']; 23 var pwdStringSpecialChr = validationOptions['special_characters']; 24 var pwdStringSpace = validationOptions['avoid_spaces']; 25 var pwdComplexity = validationOptions['pwd_complexity']; 26 27 var emptyValue = translation['pwd_value_label_empty']; 28 var pwdInfo = '<svg xmlns="http://www.w3.org/2000/svg" height="1em" viewBox="0 0 192 512"><path d="M20 424.229h20V279.771H20c-11.046 0-20-8.954-20-20V212c0-11.046 8.954-20 20-20h112c11.046 0 20 8.954 20 20v212.229h20c11.046 0 20 8.954 20 20V492c0 11.046-8.954 20-20 20H20c-11.046 0-20-8.954-20-20v-47.771c0-11.046 8.954-20 20-20zM96 0C56.235 0 24 32.235 24 72s32.235 72 72 72 72-32.235 72-72S135.764 0 96 0z"/></svg>'; 29 var pwdShow = '<svg xmlns="http://www.w3.org/2000/svg" class="pwd-icon" height="1em" viewBox="0 0 640 512"><path d="M634 471L36 3.51A16 16 0 0 0 13.51 6l-10 12.49A16 16 0 0 0 6 41l598 467.49a16 16 0 0 0 22.49-2.49l10-12.49A16 16 0 0 0 634 471zM296.79 146.47l134.79 105.38C429.36 191.91 380.48 144 320 144a112.26 112.26 0 0 0-23.21 2.47zm46.42 219.07L208.42 260.16C210.65 320.09 259.53 368 320 368a113 113 0 0 0 23.21-2.46zM320 112c98.65 0 189.09 55 237.93 144a285.53 285.53 0 0 1-44 60.2l37.74 29.5a333.7 333.7 0 0 0 52.9-75.11 32.35 32.35 0 0 0 0-29.19C550.29 135.59 442.93 64 320 64c-36.7 0-71.71 7-104.63 18.81l46.41 36.29c18.94-4.3 38.34-7.1 58.22-7.1zm0 288c-98.65 0-189.08-55-237.93-144a285.47 285.47 0 0 1 44.05-60.19l-37.74-29.5a333.6 333.6 0 0 0-52.89 75.1 32.35 32.35 0 0 0 0 29.19C89.72 376.41 197.08 448 320 448c36.7 0 71.71-7.05 104.63-18.81l-46.41-36.28C359.28 397.2 339.89 400 320 400z"/></svg>'; 30 var pwdShowActive = '<svg xmlns="http://www.w3.org/2000/svg" class="pwd-icon-active" height="1em" viewBox="0 0 576 512"><path d="M288 144a110.94 110.94 0 0 0-31.24 5 55.4 55.4 0 0 1 7.24 27 56 56 0 0 1-56 56 55.4 55.4 0 0 1-27-7.24A111.71 111.71 0 1 0 288 144zm284.52 97.4C518.29 135.59 410.93 64 288 64S57.68 135.64 3.48 241.41a32.35 32.35 0 0 0 0 29.19C57.71 376.41 165.07 448 288 448s230.32-71.64 284.52-177.41a32.35 32.35 0 0 0 0-29.19zM288 400c-98.65 0-189.09-55-237.93-144C98.91 167 189.34 112 288 112s189.09 55 237.93 144C477.1 345 386.66 400 288 400z"/></svg>'; 31 var closeIcon = '<svg xmlns="http://www.w3.org/2000/svg" height="1em" viewBox="0 0 320 512"><path d="M193.94 256L296.5 153.44l21.15-21.15c3.12-3.12 3.12-8.19 0-11.31l-22.63-22.63c-3.12-3.12-8.19-3.12-11.31 0L160 222.06 36.29 98.34c-3.12-3.12-8.19-3.12-11.31 0L2.34 120.97c-3.12 3.12-3.12 8.19 0 11.31L126.06 256 2.34 379.71c-3.12 3.12-3.12 8.19 0 11.31l22.63 22.63c3.12 3.12 8.19 3.12 11.31 0L160 289.94 262.56 392.5l21.15 21.15c3.12 3.12 8.19 3.12 11.31 0l22.63-22.63c3.12-3.12 3.12-8.19 0-11.31L193.94 256z"/></svg>'; 32 33 var pwdCriteriaText = ''; 34 var pwdAdviceText = ''; 35 36 let optionsIndex = 0; 37 $.each( validationOptions, function(key, value) { 38 optionsIndex++; 39 40 if (value > 0) { 41 pwdCriteriaText += '<li>'+ translation['pwd_info_criteri_'+[optionsIndex]].replace(/___VALUE___/i, minStrenghtValueLabel).replace(/___MIN_LENGTH___/i, pwdStringLength) +'</li>'; //___VALUE___ 42 } else { 43 pwdAdviceText += '<li>'+ translation['pwd_info_advice_'+[optionsIndex]].replace(/___VALUE___/i, minStrenghtV
43alueLabel).replace(/___MIN_LENGTH___/i, pwdStringLength) +'</li>'; 44 } 45 }); 46 47 var pwdCriteria = ''; 48 if (pwdCriteriaText != '') { 49 pwdCriteria = '\ 50 <div class="pwd-info-title">'+ translation['pwd_info_title'] +'<button type="button" class="close-pwd-info-layer">'+ closeIcon +'</button></div>\ 51 <ul class="pwd-info-criteri">\ 52 '+ pwdCriteriaText +'\ 53 </ul>\ 54 '; 55 } 56 57 var pwdAdvice = ''; 58 if (pwdAdviceText != '') { 59 var pwdAdviceCloseButton = ''; 60 var pwdTitleMargin = 'margin-top'; 61 if (pwdCriteria == '') { 62 pwdAdviceCloseButton = '<button type="button" class="close-pwd-info-layer">'+ closeIcon +'</button>'; 63 pwdTitleMargin = ''; 64 } 65 pwdAdvice = '\ 66 <div class="pwd-info-advice-title '+ pwdTitleMargin +'">'+ translation['pwd_info_advice_title'] + pwdAdviceCloseButton +'</div>\ 67 <ul class="pwd-info-advice">\ 68 '+ pwdAdviceText +'\ 69 </ul>\ 70 '; 71 } 72 73 var pwdInfoLayer = '\ 74 '+ pwdCriteria +'\ 75 '+ pwdAdvice +'\ 76 '; 77 var pwdStrenght = 0; 78 var submitFormObj; 79 80 function passwordStrenght( thisItem, setReturn=false ) { 81 82 var thisObj = $(thisItem); 83 84 var special_characters_reg = /[@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]/g; 85 var digit_reg = /[0-9]/g; 86 var uppercase_reg = /[A-Z]/g; 87 var lowercase_reg = /[a-z]/g; 88 var space_reg = /\s/g; 89 90 var string = thisObj.val(); 91 92 pwdStrenght = zxcvbn(string).score; 93 var passwordError = 0; 94 var passwordErrorLabel = ''; 95 96 var all_special = (string.match(special_characters_reg) != null)? string.match(special_characters_reg).length : 0 ; 97 var all_digit = (string.match(digit_reg) != null)? string.match(digit_reg).length : 0 ; 98 var all_uppercase = (string.match(uppercase_reg) != null)? string.match(uppercase_reg).length : 0 ; 99 var all_lowercase = (string.match(lowercase_reg) != null)? string.match(lowercase_reg).length : 0 ; 100 var all_space = (string.match(space_reg) != null)? string.match(space_reg).length : 0 ; 101 102 if (pwdStringLength > 0 && string.length < pwdStringLength ) { 103 passwordError = 1; 104 passwordErrorLabel = translation['pwd_errore_lunghezza'].replace(/___MIN_LENGTH___/i, pwdStringLength); 105 } else if (pwdStringLowUppCase > 0 && (all_uppercase<=0 || all_lowercase<=0) ) { 106 passwordError = 1; 107 passwordErrorLabel = translation['pwd_errore_maiuscole_minuscole']; 108 } else if (pwdStringAlpNum > 0 && ((all_uppercase+all_lowercase<=0) || all_digit<=0) ) { 109 passwordError = 1; 110 passwordErrorLabel = translation['pwd_errore_alfanumerica']; 111 } else if (pwdStringSpecialChr > 0 && all_special<=0) { 112 passwordError = 1; 113 passwordErrorLabel = translation['pwd_errore_special']; 114 } else if (pwdStringSpace > 0 && all_space>0) { 115 passwordError = 1; 116 passwordErrorLabel = translation['pwd_errore_spazio']; 117 } 118 119 120 var infoLabel = emptyValue; 121 var infoLevel = 'level-0'; 122 123 if (string.length>0 && passwordError>0) { 124 infoLabel = passwordErrorLabel; 125 infoLevel = 'level-error'; 126 pwdStrenght = 0; 127 } else { 128 if (string.length <= 0) { 129 infoLabel = emptyValue; 130 infoLevel = ''; 131 pwdStrenght = 0; 132 } else { 133 switch(pwdStrenght) { 134 case 0: 135 infoLabel = translation['pwd_value_label_1']; // Molto debole 136 infoLevel = 'level-0'; 137 break; 138 case 1: 139 infoLabel = translation['pwd_value_label_2']; // Debole 140 infoLevel = 'level-1'; 141 break; 142 case 2: 143 infoLabel = translation['pwd_value_label_3']; // Media 144 infoLevel = 'level-2'; 145 break; 146 case 3: 147 infoLabel = translation['pwd_value_label_4']; // Forte 148 infoLevel = 'level-3'; 149 break; 150 case 4: 151 infoLabel = translation['pwd_value_label_5']; // Molto forte 152 infoLevel = 'level-4'; 153 break; 154 } 155 pwdStrenght += 1; 156 } 157 } 158 159 thisItem.attr('data-pwd-level', pwdStrenght); 160 thisItem.closest('.password-strenght-wrapper').find('.pwds-strenght-data>.pwds-strenght-label').html(infoLabel); 161 thisItem.closest('.password-strenght-wrapper').attr('class', 'password-strenght-wrapper '+ infoLevel ); 162 163 if ( thisItem.val().length ) { 164 thisItem.closest('.password-strenght-wrapper').attr('data-focus','true'); 165 } 166 167 } 168 169 function setUpPwdInput() { 170 var inputPwd = $(':input[data-event="password-strenght"]'); 171 var formFloating = false;
172 var wrappingItem; 173 var wrapperTypeSelector = ''; 174 175 inputPwd.each(function( index ) { 176 177 if ( $(this).closest('.form-floating').length ) { 178 formFloating = true; 179 } 180 181 wrappingItem = $(this); 182 183 if (formFloating) { 184 wrappingItem = $(this).closest('.form-floating'); 185 wrapperTypeSelector = 'data-selector="form-floating-wrapper"'; 186 } 187 188 var options = []; 189 if ( $(this).attr('data-ps-options') ) { 190 if ( $(this).attr('data-ps-options') != '') { 191 options = $(this).attr('data-ps-options').split(','); 192 } 193 } 194 195 var pwdInfoWrapper = ''; 196 var pwdShowWrapper = ''; 197 var pwdStrenghtData = ''; 198 199 wrappingItem.wrap('<div class="password-strenght-wrapper" '+ wrapperTypeSelector +'></div>'); 200 wrappingItem.wrap('<div class="password-strenght-content"></div>'); 201 202 if ( options.length == 0 || $.inArray('show-info', options) !== -1 ) { 203 pwdInfoWrapper = '<div class="pwd-info"><button type="button" aria-label="'+ translation['pwd_info_label'] +'">'+ pwdInfo +'</button><div class="pwd-info-layer">'+ pwdInfoLayer +'</div></div>'; 204 } 205 206 if ( options.length == 0 || $.inArray('show-pwd', options) !== -1 ) { 207 pwdShowWrapper = '<button type="button" class="pwd-show" role="button" aria-label="'+ translation['pwd_show_label'] +'">'+ pwdShow + pwdShowActive +'</button>'; 208 } 209 210 if ( options.length == 0 || $.inArray('show-strenght', options) !== -1 ) { 211 pwdStrenghtData = '<div class="pwds-strenght-data"><div class="pwds-strenght-line"></div><div class="pwds-strenght-label">'+ emptyValue +'</div></div>'; 212 } 213 214 $(this).closest('.password-strenght-wrapper>.password-strenght-content').append(pwdInfoWrapper + pwdShowWrapper); 215 $(this).closest('.password-strenght-wrapper').append(pwdStrenghtData); 216 }); 217 218 } 219 220 setUpPwdInput(); 221 222 $(':input[data-event="password-strenght"]').on('input', function() { 223 if ( $(this).closest('.password-strenght-wrapper').find('.pwds-strenght-data').length ) { 224 passwordStrenght( $(this) ); 225 } 226 }); 227 228 $(':input[data-event="password-strenght"]').on('focus', function() { 229 $(this).closest('.password-strenght-wrapper').attr('data-focus','true'); 230 }).on('blur', function() { 231 if ( !$(this).val().length ) { 232 $(this).closest('.password-strenght-wrapper').removeAttr('data-focus'); 233 } 234 }); 235 236 $('.password-strenght-content>.pwd-info>button').on('click', function() { 237 toggleInfo( $(this) ); 238 }); 239 $('.password-strenght-content>.pwd-info button.close-pwd-info-layer').on('click', function() { 240 $('.pwd-info.active').removeClass('active'); 241 }); 242 $('.password-strenght-content>.pwd-info>.pwd-info-layer').on('click', function(event) { 243 event.stopPropagation(); 244 }); 245 246 $('.password-strenght-content>.pwd-show').on('click', function() { 247 $(this).toggleClass('active'); 248 if ( $(this).hasClass('active') ) { 249 $(this).closest('.password-strenght-wrapper').find(':input[data-event="password-strenght"]').attr('type', 'text'); 250 } else { 251 if ( $(this).closest('.password-strenght-wrapper').find(':input[data-event="password-strenght"]').attr('data-type') == 'pwd' ) { 252 $(this).closest('.password-strenght-wrapper').find(':input[data-event="password-strenght"]').attr('type', 'pwd'); 253 } else { 254 $(this).closest('.password-strenght-wrapper').find(':input[data-event="password-strenght"]').attr('type', 'password'); 255 } 256 } 257 }); 258 259 $(window).on('scroll', function() { 260 clearTimeout($.data(this, 'scrollTimer')); 261 $.data(this, 'scrollTimer', setTimeout(function() { 262 isInViewport( $('.pwd-info.active>.pwd-info-layer') ); 263 }, 200)); 264 }); 265 266 function isInViewport( item ) { 267 if ( $(item).is(':visible') ) { 268 let elementTop = $(item).siblings('button').offset().top; 269 let elementHeight = $(item).outerHeight() + 10; 270 let viewportTop = $(window).scrollTop(); 271 272 if ( (elementTop-elementHeight) < viewportTop ) { 273 $(item).addClass('position-bottom'); 274 } else { 275 $(item).removeClass('position-bottom'); 276 } 277 } 278 } 279 280 if ( $(':input[data-event="password-strenght"][data-ps-min-value]').length ) { 281 $(':input[data-event="password-strenght"][data-ps-min-value]').each(function( index ) { 282 let thisItem = $(this); 283 284 if ( $(this).closest('form').length ) { 285 if ( $(this).closest('form').find('button[type="submit"]').length ) { 286 submitFormObj = $(this).closest('form'); 287 } else if ( $(this).closest('form').find('button[type="button"][data-button-action="ajax-recaptcha"]').length ) { 288 submitFormObj = $(this).closest('form'); 289 } else if ( $(this).closest('form').find('button[type="button"].saveNewPassword').length ) { 290 submitFormObj = $(this).closest('form'); 291 } 292 293 $(document).on('submit', submitFormObj, function(event) { 294 295 if ( thisItem.attr('data-pwd-level') && thisItem.attr('data-pwd-level') < 3 ) { 296 event.preventDefault(); 297 if ( !thisItem.siblings('.pwd-info').hasClass('active') ) { 298 toggleInfo( thisItem.siblings('.pwd-info') ); 299 } 300 return false;
301 } 302 303 }); 304 305 } 306 307 }); 308 } 309 310 function toggleInfo(thisItem) { 311 if ( thisItem.closest('.pwd-info').hasClass('active') ) { 312 $('.pwd-info.active').removeClass('active'); 313 } else { 314 $('.pwd-info.active').removeClass('active'); 315 thisItem.closest('.pwd-info').addClass('active'); 316 317 isInViewport( thisItem.siblings('.pwd-info-layer') ); 318 } 319 } 320 321} 322 323function validatePasswordStrenght( pwdStrenghtInputObj ) { 324 if ( pwdStrenghtInputObj.length ) { 325 if ( pwdStrenghtInputObj.attr('data-pwd-level') && pwdStrenghtInputObj.attr('data-pwd-level') < 3 ) { 326 if ( !pwdStrenghtInputObj.siblings('.pwd-info').hasClass('active') ) { 327 pwdStrenghtInputObj.siblings('.pwd-info').find('>button').trigger('click'); 328 } 329 return false; 330 } 331 } 332} 333 334$(function() { 335 protectPassword(); 336});
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.