diginext-utils 2.0.6 → 2.0.8
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/dist/Checker.d.ts +5 -0
- package/dist/Checker.js +30 -0
- package/dist/Checker.js.map +1 -0
- package/dist/EventDispatcher.d.ts +11 -0
- package/dist/EventDispatcher.js +51 -0
- package/dist/EventDispatcher.js.map +1 -0
- package/dist/FileUpload.d.ts +11 -0
- package/dist/FileUpload.js +64 -0
- package/dist/FileUpload.js.map +1 -0
- package/dist/Slug.d.ts +4 -0
- package/dist/Slug.js +332 -0
- package/dist/Slug.js.map +1 -0
- package/dist/Timer.d.ts +3 -0
- package/dist/Timer.js +9 -0
- package/dist/Timer.js.map +1 -0
- package/dist/Validation.d.ts +4 -0
- package/dist/Validation.js +39 -0
- package/dist/Validation.js.map +1 -0
- package/dist/array.d.ts +91 -0
- package/dist/array.js +275 -0
- package/dist/array.js.map +1 -0
- package/dist/color.d.ts +10 -0
- package/dist/color.js +86 -0
- package/dist/color.js.map +1 -0
- package/dist/console/enableConsole.d.ts +1 -3
- package/dist/console/enableConsole.js +10 -14
- package/dist/console/enableConsole.js.map +1 -0
- package/dist/console/index.d.ts +3 -5
- package/dist/console/index.js +12 -16
- package/dist/console/index.js.map +1 -0
- package/dist/device/browser.d.ts +5 -7
- package/dist/device/browser.js +32 -34
- package/dist/device/browser.js.map +1 -0
- package/dist/device/camera.d.ts +7 -16
- package/dist/device/camera.js +166 -157
- package/dist/device/camera.js.map +1 -0
- package/dist/device.d.ts +4 -0
- package/dist/device.js +217 -0
- package/dist/device.js.map +1 -0
- package/dist/file/createDir.d.ts +1 -2
- package/dist/file/createDir.js +13 -20
- package/dist/file/createDir.js.map +1 -0
- package/dist/file/fileMove.d.ts +1 -3
- package/dist/file/fileMove.js +29 -35
- package/dist/file/fileMove.js.map +1 -0
- package/dist/file/findFilesByExt.d.ts +0 -1
- package/dist/file/findFilesByExt.js +41 -46
- package/dist/file/findFilesByExt.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.js +33 -0
- package/dist/index.js.map +1 -0
- package/dist/math/diffDate.d.ts +1 -3
- package/dist/math/diffDate.js +10 -9
- package/dist/math/diffDate.js.map +1 -0
- package/dist/math/index.d.ts +8 -10
- package/dist/math/index.js +92 -48
- package/dist/math/index.js.map +1 -0
- package/dist/math/positiveNumber.d.ts +1 -3
- package/dist/math/positiveNumber.js +13 -27
- package/dist/math/positiveNumber.js.map +1 -0
- package/dist/name/en.d.ts +1 -3
- package/dist/name/en.js +17 -12
- package/dist/name/en.js.map +1 -0
- package/dist/name/vi.d.ts +1 -3
- package/dist/name/vi.js +23 -34
- package/dist/name/vi.js.map +1 -0
- package/dist/object.d.ts +23 -0
- package/dist/object.js +57 -0
- package/dist/object.js.map +1 -0
- package/dist/permission/requestCamera.d.ts +2 -3
- package/dist/permission/requestCamera.js +37 -25
- package/dist/permission/requestCamera.js.map +1 -0
- package/dist/permission/requestDeviceOrientationControl.d.ts +0 -1
- package/dist/permission/requestDeviceOrientationControl.js +35 -174
- package/dist/permission/requestDeviceOrientationControl.js.map +1 -0
- package/dist/string/formatNumber.d.ts +1 -3
- package/dist/string/formatNumber.js +11 -27
- package/dist/string/formatNumber.js.map +1 -0
- package/dist/string/generatePassword.d.ts +1 -3
- package/dist/string/generatePassword.js +20 -26
- package/dist/string/generatePassword.js.map +1 -0
- package/dist/string/generateUUID.d.ts +1 -3
- package/dist/string/generateUUID.js +33 -13
- package/dist/string/generateUUID.js.map +1 -0
- package/dist/string/index.d.ts +8 -10
- package/dist/string/index.js +118 -96
- package/dist/string/index.js.map +1 -0
- package/dist/string/random.d.ts +6 -8
- package/dist/string/random.js +20 -23
- package/dist/string/random.js.map +1 -0
- package/dist/string/trimNull.d.ts +1 -3
- package/dist/string/trimNull.js +15 -19
- package/dist/string/trimNull.js.map +1 -0
- package/dist/string/url.d.ts +7 -14
- package/dist/string/url.js +92 -77
- package/dist/string/url.js.map +1 -0
- package/package.json +6 -8
- package/src/Checker.ts +27 -0
- package/src/EventDispatcher.ts +60 -0
- package/src/FileUpload.ts +65 -0
- package/src/Slug.ts +364 -0
- package/src/Timer.ts +5 -0
- package/src/Validation.ts +35 -0
- package/src/array.ts +261 -0
- package/src/color.ts +89 -0
- package/src/console/enableConsole.ts +6 -0
- package/src/console/index.ts +11 -0
- package/src/device/browser.ts +29 -0
- package/src/device/camera.ts +209 -0
- package/src/device.ts +223 -0
- package/src/file/createDir.ts +14 -0
- package/src/file/fileMove.ts +32 -0
- package/src/file/findFilesByExt.ts +39 -0
- package/src/index.ts +17 -0
- package/src/math/diffDate.ts +8 -0
- package/src/math/index.ts +88 -0
- package/src/math/positiveNumber.ts +10 -0
- package/src/name/en.ts +24 -0
- package/src/name/vi.ts +21 -0
- package/src/object.ts +49 -0
- package/src/permission/requestCamera.ts +43 -0
- package/src/permission/requestDeviceOrientationControl.ts +33 -0
- package/src/string/formatNumber.ts +10 -0
- package/src/string/generatePassword.ts +16 -0
- package/src/string/generateUUID.ts +35 -0
- package/src/string/index.ts +145 -0
- package/src/string/random.ts +20 -0
- package/src/string/trimNull.ts +11 -0
- package/src/string/url.ts +109 -0
- package/dist/esm/chunk-5HIQS7HE.js +0 -40
- package/dist/esm/chunk-EZUCZHGV.js +0 -9
- package/dist/esm/chunk-HDM7KM5F.js +0 -20
- package/dist/esm/chunk-LNLCKCWC.js +0 -17
- package/dist/esm/chunk-X3K4KC75.js +0 -26
- package/dist/esm/console/enableConsole.js +0 -9
- package/dist/esm/console/index.js +0 -15
- package/dist/esm/device/browser.js +0 -34
- package/dist/esm/device/camera.js +0 -137
- package/dist/esm/file/createDir.js +0 -13
- package/dist/esm/file/fileMove.js +0 -29
- package/dist/esm/file/findFilesByExt.js +0 -39
- package/dist/esm/math/diffDate.js +0 -10
- package/dist/esm/math/index.js +0 -2
- package/dist/esm/math/positiveNumber.js +0 -16
- package/dist/esm/name/en.js +0 -17
- package/dist/esm/name/vi.js +0 -31
- package/dist/esm/permission/requestCamera.js +0 -2
- package/dist/esm/permission/requestDeviceOrientationControl.js +0 -175
- package/dist/esm/string/formatNumber.js +0 -10
- package/dist/esm/string/generatePassword.js +0 -16
- package/dist/esm/string/generateUUID.js +0 -14
- package/dist/esm/string/index.js +0 -86
- package/dist/esm/string/random.js +0 -2
- package/dist/esm/string/trimNull.js +0 -14
- package/dist/esm/string/url.js +0 -69
package/package.json
CHANGED
|
@@ -1,22 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "diginext-utils",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.8",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "TOP GROUP (a.k.a Digitop)",
|
|
7
7
|
"email": "dev@wearetopgroup.com"
|
|
8
8
|
},
|
|
9
9
|
"main": "./dist/index.js",
|
|
10
|
-
"types": "./dist/index.d.ts",
|
|
11
10
|
"files": [
|
|
12
|
-
"dist
|
|
11
|
+
"dist",
|
|
12
|
+
"src"
|
|
13
13
|
],
|
|
14
|
-
"exports": {
|
|
15
|
-
".": "./dist"
|
|
16
|
-
},
|
|
17
14
|
"scripts": {
|
|
18
|
-
"build": "tsup src/**/*.ts --format esm,cjs --dts --legacy-output
|
|
19
|
-
"build2": "tsc
|
|
15
|
+
"build": "tsup src/**/*.ts --format esm,cjs --dts --legacy-output",
|
|
16
|
+
"build2": "yarn prebuild && tsc --module commonjs --outDir dist && tsc --module esnext --outDir esm",
|
|
17
|
+
"prebuild": "rm -rf dist",
|
|
20
18
|
"dev": "concurrently \"tsup src/**/*.ts --format esm,cjs --dts --watch\"",
|
|
21
19
|
"test": "mocha test/*.test.js",
|
|
22
20
|
"publish": "npm publish",
|
package/src/Checker.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check if the object or string is in JSON format
|
|
3
|
+
*/
|
|
4
|
+
const isJSON = (content: object | string) => {
|
|
5
|
+
if (typeof content == "object") {
|
|
6
|
+
try {
|
|
7
|
+
content = JSON.stringify(content);
|
|
8
|
+
} catch (err) {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
if (typeof content == "string") {
|
|
14
|
+
try {
|
|
15
|
+
content = JSON.parse(content);
|
|
16
|
+
} catch (err) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (typeof content != "object") {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
return true;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export { isJSON };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
export class EventDispatcher {
|
|
2
|
+
constructor() {}
|
|
3
|
+
|
|
4
|
+
_listeners: any;
|
|
5
|
+
|
|
6
|
+
addEventListener(type: string, listener: any) {
|
|
7
|
+
if (this._listeners === undefined) this._listeners = {};
|
|
8
|
+
|
|
9
|
+
const listeners = this._listeners;
|
|
10
|
+
|
|
11
|
+
if (listeners[type] === undefined) {
|
|
12
|
+
listeners[type] = [];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
if (listeners[type].indexOf(listener) === -1) {
|
|
16
|
+
listeners[type].push(listener);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
hasEventListener(type: string, listener: any) {
|
|
21
|
+
if (this._listeners === undefined) return false;
|
|
22
|
+
|
|
23
|
+
const listeners = this._listeners;
|
|
24
|
+
|
|
25
|
+
return listeners[type] !== undefined && listeners[type].indexOf(listener) !== -1;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
removeEventListener(type: string, listener: any) {
|
|
29
|
+
if (this._listeners === undefined) return;
|
|
30
|
+
|
|
31
|
+
const listeners = this._listeners;
|
|
32
|
+
const listenerArray = listeners[type];
|
|
33
|
+
|
|
34
|
+
if (listenerArray !== undefined) {
|
|
35
|
+
const index = listenerArray.indexOf(listener);
|
|
36
|
+
|
|
37
|
+
if (index !== -1) {
|
|
38
|
+
listenerArray.splice(index, 1);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
dispatchEvent(event: { type: string; target: any }) {
|
|
44
|
+
if (this._listeners === undefined) return;
|
|
45
|
+
|
|
46
|
+
const listeners = this._listeners;
|
|
47
|
+
const listenerArray = listeners[event.type];
|
|
48
|
+
|
|
49
|
+
if (listenerArray !== undefined) {
|
|
50
|
+
event.target = this;
|
|
51
|
+
|
|
52
|
+
// Make a copy, in case listeners are removed while iterating.
|
|
53
|
+
const array = listenerArray.slice(0);
|
|
54
|
+
|
|
55
|
+
for (let i = 0, l = array.length; i < l; i++) {
|
|
56
|
+
array[i].call(this, event);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
var logFile = "[FileUpload.js] ";
|
|
2
|
+
|
|
3
|
+
type UploadParams = { blob: Blob; url: string; params: any; onComplete: any; onError: any };
|
|
4
|
+
|
|
5
|
+
const FileUpload = {
|
|
6
|
+
uploadBlob(props: UploadParams) {
|
|
7
|
+
const { blob, url, params, onComplete, onError } = props;
|
|
8
|
+
|
|
9
|
+
var formData = new FormData();
|
|
10
|
+
formData.append("upload", blob, "img_" + +new Date() + ".jpg");
|
|
11
|
+
|
|
12
|
+
if (params) {
|
|
13
|
+
Object.keys(params).forEach((key) => {
|
|
14
|
+
var val = params[key];
|
|
15
|
+
formData.append(key, val);
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
var request = new XMLHttpRequest();
|
|
20
|
+
request.open("POST", url);
|
|
21
|
+
request.send(formData);
|
|
22
|
+
|
|
23
|
+
request.onreadystatechange = function () {
|
|
24
|
+
if (this.readyState == 4) {
|
|
25
|
+
// Typical action to be performed when the document is ready:
|
|
26
|
+
if (this.status == 200) {
|
|
27
|
+
// var response = JSON.parse(request.response) || "";
|
|
28
|
+
var response: { status?: boolean; data?: any } = {};
|
|
29
|
+
try {
|
|
30
|
+
response = JSON.parse(request.response) || "";
|
|
31
|
+
} catch (error) {
|
|
32
|
+
console.error(logFile, "Can't part JSON of the response");
|
|
33
|
+
}
|
|
34
|
+
var statusOfSafety = response.status || 0;
|
|
35
|
+
|
|
36
|
+
if (statusOfSafety == 1) {
|
|
37
|
+
console.log(logFile, "request: ", request);
|
|
38
|
+
var data = response.data || {};
|
|
39
|
+
console.log(logFile, data);
|
|
40
|
+
|
|
41
|
+
var _url = data["url"];
|
|
42
|
+
|
|
43
|
+
if (onComplete) onComplete(_url);
|
|
44
|
+
} else {
|
|
45
|
+
var errMsg = "Ảnh có nội dung không phù hợp.";
|
|
46
|
+
console.error(logFile, errMsg);
|
|
47
|
+
if (onError) onError(errMsg);
|
|
48
|
+
}
|
|
49
|
+
} else {
|
|
50
|
+
var errMsg = "Upload ảnh không thành công!";
|
|
51
|
+
console.error(logFile, errMsg);
|
|
52
|
+
if (onError) onError(errMsg);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
request.onerror = function (res) {
|
|
58
|
+
var errMsg = "Upload ảnh không thành công!";
|
|
59
|
+
console.error(logFile, errMsg, "=>", res);
|
|
60
|
+
if (onError) onError(errMsg);
|
|
61
|
+
};
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
export { FileUpload };
|
package/src/Slug.ts
ADDED
|
@@ -0,0 +1,364 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create a web friendly URL slug from a string.
|
|
3
|
+
*
|
|
4
|
+
* Requires XRegExp (http://xregexp.com) with unicode add-ons for UTF-8 support.
|
|
5
|
+
*
|
|
6
|
+
* Although supported, transliteration is discouraged because
|
|
7
|
+
* 1) most web browsers support UTF-8 characters in URLs
|
|
8
|
+
* 2) transliteration causes a loss of information
|
|
9
|
+
*
|
|
10
|
+
* @author Sean Murphy <sean@iamseanmurphy.com>
|
|
11
|
+
* @copyright Copyright 2012 Sean Murphy. All rights reserved.
|
|
12
|
+
* @license http://creativecommons.org/publicdomain/zero/1.0/
|
|
13
|
+
*
|
|
14
|
+
*/
|
|
15
|
+
declare var XRegExp: any;
|
|
16
|
+
|
|
17
|
+
const makeSlug = (s: string, opt: { [key: string]: any } = {}) => {
|
|
18
|
+
// s = String(s);
|
|
19
|
+
// opt = Object(opt);
|
|
20
|
+
|
|
21
|
+
var defaults: { [key: string]: any } = {
|
|
22
|
+
delimiter: "-",
|
|
23
|
+
lowercase: true,
|
|
24
|
+
replacements: {},
|
|
25
|
+
transliterate: typeof XRegExp === "undefined" ? true : false,
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
// Merge options
|
|
29
|
+
for (var k in defaults) {
|
|
30
|
+
if (!opt.hasOwnProperty(k)) {
|
|
31
|
+
opt[k] = defaults[k];
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
var char_map: { [key: string]: any } = {
|
|
36
|
+
// Latin
|
|
37
|
+
À: "A",
|
|
38
|
+
Á: "A",
|
|
39
|
+
Â: "A",
|
|
40
|
+
Ã: "A",
|
|
41
|
+
Ä: "A",
|
|
42
|
+
Å: "A",
|
|
43
|
+
Æ: "AE",
|
|
44
|
+
Ç: "C",
|
|
45
|
+
È: "E",
|
|
46
|
+
É: "E",
|
|
47
|
+
Ê: "E",
|
|
48
|
+
Ë: "E",
|
|
49
|
+
Ì: "I",
|
|
50
|
+
Í: "I",
|
|
51
|
+
Î: "I",
|
|
52
|
+
Ï: "I",
|
|
53
|
+
Ð: "D",
|
|
54
|
+
Ñ: "N",
|
|
55
|
+
Ò: "O",
|
|
56
|
+
Ó: "O",
|
|
57
|
+
Ô: "O",
|
|
58
|
+
Õ: "O",
|
|
59
|
+
Ö: "O",
|
|
60
|
+
Ő: "O",
|
|
61
|
+
Ø: "O",
|
|
62
|
+
Ù: "U",
|
|
63
|
+
Ú: "U",
|
|
64
|
+
Û: "U",
|
|
65
|
+
Ü: "U",
|
|
66
|
+
Ű: "U",
|
|
67
|
+
Ý: "Y",
|
|
68
|
+
Þ: "TH",
|
|
69
|
+
ß: "ss",
|
|
70
|
+
à: "a",
|
|
71
|
+
á: "a",
|
|
72
|
+
â: "a",
|
|
73
|
+
ã: "a",
|
|
74
|
+
ä: "a",
|
|
75
|
+
å: "a",
|
|
76
|
+
æ: "ae",
|
|
77
|
+
ç: "c",
|
|
78
|
+
è: "e",
|
|
79
|
+
é: "e",
|
|
80
|
+
ê: "e",
|
|
81
|
+
ë: "e",
|
|
82
|
+
ì: "i",
|
|
83
|
+
í: "i",
|
|
84
|
+
î: "i",
|
|
85
|
+
ï: "i",
|
|
86
|
+
ð: "d",
|
|
87
|
+
ñ: "n",
|
|
88
|
+
ò: "o",
|
|
89
|
+
ó: "o",
|
|
90
|
+
ô: "o",
|
|
91
|
+
õ: "o",
|
|
92
|
+
ö: "o",
|
|
93
|
+
ő: "o",
|
|
94
|
+
ø: "o",
|
|
95
|
+
ù: "u",
|
|
96
|
+
ú: "u",
|
|
97
|
+
û: "u",
|
|
98
|
+
ü: "u",
|
|
99
|
+
ű: "u",
|
|
100
|
+
ý: "y",
|
|
101
|
+
þ: "th",
|
|
102
|
+
ÿ: "y",
|
|
103
|
+
|
|
104
|
+
// Latin symbols
|
|
105
|
+
"©": "(c)",
|
|
106
|
+
|
|
107
|
+
// Greek
|
|
108
|
+
Α: "A",
|
|
109
|
+
Β: "B",
|
|
110
|
+
Γ: "G",
|
|
111
|
+
Δ: "D",
|
|
112
|
+
Ε: "E",
|
|
113
|
+
Ζ: "Z",
|
|
114
|
+
Η: "H",
|
|
115
|
+
Θ: "8",
|
|
116
|
+
Ι: "I",
|
|
117
|
+
Κ: "K",
|
|
118
|
+
Λ: "L",
|
|
119
|
+
Μ: "M",
|
|
120
|
+
Ν: "N",
|
|
121
|
+
Ξ: "3",
|
|
122
|
+
Ο: "O",
|
|
123
|
+
Π: "P",
|
|
124
|
+
Ρ: "R",
|
|
125
|
+
Σ: "S",
|
|
126
|
+
Τ: "T",
|
|
127
|
+
Υ: "Y",
|
|
128
|
+
Φ: "F",
|
|
129
|
+
Χ: "X",
|
|
130
|
+
Ψ: "PS",
|
|
131
|
+
Ω: "W",
|
|
132
|
+
Ά: "A",
|
|
133
|
+
Έ: "E",
|
|
134
|
+
Ί: "I",
|
|
135
|
+
Ό: "O",
|
|
136
|
+
Ύ: "Y",
|
|
137
|
+
Ή: "H",
|
|
138
|
+
Ώ: "W",
|
|
139
|
+
Ϊ: "I",
|
|
140
|
+
Ϋ: "Y",
|
|
141
|
+
α: "a",
|
|
142
|
+
β: "b",
|
|
143
|
+
γ: "g",
|
|
144
|
+
δ: "d",
|
|
145
|
+
ε: "e",
|
|
146
|
+
ζ: "z",
|
|
147
|
+
η: "h",
|
|
148
|
+
θ: "8",
|
|
149
|
+
ι: "i",
|
|
150
|
+
κ: "k",
|
|
151
|
+
λ: "l",
|
|
152
|
+
μ: "m",
|
|
153
|
+
ν: "n",
|
|
154
|
+
ξ: "3",
|
|
155
|
+
ο: "o",
|
|
156
|
+
π: "p",
|
|
157
|
+
ρ: "r",
|
|
158
|
+
σ: "s",
|
|
159
|
+
τ: "t",
|
|
160
|
+
υ: "y",
|
|
161
|
+
φ: "f",
|
|
162
|
+
χ: "x",
|
|
163
|
+
ψ: "ps",
|
|
164
|
+
ω: "w",
|
|
165
|
+
ά: "a",
|
|
166
|
+
έ: "e",
|
|
167
|
+
ί: "i",
|
|
168
|
+
ό: "o",
|
|
169
|
+
ύ: "y",
|
|
170
|
+
ή: "h",
|
|
171
|
+
ώ: "w",
|
|
172
|
+
ς: "s",
|
|
173
|
+
ϊ: "i",
|
|
174
|
+
ΰ: "y",
|
|
175
|
+
ϋ: "y",
|
|
176
|
+
ΐ: "i",
|
|
177
|
+
|
|
178
|
+
// Turkish
|
|
179
|
+
Ş: "S",
|
|
180
|
+
İ: "I",
|
|
181
|
+
Ğ: "G",
|
|
182
|
+
ş: "s",
|
|
183
|
+
ı: "i",
|
|
184
|
+
ğ: "g",
|
|
185
|
+
|
|
186
|
+
// Russian
|
|
187
|
+
А: "A",
|
|
188
|
+
Б: "B",
|
|
189
|
+
В: "V",
|
|
190
|
+
Г: "G",
|
|
191
|
+
Д: "D",
|
|
192
|
+
Е: "E",
|
|
193
|
+
Ё: "Yo",
|
|
194
|
+
Ж: "Zh",
|
|
195
|
+
З: "Z",
|
|
196
|
+
И: "I",
|
|
197
|
+
Й: "J",
|
|
198
|
+
К: "K",
|
|
199
|
+
Л: "L",
|
|
200
|
+
М: "M",
|
|
201
|
+
Н: "N",
|
|
202
|
+
О: "O",
|
|
203
|
+
П: "P",
|
|
204
|
+
Р: "R",
|
|
205
|
+
С: "S",
|
|
206
|
+
Т: "T",
|
|
207
|
+
У: "U",
|
|
208
|
+
Ф: "F",
|
|
209
|
+
Х: "H",
|
|
210
|
+
Ц: "C",
|
|
211
|
+
Ч: "Ch",
|
|
212
|
+
Ш: "Sh",
|
|
213
|
+
Щ: "Sh",
|
|
214
|
+
Ъ: "",
|
|
215
|
+
Ы: "Y",
|
|
216
|
+
Ь: "",
|
|
217
|
+
Э: "E",
|
|
218
|
+
Ю: "Yu",
|
|
219
|
+
Я: "Ya",
|
|
220
|
+
а: "a",
|
|
221
|
+
б: "b",
|
|
222
|
+
в: "v",
|
|
223
|
+
г: "g",
|
|
224
|
+
д: "d",
|
|
225
|
+
е: "e",
|
|
226
|
+
ё: "yo",
|
|
227
|
+
ж: "zh",
|
|
228
|
+
з: "z",
|
|
229
|
+
и: "i",
|
|
230
|
+
й: "j",
|
|
231
|
+
к: "k",
|
|
232
|
+
л: "l",
|
|
233
|
+
м: "m",
|
|
234
|
+
н: "n",
|
|
235
|
+
о: "o",
|
|
236
|
+
п: "p",
|
|
237
|
+
р: "r",
|
|
238
|
+
с: "s",
|
|
239
|
+
т: "t",
|
|
240
|
+
у: "u",
|
|
241
|
+
ф: "f",
|
|
242
|
+
х: "h",
|
|
243
|
+
ц: "c",
|
|
244
|
+
ч: "ch",
|
|
245
|
+
ш: "sh",
|
|
246
|
+
щ: "sh",
|
|
247
|
+
ъ: "",
|
|
248
|
+
ы: "y",
|
|
249
|
+
ь: "",
|
|
250
|
+
э: "e",
|
|
251
|
+
ю: "yu",
|
|
252
|
+
я: "ya",
|
|
253
|
+
|
|
254
|
+
// Ukrainian
|
|
255
|
+
Є: "Ye",
|
|
256
|
+
І: "I",
|
|
257
|
+
Ї: "Yi",
|
|
258
|
+
Ґ: "G",
|
|
259
|
+
є: "ye",
|
|
260
|
+
і: "i",
|
|
261
|
+
ї: "yi",
|
|
262
|
+
ґ: "g",
|
|
263
|
+
|
|
264
|
+
// Czech
|
|
265
|
+
Č: "C",
|
|
266
|
+
Ď: "D",
|
|
267
|
+
Ě: "E",
|
|
268
|
+
Ň: "N",
|
|
269
|
+
Ř: "R",
|
|
270
|
+
Š: "S",
|
|
271
|
+
Ť: "T",
|
|
272
|
+
Ů: "U",
|
|
273
|
+
Ž: "Z",
|
|
274
|
+
č: "c",
|
|
275
|
+
ď: "d",
|
|
276
|
+
ě: "e",
|
|
277
|
+
ň: "n",
|
|
278
|
+
ř: "r",
|
|
279
|
+
š: "s",
|
|
280
|
+
ť: "t",
|
|
281
|
+
ů: "u",
|
|
282
|
+
ž: "z",
|
|
283
|
+
|
|
284
|
+
// Polish
|
|
285
|
+
Ą: "A",
|
|
286
|
+
Ć: "C",
|
|
287
|
+
Ę: "e",
|
|
288
|
+
Ł: "L",
|
|
289
|
+
Ń: "N",
|
|
290
|
+
Ś: "S",
|
|
291
|
+
Ź: "Z",
|
|
292
|
+
Ż: "Z",
|
|
293
|
+
ą: "a",
|
|
294
|
+
ć: "c",
|
|
295
|
+
ę: "e",
|
|
296
|
+
ł: "l",
|
|
297
|
+
ń: "n",
|
|
298
|
+
ś: "s",
|
|
299
|
+
ź: "z",
|
|
300
|
+
ż: "z",
|
|
301
|
+
|
|
302
|
+
// Latvian
|
|
303
|
+
Ā: "A",
|
|
304
|
+
Ē: "E",
|
|
305
|
+
Ģ: "G",
|
|
306
|
+
Ī: "i",
|
|
307
|
+
Ķ: "k",
|
|
308
|
+
Ļ: "L",
|
|
309
|
+
Ņ: "N",
|
|
310
|
+
Ū: "u",
|
|
311
|
+
ā: "a",
|
|
312
|
+
ē: "e",
|
|
313
|
+
ģ: "g",
|
|
314
|
+
ī: "i",
|
|
315
|
+
ķ: "k",
|
|
316
|
+
ļ: "l",
|
|
317
|
+
ņ: "n",
|
|
318
|
+
ū: "u",
|
|
319
|
+
};
|
|
320
|
+
|
|
321
|
+
// Vietnamese
|
|
322
|
+
s = s.replace(/á|à|ả|ạ|ã|ă|ắ|ằ|ẳ|ẵ|ặ|â|ấ|ầ|ẩ|ẫ|ậ/gi, "a");
|
|
323
|
+
s = s.replace(/é|è|ẻ|ẽ|ẹ|ê|ế|ề|ể|ễ|ệ/gi, "e");
|
|
324
|
+
s = s.replace(/i|í|ì|ỉ|ĩ|ị/gi, "i");
|
|
325
|
+
s = s.replace(/ó|ò|ỏ|õ|ọ|ô|ố|ồ|ổ|ỗ|ộ|ơ|ớ|ờ|ở|ỡ|ợ/gi, "o");
|
|
326
|
+
s = s.replace(/ú|ù|ủ|ũ|ụ|ư|ứ|ừ|ử|ữ|ự/gi, "u");
|
|
327
|
+
s = s.replace(/ý|ỳ|ỷ|ỹ|ỵ/gi, "y");
|
|
328
|
+
s = s.replace(/đ/gi, "d");
|
|
329
|
+
s = s.replace(/\-\-\-\-\-/gi, "-");
|
|
330
|
+
s = s.replace(/\-\-\-\-/gi, "-");
|
|
331
|
+
s = s.replace(/\-\-\-/gi, "-");
|
|
332
|
+
s = s.replace(/\-\-/gi, "-");
|
|
333
|
+
s = "@" + s + "@";
|
|
334
|
+
s = s.replace(/\@\-|\-\@|\@/gi, "");
|
|
335
|
+
|
|
336
|
+
// Make custom replacements
|
|
337
|
+
for (var k in opt.replacements) {
|
|
338
|
+
s = s.replace(RegExp(k, "g"), opt.replacements[k]);
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
// Transliterate characters to ASCII
|
|
342
|
+
if (opt.transliterate) {
|
|
343
|
+
for (var k in char_map) {
|
|
344
|
+
s = s.replace(RegExp(k, "g"), char_map[k]);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
// Replace non-alphanumeric characters with our delimiter
|
|
349
|
+
var alnum = typeof XRegExp === "undefined" ? RegExp("[^a-z0-9]+", "ig") : XRegExp("[^\\p{L}\\p{N}]+", "ig");
|
|
350
|
+
s = s.replace(alnum, opt.delimiter);
|
|
351
|
+
|
|
352
|
+
// Remove duplicate delimiters
|
|
353
|
+
s = s.replace(RegExp("[" + opt.delimiter + "]{2,}", "g"), opt.delimiter);
|
|
354
|
+
|
|
355
|
+
// Truncate slug to max. characters
|
|
356
|
+
s = s.substring(0, opt.limit);
|
|
357
|
+
|
|
358
|
+
// Remove delimiter from ends
|
|
359
|
+
s = s.replace(RegExp("(^" + opt.delimiter + "|" + opt.delimiter + "$)", "g"), "");
|
|
360
|
+
|
|
361
|
+
return opt.lowercase ? s.toLowerCase() : s;
|
|
362
|
+
};
|
|
363
|
+
|
|
364
|
+
export { makeSlug };
|
package/src/Timer.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export const Validation = {
|
|
2
|
+
imageValidate(file: Blob) {
|
|
3
|
+
// console.log("imageValidate")
|
|
4
|
+
var maxSize = 10;
|
|
5
|
+
var fileSize = 1024 * 1024 * maxSize; // 10mb
|
|
6
|
+
var fileTypes = ["image/png", "image/jpeg"];
|
|
7
|
+
// var isFileValid = true;
|
|
8
|
+
if (!file || fileTypes.indexOf(file.type) < 0) {
|
|
9
|
+
alert("Vui lòng upload ảnh đúng định dạng jpg hay png");
|
|
10
|
+
return false;
|
|
11
|
+
} else if (file.size > fileSize) {
|
|
12
|
+
alert("Vui lòng upload ảnh có dung lượng thấp hơn " + maxSize + "mb");
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
return true;
|
|
16
|
+
},
|
|
17
|
+
|
|
18
|
+
videoValidate(file: Blob) {
|
|
19
|
+
// console.log("videoValidate")
|
|
20
|
+
|
|
21
|
+
var maxSize = 15;
|
|
22
|
+
var fileSize = 1024 * 1024 * maxSize; // 10mb
|
|
23
|
+
var fileTypes = "video";
|
|
24
|
+
// console.log(file.type)
|
|
25
|
+
// var isFileValid = true;
|
|
26
|
+
if (!file || file.type.indexOf(fileTypes) < 0) {
|
|
27
|
+
alert("Vui lòng upload video");
|
|
28
|
+
return false;
|
|
29
|
+
} else if (file.size > fileSize) {
|
|
30
|
+
alert("Vui lòng upload video có dung lượng thấp hơn " + maxSize + "mb");
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
return true;
|
|
34
|
+
},
|
|
35
|
+
};
|