PageSourceSearch

https://evening-mashup.com/wp-content/plugins/paid-memberships-pro/js/jquery.creditCardValidator.js?ver=5.0.29

js evening-mashup.com collected 2026-09-25 05:19:02 UTC 5,094 bytes, 181 lines download raw bytes

1// Generated by CoffeeScript 1.4.0
2
3/*
4jQuery Credit Card Validator
5
6Copyright 2012 Pawel Decowski
7
8This work is licensed under the Creative Commons Attribution-ShareAlike 3.0
9Unported License. To view a copy of this license, visit:
10
11http://creativecommons.org/licenses/by-sa/3.0/
12
13or send a letter to:
14
15Creative Commons, 444 Castro Street, Suite 900,
16Mountain View, California, 94041, USA.
17*/
18
19
20(function() {
21  var $,
22    __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
23
24  $ = jQuery;
25
26  $.fn.validateCreditCard = function(callback, options) {
27    var card, card_type, card_types, get_card_type, is_valid_length, is_valid_luhn, normalize, validate, validate_number, _i, _len, _ref, _ref1;
28    card_types = [
29      {
30        name: 'amex',
31        pattern: /^3[47]/,
32        valid_length: [15]
33      }, {
34        name: 'diners_club_carte_blanche',
35        pattern: /^30[0-5]/,
36        valid_length: [14]
37      }, {
38        name: 'diners_club_international',
39        pattern: /^36/,
40        valid_length: [14]
41      }, {
42        name: 'jcb',
43        pattern: /^35(2[89]|[3-8][0-9])/,
44        valid_length: [16]
45      }, {
46        name: 'laser',
47        pattern: /^(6304|670[69]|6771)/,
48        valid_length: [16, 17, 18, 19]
49      }, {
50        name: 'visa_electron',
51        pattern: /^(4026|417500|4508|4844|491(3|7))/,
52        valid_length: [16]
53      }, {
54        name: 'visa',
55        pattern: /^4/,
56        valid_length: [16]
57      }, {
58        name: 'mastercard',
59        pattern: /^5[1-5]/,
60        valid_length: [16]
61      }, {
62        name: 'maestro',
63        pattern: /^(5018|5020|5038|6304|6759|676[1-3])/,
64        valid_length: [12, 13, 14, 15, 16, 17, 18, 19]
65      }, {
66        name: 'discover',
67        pattern: /^(6011|622(12[6-9]|1[3-9][0-9]|[2-8][0-9]{2}|9[0-1][0-9]|92[0-5]|64[4-9])|65)/,
68        valid_length: [16]
69      }
70    ];
71    if (options == null) {
72      options = {};
73    }
74    if ((_ref = options.accept) == null) {
75      options.accept = (function() {
76        var _i, _len, _results;
77        _results = [];
78        for (_i = 0, _len = card_types.length; _i < _len; _i++) {
79          card = card_types[_i];
80          _results.push(card.name);
81        }
82        return _results;
83      })();
84    }
85    _ref1 = options.accept;
86    for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
87      card_type = _ref1[_i];
88      if (__indexOf.call((function() {
89        var _j, _len1, _results;
90        _results = [];
91        for (_j = 0, _len1 = card_types.length; _j < _len1; _j++) {
92          card = card_types[_j];
93          _results.push(card.name);
94        }
95        return _results;
96      })(), card_type) < 0) {
97        throw "Credit card type '" + card_type + "' is not supported";
98      }
99    }
100    get_card_type = function(number) {
101      var _j, _len1, _ref2;
102      _ref2 = (function() {
103        var _k, _len1, _ref2, _results;
104        _results = [];
105        for (_k = 0, _len1 = card_types.length; _k < _len1; _k++) {
106          card = card_types[_k];
107          if (_ref2 = card.name, __indexOf.call(options.accept, _ref2) >= 0) {
108            _results.push(card);
109          }
110        }
111        return _results;
112      })();
113      for (_j = 0, _len1 = _ref2.length; _j < _len1; _j++) {
114        card_type = _ref2[_j];
115        if (number.match(card_type.pattern)) {
116          return card_type;
117        }
118      }
119      return null;
120    };
121    is_valid_luhn = function(number) {
122      var digit, n, sum, _j, _len1, _ref2;
123      sum = 0;
124      _ref2 = number.split('').reverse();
125      for (n = _j = 0, _len1 = _ref2.length; _j < _len1; n = ++_j) {
126        digit = _ref2[n];
127        digit = +digit;
128        if (n % 2) {
129          digit *= 2;
130          if (digit < 10) {
131            sum += digit;
132          } else {
133            sum += digit - 9;
134          }
135        } else {
136          sum += digit;
137        }
138      }
139      return sum % 10 === 0;
140    };
141    is_valid_length = function(number, card_type) {
142      var _ref2;
143      return _ref2 = number.length, __indexOf.call(card_type.valid_length, _ref2) >= 0;
144    };
145    validate_number = function(number) {
146      var length_valid, luhn_valid;
147      card_type = get_card_type(number);
148      luhn_valid = false;
149      length_valid = false;
150      if (card_type != null) {
151        luhn_valid = is_valid_luhn(number);
152        length_valid = is_valid_length(number, card_type);
153      }
154      return callback({
155        card_type: card_type,
156        luhn_valid: luhn_valid,
157        length_valid: length_valid
158      });
159    };
160    validate = function() {
161      var number;
162      number = normalize($(this).val());
163      return validate_number(number);
164    };
165    normalize = function(number) {
166      return number.replace(/[ -]/g, '');
167    };
168    this.bind('input', function() {
169      $(this).unbind('keyup');
170      return validate.call(this);
171    });
172    this.bind('keyup', function() {
173      return validate.call(this);
174    });
175    if (this.length !== 0) {
176      validate.call(this);
177    }
178    return this;
179  };
180
181}).call(this);

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.