PageSourceSearch

https://sistema.gigarede.com/central_assinante_web/assets/lib/strength/js/strength.js

js gigarede.com collected 2026-09-24 14:13:50 UTC 5,791 bytes, 158 lines download raw bytes

1/*!
2 * strength.controller
3 * Original author: @aaronlumsden
4 * Further changes, comments: @aaronlumsden
5 * Licensed under the MIT license
6 */
7;(function ( $, window, document, undefined ) {
8
9    var pluginName = "strength",
10        defaults = {
11            strengthClass: 'strength',
12            strengthMeterClass: 'strength_meter',
13            strengthButtonClass: 'button_strength',
14            strengthButtonText: 'Show Password',
15            strengthButtonTextToggle: 'Hide Password'
16        };
17
18       // $('<style>body { background-color: red; color: white; }</style>').appendTo('head');
19
20    function Plugin( element, options ) {
21        this.element = element;
22        this.$elem = $(this.element);
23        this.options = $.extend( {}, defaults, options );
24        this._defaults = defaults;
25        this._name = pluginName;
26        this.init();
27    }
28
29    Plugin.prototype = {
30
31        init: function() {
32
33
34            var characters = 0;
35            var capitalletters = 0;
36            var loweletters = 0;
37            var number = 0;
38            var special = 0;
39
40            var upperCase= new RegExp('[A-Z]');
41            var lowerCase= new RegExp('[a-z]');
42            var numbers = new RegExp('[0-9]');
43            var specialchars = new RegExp('([!,%,&,@,#,$,^,*,?,_,~])');
44
45            function GetPercentage(a, b) {
46                    return ((b / a) * 100);
47                }
48
49                function check_strength(thisval,thisid){
50                     if (thisval.length > 8) { characters = 1; } else { characters = 0; };
51                    if (thisval.match(upperCase)) { capitalletters = 1} else { capitalletters = 0; };
52                    if (thisval.match(lowerCase)) { loweletters = 1}  else { loweletters = 0; };
53                    if (thisval.match(numbers)) { number = 1}  else { number = 0; };
54
55                    var total = characters + capitalletters + loweletters + number + special;
56                    var totalpercent = GetPercentage(7, total).toFixed(0);
57
58                  
59
60                    get_total(total,thisid);
61                }
62
63            function get_total(total,thisid){
64
65                  var thismeter = $('div[data-meter="'+thisid+'"]');
66                if(total == 0){
67                      thismeter.removeClass().html('');
68                }else if (total <= 1) {
69                   thismeter.removeClass();
70                   thismeter.addClass('veryweak').html('<p>Muito Fraca</p>');
71                } else if (total == 2){
72                    thismeter.removeClass();
73                   thismeter.addClass('weak').html('<p>Fraca</p>');
74                } else if(total == 3){
75                    thismeter.removeClass();
76                   thismeter.addClass('medium').html('<p>Média</p>');
77
78                } else {
79                     thismeter.removeClass();
80                   thismeter.addClass('strong').html('<p>Forte</p>');
81                }
82            }
83
84            var isShown = false;
85            var strengthButtonText = this.options.strengthButtonText;
86            var strengthButtonTextToggle = this.options.strengthButtonTextToggle;
87
88
89            thisid = this.$elem.attr('id');
90
91            this.$elem.addClass(this.options.strengthClass).attr('data-password',thisid).after('<input style="display:none" class="'+this.options.strengthClass+'" data-password="'+thisid+'" type="text" name="" value=""><a data-password-button="'+thisid+'" href="" class="'+this.options.strengthButtonClass+'">'+this.options.strengthButtonText+'</a><div class="'+this.options.strengthMeterClass+'"><div data-meter="'+thisid+'"><p></p></div></div>');
92             
93            this.$elem.bind('keyup keydown', function(event) {
94                thisval = $('#'+thisid).val();
95                $('input[type="text"][data-password="'+thisid+'"]').val(thisval);
96                check_strength(thisval,thisid);
97                
98            });
99
100             $('input[type="text"][data-password="'+thisid+'"]').bind('keyup keydown', function(event) {
101                thisval = $('input[type="text"][data-password="'+thisid+'"]').val();
102                console.log(thisval);
103                $('input[type="password"][data-password="'+thisid+'"]').val(thisval);
104                check_strength(thisval,thisid);
105                
106            });
107
108
109
110            $(document.body).on('click', '.'+this.options.strengthButtonClass, function(e) {
111                e.preventDefault();
112
113               thisclass = 'hide_'+$(this).attr('class');
114
115
116
117
118                if (isShown) {
119                    $('input[type="text"][data-password="'+thisid+'"]').hide();
120                    $('input[type="password"][data-password="'+thisid+'"]').show().focus();
121                    $('a[data-password-button="'+thisid+'"]').removeClass(thisclass).html(strengthButtonText);
122                    isShown = false;
123
124                } else {
125                    $('input[type="text"][data-password="'+thisid+'"]').show().focus();
126                    $('input[type="password"][data-password="'+thisid+'"]').hide();
127                    $('a[data-password-button="'+thisid+'"]').addClass(thisclass).html(strengthButtonTextToggle);
128                    isShown = true;
129   
130                }
131
132
133               
134            });
135
136
137         
138            
139        },
140
141        yourOtherFunction: function(el, options) {
142            // some logic
143        }
144    };
145
146    // A really lightweight plugin wrapper around the constructor,
147    // preventing against multiple instantiations
148    $.fn[pluginName] = function ( options ) {
149        return this.each(function () {
150            if (!$.data(this, "plugin_" + pluginName)) {
151                $.data(this, "plugin_" + pluginName, new Plugin( this, options ));
152            }
153        });
154    };
155
156})( jQuery, window, document );
157
158

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.