@osimatic/helpers-js 1.1.24 → 1.1.26
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/contact_details.js +37 -8
- package/date_time.js +1 -1
- package/file.js +13 -0
- package/package.json +1 -1
package/contact_details.js
CHANGED
|
@@ -56,7 +56,14 @@ class TelephoneNumber {
|
|
|
56
56
|
|
|
57
57
|
static getCountryIsoCode(phoneNumber, localCountryIsoCode) {
|
|
58
58
|
localCountryIsoCode = (typeof localCountryIsoCode != 'undefined' ? localCountryIsoCode.toUpperCase() : serviceCountry);
|
|
59
|
-
|
|
59
|
+
try {
|
|
60
|
+
const number = libphonenumber.parsePhoneNumber(phoneNumber, localCountryIsoCode);
|
|
61
|
+
return number != null ? number.country : null;
|
|
62
|
+
} catch (error) {
|
|
63
|
+
console.error(error);
|
|
64
|
+
}
|
|
65
|
+
return null;
|
|
66
|
+
//return libphonenumber.parsePhoneNumber(phoneNumber, localCountryIsoCode).country || '';
|
|
60
67
|
}
|
|
61
68
|
static getCountryName(phoneNumber, localCountryIsoCode) {
|
|
62
69
|
return Country.getCountryName(this.getCountryIsoCode(phoneNumber, localCountryIsoCode));
|
|
@@ -66,11 +73,25 @@ class TelephoneNumber {
|
|
|
66
73
|
}
|
|
67
74
|
static formatNational(phoneNumber, localCountryIsoCode) {
|
|
68
75
|
localCountryIsoCode = (typeof localCountryIsoCode != 'undefined' ? localCountryIsoCode.toUpperCase() : serviceCountry);
|
|
69
|
-
|
|
76
|
+
try {
|
|
77
|
+
const number = libphonenumber.parsePhoneNumber(phoneNumber, localCountryIsoCode);
|
|
78
|
+
return number != null ? number.formatNational() : '';
|
|
79
|
+
} catch (error) {
|
|
80
|
+
console.error(error);
|
|
81
|
+
}
|
|
82
|
+
return '';
|
|
83
|
+
//return libphonenumber.parsePhoneNumber(phoneNumber, localCountryIsoCode).formatNational();
|
|
70
84
|
}
|
|
71
85
|
static formatInternational(phoneNumber, localCountryIsoCode) {
|
|
72
86
|
localCountryIsoCode = (typeof localCountryIsoCode != 'undefined' ? localCountryIsoCode.toUpperCase() : serviceCountry);
|
|
73
|
-
|
|
87
|
+
try {
|
|
88
|
+
const number = libphonenumber.parsePhoneNumber(phoneNumber, localCountryIsoCode);
|
|
89
|
+
return number != null ? number.formatInternational() : '';
|
|
90
|
+
} catch (error) {
|
|
91
|
+
console.error(error);
|
|
92
|
+
}
|
|
93
|
+
return '';
|
|
94
|
+
//return libphonenumber.parsePhoneNumber(phoneNumber, localCountryIsoCode).formatInternational();
|
|
74
95
|
}
|
|
75
96
|
static formatInternationalWithTelLink(phoneNumber, localCountryIsoCode) {
|
|
76
97
|
return '<a href="tel:'+phoneNumber+'">'+TelephoneNumber.formatInternational(phoneNumber, localCountryIsoCode)+'</a>';
|
|
@@ -90,13 +111,16 @@ class TelephoneNumber {
|
|
|
90
111
|
} catch (error) {
|
|
91
112
|
console.error(error);
|
|
92
113
|
}
|
|
93
|
-
return
|
|
114
|
+
return null;
|
|
94
115
|
}
|
|
95
116
|
|
|
96
117
|
static check(phoneNumber, localCountryIsoCode) {
|
|
97
118
|
localCountryIsoCode = (typeof localCountryIsoCode != 'undefined' ? localCountryIsoCode.toUpperCase() : serviceCountry);
|
|
98
|
-
|
|
99
|
-
|
|
119
|
+
try {
|
|
120
|
+
const number = libphonenumber.parsePhoneNumber(phoneNumber, localCountryIsoCode);
|
|
121
|
+
return number != null ? number.isValid() : false;
|
|
122
|
+
} catch (error) { }
|
|
123
|
+
return false;
|
|
100
124
|
//var numberObject = libphonenumber.parse(phoneNumber, localCountryIsoCode);
|
|
101
125
|
//return (typeof numberObject.country !== 'undefined');
|
|
102
126
|
}
|
|
@@ -117,8 +141,13 @@ class TelephoneNumber {
|
|
|
117
141
|
return 'MASKED';
|
|
118
142
|
}
|
|
119
143
|
|
|
120
|
-
|
|
121
|
-
|
|
144
|
+
try {
|
|
145
|
+
const number = libphonenumber.parsePhoneNumber(phoneNumber, localCountryIsoCode);
|
|
146
|
+
return number != null ? number.getType() : null;
|
|
147
|
+
} catch (error) {
|
|
148
|
+
console.error(error);
|
|
149
|
+
}
|
|
150
|
+
return null;
|
|
122
151
|
}
|
|
123
152
|
|
|
124
153
|
static getTypeLabelList() {
|
package/date_time.js
CHANGED
package/file.js
CHANGED
|
@@ -131,6 +131,19 @@ class Img {
|
|
|
131
131
|
var urlCreator = window.URL || window.webkitURL;
|
|
132
132
|
img.attr('src', urlCreator.createObjectURL(blob));
|
|
133
133
|
}
|
|
134
|
+
|
|
135
|
+
static async getBase64FromUrl(url) {
|
|
136
|
+
const data = await fetch(url);
|
|
137
|
+
const blob = await data.blob();
|
|
138
|
+
return new Promise((resolve) => {
|
|
139
|
+
const reader = new FileReader();
|
|
140
|
+
reader.readAsDataURL(blob);
|
|
141
|
+
reader.onloadend = () => {
|
|
142
|
+
const base64data = reader.result;
|
|
143
|
+
resolve(base64data);
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
}
|
|
134
147
|
}
|
|
135
148
|
|
|
136
149
|
module.exports = { File, CSV, Img };
|