PageSourceSearch

https://www.businessqualifications.com/wp-content/plugins/woocomme…/jquery.payment.js?ver=3.0.0-wc.6.3.2

js businessqualifications.com collected 2026-10-08 04:31:25 UTC 17,720 bytes, 656 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, replaceFullWidthChars, restrictCVC, restrictCardNumber, restrictExpiry, restrictNumeric, safeVal, 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  $ = window.jQuery || window.Zepto || window.$;
10
11  $.payment = {};
12
13  $.payment.fn = {};
14
15  $.fn.payment = function() {
16    var args, method;
17    method = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
18    return $.payment.fn[method].apply(this, args);
19  };
20
21  defaultFormat = /(\d{1,4})/g;
22
23  $.payment.cards = cards = [
24    {
25      type: 'maestro',
26      patterns: [5018, 502, 503, 506, 56, 58, 639, 6220, 67],
27      format: defaultFormat,
28      length: [12, 13, 14, 15, 16, 17, 18, 19],
29      cvcLength: [3],
30      luhn: true
31    }, {
32      type: 'forbrugsforeningen',
33      patterns: [600],
34      format: defaultFormat,
35      length: [16],
36      cvcLength: [3],
37      luhn: true
38    }, {
39      type: 'dankort',
40      patterns: [5019],
41      format: defaultFormat,
42      length: [16],
43      cvcLength: [3],
44      luhn: true
45    }, {
46      type: 'visa',
47      patterns: [4],
48      format: defaultFormat,
49      length: [13, 16],
50      cvcLength: [3],
51      luhn: true
52    }, {
53      type: 'mastercard',
54      patterns: [51, 52, 53, 54, 55, 22, 23, 24, 25, 26, 27],
55      format: defaultFormat,
56      length: [16],
57      cvcLength: [3],
58      luhn: true
59    }, {
60      type: 'amex',
61      patterns: [34, 37],
62      format: /(\d{1,4})(\d{1,6})?(\d{1,5})?/,
63      length: [15],
64      cvcLength: [3, 4],
65      luhn: true
66    }, {
67      type: 'dinersclub',
68      patterns: [30, 36, 38, 39],
69      format: /(\d{1,4})(\d{1,6})?(\d{1,4})?/,
70      length: [14],
71      cvcLength: [3],
72      luhn: true
73    }, {
74      type: 'discover',
75      patterns: [60, 64, 65, 622],
76      format: defaultFormat,
77      length: [16],
78      cvcLength: [3],
79      luhn: true
80    }, {
81      type: 'unionpay',
82      patterns: [62, 88],
83      format: defaultFormat,
84      length: [16, 17, 18, 19],
85      cvcLength: [3],
86      luhn: false
87    }, {
88      type: 'jcb',
89      patterns: [35],
90      format: defaultFormat,
91      length: [16],
92      cvcLength: [3],
93      luhn: true
94    }
95  ];
96
97  cardFromNumber = function(num) {
98    var card, p, pattern, _i, _j, _len, _len1, _ref;
99    num = (num + '').replace(/\D/g, '');
100    for (_i = 0, _len = cards.length; _i < _len; _i++) {
101      card = cards[_i];
102      _ref = card.patterns;
103      for (_j = 0, _len1 = _ref.length; _j < _len1; _j++) {
104        pattern = _ref[_j];
105        p = pattern + '';
106        if (num.substr(0, p.length) === p) {
107          return card;
108        }
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  safeVal = function(value, $target) {
156    var currPair, cursor, digit, error, last, prevPair;
157    try {
158      cursor = $target.prop('selectionStart');
159    } catch (_error) {
160      error = _error;
161      cursor = null;
162    }
163    last = $target.val();
164    $target.val(value);
165    if (cursor !== null && $target.is(":focus")) {
166      if (cursor === last.length) {
167        cursor = value.length;
168      }
169      if (last !== value) {
170        prevPair = last.slice(cursor - 1, +cursor + 1 || 9e9);
171        currPair = value.slice(cursor - 1, +cursor + 1 || 9e9);
172        digit = value[cursor];
173        if (/\d/.test(digit) && prevPair === ("" + digit + " ") && currPair === (" " + digit)) {
174          cursor = cursor + 1;
175        }
176      }
177      $target.prop('selectionStart', cursor);
178      return $target.prop('selectionEnd', cursor);
179    }
180  };
181
182  replaceFullWidthChars = function(str) {
183    var chars, chr, fullWidth, halfWidth, idx, value, _i, _len;
184    if (str == null) {
185      str = '';
186    }
187    fullWidth = '\uff10\uff11\uff12\uff13\uff14\uff15\uff16\uff17\uff18\uff19';
188    halfWidth = '0123456789';
189    value = '';
190    chars = str.split('');
191    for (_i = 0, _len = chars.length; _i < _len; _i++) {
192      chr = chars[_i];
193      idx = fullWidth.indexOf(chr);
194      if (idx > -1) {
195        chr = halfWidth[idx];
196      }
197      value += chr;
198    }
199    return value;
200  };
201
202  reFormatNumeric = function(e) {
203    var $target;
204    $target = $(e.currentTarget);
205    return setTimeout(function() {
206      var value;
207      value = $target.val();
208      value = replaceFullWidthChars(value);
209      value = value.replace(/\D/g, '');
210      return safeVal(value, $target);
211    });
212  };
213
214  reFormatCardNumber = function(e) {
215    var $target;
216    $target = $(e.currentTarget);
217    return setTimeout(function() {
218      var value;
219      value = $target.val();
220      value = replaceFullWidthChars(value);
221      value = $.payment.formatCardNumber(value);
222      return safeVal(value, $target);
223    });
224  };
225
226  formatCardNumber = function(e) {
227    var $target, card, digit, length, re, upperLength, value;
228    digit = String.fromCharCode(e.which);
229    if (!/^\d+$/.test(digit)) {
230      return;
231    }
232    $target = $(e.currentTarget);
233    value = $target.val();
234    card = cardFromNumber(value + digit);
235    length = (value.replace(/\D/g, '') + digit).length;
236    upperLength = 16;
237    if (card) {
238      upperLength = card.length[card.length.length - 1];
239    }
240    if (length >= upperLength) {
241      return;
242    }
243    if (($target.prop('selectionStart') != null) && $target.prop('selectionStart') !== value.length) {
244      return;
245    }
246    if (card && card.type === 'amex') {
247      re = /^(\d{4}|\d{4}\s\d{6})$/;
248    } else {
249      re = /(?:^|\s)(\d{4})$/;
250    }
251    if (re.test(value)) {
252      e.preventDefault();
253      return setTimeout(function() {
254        return $target.val(value + ' ' + digit);
255      });
256    } else if (re.test(value + digit)) {
257      e.preventDefault();
258      return setTimeout(function() {
259        return $target.val(value + digit + ' ');
260      });
261    }
262  };
263
264  formatBackCardNumber = function(e) {
265    var $target, value;
266    $target = $(e.currentTarget);
267    value = $target.val();
268    if (e.which !== 8) {
269      return;
270    }
271    if (($target.prop('selectionStart') != null) && $target.prop('selectionStart') !== value.length) {
272      return;
273    }
274    if (/\d\s$/.test(value)) {
275      e.preventDefault();
276      return setTimeout(function() {
277        return $target.val(value.replace(/\d\s$/, ''));
278      });
279    } else if (/\s\d?$/.test(value)) {
280      e.preventDefault();
281      return setTimeout(function() {
282        return $target.val(value.replace(/\d$/, ''));
283      });
284    }
285  };
286
287  reFormatExpiry = function(e) {
288    var $target;
289    $target = $(e.currentTarget);
290    return setTimeout(function() {
291      var value;
292      value = $target.val();
293      value = replaceFullWidthChars(value);
294      value = $.payment.formatExpiry(value);
295      return safeVal(value, $target);
296    });
297  };
298
299  formatExpiry = function(e) {
300    var $target, digit, val;
301    digit = String.fromCharCode(e.which);
302    if (!/^\d+$/.test(digit)) {
303      return;
304    }
305    $target = $(e.currentTarget);
306    val = $target.val() + digit;
307    if (/^\d$/.test(val) && (val !== '0' && val !== '1')) {
308      e.preventDefault();
309      return setTimeout(function() {
310        return $target.val("0" + val + " / ");
311      });
312    } else if (/^\d\d$/.test(val)) {
313      e.preventDefault();
314      return setTimeout(function() {
315        var m1, m2;
316        m1 = parseInt(val[0], 10);
317        m2 = parseInt(val[1], 10);
318        if (m2 > 2 && m1 !== 0) {
319          return $target.val("0" + m1 + " / " + m2);
320        } else {
321          return $target.val("" + val + " / ");
322        }
323      });
324    }
325  };
326
327  formatForwardExpiry = function(e) {
328    var $target, digit, val;
329    digit = String.fromCharCode(e.which);
330    if (!/^\d+$/.test(digit)) {
331      return;
332    }
333    $target = $(e.currentTarget);
334    val = $target.val();
335    if (/^\d\d$/.test(val)) {
336      return $target.val("" + val + " / ");
337    }
338  };
339
340  formatForwardSlashAndSpace = function(e) {
341    var $target, val, which;
342    which = String.fromCharCode(e.which);
343    if (!(which === '/' || which === ' ')) {
344      return;
345    }
346    $target = $(e.currentTarget);
347    val = $target.val();
348    if (/^\d$/.test(val) && val !== '0') {
349      return $target.val("0" + val + " / ");
350    }
351  };
352
353  formatBackExpiry = function(e) {
354    var $target, value;
355    $target = $(e.currentTarget);
356    value = $target.val();
357    if (e.which !== 8) {
358      return;
359    }
360    if (($target.prop('selectionStart') != null) && $target.prop('selectionStart') !== value.length) {
361      return;
362    }
363    if (/\d\s\/\s$/.test(value)) {
364      e.preventDefault();
365      return setTimeout(function() {
366        return $target.val(value.replace(/\d\s\/\s$/, ''));
367      });
368    }
369  };
370
371  reFormatCVC = function(e) {
372    var $target;
373    $target = $(e.currentTarget);
374    return setTimeout(function() {
375      var value;
376      value = $target.val();
377      value = replaceFullWidthChars(value);
378      value = value.replace(/\D/g, '').slice(0, 4);
379      return safeVal(value, $target);
380    });
381  };
382
383  restrictNumeric = function(e) {
384    var input;
385    if (e.metaKey || e.ctrlKey) {
386      return true;
387    }
388    if (e.which === 32) {
389      return false;
390    }
391    if (e.which === 0) {
392      return true;
393    }
394    if (e.which < 33) {
395      return true;
396    }
397    input = String.fromCharCode(e.which);
398    return !!/[\d\s]/.test(input);
399  };
400
401  restrictCardNumber = function(e) {
402    var $target, card, digit, value;
403    $target = $(e.currentTarget);
404    digit = String.fromCharCode(e.which);
405    if (!/^\d+$/.test(digit)) {
406      return;
407    }
408    if (hasTextSelected($target)) {
409      return;
410    }
411    value = ($target.val() + digit).replace(/\D/g, '');
412    card = cardFromNumber(value);
413    if (card) {
414      return value.length <= card.length[card.length.length - 1];
415    } else {
416      return value.length <= 16;
417    }
418  };
419
420  restrictExpiry = function(e) {
421    var $target, digit, value;
422    $target = $(e.currentTarget);
423    digit = String.fromCharCode(e.which);
424    if (!/^\d+$/.test(digit)) {
425      return;
426    }
427    if (hasTextSelected($target)) {
428      return;
429    }
430    value = $target.val() + digit;
431    value = value.replace(/\D/g, '');
432    if (value.length > 6) {
433      return false;
434    }
435  };
436
437  restrictCVC = function(e) {
438    var $target, digit, val;
439    $target = $(e.currentTarget);
440    digit = String.fromCharCode(e.which);
441    if (!/^\d+$/.test(digit)) {
442      return;
443    }
444    if (hasTextSelected($target)) {
445      return;
446    }
447    val = $target.val() + digit;
448    return val.length <= 4;
449  };
450
451  setCardType = function(e) {
452    var $target, allTypes, card, cardType, val;
453    $target = $(e.currentTarget);
454    val = $target.val();
455    cardType = $.payment.cardType(val) || 'unknown';
456    if (!$target.hasClass(cardType)) {
457      allTypes = (function() {
458        var _i, _len, _results;
459        _results = [];
460        for (_i = 0, _len = cards.length; _i < _len; _i++) {
461          card = cards[_i];
462          _results.push(card.type);
463        }
464        return _results;
465      })();
466      $target.removeClass('unknown');
467      $target.removeClass(allTypes.join(' '));
468      $target.addClass(cardType);
469      $target.toggleClass('identified', cardType !== 'unknown');
470      return $target.trigger('payment.cardType', cardType);
471    }
472  };
473
474  $.payment.fn.formatCardCVC = function() {
475    this.on('keypress', restrictNumeric);
476    this.on('keypress', restrictCVC);
477    this.on('paste', reFormatCVC);
478    this.on('change', reFormatCVC);
479    this.on('input', reFormatCVC);
480    return this;
481  };
482
483  $.payment.fn.formatCardExpiry = function() {
484    this.on('keypress', restrictNumeric);
485    this.on('keypress', restrictExpiry);
486    this.on('keypress', formatExpiry);
487    this.on('keypress', formatForwardSlashAndSpace);
488    this.on('keypress', formatForwardExpiry);
489    this.on('keydown', formatBackExpiry);
490    this.on('change', reFormatExpiry);
491    this.on('input', reFormatExpiry);
492    return this;
493  };
494
495  $.payment.fn.formatCardNumber = function() {
496    this.on('keypress', restrictNumeric);
497    this.on('keypress', restrictCardNumber);
498    this.on('keypress', formatCardNumber);
499    this.on('keydown', formatBackCardNumber);
500    this.on('keyup', setCardType);
501    this.on('paste', reFormatCardNumber);
502    this.on('change', reFormatCardNumber);
503    this.on('input', reFormatCardNumber);
504    this.on('input', setCardType);
505    return this;
506  };
507
508  $.payment.fn.restrictNumeric = function() {
509    this.on('keypress', restrictNumeric);
510    this.on('paste', reFormatNumeric);
511    this.on('change', reFormatNumeric);
512    this.on('input', reFormatNumeric);
513    return this;
514  };
515
516  $.payment.fn.cardExpiryVal = function() {
517    return $.payment.cardExpiryVal($(this).val());
518  };
519
520  $.payment.cardExpiryVal = function(value) {
521    var month, prefix, year, _ref;
522    _ref = value.split(/[\s\/]+/, 2), month = _ref[0], year = _ref[1];
523    if ((year != null ? year.length : void 0) === 2 && /^\d+$/.test(year)) {
524      prefix = (new Date).getFullYear();
525      prefix = prefix.toString().slice(0, 2);
526      year = prefix + year;
527    }
528    month = parseInt(month, 10);
529    year = parseInt(year, 10);
530    return {
531      month: month,
532      year: year
533    };
534  };
535
536  $.payment.validateCardNumber = function(num) {
537    var card, _ref;
538    num = (num + '').replace(/\s+|-/g, '');
539    if (!/^\d+$/.test(num)) {
540      return false;
541    }
542    card = cardFromNumber(num);
543    if (!card) {
544      return false;
545    }
546    return (_ref = num.length, __indexOf.call(card.length, _ref) >= 0) && (card.luhn === false || luhnCheck(num));
547  };
548
549  $.payment.validateCardExpiry = function(month, year) {
550    var currentTime, expiry, _ref;
551    if (typeof month === 'object' && 'month' in month) {
552      _ref = month, month = _ref.month, year = _ref.year;
553    }
554    if (!(month && year)) {
555      return false;
556    }
557    month = ( month || 0 == month ) ? month.toString().trim() : '';
558    year = ( year || 0 == year ) ? year.toString().trim() : '';
559    if (!/^\d+$/.test(month)) {
560      return false;
561    }
562    if (!/^\d+$/.test(year)) {
563      return false;
564    }
565    if (!((1 <= month && month <= 12))) {
566      return false;
567    }
568    if (year.length === 2) {
569      if (year < 70) {
570        year = "20" + year;
571      } else {
572        year = "19" + year;
573      }
574    }
575    if (year.length !== 4) {
576      return false;
577    }
578    expiry = new Date(year, month);
579    currentTime = new Date;
580    expiry.setMonth(expiry.getMonth() - 1);
581    expiry.setMonth(expiry.getMonth() + 1, 1);
582    return expiry > currentTime;
583  };
584
585  $.payment.validateCardCVC = function(cvc, type) {
586    var card, _ref;
587    cvc = ( cvc || 0 == cvc ) ? cvc.toString().trim() : '';
588    if (!/^\d+$/.test(cvc)) {
589      return false;
590    }
591    card = cardFromType(type);
592    if (card != null) {
593      return _ref = cvc.length, __indexOf.call(card.cvcLength, _ref) >= 0;
594    } else {
595      return cvc.length >= 3 && cvc.length <= 4;
596    }
597  };
598
599  $.payment.cardType = function(num) {
600    var _ref;
601    if (!num) {
602      return null;
603    }
604    return ((_ref = cardFromNumber(num)) != null ? _ref.type : void 0) || null;
605  };
606
607  $.payment.formatCardNumber = function(num) {
608    var card, groups, upperLength, _ref;
609    num = num.replace(/\D/g, '');
610    card = cardFromNumber(num);
611    if (!card) {
612      return num;
613    }
614    upperLength = card.length[card.length.length - 1];
615    num = num.slice(0, upperLength);
616    if (card.format.global) {
617      return (_ref = num.match(card.format)) != null ? _ref.join(' ') : void 0;
618    } else {
619      groups = card.format.exec(num);
620      if (groups == null) {
621        return;
622      }
623      groups.shift();
624      groups = $.grep(groups, function(n) {
625        return n;
626      });
627      return groups.join(' ');
628    }
629  };
630
631  $.payment.formatExpiry = function(expiry) {
632    var mon, parts, sep, year;
633    parts = expiry.match(/^\D*(\d{1,2})(\D+)?(\d{1,4})?/);
634    if (!parts) {
635      return '';
636    }
637    mon = parts[1] || '';
638    sep = parts[2] || '';
639    year = parts[3] || '';
640    if (year.length > 0) {
641      sep = ' / ';
642    } else if (sep === ' /') {
643      mon = mon.substring(0, 1);
644      sep = '';
645    } else if (mon.length === 2 || sep.length > 0) {
646      sep = ' / ';
647    } else if (mon.length === 1 && (mon !== '0' && mon !== '1')) {
648      mon = "0" + mon;
649      sep = ' / ';
650    }
651    return mon + sep + year;
652  };
653
654}).call(this);
655
656});

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.