1/*------- Author: Tyler [email protected] -------*/ 2 3//=å¯ç å¼ºåº¦æ£æµ 4var passwordStrength = function(value, key, className){ 5 //æå°æå¤§é¿åº¦ 6 var minLength = 5; 7 var maxLength = 20; 8 9 //å¯ç å¤æåº¦å®ä¹ 10 var lower = /[a-z]/g; 11 var upper = /[A-Z]/g; 12 var numberic = /\d/g; 13 var symbols = /[\W_]/g; 14 var repeat = new RegExp('(.{' + parseInt(value.length / 2) + ',})\1', 'g'); 15 16 //åå§ç¶æ 17 var status = 'poor'; 18 var strength = -1; 19 20 if(!value || value.length < minLength) { 21 strength = -1; 22 } 23 else { 24 strength = parseInt(value.length / minLength) - 1; 25 } 26 if(value.match(repeat)) { 27 strength --; 28 } 29 if(value.match(lower) || value.match(upper)) { 30 strength ++; 31 } 32 if(value.match(numberic)) { 33 strength ++; 34 } 35 if(value.match(symbols)) { 36 strength ++; 37 } 38 if(value.length > minLength && strength < 2) { 39 strength ++; 40 } 41 42 switch(strength) { 43 case -1: 44 case 0: 45 case 1: 46 status = 'poor'; 47 break; 48 case 2: 49 status = 'weak'; 50 break; 51 case 3: 52 status = 'good'; 53 break; 54 default: 55 status = 'strong'; 56 break; 57 } 58 key.className = (className ? className + ' ' : '') + 'password-' + status; 59}; 60passwordStrength.init = function(element, key) { 61 $(element).each(function(index, el){ 62 if(!el) return; 63 if(key) { 64 key = $(el.parentNode).find(key); 65 } 66 else { 67 key = $(el).next(); 68 } 69 if(!key) return; 70 // key.css('visibility', 'visible'); 71 var className = key[0].className; 72 $(el).on('input propertychange', function(e){ 73 if(e.type === 'propertychange' && e.propertyName && e.propertyName.toLowerCase() !== 'value') return; 74 var prev = passwordStrength.prev; 75 var value = this.value; 76 if(prev !== value) { 77 passwordStrength(value, key[0], className); 78 } 79 passwordStrength.prev = value; 80 }); 81 }); 82} 83 84//ç¹å»æ´æ¢éªè¯ç 85function changeVerify(element, hasEvent) { 86 $(element).each(function(index){ 87 var $el = $(this); 88 var url; 89 var img; 90 if(this.tagName === 'IMG') { 91 img = $(this); 92 url = $el.attr('src'); 93 } 94 else { 95 img = $el.siblings('img'); 96 url = $el.attr('href'); 97 } 98 if(hasEvent) $el.on('click', function() { 99 changeCode(img, url); 100 }); 101 else changeCode(img, url); 102 }); 103} 104function changeCode(img, url){ 105 url = url || img.attr('src'); 106 var random = +new Date; 107 var urlrandom = url.match(/\b_=([\d]+)\b/); 108 if(urlrandom) { 109 url = url.replace(urlrandom[1], random); 110 } 111 else { 112 url += (url.indexOf('?') > -1 ? '&' : '?') + '_=' + random; 113 } 114 img.attr('src', url); 115 return false; 116} 117 118//=å ¨é 119function checkAll(el, elements) { 120 $(elements).prop('checked', $(el).prop('checked')); 121} 122 123//= placeholderå ¼å®¹æ§å®ç° 124//页é¢åå§åæ¶å¯¹ææinputååå§å 125//Placeholder.init(); 126//æè åç¬è®¾ç½®æä¸ªå ç´ 127//Placeholder.create($('t1')); 128var Placeholder = { 129 support: (function() { 130 return 'placeholder' in document.createElement('input'); 131 })(), 132 //æç¤ºæåçæ ·å¼ 133 className: 'placeholder', 134 init: function() { 135 if (!this.support) { 136 this.create($('input, textarea')); 137 } 138 }, 139 build: function(input, html) { 140 var parent = input.parent(); 141 var $this = Placeholder; 142 if(parent.css('position') == 'static') { 143 parent.css('position', 'relative'); 144 } 145 var placeholder = input.prev('.' + this.className) || $('<span>', { 146 'class': this.className, 147 html: html, 148 style: 'visibility:hidden;' 149 }).before(input) 150 .locate({target: input, from:'lc', to:'lc', offset:{x:4}, offsetParent:true}) 151 .on('click', function(e){ 152 $this.hide(this); 153 input.focus(); 154 }); 155 return placeholder; 156 }, 157 create: function(inputs) { 158 var $this = this; 159 $(inputs).each(function(index){ 160 var el = $(this); 161 if (!$this.support && el.attr('placeholder')) { 162 var value = el.attr('placeholder'); 163 el.data('placeholder', $this.build(el, value)); 164 165 $this.show(el); 166 167 el.on('focusin', function(e) { 168 $this.hide(this); 169 }).on('focusout', function(e) { 170 $this.show(this); 171 }); 172 } 173 }); 174 }, 175 show: function(el) { 176 if(!this.support && el.value === '' && $(el).is(':visible') && $(el).css('visibility') !== 'hidden') { 177 $(el).data('placeholder').css('visibility', 'visible'); 178 } 179 }, 180 hide: function(el) { 181 if(!this.support) ($(el).data('placeholder') || $(el)).css('visibility', 'hidden'); 182 } 183}; 184 185$(function(){ 186 var forms = document.forms; 187 if(forms.length) { 188 189 //= èªå¨æ£æµå¯ç 强度 190 passwordStrength.init($('form .auto-password-check-handle'), '.password-check'); 191 192 //= èªå¨ç»å®æ´æ¢éªè¯ç 193 changeVerify($('form .auto-change-verify-handle'), true); 194 195 //= è®°ä½å¸å· 196 $('form .action-remember-account').on('change', function(e){ 197 if(this.checked) { 198 $.cookie('S[SIGN][REMEMBER]', '1', 365); 199 } 200 else { 201 $.cookie('S[SIGN][REMEMBER]', '0', 365); 202 } 203 }).trigger('change'); 204 205 //æ£æµå¸å·éå¤ 206 $('form [data-remote]').on('change', function(e) { 207 var element = $(this); 208 var value = this.value; 209 var name = this.name; 210 var url = $(this).data('remote'); 211 var method = element.data('remoteType') || element.parents('form').attr('method'); 212 var callback = element.data('remoteCallback'); 213 if(url && name && value) { 214 $[method](url, name + '=' + value, function(rs) { 215 if(typeof rs === 'string') { 216 rs = JSON.parse(rs); 217 } 218 if(callback) return callback.call(element, rs); 219 var tips = new Tips({target: element.closest('.form-row')}); 220 if(rs.error) { 221 return tips.error(rs.message); 222 } 223 else if(rs.success) { 224 return tips.success(rs.message); 225 } 226 }) 227 } 228 }); 229 } 230 231 //å¤ç type=number æ ¼å¼å®¹é 232 233 234 //å¤çinput placeholderå ¼å®¹ 235 Placeholder.init(); 236});
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.