diginext-utils 2.1.21 → 2.1.23
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/README.md +162 -162
- package/dist/Checker.mjs +29 -0
- package/dist/EventDispatcher.mjs +54 -0
- package/dist/FileUpload.mjs +62 -0
- package/dist/Slug.mjs +9 -0
- package/dist/Timer-7b0c4e7c.d.ts +11 -0
- package/dist/Timer.mjs +7 -0
- package/dist/Validation.mjs +35 -0
- package/dist/array-c38eff4c.d.ts +158 -0
- package/dist/array.mjs +49 -0
- package/dist/browser-8d042ffe.d.ts +22 -0
- package/dist/camera-1a859d72.d.ts +15 -0
- package/dist/chunk-24DHBJAC.mjs +35 -0
- package/dist/chunk-32BJ2V3H.mjs +195 -0
- package/dist/chunk-32PJ3FML.mjs +57 -0
- package/dist/chunk-3OYOTSDB.mjs +339 -0
- package/dist/chunk-4CWVMQ53.mjs +167 -0
- package/dist/chunk-4VQ25N7H.mjs +43 -0
- package/dist/chunk-6OZHYD5H.mjs +91 -0
- package/dist/chunk-76AY2CWV.mjs +22 -0
- package/dist/chunk-7MK72U4O.mjs +19 -0
- package/dist/chunk-7SOQVGCL.mjs +12 -0
- package/dist/chunk-7XKT3AQX.mjs +17 -0
- package/dist/chunk-AT5ZUBQL.mjs +151 -0
- package/dist/chunk-CKILLYAP.mjs +16 -0
- package/dist/chunk-D5JDP7JB.mjs +56 -0
- package/dist/chunk-DEOVENCJ.mjs +15 -0
- package/dist/chunk-FILFH56Y.mjs +21 -0
- package/dist/chunk-FTXB3IBS.mjs +20 -0
- package/dist/chunk-GJMNV2OC.mjs +35 -0
- package/dist/chunk-GNJDIUYM.mjs +40 -0
- package/dist/chunk-HN4EHJ2H.mjs +39 -0
- package/dist/chunk-HTAKHCLC.mjs +43 -0
- package/dist/chunk-JAP2EUEW.mjs +86 -0
- package/dist/chunk-JFASFX5Y.mjs +16 -0
- package/dist/chunk-JIMOWRMS.mjs +118 -0
- package/dist/chunk-K4KENOE6.mjs +20 -0
- package/dist/chunk-LGBBKRBU.mjs +40 -0
- package/dist/chunk-PMJLVOEM.mjs +25 -0
- package/dist/chunk-PSVXSTS4.mjs +51 -0
- package/dist/chunk-SNYWQI35.mjs +41 -0
- package/dist/chunk-TV4YHUBU.mjs +23 -0
- package/dist/chunk-UHUY6K7N.mjs +24 -0
- package/dist/chunk-UZ7BFUDR.mjs +258 -0
- package/dist/chunk-YLZC36RI.mjs +32 -0
- package/dist/chunk-ZNIXVHZT.mjs +24 -0
- package/dist/color.mjs +85 -0
- package/dist/console/enableConsole.mjs +9 -0
- package/dist/console/index.mjs +14 -0
- package/dist/console/log.mjs +19 -0
- package/dist/createDir-220e0081.d.ts +13 -0
- package/dist/device/browser.mjs +15 -0
- package/dist/device/camera.mjs +8 -0
- package/dist/device/index.mjs +15 -0
- package/dist/device/os.mjs +33 -0
- package/dist/enableConsole-ddc24282.d.ts +11 -0
- package/dist/file/createDir.mjs +7 -0
- package/dist/file/fileMove.mjs +7 -0
- package/dist/file/findFilesByExt.mjs +11 -0
- package/dist/file/index.mjs +17 -0
- package/dist/fileMove-3a09e429.d.ts +13 -0
- package/dist/findFilesByExt-753e91d7.d.ts +24 -0
- package/dist/gameboi/index.d.ts +2 -0
- package/dist/gameboi/index.js +5 -0
- package/dist/gameboi/index.js.map +1 -1
- package/dist/gameboi/index.mjs +65 -0
- package/dist/images/downloadByUrl.mjs +53 -0
- package/dist/images/index.mjs +14 -0
- package/dist/images/loadImage.js +1 -1
- package/dist/images/loadImage.js.map +1 -1
- package/dist/images/loadImage.mjs +21 -0
- package/dist/images/resize.mjs +9 -0
- package/dist/images/upload.mjs +13 -0
- package/dist/index-1e114d55.d.ts +26 -0
- package/dist/index-1f738e52.d.ts +22 -0
- package/dist/index-22309f0c.d.ts +23 -0
- package/dist/index-3eeb7834.d.ts +90 -0
- package/dist/index-6ae3c86b.d.ts +63 -0
- package/dist/index.mjs +87 -0
- package/dist/json.mjs +29 -0
- package/dist/math/diffDate.mjs +9 -0
- package/dist/math/index.mjs +34 -0
- package/dist/math/positiveNumber.mjs +10 -0
- package/dist/name/en.mjs +9 -0
- package/dist/name/index.mjs +20 -0
- package/dist/name/vi.mjs +14 -0
- package/dist/object-43aaaf92.d.ts +80 -0
- package/dist/object.mjs +21 -0
- package/dist/permission/index.mjs +15 -0
- package/dist/permission/requestCamera.mjs +9 -0
- package/dist/permission/requestDeviceOrientationControl.mjs +10 -0
- package/dist/requestCamera-32b7dfc7.d.ts +14 -0
- package/dist/requestDeviceOrientationControl-b6458660.d.ts +11 -0
- package/dist/response/index.mjs +16 -0
- package/dist/string/convertPathnameAndQuery.mjs +28 -0
- package/dist/string/formatNumber.mjs +10 -0
- package/dist/string/generatePassword.mjs +10 -0
- package/dist/string/generateUUID.mjs +9 -0
- package/dist/string/getTextBetweenCharByIndex.mjs +22 -0
- package/dist/string/index.mjs +31 -0
- package/dist/string/indexesOf.mjs +7 -0
- package/dist/string/makeDaySlug.mjs +9 -0
- package/dist/string/random.mjs +23 -0
- package/dist/string/trimNull.mjs +9 -0
- package/dist/string/url.mjs +21 -0
- package/dist/url-0da0be84.d.ts +43 -0
- package/esm/gameboi/index.d.ts +2 -0
- package/esm/gameboi/index.js +5 -0
- package/esm/gameboi/index.js.map +1 -1
- package/esm/images/loadImage.js +1 -1
- package/esm/images/loadImage.js.map +1 -1
- package/package.json +6 -2
package/README.md
CHANGED
|
@@ -1,162 +1,162 @@
|
|
|
1
|
-
# The library of utility plugins
|
|
2
|
-
|
|
3
|
-
## Exports
|
|
4
|
-
|
|
5
|
-
- "diginext-utils/dist": ES6 modules / NodeJS
|
|
6
|
-
- "diginext-utils/esm": Node modules / JavaScript modules
|
|
7
|
-
|
|
8
|
-
## Imports
|
|
9
|
-
|
|
10
|
-
### ES5 module import:
|
|
11
|
-
|
|
12
|
-
```javascript
|
|
13
|
-
import utils from "diginext-utils";
|
|
14
|
-
console.log(utils.xname.NameEN.generateName()); // output some random name in English
|
|
15
|
-
|
|
16
|
-
// or
|
|
17
|
-
|
|
18
|
-
import { NameEN } from "diginext-utils/dist/name";
|
|
19
|
-
console.log(NameEN.generateName()); // output some random name in English
|
|
20
|
-
|
|
21
|
-
// or just
|
|
22
|
-
import { generateName } from "diginext-utils/dist/name/en";
|
|
23
|
-
console.log(generateName()); // output some random name in English
|
|
24
|
-
|
|
25
|
-
// or with require(...)
|
|
26
|
-
const xurl = require("../dist/string/url");
|
|
27
|
-
xurl.isLink("abc"); // FALSE
|
|
28
|
-
xurl.isLink("https://www.google.com"); // TRUE
|
|
29
|
-
```
|
|
30
|
-
|
|
31
|
-
### Node module import:
|
|
32
|
-
|
|
33
|
-
**IMPORTANT**: Set "type" as "module" your `package.json`
|
|
34
|
-
|
|
35
|
-
```javascript
|
|
36
|
-
// NodeJS moduies
|
|
37
|
-
import utils from "diginext-utils";
|
|
38
|
-
console.log(utils.xname.NameEN.generateName()); // output some random name in English
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
```html
|
|
42
|
-
// browser
|
|
43
|
-
<script type="module">
|
|
44
|
-
import { NameEN } from "diginext-utils/esm/name/index.js"; // ".js" file extension is required !
|
|
45
|
-
console.log(NameEN.generateName()); // output some random name in English
|
|
46
|
-
</script>
|
|
47
|
-
```
|
|
48
|
-
|
|
49
|
-
## Features
|
|
50
|
-
|
|
51
|
-
- xconsole
|
|
52
|
-
- xarray
|
|
53
|
-
- sumArray
|
|
54
|
-
- averageArray
|
|
55
|
-
- minArray
|
|
56
|
-
- maxArray
|
|
57
|
-
- sortElementByString
|
|
58
|
-
- sortElementByNumber
|
|
59
|
-
- firstElement
|
|
60
|
-
- lastElement
|
|
61
|
-
- randomIndex
|
|
62
|
-
- randomElement
|
|
63
|
-
- mergeAndMakeUniqueElement
|
|
64
|
-
- allMatchInArray
|
|
65
|
-
- removeItem
|
|
66
|
-
- removeItemByKey
|
|
67
|
-
- getRandom
|
|
68
|
-
- getHalfRandom
|
|
69
|
-
- shuffle
|
|
70
|
-
- moveIndex
|
|
71
|
-
- moveArray
|
|
72
|
-
- xmath
|
|
73
|
-
- rand
|
|
74
|
-
- randRound
|
|
75
|
-
- randHalt
|
|
76
|
-
- randInt
|
|
77
|
-
- randFloat
|
|
78
|
-
- degToRad
|
|
79
|
-
- radToDeg
|
|
80
|
-
- angleBetweenPoints
|
|
81
|
-
- diffDate
|
|
82
|
-
- positiveNumber
|
|
83
|
-
- xname
|
|
84
|
-
- NameEN.generateName()
|
|
85
|
-
- NameVI.generateName()
|
|
86
|
-
- xobject
|
|
87
|
-
- isNull
|
|
88
|
-
- toBool
|
|
89
|
-
- toInt
|
|
90
|
-
- toFloat
|
|
91
|
-
- toArray
|
|
92
|
-
- objectToArray
|
|
93
|
-
- xjson
|
|
94
|
-
- isValid
|
|
95
|
-
- xfile
|
|
96
|
-
- createDir
|
|
97
|
-
- fileMove
|
|
98
|
-
- findFileByExt
|
|
99
|
-
- xstring
|
|
100
|
-
- getBetween
|
|
101
|
-
- makeString
|
|
102
|
-
- toUpperCase
|
|
103
|
-
- toLowerCase
|
|
104
|
-
- titleize
|
|
105
|
-
- capitalize
|
|
106
|
-
- capitalizeName
|
|
107
|
-
- clearUnicodeCharacters
|
|
108
|
-
- generateUUID
|
|
109
|
-
- randAllCharacterByLength
|
|
110
|
-
- randomStringByLength
|
|
111
|
-
- formatNumber
|
|
112
|
-
- generatePassword
|
|
113
|
-
- trimNull
|
|
114
|
-
- addQueryParam
|
|
115
|
-
- getUrlParams
|
|
116
|
-
- isLink
|
|
117
|
-
- getFileNameWithoutExtension
|
|
118
|
-
- getFileNameWithExtension
|
|
119
|
-
- getFileExtension
|
|
120
|
-
- isImage
|
|
121
|
-
- xurl
|
|
122
|
-
- addQueryParam
|
|
123
|
-
- getUrlParams
|
|
124
|
-
- isLink
|
|
125
|
-
- getFileNameWithoutExtension
|
|
126
|
-
- getFileNameWithExtension
|
|
127
|
-
- getFileExtension
|
|
128
|
-
- isImage
|
|
129
|
-
- slug
|
|
130
|
-
- makeSlug
|
|
131
|
-
- color
|
|
132
|
-
- random
|
|
133
|
-
- pSBC
|
|
134
|
-
- hexToRgb
|
|
135
|
-
- hexDarken
|
|
136
|
-
- hexLighten
|
|
137
|
-
- RGBToHex
|
|
138
|
-
- device
|
|
139
|
-
- camera
|
|
140
|
-
- requestCamera
|
|
141
|
-
- requestDeviceOrientationControl
|
|
142
|
-
- browser
|
|
143
|
-
- isPotrait
|
|
144
|
-
- isLandscape
|
|
145
|
-
- ua
|
|
146
|
-
- isFacebookWebview
|
|
147
|
-
- isInAppWebview
|
|
148
|
-
- Timer
|
|
149
|
-
- wait
|
|
150
|
-
- Validation
|
|
151
|
-
- imageValidate
|
|
152
|
-
- videoValidate
|
|
153
|
-
|
|
154
|
-
## Dev
|
|
155
|
-
|
|
156
|
-
```
|
|
157
|
-
yarn dev
|
|
158
|
-
```
|
|
159
|
-
|
|
160
|
-
## Support
|
|
161
|
-
|
|
162
|
-
Liên hệ [TOP GROUP Developers](mailto:dev@wearetopgroup.com) nếu cần hỗ trợ.
|
|
1
|
+
# The library of utility plugins
|
|
2
|
+
|
|
3
|
+
## Exports
|
|
4
|
+
|
|
5
|
+
- "diginext-utils/dist": ES6 modules / NodeJS
|
|
6
|
+
- "diginext-utils/esm": Node modules / JavaScript modules
|
|
7
|
+
|
|
8
|
+
## Imports
|
|
9
|
+
|
|
10
|
+
### ES5 module import:
|
|
11
|
+
|
|
12
|
+
```javascript
|
|
13
|
+
import utils from "diginext-utils";
|
|
14
|
+
console.log(utils.xname.NameEN.generateName()); // output some random name in English
|
|
15
|
+
|
|
16
|
+
// or
|
|
17
|
+
|
|
18
|
+
import { NameEN } from "diginext-utils/dist/name";
|
|
19
|
+
console.log(NameEN.generateName()); // output some random name in English
|
|
20
|
+
|
|
21
|
+
// or just
|
|
22
|
+
import { generateName } from "diginext-utils/dist/name/en";
|
|
23
|
+
console.log(generateName()); // output some random name in English
|
|
24
|
+
|
|
25
|
+
// or with require(...)
|
|
26
|
+
const xurl = require("../dist/string/url");
|
|
27
|
+
xurl.isLink("abc"); // FALSE
|
|
28
|
+
xurl.isLink("https://www.google.com"); // TRUE
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
### Node module import:
|
|
32
|
+
|
|
33
|
+
**IMPORTANT**: Set "type" as "module" your `package.json`
|
|
34
|
+
|
|
35
|
+
```javascript
|
|
36
|
+
// NodeJS moduies
|
|
37
|
+
import utils from "diginext-utils";
|
|
38
|
+
console.log(utils.xname.NameEN.generateName()); // output some random name in English
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
```html
|
|
42
|
+
// browser
|
|
43
|
+
<script type="module">
|
|
44
|
+
import { NameEN } from "diginext-utils/esm/name/index.js"; // ".js" file extension is required !
|
|
45
|
+
console.log(NameEN.generateName()); // output some random name in English
|
|
46
|
+
</script>
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Features
|
|
50
|
+
|
|
51
|
+
- xconsole
|
|
52
|
+
- xarray
|
|
53
|
+
- sumArray
|
|
54
|
+
- averageArray
|
|
55
|
+
- minArray
|
|
56
|
+
- maxArray
|
|
57
|
+
- sortElementByString
|
|
58
|
+
- sortElementByNumber
|
|
59
|
+
- firstElement
|
|
60
|
+
- lastElement
|
|
61
|
+
- randomIndex
|
|
62
|
+
- randomElement
|
|
63
|
+
- mergeAndMakeUniqueElement
|
|
64
|
+
- allMatchInArray
|
|
65
|
+
- removeItem
|
|
66
|
+
- removeItemByKey
|
|
67
|
+
- getRandom
|
|
68
|
+
- getHalfRandom
|
|
69
|
+
- shuffle
|
|
70
|
+
- moveIndex
|
|
71
|
+
- moveArray
|
|
72
|
+
- xmath
|
|
73
|
+
- rand
|
|
74
|
+
- randRound
|
|
75
|
+
- randHalt
|
|
76
|
+
- randInt
|
|
77
|
+
- randFloat
|
|
78
|
+
- degToRad
|
|
79
|
+
- radToDeg
|
|
80
|
+
- angleBetweenPoints
|
|
81
|
+
- diffDate
|
|
82
|
+
- positiveNumber
|
|
83
|
+
- xname
|
|
84
|
+
- NameEN.generateName()
|
|
85
|
+
- NameVI.generateName()
|
|
86
|
+
- xobject
|
|
87
|
+
- isNull
|
|
88
|
+
- toBool
|
|
89
|
+
- toInt
|
|
90
|
+
- toFloat
|
|
91
|
+
- toArray
|
|
92
|
+
- objectToArray
|
|
93
|
+
- xjson
|
|
94
|
+
- isValid
|
|
95
|
+
- xfile
|
|
96
|
+
- createDir
|
|
97
|
+
- fileMove
|
|
98
|
+
- findFileByExt
|
|
99
|
+
- xstring
|
|
100
|
+
- getBetween
|
|
101
|
+
- makeString
|
|
102
|
+
- toUpperCase
|
|
103
|
+
- toLowerCase
|
|
104
|
+
- titleize
|
|
105
|
+
- capitalize
|
|
106
|
+
- capitalizeName
|
|
107
|
+
- clearUnicodeCharacters
|
|
108
|
+
- generateUUID
|
|
109
|
+
- randAllCharacterByLength
|
|
110
|
+
- randomStringByLength
|
|
111
|
+
- formatNumber
|
|
112
|
+
- generatePassword
|
|
113
|
+
- trimNull
|
|
114
|
+
- addQueryParam
|
|
115
|
+
- getUrlParams
|
|
116
|
+
- isLink
|
|
117
|
+
- getFileNameWithoutExtension
|
|
118
|
+
- getFileNameWithExtension
|
|
119
|
+
- getFileExtension
|
|
120
|
+
- isImage
|
|
121
|
+
- xurl
|
|
122
|
+
- addQueryParam
|
|
123
|
+
- getUrlParams
|
|
124
|
+
- isLink
|
|
125
|
+
- getFileNameWithoutExtension
|
|
126
|
+
- getFileNameWithExtension
|
|
127
|
+
- getFileExtension
|
|
128
|
+
- isImage
|
|
129
|
+
- slug
|
|
130
|
+
- makeSlug
|
|
131
|
+
- color
|
|
132
|
+
- random
|
|
133
|
+
- pSBC
|
|
134
|
+
- hexToRgb
|
|
135
|
+
- hexDarken
|
|
136
|
+
- hexLighten
|
|
137
|
+
- RGBToHex
|
|
138
|
+
- device
|
|
139
|
+
- camera
|
|
140
|
+
- requestCamera
|
|
141
|
+
- requestDeviceOrientationControl
|
|
142
|
+
- browser
|
|
143
|
+
- isPotrait
|
|
144
|
+
- isLandscape
|
|
145
|
+
- ua
|
|
146
|
+
- isFacebookWebview
|
|
147
|
+
- isInAppWebview
|
|
148
|
+
- Timer
|
|
149
|
+
- wait
|
|
150
|
+
- Validation
|
|
151
|
+
- imageValidate
|
|
152
|
+
- videoValidate
|
|
153
|
+
|
|
154
|
+
## Dev
|
|
155
|
+
|
|
156
|
+
```
|
|
157
|
+
yarn dev
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
## Support
|
|
161
|
+
|
|
162
|
+
Liên hệ [TOP GROUP Developers](mailto:dev@wearetopgroup.com) nếu cần hỗ trợ.
|
package/dist/Checker.mjs
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import "./chunk-4VQ25N7H.mjs";
|
|
2
|
+
|
|
3
|
+
// src/Checker.ts
|
|
4
|
+
var isJSON = (content) => {
|
|
5
|
+
if (typeof content == "object") {
|
|
6
|
+
try {
|
|
7
|
+
content = JSON.stringify(content);
|
|
8
|
+
} catch (err) {
|
|
9
|
+
return false;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
if (typeof content == "string") {
|
|
13
|
+
try {
|
|
14
|
+
content = JSON.parse(content);
|
|
15
|
+
} catch (err) {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
if (typeof content != "object") {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
return true;
|
|
23
|
+
};
|
|
24
|
+
var Checker = { isJSON };
|
|
25
|
+
var Checker_default = Checker;
|
|
26
|
+
export {
|
|
27
|
+
Checker_default as default,
|
|
28
|
+
isJSON
|
|
29
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import "./chunk-4VQ25N7H.mjs";
|
|
2
|
+
|
|
3
|
+
// src/EventDispatcher.ts
|
|
4
|
+
var EventDispatcher = class {
|
|
5
|
+
constructor() {
|
|
6
|
+
}
|
|
7
|
+
addEventListener(type, listener) {
|
|
8
|
+
if (this._listeners === void 0)
|
|
9
|
+
this._listeners = {};
|
|
10
|
+
const listeners = this._listeners;
|
|
11
|
+
if (listeners[type] === void 0) {
|
|
12
|
+
listeners[type] = [];
|
|
13
|
+
}
|
|
14
|
+
if (listeners[type].indexOf(listener) === -1) {
|
|
15
|
+
listeners[type].push(listener);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
hasEventListener(type, listener) {
|
|
19
|
+
if (this._listeners === void 0)
|
|
20
|
+
return false;
|
|
21
|
+
const listeners = this._listeners;
|
|
22
|
+
return listeners[type] !== void 0 && listeners[type].indexOf(listener) !== -1;
|
|
23
|
+
}
|
|
24
|
+
removeEventListener(type, listener) {
|
|
25
|
+
if (this._listeners === void 0)
|
|
26
|
+
return;
|
|
27
|
+
const listeners = this._listeners;
|
|
28
|
+
const listenerArray = listeners[type];
|
|
29
|
+
if (listenerArray !== void 0) {
|
|
30
|
+
const index = listenerArray.indexOf(listener);
|
|
31
|
+
if (index !== -1) {
|
|
32
|
+
listenerArray.splice(index, 1);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
dispatchEvent(event) {
|
|
37
|
+
if (this._listeners === void 0)
|
|
38
|
+
return;
|
|
39
|
+
const listeners = this._listeners;
|
|
40
|
+
const listenerArray = listeners[event.type];
|
|
41
|
+
if (listenerArray !== void 0) {
|
|
42
|
+
event.target = this;
|
|
43
|
+
const array = listenerArray.slice(0);
|
|
44
|
+
for (let i = 0, l = array.length; i < l; i++) {
|
|
45
|
+
array[i].call(this, event);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
var EventDispatcher_default = EventDispatcher;
|
|
51
|
+
export {
|
|
52
|
+
EventDispatcher,
|
|
53
|
+
EventDispatcher_default as default
|
|
54
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import "./chunk-4VQ25N7H.mjs";
|
|
2
|
+
|
|
3
|
+
// src/FileUpload.ts
|
|
4
|
+
var logFile = "[FileUpload.js] ";
|
|
5
|
+
var FileUpload = {
|
|
6
|
+
uploadBlob(props) {
|
|
7
|
+
const { blob, url, params, onComplete, onError } = props;
|
|
8
|
+
var formData = new FormData();
|
|
9
|
+
formData.append("upload", blob, "img_" + +/* @__PURE__ */ new Date() + ".jpg");
|
|
10
|
+
if (params) {
|
|
11
|
+
Object.keys(params).forEach((key) => {
|
|
12
|
+
var val = params[key];
|
|
13
|
+
formData.append(key, val);
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
var request = new XMLHttpRequest();
|
|
17
|
+
request.open("POST", url);
|
|
18
|
+
request.send(formData);
|
|
19
|
+
request.onreadystatechange = function() {
|
|
20
|
+
if (this.readyState == 4) {
|
|
21
|
+
if (this.status == 200) {
|
|
22
|
+
var response = {};
|
|
23
|
+
try {
|
|
24
|
+
response = JSON.parse(request.response) || "";
|
|
25
|
+
} catch (error) {
|
|
26
|
+
console.error(logFile, "Can't part JSON of the response");
|
|
27
|
+
}
|
|
28
|
+
var statusOfSafety = response.status || 0;
|
|
29
|
+
if (statusOfSafety == 1) {
|
|
30
|
+
console.log(logFile, "request: ", request);
|
|
31
|
+
var data = response.data || {};
|
|
32
|
+
console.log(logFile, data);
|
|
33
|
+
var _url = data["url"];
|
|
34
|
+
if (onComplete)
|
|
35
|
+
onComplete(_url);
|
|
36
|
+
} else {
|
|
37
|
+
var errMsg = "\u1EA2nh c\xF3 n\u1ED9i dung kh\xF4ng ph\xF9 h\u1EE3p.";
|
|
38
|
+
console.error(logFile, errMsg);
|
|
39
|
+
if (onError)
|
|
40
|
+
onError(errMsg);
|
|
41
|
+
}
|
|
42
|
+
} else {
|
|
43
|
+
var errMsg = "Upload \u1EA3nh kh\xF4ng th\xE0nh c\xF4ng!";
|
|
44
|
+
console.error(logFile, errMsg);
|
|
45
|
+
if (onError)
|
|
46
|
+
onError(errMsg);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
request.onerror = function(res) {
|
|
51
|
+
var errMsg = "Upload \u1EA3nh kh\xF4ng th\xE0nh c\xF4ng!";
|
|
52
|
+
console.error(logFile, errMsg, "=>", res);
|
|
53
|
+
if (onError)
|
|
54
|
+
onError(errMsg);
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
var FileUpload_default = FileUpload;
|
|
59
|
+
export {
|
|
60
|
+
FileUpload,
|
|
61
|
+
FileUpload_default as default
|
|
62
|
+
};
|
package/dist/Slug.mjs
ADDED
package/dist/Timer.mjs
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import "./chunk-4VQ25N7H.mjs";
|
|
2
|
+
|
|
3
|
+
// src/Validation.ts
|
|
4
|
+
var Validation = {
|
|
5
|
+
imageValidate(file) {
|
|
6
|
+
var maxSize = 10;
|
|
7
|
+
var fileSize = 1024 * 1024 * maxSize;
|
|
8
|
+
var fileTypes = ["image/png", "image/jpeg"];
|
|
9
|
+
if (!file || fileTypes.indexOf(file.type) < 0) {
|
|
10
|
+
alert("Vui l\xF2ng upload \u1EA3nh \u0111\xFAng \u0111\u1ECBnh d\u1EA1ng jpg hay png");
|
|
11
|
+
return false;
|
|
12
|
+
} else if (file.size > fileSize) {
|
|
13
|
+
alert("Vui l\xF2ng upload \u1EA3nh c\xF3 dung l\u01B0\u1EE3ng th\u1EA5p h\u01A1n " + maxSize + "mb");
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
return true;
|
|
17
|
+
},
|
|
18
|
+
videoValidate(file) {
|
|
19
|
+
var maxSize = 15;
|
|
20
|
+
var fileSize = 1024 * 1024 * maxSize;
|
|
21
|
+
var fileTypes = "video";
|
|
22
|
+
if (!file || file.type.indexOf(fileTypes) < 0) {
|
|
23
|
+
alert("Vui l\xF2ng upload video");
|
|
24
|
+
return false;
|
|
25
|
+
} else if (file.size > fileSize) {
|
|
26
|
+
alert("Vui l\xF2ng upload video c\xF3 dung l\u01B0\u1EE3ng th\u1EA5p h\u01A1n " + maxSize + "mb");
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
var Validation_default = Validation;
|
|
33
|
+
export {
|
|
34
|
+
Validation_default as default
|
|
35
|
+
};
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
declare const sumArray: (array: [], key: string) => number;
|
|
2
|
+
/**
|
|
3
|
+
*
|
|
4
|
+
* @param {Array} array
|
|
5
|
+
* @param {string} key
|
|
6
|
+
* @returns {Number}
|
|
7
|
+
*/
|
|
8
|
+
declare const averageArray: (array: [], key: string) => number;
|
|
9
|
+
/**
|
|
10
|
+
*
|
|
11
|
+
* @param {Array} array
|
|
12
|
+
* @param {string} key
|
|
13
|
+
* @returns {Number}
|
|
14
|
+
*/
|
|
15
|
+
declare const minArray: (array: [], key: string) => number;
|
|
16
|
+
/**
|
|
17
|
+
*
|
|
18
|
+
* @param {Array} array
|
|
19
|
+
* @param {string} key
|
|
20
|
+
* @returns {Number}
|
|
21
|
+
*/
|
|
22
|
+
declare const maxArray: (array: [], key: string) => number;
|
|
23
|
+
/**
|
|
24
|
+
*
|
|
25
|
+
* @param {Array} array
|
|
26
|
+
* @param {string} key
|
|
27
|
+
* @returns {Array}
|
|
28
|
+
*/
|
|
29
|
+
declare const sortElementByString: (array: any, key: string) => any[] | undefined;
|
|
30
|
+
/**
|
|
31
|
+
*
|
|
32
|
+
* @param {Array} array
|
|
33
|
+
* @param {string} key
|
|
34
|
+
* @returns {Array}
|
|
35
|
+
*/
|
|
36
|
+
declare const sortElementByNumber: (array: any, key: string) => any[] | undefined;
|
|
37
|
+
/**
|
|
38
|
+
*
|
|
39
|
+
* @param {Array} array
|
|
40
|
+
* @returns {any}
|
|
41
|
+
*/
|
|
42
|
+
declare const firstElement: (array: any[]) => any;
|
|
43
|
+
/**
|
|
44
|
+
*
|
|
45
|
+
* @param {Array} array
|
|
46
|
+
* @returns {any}
|
|
47
|
+
*/
|
|
48
|
+
declare const lastElement: (array: any[]) => any;
|
|
49
|
+
/**
|
|
50
|
+
*
|
|
51
|
+
* @param {Array} array
|
|
52
|
+
* @returns {any}
|
|
53
|
+
*/
|
|
54
|
+
declare const randomIndex: (array: any[]) => number;
|
|
55
|
+
/**
|
|
56
|
+
*
|
|
57
|
+
* @param {Array} array
|
|
58
|
+
* @returns {any}
|
|
59
|
+
*/
|
|
60
|
+
declare const randomElement: (array: any[]) => any;
|
|
61
|
+
/**
|
|
62
|
+
* Remove same elements from 2 arrays
|
|
63
|
+
*/
|
|
64
|
+
declare const mergeAndMakeUniqueElement: (list1: any[], list2: any[], key: string) => any[] | undefined;
|
|
65
|
+
/**
|
|
66
|
+
* check target == toMatch
|
|
67
|
+
* @param {Array} target
|
|
68
|
+
* @param {Array} toMatch
|
|
69
|
+
* @returns {Boolean}
|
|
70
|
+
*/
|
|
71
|
+
declare const allMatchInArray: (target: any[], toMatch: any[]) => boolean;
|
|
72
|
+
declare const removeItem: (item: any, array: any[]) => any[];
|
|
73
|
+
declare const removeItemByKey: (key: string, value: any, array: any[]) => any[];
|
|
74
|
+
declare const getRandom: (array: any[], n?: number) => any[];
|
|
75
|
+
/**
|
|
76
|
+
* Get an array with shuffle element
|
|
77
|
+
*/
|
|
78
|
+
declare const getHalfRandom: (array: any[], n: number) => any[];
|
|
79
|
+
/**
|
|
80
|
+
* Make array shuffle itself
|
|
81
|
+
*/
|
|
82
|
+
declare const shuffle: (array: any[]) => any[];
|
|
83
|
+
/**
|
|
84
|
+
*
|
|
85
|
+
* @param {Array} array
|
|
86
|
+
* @param {Number} oldIndex
|
|
87
|
+
* @param {Number} newIndex
|
|
88
|
+
* @returns {Array}
|
|
89
|
+
*/
|
|
90
|
+
declare const moveIndex: (array: any[], oldIndex: number, newIndex: number) => any[];
|
|
91
|
+
declare const moveArray: (array: any[], oldIndex: number, newIndex: number) => any[];
|
|
92
|
+
declare const xarray: {
|
|
93
|
+
sumArray: (array: [], key: string) => number;
|
|
94
|
+
averageArray: (array: [], key: string) => number;
|
|
95
|
+
minArray: (array: [], key: string) => number;
|
|
96
|
+
maxArray: (array: [], key: string) => number;
|
|
97
|
+
sortElementByString: (array: any, key: string) => any[] | undefined;
|
|
98
|
+
sortElementByNumber: (array: any, key: string) => any[] | undefined;
|
|
99
|
+
firstElement: (array: any[]) => any;
|
|
100
|
+
lastElement: (array: any[]) => any;
|
|
101
|
+
randomIndex: (array: any[]) => number;
|
|
102
|
+
randomElement: (array: any[]) => any;
|
|
103
|
+
mergeAndMakeUniqueElement: (list1: any[], list2: any[], key: string) => any[] | undefined;
|
|
104
|
+
allMatchInArray: (target: any[], toMatch: any[]) => boolean;
|
|
105
|
+
removeItem: (item: any, array: any[]) => any[];
|
|
106
|
+
removeItemByKey: (key: string, value: any, array: any[]) => any[];
|
|
107
|
+
getRandom: (array: any[], n?: number) => any[];
|
|
108
|
+
getHalfRandom: (array: any[], n: number) => any[];
|
|
109
|
+
shuffle: (array: any[]) => any[];
|
|
110
|
+
moveIndex: (array: any[], oldIndex: number, newIndex: number) => any[];
|
|
111
|
+
moveArray: (array: any[], oldIndex: number, newIndex: number) => any[];
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
declare const array_allMatchInArray: typeof allMatchInArray;
|
|
115
|
+
declare const array_averageArray: typeof averageArray;
|
|
116
|
+
declare const array_firstElement: typeof firstElement;
|
|
117
|
+
declare const array_getHalfRandom: typeof getHalfRandom;
|
|
118
|
+
declare const array_getRandom: typeof getRandom;
|
|
119
|
+
declare const array_lastElement: typeof lastElement;
|
|
120
|
+
declare const array_maxArray: typeof maxArray;
|
|
121
|
+
declare const array_mergeAndMakeUniqueElement: typeof mergeAndMakeUniqueElement;
|
|
122
|
+
declare const array_minArray: typeof minArray;
|
|
123
|
+
declare const array_moveArray: typeof moveArray;
|
|
124
|
+
declare const array_moveIndex: typeof moveIndex;
|
|
125
|
+
declare const array_randomElement: typeof randomElement;
|
|
126
|
+
declare const array_randomIndex: typeof randomIndex;
|
|
127
|
+
declare const array_removeItem: typeof removeItem;
|
|
128
|
+
declare const array_removeItemByKey: typeof removeItemByKey;
|
|
129
|
+
declare const array_shuffle: typeof shuffle;
|
|
130
|
+
declare const array_sortElementByNumber: typeof sortElementByNumber;
|
|
131
|
+
declare const array_sortElementByString: typeof sortElementByString;
|
|
132
|
+
declare const array_sumArray: typeof sumArray;
|
|
133
|
+
declare namespace array {
|
|
134
|
+
export {
|
|
135
|
+
array_allMatchInArray as allMatchInArray,
|
|
136
|
+
array_averageArray as averageArray,
|
|
137
|
+
xarray as default,
|
|
138
|
+
array_firstElement as firstElement,
|
|
139
|
+
array_getHalfRandom as getHalfRandom,
|
|
140
|
+
array_getRandom as getRandom,
|
|
141
|
+
array_lastElement as lastElement,
|
|
142
|
+
array_maxArray as maxArray,
|
|
143
|
+
array_mergeAndMakeUniqueElement as mergeAndMakeUniqueElement,
|
|
144
|
+
array_minArray as minArray,
|
|
145
|
+
array_moveArray as moveArray,
|
|
146
|
+
array_moveIndex as moveIndex,
|
|
147
|
+
array_randomElement as randomElement,
|
|
148
|
+
array_randomIndex as randomIndex,
|
|
149
|
+
array_removeItem as removeItem,
|
|
150
|
+
array_removeItemByKey as removeItemByKey,
|
|
151
|
+
array_shuffle as shuffle,
|
|
152
|
+
array_sortElementByNumber as sortElementByNumber,
|
|
153
|
+
array_sortElementByString as sortElementByString,
|
|
154
|
+
array_sumArray as sumArray,
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
export { array as a, averageArray as b, maxArray as c, sortElementByString as d, sortElementByNumber as e, firstElement as f, randomElement as g, mergeAndMakeUniqueElement as h, allMatchInArray as i, removeItem as j, removeItemByKey as k, lastElement as l, minArray as m, getRandom as n, getHalfRandom as o, shuffle as p, moveIndex as q, randomIndex as r, sumArray as s, moveArray as t, xarray as x };
|