Separate CreditCard constants into its own class
This commit is contained in:
parent
0fbeabf7a6
commit
47b40e0049
|
@ -21,7 +21,7 @@ import AutofillScript from '../models/autofillScript';
|
||||||
|
|
||||||
import { BrowserApi } from '../browser/browserApi';
|
import { BrowserApi } from '../browser/browserApi';
|
||||||
|
|
||||||
import { AutoFillConstants } from './autofillConstants';
|
import { AutoFillConstants, CreditCardAutoFillConstants } from './autofillConstants';
|
||||||
export default class AutofillService implements AutofillServiceInterface {
|
export default class AutofillService implements AutofillServiceInterface {
|
||||||
|
|
||||||
constructor(private cipherService: CipherService, private userService: UserService,
|
constructor(private cipherService: CipherService, private userService: UserService,
|
||||||
|
@ -373,8 +373,8 @@ export default class AutofillService implements AutofillServiceInterface {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let i = 0; i < AutoFillConstants.CardAttributes.length; i++) {
|
for (let i = 0; i < CreditCardAutoFillConstants.CardAttributes.length; i++) {
|
||||||
const attr = AutoFillConstants.CardAttributes[i];
|
const attr = CreditCardAutoFillConstants.CardAttributes[i];
|
||||||
if (!f.hasOwnProperty(attr) || !f[attr] || !f.viewable) {
|
if (!f.hasOwnProperty(attr) || !f[attr] || !f.viewable) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -525,36 +525,36 @@ export default class AutofillService implements AutofillServiceInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
let exp: string = null;
|
let exp: string = null;
|
||||||
for (let i = 0; i < AutoFillConstants.MonthAbbr.length; i++) {
|
for (let i = 0; i < CreditCardAutoFillConstants.MonthAbbr.length; i++) {
|
||||||
if (this.fieldAttrsContain(fillFields.exp, AutoFillConstants.MonthAbbr[i] + '/' + AutoFillConstants.YearAbbrShort[i]) &&
|
if (this.fieldAttrsContain(fillFields.exp, CreditCardAutoFillConstants.MonthAbbr[i] + '/' + CreditCardAutoFillConstants.YearAbbrShort[i]) &&
|
||||||
partYear != null) {
|
partYear != null) {
|
||||||
exp = fullMonth + '/' + partYear;
|
exp = fullMonth + '/' + partYear;
|
||||||
} else if (this.fieldAttrsContain(fillFields.exp, AutoFillConstants.MonthAbbr[i] + '/' + AutoFillConstants.YearAbbrLong[i])) {
|
} else if (this.fieldAttrsContain(fillFields.exp, CreditCardAutoFillConstants.MonthAbbr[i] + '/' + CreditCardAutoFillConstants.YearAbbrLong[i])) {
|
||||||
exp = fullMonth + '/' + fullYear;
|
exp = fullMonth + '/' + fullYear;
|
||||||
} else if (this.fieldAttrsContain(fillFields.exp, AutoFillConstants.YearAbbrShort[i] + '/' + AutoFillConstants.MonthAbbr[i]) &&
|
} else if (this.fieldAttrsContain(fillFields.exp, CreditCardAutoFillConstants.YearAbbrShort[i] + '/' + CreditCardAutoFillConstants.MonthAbbr[i]) &&
|
||||||
partYear != null) {
|
partYear != null) {
|
||||||
exp = partYear + '/' + fullMonth;
|
exp = partYear + '/' + fullMonth;
|
||||||
} else if (this.fieldAttrsContain(fillFields.exp, AutoFillConstants.YearAbbrLong[i] + '/' + AutoFillConstants.MonthAbbr[i])) {
|
} else if (this.fieldAttrsContain(fillFields.exp, CreditCardAutoFillConstants.YearAbbrLong[i] + '/' + CreditCardAutoFillConstants.MonthAbbr[i])) {
|
||||||
exp = fullYear + '/' + fullMonth;
|
exp = fullYear + '/' + fullMonth;
|
||||||
} else if (this.fieldAttrsContain(fillFields.exp, AutoFillConstants.MonthAbbr[i] + '-' + AutoFillConstants.YearAbbrShort[i]) &&
|
} else if (this.fieldAttrsContain(fillFields.exp, CreditCardAutoFillConstants.MonthAbbr[i] + '-' + CreditCardAutoFillConstants.YearAbbrShort[i]) &&
|
||||||
partYear != null) {
|
partYear != null) {
|
||||||
exp = fullMonth + '-' + partYear;
|
exp = fullMonth + '-' + partYear;
|
||||||
} else if (this.fieldAttrsContain(fillFields.exp, AutoFillConstants.MonthAbbr[i] + '-' + AutoFillConstants.YearAbbrLong[i])) {
|
} else if (this.fieldAttrsContain(fillFields.exp, CreditCardAutoFillConstants.MonthAbbr[i] + '-' + CreditCardAutoFillConstants.YearAbbrLong[i])) {
|
||||||
exp = fullMonth + '-' + fullYear;
|
exp = fullMonth + '-' + fullYear;
|
||||||
} else if (this.fieldAttrsContain(fillFields.exp, AutoFillConstants.YearAbbrShort[i] + '-' + AutoFillConstants.MonthAbbr[i]) &&
|
} else if (this.fieldAttrsContain(fillFields.exp, CreditCardAutoFillConstants.YearAbbrShort[i] + '-' + CreditCardAutoFillConstants.MonthAbbr[i]) &&
|
||||||
partYear != null) {
|
partYear != null) {
|
||||||
exp = partYear + '-' + fullMonth;
|
exp = partYear + '-' + fullMonth;
|
||||||
} else if (this.fieldAttrsContain(fillFields.exp, AutoFillConstants.YearAbbrLong[i] + '-' + AutoFillConstants.MonthAbbr[i])) {
|
} else if (this.fieldAttrsContain(fillFields.exp, CreditCardAutoFillConstants.YearAbbrLong[i] + '-' + CreditCardAutoFillConstants.MonthAbbr[i])) {
|
||||||
exp = fullYear + '-' + fullMonth;
|
exp = fullYear + '-' + fullMonth;
|
||||||
} else if (this.fieldAttrsContain(fillFields.exp, AutoFillConstants.YearAbbrShort[i] + AutoFillConstants.MonthAbbr[i]) &&
|
} else if (this.fieldAttrsContain(fillFields.exp, CreditCardAutoFillConstants.YearAbbrShort[i] + CreditCardAutoFillConstants.MonthAbbr[i]) &&
|
||||||
partYear != null) {
|
partYear != null) {
|
||||||
exp = partYear + fullMonth;
|
exp = partYear + fullMonth;
|
||||||
} else if (this.fieldAttrsContain(fillFields.exp, AutoFillConstants.YearAbbrLong[i] + AutoFillConstants.MonthAbbr[i])) {
|
} else if (this.fieldAttrsContain(fillFields.exp, CreditCardAutoFillConstants.YearAbbrLong[i] + CreditCardAutoFillConstants.MonthAbbr[i])) {
|
||||||
exp = fullYear + fullMonth;
|
exp = fullYear + fullMonth;
|
||||||
} else if (this.fieldAttrsContain(fillFields.exp, AutoFillConstants.MonthAbbr[i] + AutoFillConstants.YearAbbrShort[i]) &&
|
} else if (this.fieldAttrsContain(fillFields.exp, CreditCardAutoFillConstants.MonthAbbr[i] + CreditCardAutoFillConstants.YearAbbrShort[i]) &&
|
||||||
partYear != null) {
|
partYear != null) {
|
||||||
exp = fullMonth + partYear;
|
exp = fullMonth + partYear;
|
||||||
} else if (this.fieldAttrsContain(fillFields.exp, AutoFillConstants.MonthAbbr[i] + AutoFillConstants.YearAbbrLong[i])) {
|
} else if (this.fieldAttrsContain(fillFields.exp, CreditCardAutoFillConstants.MonthAbbr[i] + CreditCardAutoFillConstants.YearAbbrLong[i])) {
|
||||||
exp = fullMonth + fullYear;
|
exp = fullMonth + fullYear;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -579,7 +579,7 @@ export default class AutofillService implements AutofillServiceInterface {
|
||||||
}
|
}
|
||||||
|
|
||||||
let doesContain = false;
|
let doesContain = false;
|
||||||
AutoFillConstants.CardAttributesExtended.forEach(attr => {
|
CreditCardAutoFillConstants.CardAttributesExtended.forEach(attr => {
|
||||||
if (doesContain || !field.hasOwnProperty(attr) || !field[attr]) {
|
if (doesContain || !field.hasOwnProperty(attr) || !field[attr]) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,21 +1,4 @@
|
||||||
export class AutoFillConstants {
|
export class AutoFillConstants {
|
||||||
static readonly CardAttributes: string[] = [
|
|
||||||
"autoCompleteType",
|
|
||||||
"data-stripe",
|
|
||||||
"htmlName",
|
|
||||||
"htmlID",
|
|
||||||
"label-tag",
|
|
||||||
"placeholder",
|
|
||||||
"label-left",
|
|
||||||
"label-top",
|
|
||||||
"data-recurly",
|
|
||||||
];
|
|
||||||
|
|
||||||
static readonly CardAttributesExtended: string[] = [
|
|
||||||
...AutoFillConstants.CardAttributes,
|
|
||||||
"label-right",
|
|
||||||
];
|
|
||||||
|
|
||||||
static readonly IdentityAttributes: string[] = [
|
static readonly IdentityAttributes: string[] = [
|
||||||
"autoCompleteType",
|
"autoCompleteType",
|
||||||
"data-stripe",
|
"data-stripe",
|
||||||
|
@ -84,12 +67,6 @@ export class AutoFillConstants {
|
||||||
"search",
|
"search",
|
||||||
];
|
];
|
||||||
|
|
||||||
// Each index represents a language. These three arrays should all be the same length.
|
|
||||||
// 0: English, 1: Danish, 2: German/Dutch, 3: French/Spanish/Italian, 4: Russian, 5: Portuguese
|
|
||||||
static readonly MonthAbbr = ["mm", "mm", "mm", "mm", "mm", "mm"];
|
|
||||||
static readonly YearAbbrShort = ["yy", "åå", "jj", "aa", "гг", "rr"];
|
|
||||||
static readonly YearAbbrLong = ["yyyy", "åååå", "jjjj", "aa", "гггг", "rrrr"];
|
|
||||||
|
|
||||||
static readonly OperationDelays = new Map<string, number>([["buzzsprout.com", 100]]);
|
static readonly OperationDelays = new Map<string, number>([["buzzsprout.com", 100]]);
|
||||||
|
|
||||||
static readonly IsoCountries: { [id: string]: string } = {
|
static readonly IsoCountries: { [id: string]: string } = {
|
||||||
|
@ -418,3 +395,28 @@ export class AutoFillConstants {
|
||||||
saskatchewan: "SK",
|
saskatchewan: "SK",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export class CreditCardAutoFillConstants {
|
||||||
|
static readonly CardAttributes: string[] = [
|
||||||
|
"autoCompleteType",
|
||||||
|
"data-stripe",
|
||||||
|
"htmlName",
|
||||||
|
"htmlID",
|
||||||
|
"label-tag",
|
||||||
|
"placeholder",
|
||||||
|
"label-left",
|
||||||
|
"label-top",
|
||||||
|
"data-recurly",
|
||||||
|
];
|
||||||
|
|
||||||
|
static readonly CardAttributesExtended: string[] = [
|
||||||
|
...CreditCardAutoFillConstants.CardAttributes,
|
||||||
|
"label-right",
|
||||||
|
];
|
||||||
|
|
||||||
|
// Each index represents a language. These three arrays should all be the same length.
|
||||||
|
// 0: English, 1: Danish, 2: German/Dutch, 3: French/Spanish/Italian, 4: Russian, 5: Portuguese
|
||||||
|
static readonly MonthAbbr = ["mm", "mm", "mm", "mm", "mm", "mm"];
|
||||||
|
static readonly YearAbbrShort = ["yy", "åå", "jj", "aa", "гг", "rr"];
|
||||||
|
static readonly YearAbbrLong = ["yyyy", "åååå", "jjjj", "aa", "гггг", "rrrr"];
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue