1$.fn.extend({ccFormat:function(){var card_types=[{name:'American Express',code:'ax',pattern:/^3[47]/,valid_length:[15],formats:[{length:15,format:'xxxx xxxxxxx xxxx'}]},{name:'Diners Club',code:'dc',pattern:/^3[68]/,valid_length:[14],formats:[{length:14,format:'xxxx xxxx xxxx xx'}]},{name:'JCB',code:'jc',pattern:/^35/,valid_length:[16],formats:[{length:16,format:'xxxx xxxx xxxx xxxx'}]},{name:'Visa',code:'vs',pattern:/^4/,valid_length:[16],formats:[{length:16,format:'xxxx xxxx xxxx xxxx'}]},{name:'Mastercard',code:'mc',pattern:/^5[1-5]/,valid_length:[16],formats:[{length:16,format:'xxxx xxxx xxxx xxxx'}]}];function isValidLength(cc_num,card_type){for(var i in card_type.valid_length){if(cc_num.length<=card_type.valid_length[i]){return true;}} 2return false;};function getCardType(cc_num){for(var i in card_types){var card_type=card_types[i];if(cc_num.match(card_type.pattern)&&isValidLength(cc_num,card_type)){return card_type;}}};function getCardFormatString(cc_num,card_type){for(var i in card_type.formats){var format=card_type.formats[i];if(cc_num.length<=format.length){return format.format;}}};function formatCardNumber(cc_num,card_type){var numAppendedChars=0;var formattedNumber='';if(!card_type){return cc_num;} 3var cardFormatString=getCardFormatString(cc_num,card_type);for(var i=0;i<cc_num.length;i++){cardFormatIndex=i+numAppendedChars;if(!cardFormatString||cardFormatIndex>=cardFormatString.length){return cc_num;} 4if(cardFormatString.charAt(cardFormatIndex)!=='x'){numAppendedChars++;formattedNumber+=cardFormatString.charAt(cardFormatIndex)+cc_num.charAt(i);}else{formattedNumber+=cc_num.charAt(i);}} 5return formattedNumber;};function monitorCcFormat($elem){var cc_num=$elem.val().replace(/\D/g,'');var card_type=getCardType(cc_num);$elem.val(formatCardNumber(cc_num,card_type));addCardClassIdentifier($elem,card_type);};function addCardClassIdentifier($elem,card_type){var classIdentifier='cc_type_unknown';if(card_type){classIdentifier='cc_type_'+card_type.code;} 6if(!$elem.hasClass(classIdentifier)){var classes='';for(var i in card_types){classes+='cc_type_'+card_types[i].code+' ';} 7$elem.removeClass(classes+'cc_type_unknown');$elem.addClass(classIdentifier);}};this.each(function(){var $elem=$(this);if($elem.is('input')){$elem.unbind('.ccFormat').bind('input.ccFormat',function(){monitorCcFormat($elem);});}});return 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.