|
@@ -5,23 +5,26 @@ function normalize (item) {
|
|
|
}
|
|
|
|
|
|
function normalizePhone (item) {
|
|
|
- let phone = String(item).replace(/\s|\+|\(|\)|\/|,|-|'/g, '').replace(/^0+/, '')
|
|
|
+ let phone = String(item).replace(/\s|\+|\/|,|-|'/g, '').replace(/\(0\)/, '').replace(/^0+/, '')
|
|
|
if (phone.match(/[^\d*]/)) {
|
|
|
- return `FEHLER: ${phone}`
|
|
|
+ return `FEHLER (nicht-numerische Zeichen): ${phone}`
|
|
|
}
|
|
|
- if (phone.length === 9) {
|
|
|
- // Missing 0
|
|
|
- phone = `0${phone}`
|
|
|
+ if (phone.length === 0) {
|
|
|
+ return null
|
|
|
}
|
|
|
-
|
|
|
- const len = phone.length
|
|
|
- if (phone[len - 10] === '0') {
|
|
|
- return `${phone.substring(len - 10, len - 7)} ${phone.substring(len - 7, len - 4)} ${phone.substring(len - 4, len - 2)} ${phone.substring(len - 2, len)}`
|
|
|
+ else if (phone.length === 9) {
|
|
|
+ // Assume swiss number
|
|
|
+ phone = `+41${phone}`
|
|
|
+ }
|
|
|
+ else if (phone.length === 11) {
|
|
|
+ phone = `+${phone}`
|
|
|
}
|
|
|
- if (len > 10) {
|
|
|
- return `FEHLER: ${phone} ${phone.substring(0, len - 7)}`
|
|
|
+ else {
|
|
|
+ return `FEHLER (falsche Länge): ${phone}`
|
|
|
}
|
|
|
- return `${phone}`
|
|
|
+
|
|
|
+ const len = phone.length
|
|
|
+ return phone
|
|
|
}
|
|
|
|
|
|
const state = {
|
|
@@ -31,6 +34,8 @@ const state = {
|
|
|
filters: {}
|
|
|
}
|
|
|
|
|
|
+const reMobile = /^\+417/
|
|
|
+
|
|
|
/** Class representing a player */
|
|
|
class Player {
|
|
|
/**
|
|
@@ -50,6 +55,7 @@ class Player {
|
|
|
this.TelP = normalizePhone(data[13])
|
|
|
this.TelG = normalizePhone(data[14])
|
|
|
this.Mobile = normalizePhone(data[15])
|
|
|
+ this.Email = normalize(data[16])
|
|
|
this.Klassierung = normalize(data[17])
|
|
|
this.LizenzDP = normalize(data[23])
|
|
|
this.NameDP = normalize(data[24])
|
|
@@ -64,6 +70,24 @@ class Player {
|
|
|
this.isJunior = (this.Geburtsdatum) ? this.Geburtsdatum.getTime() >= (new Date((new Date()).getFullYear() - 18, 11, 31, 23, 59, 59, 999)).getTime() : false
|
|
|
this.isJuniorDP = (this.isDoubles & !!this.GeburtsdatumDP) ? this.GeburtsdatumDP.getTime() >= (new Date((new Date()).getFullYear() - 18, 11, 31, 23, 59, 59, 999)).getTime() : false
|
|
|
this.name = this.isDoubles ? `${this.Name} ${this.Vorname} / ${this.NameDP} ${this.VornameDP}` : `${this.Name} ${this.Vorname}`
|
|
|
+ if (this.Mobile && this.Mobile.match(reMobile)) {
|
|
|
+ this.phone = this.Mobile
|
|
|
+ }
|
|
|
+ else if (this.TelP && this.TelP.match(reMobile)) {
|
|
|
+ this.phone = this.TelP
|
|
|
+ }
|
|
|
+ else if (this.TelG && this.TelG.match(reMobile)) {
|
|
|
+ this.phone = this.TelG
|
|
|
+ }
|
|
|
+ else if (this.Mobile && this.Mobile.match(/FEHLER/)) {
|
|
|
+ this.phone = this.Mobile
|
|
|
+ }
|
|
|
+ else if (this.TelP && this.TelP.match(/FEHLER/)) {
|
|
|
+ this.phone = this.TelP
|
|
|
+ }
|
|
|
+ else if (this.TelG && this.TelG.match(/FEHLER/)) {
|
|
|
+ this.phone = this.TelG
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|