PageSourceSearch

https://perfect-home.mx/wp-content/plugins/openpay-cards/assets/js/jquery.payment.js?ver=6.9.1

js perfect-home.mx collected 2026-10-09 21:58:57 UTC 15,687 bytes, 595 lines download raw bytes

1jQuery( function( $ ) {
2
3// Generated by CoffeeScript 1.7.1
4(function() {
5  var cardFromNumber, cardFromType, cards, defaultFormat, formatBackCardNumber, formatBackExpiry, formatCardNumber, formatExpiry, formatForwardExpiry, formatForwardSlashAndSpace, hasTextSelected, luhnCheck, reFormatCVC, reFormatCardNumber, reFormatExpiry, reFormatNumeric, restrictCVC, restrictCardNumber, restrictExpiry, restrictNumeric, setCardType,
6    __slice = [].slice,
7    __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; };
8
9  $.payment = {};
10
11  $.payment.fn = {};
12
13  $.fn.payment = function() {
14    var args, method;
15    method = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
16    return $.payment.fn[method].apply(this, args);
17  };
18
19  defaultFormat = /(\d{1,4})/g;
20
21  $.payment.cards = cards = [
22    {
23      type: 'visaelectron',
24      pattern: /^4(026|17500|405|508|844|91[37])/,
25      format: defaultFormat,
26      length: [16],
27      cvcLength: [3],
28      luhn: true
29    }, {
30      type: 'maestro',
31      pattern: /^(5(018|0[23]|[68])|6(39|7))/,
32      format: defaultFormat,
33      length: [12, 13, 14, 15, 16, 17, 18, 19],
34      cvcLength: [3],
35      luhn: true
36    }, {
37      type: 'forbrugsforeningen',
38      pattern: /^600/,
39      format: defaultFormat,
40      length: [16],
41      cvcLength: [3],
42      luhn: true
43    }, {
44      type: 'dankort',
45      pattern: /^5019/,
46      format: defaultFormat,
47      length: [16],
48      cvcLength: [3],
49      luhn: true
50    }, {
51      type: 'visa',
52      pattern: /^4/,
53      format: defaultFormat,
54      length: [13, 16],
55      cvcLength: [3],
56      luhn: true
57    }, {
58      type: 'mastercard',
59      pattern: /^(5[0-5]|2[2-7])/,
60      format: defaultFormat,
61      length: [16],
62      cvcLength: [3],
63      luhn: true
64    }, {
65      type: 'amex',
66      pattern: /^3[47]/,
67      format: /(\d{1,4})(\d{1,6})?(\d{1,5})?/,
68      length: [15],
69      cvcLength: [3, 4],
70      luhn: true
71    }, {
72      type: 'dinersclub',
73      pattern: /^3[0689]/,
74      format: /(\d{1,4})(\d{1,6})?(\d{1,4})?/,
75      length: [14],
76      cvcLength: [3],
77      luhn: true
78    }, {
79      type: 'discover',
80      pattern: /^6([045]|22)/,
81      format: defaultFormat,
82      length: [16],
83      cvcLength: [3],
84      luhn: true
85    }, {
86      type: 'unionpay',
87      pattern: /^(62|88)/,
88      format: defaultFormat,
89      length: [16, 17, 18, 19],
90      cvcLength: [3],
91      luhn: false
92    }, {
93      type: 'jcb',
94      pattern: /^35/,
95      format: defaultFormat,
96      length: [16],
97      cvcLength: [3],
98      luhn: true
99    }
100  ];
101
102  cardFromNumber = function(num) {
103    var card, _i, _len;
104    num = (num + '').replace(/\D/g, '');
105    for (_i = 0, _len = cards.length; _i < _len; _i++) {
106      card = cards[_i];
107      if (card.pattern.test(num)) {
108        return card;
109      }
110    }
111  };
112
113  cardFromType = function(type) {
114    var card, _i, _len;
115    for (_i = 0, _len = cards.length; _i < _len; _i++) {
116      card = cards[_i];
117      if (card.type === type) {
118        return card;
119      }
120    }
121  };
122
123  luhnCheck = function(num) {
124    var digit, digits, odd, sum, _i, _len;
125    odd = true;
126    sum = 0;
127    digits = (num + '').split('').reverse();
128    for (_i = 0, _len = digits.length; _i < _len; _i++) {
129      digit = digits[_i];
130      digit = parseInt(digit, 10);
131      if ((odd = !odd)) {
132        digit *= 2;
133      }
134      if (digit > 9) {
135        digit -= 9;
136      }
137      sum += digit;
138    }
139    return sum % 10 === 0;
140  };
141
142  hasTextSelected = function($target) {
143    var _ref;
144    if (($target.prop('selectionStart') != null) && $target.prop('selectionStart') !== $target.prop('selectionEnd')) {
145      return true;
146    }
147    if ((typeof document !== "undefined" && document !== null ? (_ref = document.selection) != null ? _ref.createRange : void 0 : void 0) != null) {
148      if (document.selection.createRange().text) {
149        return true;
150      }
151    }
152    return false;
153  };
154
155  reFormatNumeric = function(e) {
156    return setTimeout(function() {
157      var $target, value;
158      $target = $(e.currentTarget);
159      value = $target.val();
160      value = value.replace(/\D/g, '');
161      return $target.val(value);
162    });
163  };
164
165  reFormatCardNumber = function(e) {
166    return setTimeout(function() {
167      var $target, value;
168      $target = $(e.currentTarget);
169      value = $target.val();
170      value = $.payment.formatCardNumber(value);
171      return $target.val(value);
172    });
173  };
174
175  formatCardNumber = function(e) {
176    var $target, card, digit, length, re, upperLength, value;
177    digit = String.fromCharCode(e.which);
178    if (!/^\d+$/.test(digit)) {
179      return;
180    }
181    $target = $(e.currentTarget);
182    value = $target.val();
183    card = cardFromNumber(value + digit);
184    length = (value.replace(/\D/g, '') + digit).length;
185    upperLength = 16;
186    if (card) {
187      upperLength = card.length[card.length.length - 1];
188    }
189    if (length >= upperLength) {
190      return;
191    }
192    if (($target.prop('selectionStart') != null) && $target.prop('selectionStart') !== value.length) {
193      return;
194    }
195    if (card && card.type === 'amex') {
196      re = /^(\d{4}|\d{4}\s\d{6})$/;
197    } else {
198      re = /(?:^|\s)(\d{4})$/;
199    }
200    if (re.test(value)) {
201      e.preventDefault();
202      return setTimeout(function() {
203        return $target.val(value + ' ' + digit);
204      });
205    } else if (re.test(value + digit)) {
206      e.preventDefault();
207      return setTimeout(function() {
208        return $target.val(value + digit + ' ');
209      });
210    }
211  };
212
213  formatBackCardNumber = function(e) {
214    var $target, value;
215    $target = $(e.currentTarget);
216    value = $target.val();
217    if (e.which !== 8) {
218      return;
219    }
220    if (($target.prop('selectionStart') != null) && $target.prop('selectionStart') !== value.length) {
221      return;
222    }
223    if (/\d\s$/.test(value)) {
224      e.preventDefault();
225      return setTimeout(function() {
226        return $target.val(value.replace(/\d\s$/, ''));
227      });
228    } else if (/\s\d?$/.test(value)) {
229      e.preventDefault();
230      return setTimeout(function() {
231        return $target.val(value.replace(/\d$/, ''));
232      });
233    }
234  };
235
236  reFormatExpiry = function(e) {
237    return setTimeout(function() {
238      var $target, value;
239      $target = $(e.currentTarget);
240      value = $target.val();
241      value = $.payment.formatExpiry(value);
242      return $target.val(value);
243    });
244  };
245
246  formatExpiry = function(e) {
247    var $target, digit, val;
248    digit = String.fromCharCode(e.which);
249    if (!/^\d+$/.test(digit)) {
250      return;
251    }
252    $target = $(e.currentTarget);
253    val = $target.val() + digit;
254    if (/^\d$/.test(val) && (val !== '0' && val !== '1')) {
255      e.preventDefault();
256      return setTimeout(function() {
257        return $target.val("0" + val + " / ");
258      });
259    } else if (/^\d\d$/.test(val)) {
260      e.preventDefault();
261      return setTimeout(function() {
262        return $target.val("" + val + " / ");
263      });
264    }
265  };
266
267  formatForwardExpiry = function(e) {
268    var $target, digit, val;
269    digit = String.fromCharCode(e.which);
270    if (!/^\d+$/.test(digit)) {
271      return;
272    }
273    $target = $(e.currentTarget);
274    val = $target.val();
275    if (/^\d\d$/.test(val)) {
276      return $target.val("" + val + " / ");
277    }
278  };
279
280  formatForwardSlashAndSpace = function(e) {
281    var $target, val, which;
282    which = String.fromCharCode(e.which);
283    if (!(which === '/' || which === ' ')) {
284      return;
285    }
286    $target = $(e.currentTarget);
287    val = $target.val();
288    if (/^\d$/.test(val) && val !== '0') {
289      return $target.val("0" + val + " / ");
290    }
291  };
292
293  formatBackExpiry = function(e) {
294    var $target, value;
295    $target = $(e.currentTarget);
296    value = $target.val();
297    if (e.which !== 8) {
298      return;
299    }
300    if (($target.prop('selectionStart') != null) && $target.prop('selectionStart') !== value.length) {
301      return;
302    }
303    if (/\d\s\/\s$/.test(value)) {
304      e.preventDefault();
305      return setTimeout(function() {
306        return $target.val(value.replace(/\d\s\/\s$/, ''));
307      });
308    }
309  };
310
311  reFormatCVC = function(e) {
312    return setTimeout(function() {
313      var $target, value;
314      $target = $(e.currentTarget);
315      value = $target.val();
316      value = value.replace(/\D/g, '').slice(0, 4);
317      return $target.val(value);
318    });
319  };
320
321  restrictNumeric = function(e) {
322    var input;
323    if (e.metaKey || e.ctrlKey) {
324      return true;
325    }
326    if (e.which === 32) {
327      return false;
328    }
329    if (e.which === 0) {
330      return true;
331    }
332    if (e.which < 33) {
333      return true;
334    }
335    input = String.fromCharCode(e.which);
336    return !!/[\d\s]/.test(input);
337  };
338
339  restrictCardNumber = function(e) {
340    var $target, card, digit, value;
341    $target = $(e.currentTarget);
342    digit = String.fromCharCode(e.which);
343    if (!/^\d+$/.test(digit)) {
344      return;
345    }
346    if (hasTextSelected($target)) {
347      return;
348    }
349    value = ($target.val() + digit).replace(/\D/g, '');
350    card = cardFromNumber(value);
351    if (card) {
352      return value.length <= card.length[card.length.length - 1];
353    } else {
354      return value.length <= 16;
355    }
356  };
357
358  restrictExpiry = function(e) {
359    var $target, digit, value;
360    $target = $(e.currentTarget);
361    digit = String.fromCharCode(e.which);
362    if (!/^\d+$/.test(digit)) {
363      return;
364    }
365    if (hasTextSelected($target)) {
366      return;
367    }
368    value = $target.val() + digit;
369    value = value.replace(/\D/g, '');
370    if (value.length > 6) {
371      return false;
372    }
373  };
374
375  restrictCVC = function(e) {
376    var $target, digit, val;
377    $target = $(e.currentTarget);
378    digit = String.fromCharCode(e.which);
379    if (!/^\d+$/.test(digit)) {
380      return;
381    }
382    if (hasTextSelected($target)) {
383      return;
384    }
385    val = $target.val() + digit;
386    return val.length <= 4;
387  };
388
389  setCardType = function(e) {
390    var $target, allTypes, card, cardType, val;
391    $target = $(e.currentTarget);
392    val = $target.val();
393    cardType = $.payment.cardType(val) || 'unknown';
394    if (!$target.hasClass(cardType)) {
395      allTypes = (function() {
396        var _i, _len, _results;
397        _results = [];
398        for (_i = 0, _len = cards.length; _i < _len; _i++) {
399          card = cards[_i];
400          _results.push(card.type);
401        }
402        return _results;
403      })();
404      $target.removeClass('unknown');
405      $target.removeClass(allTypes.join(' '));
406      $target.addClass(cardType);
407      $target.toggleClass('identified', cardType !== 'unknown');
408      return $target.trigger('payment.cardType', cardType);
409    }
410  };
411
412  $.payment.fn.formatCardCVC = function() {
413    this.on('keypress', restrictNumeric);
414    this.on('keypress', restrictCVC);
415    this.on('paste', reFormatCVC);
416    this.on('change', reFormatCVC);
417    this.on('input', reFormatCVC);
418    return this;
419  };
420
421  $.payment.fn.formatCardExpiry = function() {
422    this.on('keypress', restrictNumeric);
423    this.on('keypress', restrictExpiry);
424    this.on('keypress', formatExpiry);
425    this.on('keypress', formatForwardSlashAndSpace);
426    this.on('keypress', formatForwardExpiry);
427    this.on('keydown', formatBackExpiry);
428    this.on('change', reFormatExpiry);
429    this.on('input', reFormatExpiry);
430    return this;
431  };
432
433  $.payment.fn.formatCardNumber = function() {
434    this.on('keypress', restrictNumeric);
435    this.on('keypress', restrictCardNumber);
436    this.on('keypress', formatCardNumber);
437    this.on('keydown', formatBackCardNumber);
438    this.on('keyup', setCardType);
439    this.on('paste', reFormatCardNumber);
440    this.on('change', reFormatCardNumber);
441    this.on('input', reFormatCardNumber);
442    this.on('input', setCardType);
443    return this;
444  };
445
446  $.payment.fn.restrictNumeric = function() {
447    this.on('keypress', restrictNumeric);
448    this.on('paste', reFormatNumeric);
449    this.on('change', reFormatNumeric);
450    this.on('input', reFormatNumeric);
451    return this;
452  };
453
454  $.payment.fn.cardExpiryVal = function() {
455    return $.payment.cardExpiryVal($(this).val());
456  };
457
458  $.payment.cardExpiryVal = function(value) {
459    var month, prefix, year, _ref;
460    value = value.replace(/\s/g, '');
461    _ref = value.split('/', 2), month = _ref[0], year = _ref[1];
462    if ((year != null ? year.length : void 0) === 2 && /^\d+$/.test(year)) {
463      prefix = (new Date).getFullYear();
464      prefix = prefix.toString().slice(0, 2);
465      year = prefix + year;
466    }
467    month = parseInt(month, 10);
468    year = parseInt(year, 10);
469    return {
470      month: month,
471      year: year
472    };
473  };
474
475  $.payment.validateCardNumber = function(num) {
476    var card, _ref;
477    num = (num + '').replace(/\s+|-/g, '');
478    if (!/^\d+$/.test(num)) {
479      return false;
480    }
481    card = cardFromNumber(num);
482    if (!card) {
483      return false;
484    }
485    return (_ref = num.length, __indexOf.call(card.length, _ref) >= 0) && (card.luhn === false || luhnCheck(num));
486  };
487
488  $.payment.validateCardExpiry = function(month, year) {
489    var currentTime, expiry, _ref;
490    if (typeof month === 'object' && 'month' in month) {
491      _ref = month, month = _ref.month, year = _ref.year;
492    }
493    if (!(month && year)) {
494      return false;
495    }
496    month = $.trim(month);
497    year = $.trim(year);
498    if (!/^\d+$/.test(month)) {
499      return false;
500    }
501    if (!/^\d+$/.test(year)) {
502      return false;
503    }
504    if (!((1 <= month && month <= 12))) {
505      return false;
506    }
507    if (year.length === 2) {
508      if (year < 70) {
509        year = "20" + year;
510      } else {
511        year = "19" + year;
512      }
513    }
514    if (year.length !== 4) {
515      return false;
516    }
517    expiry = new Date(year, month);
518    currentTime = new Date;
519    expiry.setMonth(expiry.getMonth() - 1);
520    expiry.setMonth(expiry.getMonth() + 1, 1);
521    return expiry > currentTime;
522  };
523
524  $.payment.validateCardCVC = function(cvc, type) {
525    var card, _ref;
526    cvc = $.trim(cvc);
527    if (!/^\d+$/.test(cvc)) {
528      return false;
529    }
530    card = cardFromType(type);
531    if (card != null) {
532      return _ref = cvc.length, __indexOf.call(card.cvcLength, _ref) >= 0;
533    } else {
534      return cvc.length >= 3 && cvc.length <= 4;
535    }
536  };
537
538  $.payment.cardType = function(num) {
539    var _ref;
540    if (!num) {
541      return null;
542    }
543    return ((_ref = cardFromNumber(num)) != null ? _ref.type : void 0) || null;
544  };
545
546  $.payment.formatCardNumber = function(num) {
547    var card, groups, upperLength, _ref;
548    num = num.replace(/\D/g, '');
549    card = cardFromNumber(num);
550    if (!card) {
551      return num;
552    }
553    upperLength = card.length[card.length.length - 1];
554    num = num.slice(0, upperLength);
555    if (card.format.global) {
556      return (_ref = num.match(card.format)) != null ? _ref.join(' ') : void 0;
557    } else {
558      groups = card.format.exec(num);
559      if (groups == null) {
560        return;
561      }
562      groups.shift();
563      groups = $.grep(groups, function(n) {
564        return n;
565      });
566      return groups.join(' ');
567    }
568  };
569
570  $.payment.formatExpiry = function(expiry) {
571    var mon, parts, sep, year;
572    parts = expiry.match(/^\D*(\d{1,2})(\D+)?(\d{1,2})?/);
573    if (!parts) {
574      return '';
575    }
576    mon = parts[1] || '';
577    sep = parts[2] || '';
578    year = parts[3] || '';
579    if (year.length > 0) {
580      sep = ' / ';
581    } else if (sep === ' /') {
582      mon = mon.substring(0, 1);
583      sep = '';
584    } else if (mon.length === 2 || sep.length > 0) {
585      sep = ' / ';
586    } else if (mon.length === 1 && (mon !== '0' && mon !== '1')) {
587      mon = "0" + mon;
588      sep = ' / ';
589    }
590    return mon + sep + year;
591  };
592
593}).call(this);
594
595});

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.