woocommerce/assets/js/jquery-payment/jquery.payment.min.js

1 line
8.1 KiB
JavaScript
Raw Normal View History

2021-12-10 12:03:04 +00:00
jQuery(function(k){(function(){var l,r,u,t,e,n,a,i,o,s,c,h,p,f,g,v,d,m,y,C,T,w,$,S=[].slice,D=[].indexOf||function(t){for(var e=0,n=this.length;e<n;e++)if(e in this&&this[e]===t)return e;return-1};(k=window.jQuery||window.Zepto||window.$).payment={},k.payment.fn={},k.fn.payment=function(){var t=arguments[0],e=2<=arguments.length?S.call(arguments,1):[];return k.payment.fn[t].apply(this,e)},t=/(\d{1,4})/g,k.payment.cards=u=[{type:"maestro",patterns:[5018,502,503,506,56,58,639,6220,67],format:t,length:[12,13,14,15,16,17,18,19],cvcLength:[3],luhn:!0},{type:"forbrugsforeningen",patterns:[600],format:t,length:[16],cvcLength:[3],luhn:!0},{type:"dankort",patterns:[5019],format:t,length:[16],cvcLength:[3],luhn:!0},{type:"visa",patterns:[4],format:t,length:[13,16],cvcLength:[3],luhn:!0},{type:"mastercard",patterns:[51,52,53,54,55,22,23,24,25,26,27],format:t,length:[16],cvcLength:[3],luhn:!0},{type:"amex",patterns:[34,37],format:/(\d{1,4})(\d{1,6})?(\d{1,5})?/,length:[15],cvcLength:[3,4],luhn:!0},{type:"dinersclub",patterns:[30,36,38,39],format:/(\d{1,4})(\d{1,6})?(\d{1,4})?/,length:[14],cvcLength:[3],luhn:!0},{type:"discover",patterns:[60,64,65,622],format:t,length:[16],cvcLength:[3],luhn:!0},{type:"unionpay",patterns:[62,88],format:t,length:[16,17,18,19],cvcLength:[3],luhn:!1},{type:"jcb",patterns:[35],format:t,length:[16],cvcLength:[3],luhn:!0}],l=function(t){var e,n,r,a,i,o,l;for(t=(t+"").replace(/\D/g,""),r=0,i=u.length;r<i;r++)for(a=0,o=(l=(e=u[r]).patterns).length;a<o;a++)if(n=l[a]+"",t.substr(0,n.length)===n)return e},r=function(t){for(var e,n=0,r=u.length;n<r;n++)if((e=u[n]).type===t)return e},h=function(t){for(var e,n=!0,r=0,a=(t+"").split("").reverse(),i=0,o=a.length;i<o;i++)e=a[i],e=parseInt(e,10),(n=!n)&&(e*=2),9<e&&(e-=9),r+=e;return r%10==0},c=function(t){var e;return null!=t.prop("selectionStart")&&t.prop("selectionStart")!==t.prop("selectionEnd")||!(null==("undefined"!=typeof document&&null!==document&&null!=(e=document.selection)?e.createRange:void 0)||!document.selection.createRange().text)},w=function(t,e){var n,r,a;try{n=e.prop("selectionStart")}catch(i){n=null}if(r=e.val(),e.val(t),null!==n&&e.is(":focus"))return n===r.length&&(n=t.length),r!==t&&(a=r.slice(n-1,+n+1||9e9),r=t.slice(n-1,+n+1||9e9),t=t[n],/\d/.test(t)&&a===t+" "&&r===" "+t&&(n+=1)),e.prop("selectionStart",n),e.prop("selectionEnd",n)},d=function(t){var e,n,r,a,i,o;for(null==t&&(t=""),a="",i=0,o=(e=t.split("")).length;i<o;i++)n=e[i],-1<(r="".indexOf(n))&&(n="0123456789"[r]),a+=n;return a},v=function(t){var e=k(t.currentTarget);return setTimeout(function(){var t=e.val();return t=(t=d(t)).replace(/\D/g,""),w(t,e)})},f=function(t){var e=k(t.currentTarget);return setTimeout(function(){var t=e.val();return t=d(t),t=k.payment.formatCardNumber(t),w(t,e)})},a=function(t){var e,n,r,a,i,o=String.fromCharCode(t.which);if(/^\d+$/.test(o)&&(e=k(t.currentTarget),i=e.val(),r=l(i+o),n=(i.replace(/\D/g,"")+o).length,a=16,r&&(a=r.length[r.length.length-1]),!(a<=n||null!=e.prop("selectionStart")&&e.prop("selectionStart")!==i.length)))return(r=r&&"amex"===r.type?/^(\d{4}|\d{4}\s\d{6})$/:/(?:^|\s)(\d{4})$/).test(i)?(t.preventDefault(),setTimeout(function(){return e.val(i+" "+o)})):r.test(i+o)?(t.preventDefault(),setTimeout(function(){return e.val(i+o+" ")})):void 0},e=function(t){var e=k(t.currentTarget),n=e.val();if(8===t.which&&(null==e.prop("selectionStart")||e.prop("selectionStart")===n.length))return/\d\s$/.test(n)?(t.preventDefault(),setTimeout(function(){return e.val(n.replace(/\d\s$/,""))})):/\s\d?$/.test(n)?(t.preventDefault(),setTimeout(function(){return e.val(n.replace(/\d$/,""))})):void 0},g=function(t){var e=k(t.currentTarget);return setTimeout(function(){var t=e.val();return t=d(t),t=k.payment.formatExpiry(t),w(t,e)})},i=function(t){var n,r,e=String.fromCharCode(t.which);if(/^\d+$/.test(e))return n=k(t.currentTarget),r=n.val()+e,/^\d$/.test(r)&&"0"!==r&&"1"!==r?(t.preventDefault(),setTimeout(function(){return n.val("0"+r+" / ")})):/^\d\d$/.test(r)?(t.preventDefault(),setTimeout(function(){var t=parseInt(r[0],10),e=parseInt(