dphelper 0.2.2 → 0.2.21
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 +112 -13
- package/README.md.bak +70 -0
- package/init.js +114 -112
- package/package.json +17 -2
- package/scripts/{arrayDeleteItem.js → .OLD/arrayDeleteItem.js} +0 -0
- package/scripts/{arrayItemFinder.js → .OLD/arrayItemFinder.js} +0 -0
- package/scripts/{arrayMerge.js → .OLD/arrayMerge.js} +0 -0
- package/scripts/.OLD/arrayUnique.js +15 -0
- package/scripts/anchorToOnClick.js +36 -36
- package/scripts/array.js +69 -0
- package/scripts/currency.js +21 -21
- package/scripts/object2array.js +16 -18
- package/scripts/randomNum.js +14 -14
package/README.md
CHANGED
|
@@ -1,13 +1,112 @@
|
|
|
1
|
-
# dpHelper
|
|
2
|
-
|
|
3
|
-
Many utils for your projects
|
|
4
|
-
|
|
5
|
-
Use "npm i dphelper" to install
|
|
6
|
-
|
|
7
|
-
in the index:
|
|
8
|
-
|
|
9
|
-
```js
|
|
10
|
-
import "dphelper"
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
type 'dphelper' in your console to have a look about all available functions that you can use globaly!
|
|
1
|
+
# dpHelper
|
|
2
|
+
|
|
3
|
+
Many utils for your projects
|
|
4
|
+
|
|
5
|
+
Use "npm i dphelper" to install
|
|
6
|
+
|
|
7
|
+
in the index:
|
|
8
|
+
|
|
9
|
+
```js
|
|
10
|
+
import "dphelper"
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
type 'dphelper' in your console to have a look about all available functions that you can use globaly!
|
|
14
|
+
|
|
15
|
+
You can call these from everywhere without import
|
|
16
|
+
|
|
17
|
+
## CURRENCY
|
|
18
|
+
|
|
19
|
+
```js
|
|
20
|
+
dphelper.currency( val, int = 'en-US', cur = 'USD' )
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## OPTIONS
|
|
24
|
+
|
|
25
|
+
### MEMORY / STORAGE
|
|
26
|
+
|
|
27
|
+
```js
|
|
28
|
+
dphelper.storage.get( name )
|
|
29
|
+
dphelper.storage.set( name , value )
|
|
30
|
+
dphelper.storage.delete( name )
|
|
31
|
+
dphelper.storage.clearAll()
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### MEMORY / COOKIE
|
|
35
|
+
|
|
36
|
+
```js
|
|
37
|
+
dphelper.cookie.set( name , value , time , path = '/' )
|
|
38
|
+
dphelper.cookie.get( name )
|
|
39
|
+
dphelper.cookie.delete( name )
|
|
40
|
+
dphelper.cookie.clearAll()
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### MEMORY / INDEXED-DB
|
|
44
|
+
|
|
45
|
+
```js
|
|
46
|
+
dphelper.indexedDB.create( storeName, table, name )
|
|
47
|
+
dphelper.indexedDB.open( storeName )
|
|
48
|
+
dphelper.indexedDB.store( storeName, table )
|
|
49
|
+
dphelper.indexedDB.insert( storeName, table, key, value )
|
|
50
|
+
dphelper.indexedDB.update( storeName, table, key, value )
|
|
51
|
+
dphelper.indexedDB.get( storeName, table, key )
|
|
52
|
+
|
|
53
|
+
window.dphelper.dbExist() -> know databases
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### NUMBERS
|
|
57
|
+
|
|
58
|
+
```js
|
|
59
|
+
dphelper.rnd() // generate long random number
|
|
60
|
+
dphelper.tmr() // generate number by timer
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### DATE / TIME
|
|
64
|
+
|
|
65
|
+
```js
|
|
66
|
+
dphelper.epoch() // return epoch time
|
|
67
|
+
dphelper.parseDate( value ) // epoch to human date
|
|
68
|
+
dphelper.dateUTC() // generate UTC date format
|
|
69
|
+
dphelper.dateIso2Epoch( value ) // transform human date to epoch
|
|
70
|
+
dphelper.dateConvert( value , format ) // format like 23 Dec, 2021
|
|
71
|
+
dphelper.date2MMDDYYYY( value ) // format like 12312021
|
|
72
|
+
dphelper.date2Iso( value , int = 'en' ) // format in bese of internationalization
|
|
73
|
+
dphelper.localISOTime( value ) // format Thu, 31 May 2012 08:33:41 +0000
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
### PATH RAILS
|
|
77
|
+
|
|
78
|
+
```js
|
|
79
|
+
dphelper.pathRail() // Generate array start from subFolders
|
|
80
|
+
dphelper.pathQuery() // Generate array start from querystring
|
|
81
|
+
dphelper.pathHash() // Generate array start from hash path
|
|
82
|
+
dphelper.pushState(state, title, url) // Create a new spushState and avoid page reload
|
|
83
|
+
dphelper.anchorToOnClick( container ) // Transform all a href to onclick (use . for class or # for div )
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### FILE
|
|
87
|
+
|
|
88
|
+
```js
|
|
89
|
+
dphelper.loadFile(element, path) // text to element
|
|
90
|
+
dphelper.loadJson( file ) // load json data to a variable
|
|
91
|
+
dphelper.loadJsonExternal( path, method='GET', type='application/json' ) // load json from remote to variable
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### FORM
|
|
95
|
+
|
|
96
|
+
```js
|
|
97
|
+
dphelper.serializeForm( form ) // serialize a form (input array) to json
|
|
98
|
+
dphelper.objSerialize(value) // serialize object to json
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### ARRAY
|
|
102
|
+
|
|
103
|
+
```js
|
|
104
|
+
dphelper.array.find( id, array ) // find value by ID into array
|
|
105
|
+
dphelper.array.delete( id, array ) // delete value by ID from array
|
|
106
|
+
dphelper.array.merge( arrayA , arrayB ) // merge two array
|
|
107
|
+
dphelper.array.unique( array ) // remove all duplicates
|
|
108
|
+
|
|
109
|
+
dphelper.obj2array( object ) // transform obj to array
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
... TO BE CONTINUE
|
package/README.md.bak
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# dpHelper
|
|
2
|
+
|
|
3
|
+
Many utils for your projects
|
|
4
|
+
|
|
5
|
+
Use "npm i dphelper" to install
|
|
6
|
+
|
|
7
|
+
in the index:
|
|
8
|
+
|
|
9
|
+
```js
|
|
10
|
+
import "dphelper"
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
type 'dphelper' in your console to have a look about all available functions that you can use globaly!
|
|
14
|
+
|
|
15
|
+
You can call these from everywhere without import
|
|
16
|
+
|
|
17
|
+
## CURRENCY
|
|
18
|
+
|
|
19
|
+
```js
|
|
20
|
+
dphelper.currency( val, int = 'en-US', cur = 'USD' )
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
## MEMORY
|
|
24
|
+
|
|
25
|
+
### STORAGE
|
|
26
|
+
|
|
27
|
+
```js
|
|
28
|
+
dphelper.storage.get( name )
|
|
29
|
+
dphelper.storage.set( name , value )
|
|
30
|
+
dphelper.storage.delete( name )
|
|
31
|
+
dphelper.storage.clearAll()
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
### COOKIE
|
|
35
|
+
|
|
36
|
+
```js
|
|
37
|
+
dphelper.cookie.set( name , value , time , path = '/' )
|
|
38
|
+
dphelper.cookie.get( name )
|
|
39
|
+
dphelper.cookie.delete( name )
|
|
40
|
+
dphelper.cookie.clearAll()
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### INDEXED-DB
|
|
44
|
+
|
|
45
|
+
```js
|
|
46
|
+
dphelper.indexedDB.create( storeName, table, name )
|
|
47
|
+
dphelper.indexedDB.open( storeName )
|
|
48
|
+
dphelper.indexedDB.store( storeName, table )
|
|
49
|
+
dphelper.indexedDB.insert( storeName, table, key, value )
|
|
50
|
+
dphelper.indexedDB.update( storeName, table, key, value )
|
|
51
|
+
dphelper.indexedDB.get( storeName, table, key )
|
|
52
|
+
|
|
53
|
+
window.dphelper.dbExist() -> know databases
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### NUMBERS
|
|
57
|
+
|
|
58
|
+
```js
|
|
59
|
+
dphelper.rnd() // generate long random number
|
|
60
|
+
dphelper.tmr() // generate number by timer
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### TIME
|
|
64
|
+
|
|
65
|
+
```js
|
|
66
|
+
dphelper.epoch() // return epoch time
|
|
67
|
+
dphelper.parseDate(value) // epoch to human date
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### 3Party
|
package/init.js
CHANGED
|
@@ -1,112 +1,114 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* dpHelper <https://github.com/passariello/dpHelper>
|
|
3
|
-
*
|
|
4
|
-
* Copyright (c) 2021, Dario Passariello.
|
|
5
|
-
* Licensed under the Apache-2.0 License.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/***********************************************************************/
|
|
9
|
-
|
|
10
|
-
(function () {
|
|
11
|
-
|
|
12
|
-
if (typeof window === 'undefined') {
|
|
13
|
-
global.window = {};
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const pjson = require('./package.json');
|
|
17
|
-
|
|
18
|
-
// CREATE ROOT STORE
|
|
19
|
-
const dphelper = window.dphelper = {};
|
|
20
|
-
|
|
21
|
-
// FIRST MESSAGE
|
|
22
|
-
console.groupCollapsed( `%c${pjson.name} v${pjson.version}%c`,"color:orange","" );
|
|
23
|
-
console.debug( `%c${pjson.name} v${pjson.version}%c by Dario Passariello started`,"color:orange","" );
|
|
24
|
-
console.debug( `%cType ${pjson.name} in this console to see it`, "color:gray","" );
|
|
25
|
-
console.debug( "%cFor help visit: " + pjson.repository.help, "color:gray","" );
|
|
26
|
-
console.debug( 'name: %c' + pjson.name,"color:orange","" );
|
|
27
|
-
console.debug( 'version: %c' + pjson.version,"color:orange","" );
|
|
28
|
-
console.debug( 'description: %c' + pjson.description,"color:orange","" );
|
|
29
|
-
console.debug( 'license: %c' + pjson.license,"color:orange","" );
|
|
30
|
-
console.debug( 'repository: %c' + pjson.repository.url,"color:orange","" );
|
|
31
|
-
console.debug( 'author: %c' + pjson.author.name,"color:orange","" );
|
|
32
|
-
console.debug( 'email: %c' + pjson.author.email,"color:orange","" );
|
|
33
|
-
console.groupEnd();
|
|
34
|
-
|
|
35
|
-
const $ = require("jquery");
|
|
36
|
-
|
|
37
|
-
// 3party
|
|
38
|
-
require('./3party/shortcut.js');
|
|
39
|
-
|
|
40
|
-
// CURRENCY
|
|
41
|
-
require('./scripts/currency.js');
|
|
42
|
-
|
|
43
|
-
// MEMORY
|
|
44
|
-
require('./scripts/storage.js');
|
|
45
|
-
require('./scripts/cookie.js');
|
|
46
|
-
require('./scripts/indexedDB.js');
|
|
47
|
-
|
|
48
|
-
// NUMBERS
|
|
49
|
-
require('./scripts/randomNum.js');
|
|
50
|
-
require('./scripts/randomNumTmr.js');
|
|
51
|
-
|
|
52
|
-
// TIME
|
|
53
|
-
require('./scripts/epoch.js');
|
|
54
|
-
require('./scripts/parseDate.js');
|
|
55
|
-
require('./scripts/dateUTC.js');
|
|
56
|
-
require('./scripts/dateIso2Epoch.js');
|
|
57
|
-
require('./scripts/dateConvert.js');
|
|
58
|
-
require('./scripts/date2MMDDYYYY.js');
|
|
59
|
-
require('./scripts/date2Iso.js');
|
|
60
|
-
require('./scripts/dateLocal-ISOTime.js');
|
|
61
|
-
|
|
62
|
-
// PATH
|
|
63
|
-
require('./scripts/pathRail.js');
|
|
64
|
-
require('./scripts/pathQuery.js');
|
|
65
|
-
require('./scripts/pathHash.js');
|
|
66
|
-
require('./scripts/pushState.js');
|
|
67
|
-
require('./scripts/anchorToOnClick.js');
|
|
68
|
-
|
|
69
|
-
// FILE
|
|
70
|
-
require('./scripts/loadFile.js');
|
|
71
|
-
//require('./scripts/loadAsset.js');
|
|
72
|
-
require('./scripts/loadJson.js');
|
|
73
|
-
require('./scripts/loadJsonExternal.js');
|
|
74
|
-
|
|
75
|
-
// FORMS
|
|
76
|
-
require('./scripts/serializeForm.js');
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
require('./scripts/
|
|
81
|
-
require('./scripts/
|
|
82
|
-
require('./scripts/
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
require('./scripts/
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
require('./scripts/
|
|
89
|
-
require('./scripts/
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
require('./scripts/
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
require('./scripts/
|
|
96
|
-
require('./scripts/
|
|
97
|
-
require('./scripts/
|
|
98
|
-
require('./scripts/
|
|
99
|
-
require('./scripts/
|
|
100
|
-
require('./scripts/
|
|
101
|
-
require('./scripts/
|
|
102
|
-
require('./scripts/
|
|
103
|
-
require('./scripts/
|
|
104
|
-
require('./scripts/
|
|
105
|
-
require('./scripts/
|
|
106
|
-
require('./scripts/
|
|
107
|
-
require('./scripts/
|
|
108
|
-
require('./scripts/
|
|
109
|
-
require('./scripts/
|
|
110
|
-
require('./scripts/
|
|
111
|
-
|
|
112
|
-
|
|
1
|
+
/*!
|
|
2
|
+
* dpHelper <https://github.com/passariello/dpHelper>
|
|
3
|
+
*
|
|
4
|
+
* Copyright (c) 2021, Dario Passariello.
|
|
5
|
+
* Licensed under the Apache-2.0 License.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/***********************************************************************/
|
|
9
|
+
|
|
10
|
+
(function () {
|
|
11
|
+
|
|
12
|
+
if (typeof window === 'undefined') {
|
|
13
|
+
global.window = {};
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const pjson = require('./package.json');
|
|
17
|
+
|
|
18
|
+
// CREATE ROOT STORE
|
|
19
|
+
const dphelper = window.dphelper = {};
|
|
20
|
+
|
|
21
|
+
// FIRST MESSAGE
|
|
22
|
+
console.groupCollapsed( `%c${pjson.name} v${pjson.version}%c`,"color:orange","" );
|
|
23
|
+
console.debug( `%c${pjson.name} v${pjson.version}%c by Dario Passariello started`,"color:orange","" );
|
|
24
|
+
console.debug( `%cType ${pjson.name} in this console to see it`, "color:gray","" );
|
|
25
|
+
console.debug( "%cFor help visit: " + pjson.repository.help, "color:gray","" );
|
|
26
|
+
console.debug( 'name: %c' + pjson.name,"color:orange","" );
|
|
27
|
+
console.debug( 'version: %c' + pjson.version,"color:orange","" );
|
|
28
|
+
console.debug( 'description: %c' + pjson.description,"color:orange","" );
|
|
29
|
+
console.debug( 'license: %c' + pjson.license,"color:orange","" );
|
|
30
|
+
console.debug( 'repository: %c' + pjson.repository.url,"color:orange","" );
|
|
31
|
+
console.debug( 'author: %c' + pjson.author.name,"color:orange","" );
|
|
32
|
+
console.debug( 'email: %c' + pjson.author.email,"color:orange","" );
|
|
33
|
+
console.groupEnd();
|
|
34
|
+
|
|
35
|
+
const $ = require("jquery");
|
|
36
|
+
|
|
37
|
+
// 3party
|
|
38
|
+
require('./3party/shortcut.js');
|
|
39
|
+
|
|
40
|
+
// CURRENCY
|
|
41
|
+
require('./scripts/currency.js');
|
|
42
|
+
|
|
43
|
+
// MEMORY
|
|
44
|
+
require('./scripts/storage.js');
|
|
45
|
+
require('./scripts/cookie.js');
|
|
46
|
+
require('./scripts/indexedDB.js');
|
|
47
|
+
|
|
48
|
+
// NUMBERS
|
|
49
|
+
require('./scripts/randomNum.js');
|
|
50
|
+
require('./scripts/randomNumTmr.js');
|
|
51
|
+
|
|
52
|
+
// TIME
|
|
53
|
+
require('./scripts/epoch.js');
|
|
54
|
+
require('./scripts/parseDate.js');
|
|
55
|
+
require('./scripts/dateUTC.js');
|
|
56
|
+
require('./scripts/dateIso2Epoch.js');
|
|
57
|
+
require('./scripts/dateConvert.js');
|
|
58
|
+
require('./scripts/date2MMDDYYYY.js');
|
|
59
|
+
require('./scripts/date2Iso.js');
|
|
60
|
+
require('./scripts/dateLocal-ISOTime.js');
|
|
61
|
+
|
|
62
|
+
// PATH
|
|
63
|
+
require('./scripts/pathRail.js');
|
|
64
|
+
require('./scripts/pathQuery.js');
|
|
65
|
+
require('./scripts/pathHash.js');
|
|
66
|
+
require('./scripts/pushState.js');
|
|
67
|
+
require('./scripts/anchorToOnClick.js');
|
|
68
|
+
|
|
69
|
+
// FILE
|
|
70
|
+
require('./scripts/loadFile.js');
|
|
71
|
+
//require('./scripts/loadAsset.js');
|
|
72
|
+
require('./scripts/loadJson.js');
|
|
73
|
+
require('./scripts/loadJsonExternal.js');
|
|
74
|
+
|
|
75
|
+
// FORMS
|
|
76
|
+
require('./scripts/serializeForm.js');
|
|
77
|
+
require('./scripts/serializeObj.js');
|
|
78
|
+
|
|
79
|
+
// ARRAY
|
|
80
|
+
// require('./scripts/arrayItemFinder.js');
|
|
81
|
+
// require('./scripts/arrayDeleteItem.js');
|
|
82
|
+
// require('./scripts/arrayMerge.js');
|
|
83
|
+
// require('./scripts/arrayUnique.js');
|
|
84
|
+
require('./scripts/array.js');
|
|
85
|
+
require('./scripts/object2array.js');
|
|
86
|
+
|
|
87
|
+
// SCROLL
|
|
88
|
+
require('./scripts/scrollToElement.js');
|
|
89
|
+
require('./scripts/scrollSmooth.js');
|
|
90
|
+
require('./scripts/scrollIndicator.js');
|
|
91
|
+
require('./scripts/scrollMemory.js');
|
|
92
|
+
require('./scripts/scrollCustom.js');
|
|
93
|
+
|
|
94
|
+
// OTHER
|
|
95
|
+
require('./scripts/uuid.js');
|
|
96
|
+
require('./scripts/noCache.js');
|
|
97
|
+
require('./scripts/parseBool.js');
|
|
98
|
+
require('./scripts/isPromise.js');
|
|
99
|
+
require('./scripts/textChanger.js');
|
|
100
|
+
require('./scripts/nl2br.js');
|
|
101
|
+
require('./scripts/sleep.js');
|
|
102
|
+
require('./scripts/printInfo.js');
|
|
103
|
+
require('./scripts/disableSelect.js');
|
|
104
|
+
require('./scripts/fullScreen.js');
|
|
105
|
+
require('./scripts/disableSpellCheck.js');
|
|
106
|
+
require('./scripts/triggerClick.js');
|
|
107
|
+
require('./scripts/handleEvent.js');
|
|
108
|
+
require('./scripts/window.js');
|
|
109
|
+
require('./scripts/purge.js');
|
|
110
|
+
require('./scripts/svgSupport.js');
|
|
111
|
+
require('./scripts/stopConsole.js');
|
|
112
|
+
require('./scripts/onBeforeUnLoad.js');
|
|
113
|
+
|
|
114
|
+
})();
|
package/package.json
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dphelper",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.21",
|
|
4
4
|
"description": "Many utils for your projects",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"publishConfig": {},
|
|
7
|
+
|
|
7
8
|
"scripts": {
|
|
8
|
-
"
|
|
9
|
+
"test1": "echo \"Error: no test specified\" && exit 1",
|
|
10
|
+
"test": "jest --silent --detectOpenHandles",
|
|
11
|
+
"test-coverage": "jest --coverage --silent"
|
|
9
12
|
},
|
|
13
|
+
|
|
10
14
|
"targets": {
|
|
11
15
|
"main": {
|
|
12
16
|
"includeNodeModules": {
|
|
@@ -17,23 +21,29 @@
|
|
|
17
21
|
}
|
|
18
22
|
},
|
|
19
23
|
"deprecated": false,
|
|
24
|
+
|
|
20
25
|
"engines": {
|
|
21
26
|
"node": ">=0.10.0"
|
|
22
27
|
},
|
|
28
|
+
|
|
23
29
|
"repository": {
|
|
24
30
|
"type": "git",
|
|
25
31
|
"url": "https://github.com/passariello/dpHelper",
|
|
26
32
|
"help": "https://github.com/passariello/dpHelper#readme"
|
|
27
33
|
},
|
|
34
|
+
|
|
28
35
|
"eslintConfig": {
|
|
29
36
|
"globals": {
|
|
30
37
|
"window": true
|
|
31
38
|
}
|
|
32
39
|
},
|
|
40
|
+
|
|
33
41
|
"bugs": {
|
|
34
42
|
"url": "https://github.com/passariello/dpHelper/issues"
|
|
35
43
|
},
|
|
44
|
+
|
|
36
45
|
"homepage": "https://github.com/passariello/dpHelper",
|
|
46
|
+
|
|
37
47
|
"keywords": [
|
|
38
48
|
"utils",
|
|
39
49
|
"tools",
|
|
@@ -46,17 +56,21 @@
|
|
|
46
56
|
"powerful",
|
|
47
57
|
"passariello"
|
|
48
58
|
],
|
|
59
|
+
|
|
49
60
|
"author": {
|
|
50
61
|
"name": "Dario Passariello",
|
|
51
62
|
"website": "https://dario.passariello.ca",
|
|
52
63
|
"email": "dariopassariello@gmail.com"
|
|
53
64
|
},
|
|
65
|
+
|
|
54
66
|
"license": "Apache-2.0",
|
|
67
|
+
|
|
55
68
|
"dependencies": {
|
|
56
69
|
"jquery": "^3.6.0",
|
|
57
70
|
"jshint": "^2.13.1",
|
|
58
71
|
"require": "^0.4.4"
|
|
59
72
|
},
|
|
73
|
+
|
|
60
74
|
"contributors": [
|
|
61
75
|
{
|
|
62
76
|
"name": "Dario Passariello",
|
|
@@ -67,4 +81,5 @@
|
|
|
67
81
|
"email": "valeriacalascaglitta@gmail.com"
|
|
68
82
|
}
|
|
69
83
|
]
|
|
84
|
+
|
|
70
85
|
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* dpHelper <https://github.com/passariello/dpHelper>
|
|
3
|
+
*
|
|
4
|
+
* arrayUnique
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) 2021, Dario Passariello.
|
|
7
|
+
* Licensed under the Apache-2.0 License.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/***********************************************************************/
|
|
11
|
+
|
|
12
|
+
window.dphelper.arrayUnique = ( array ) => {
|
|
13
|
+
let unique = [...new Set( array )];
|
|
14
|
+
return unique;
|
|
15
|
+
};
|
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* dpHelper <https://github.com/passariello/dpHelper>
|
|
3
|
-
*
|
|
4
|
-
* anchorToOnClick
|
|
5
|
-
*
|
|
6
|
-
* Copyright (c) 2021, Dario Passariello.
|
|
7
|
-
* Licensed under the Apache-2.0 License.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
/***********************************************************************/
|
|
11
|
-
|
|
12
|
-
window.dphelper.anchorToOnClick = function(){
|
|
13
|
-
// const $ = require("jquery");
|
|
14
|
-
|
|
15
|
-
$('a').each( function( index ) {
|
|
16
|
-
|
|
17
|
-
let elem = $( this );
|
|
18
|
-
let href = elem.attr( 'href' );
|
|
19
|
-
|
|
20
|
-
if( href ){
|
|
21
|
-
elem
|
|
22
|
-
.on( 'mouseup', function(){
|
|
23
|
-
Loader( 'body' , null );
|
|
24
|
-
})
|
|
25
|
-
.css('cursor','pointer')
|
|
26
|
-
.addClass( dphelper.pathRail()[3].replace(/\//g, '') )
|
|
27
|
-
.removeAttr( 'href' )
|
|
28
|
-
.on( 'click', function(){
|
|
29
|
-
window.location.href = href;
|
|
30
|
-
window.history.pushState('', '', href);
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
};
|
|
1
|
+
/*!
|
|
2
|
+
* dpHelper <https://github.com/passariello/dpHelper>
|
|
3
|
+
*
|
|
4
|
+
* anchorToOnClick
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) 2021, Dario Passariello.
|
|
7
|
+
* Licensed under the Apache-2.0 License.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/***********************************************************************/
|
|
11
|
+
|
|
12
|
+
window.dphelper.anchorToOnClick = function( container ){
|
|
13
|
+
// const $ = require("jquery");
|
|
14
|
+
|
|
15
|
+
$( container + ' a' ).each( function( index ) {
|
|
16
|
+
|
|
17
|
+
let elem = $( this );
|
|
18
|
+
let href = elem.attr( 'href' );
|
|
19
|
+
|
|
20
|
+
if( href ){
|
|
21
|
+
elem
|
|
22
|
+
.on( 'mouseup', function(){
|
|
23
|
+
Loader( 'body' , null );
|
|
24
|
+
})
|
|
25
|
+
.css('cursor','pointer')
|
|
26
|
+
.addClass( dphelper.pathRail()[3].replace(/\//g, '') )
|
|
27
|
+
.removeAttr( 'href' )
|
|
28
|
+
.on( 'click', function(){
|
|
29
|
+
window.location.href = href;
|
|
30
|
+
window.history.pushState('', '', href);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
};
|
package/scripts/array.js
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* dpHelper <https://github.com/passariello/dpHelper>
|
|
3
|
+
*
|
|
4
|
+
* arrayDeleteItem
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) 2021, Dario Passariello.
|
|
7
|
+
* Licensed under the Apache-2.0 License.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/***********************************************************************/
|
|
11
|
+
|
|
12
|
+
window.dphelper.array = {
|
|
13
|
+
|
|
14
|
+
// FIND
|
|
15
|
+
find: ( id, array )=>{
|
|
16
|
+
for (let node of array) {
|
|
17
|
+
if (node.id === id) return node;
|
|
18
|
+
|
|
19
|
+
if (node.children) {
|
|
20
|
+
let finalNode = window.dphelper.arrayFindItem(id, node.children);
|
|
21
|
+
if (finalNode) return finalNode;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
return false;
|
|
25
|
+
},
|
|
26
|
+
|
|
27
|
+
// UNIQUE
|
|
28
|
+
unique: ( array ) => {
|
|
29
|
+
let unique = [...new Set( array )];
|
|
30
|
+
return unique;
|
|
31
|
+
},
|
|
32
|
+
|
|
33
|
+
// DELETE
|
|
34
|
+
delete: ( id, array ) => {
|
|
35
|
+
array.some(function iter (o,i,a) {
|
|
36
|
+
|
|
37
|
+
if (o.Id === id) {
|
|
38
|
+
a.splice(i, 1);
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
var key = Object.keys(o);
|
|
43
|
+
|
|
44
|
+
for (let key of Object.keys(o)) {
|
|
45
|
+
let value = o[key];
|
|
46
|
+
if(value.length && typeof value === 'object') return value && value.map(iter);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// OLD SCHOOL WAY
|
|
50
|
+
// for (var p=0; p < key.length; ++p){
|
|
51
|
+
// if( o[key[p]]?.length && typeof o[key[p]] === 'object') return o[key[p]] && o[key[p]].some(iter);
|
|
52
|
+
// }
|
|
53
|
+
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
},
|
|
57
|
+
|
|
58
|
+
// MERGE
|
|
59
|
+
merge: ( arrayA, arrayB ) => {
|
|
60
|
+
for (const key of Object.keys(source)) {
|
|
61
|
+
if (source[key] instanceof Object && target[key]) Object.assign(source[key], window.dphelper.mergeArrays(target[key], source[key]));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
Object.assign(target || {}, source);
|
|
65
|
+
return target;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
};
|
|
69
|
+
|
package/scripts/currency.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* dpHelper <https://github.com/passariello/dpHelper>
|
|
3
|
-
*
|
|
4
|
-
* currency
|
|
5
|
-
*
|
|
6
|
-
* Copyright (c) 2021, Dario Passariello.
|
|
7
|
-
* Licensed under the Apache-2.0 License.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
/***********************************************************************/
|
|
11
|
-
|
|
12
|
-
window.dphelper.currency = ( val, int = 'en-US',
|
|
13
|
-
if( !val || isNaN( val ) ) val = 0;
|
|
14
|
-
var formatter = new Intl.NumberFormat( int , {
|
|
15
|
-
style: 'currency',
|
|
16
|
-
currency: cur,
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
// return ( val ).toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,')
|
|
20
|
-
return formatter.format( val );
|
|
21
|
-
};
|
|
1
|
+
/*!
|
|
2
|
+
* dpHelper <https://github.com/passariello/dpHelper>
|
|
3
|
+
*
|
|
4
|
+
* currency
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) 2021, Dario Passariello.
|
|
7
|
+
* Licensed under the Apache-2.0 License.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/***********************************************************************/
|
|
11
|
+
|
|
12
|
+
window.dphelper.currency = ( val, int = 'en-US', cur = 'USD' ) => {
|
|
13
|
+
if( !val || isNaN( val ) ) val = 0;
|
|
14
|
+
var formatter = new Intl.NumberFormat( int , {
|
|
15
|
+
style: 'currency',
|
|
16
|
+
currency: cur,
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
// return ( val ).toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,')
|
|
20
|
+
return formatter.format( val );
|
|
21
|
+
};
|
package/scripts/object2array.js
CHANGED
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* dpHelper <https://github.com/passariello/dpHelper>
|
|
3
|
-
*
|
|
4
|
-
* object2array
|
|
5
|
-
*
|
|
6
|
-
* Copyright (c) 2021, Dario Passariello.
|
|
7
|
-
* Licensed under the Apache-2.0 License.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
/***********************************************************************/
|
|
11
|
-
|
|
12
|
-
window.dphelper.
|
|
13
|
-
return Object
|
|
14
|
-
.entries(object)
|
|
15
|
-
.map(([key, value]) => Object.assign({key}, value && typeof value === 'object' ? {forms: ObjToArray(value)}
|
|
16
|
-
|
|
17
|
-
));
|
|
18
|
-
};
|
|
1
|
+
/*!
|
|
2
|
+
* dpHelper <https://github.com/passariello/dpHelper>
|
|
3
|
+
*
|
|
4
|
+
* object2array
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) 2021, Dario Passariello.
|
|
7
|
+
* Licensed under the Apache-2.0 License.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/***********************************************************************/
|
|
11
|
+
|
|
12
|
+
window.dphelper.obj2array = ( object ) => {
|
|
13
|
+
return Object
|
|
14
|
+
.entries( object )
|
|
15
|
+
.map( ( [ key, value ] ) => Object.assign( { key } , value && typeof value === 'object' ? { forms: ObjToArray( value ) } : { value, forms: [] } ) );
|
|
16
|
+
};
|
package/scripts/randomNum.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* dpHelper <https://github.com/passariello/dpHelper>
|
|
3
|
-
*
|
|
4
|
-
* random number
|
|
5
|
-
*
|
|
6
|
-
* Copyright (c) 2021, Dario Passariello.
|
|
7
|
-
* Licensed under the Apache-2.0 License.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
/***********************************************************************/
|
|
11
|
-
|
|
12
|
-
window.dphelper.rnd = () => {
|
|
13
|
-
return Math.floor(100000 + Math.random() * dphelper.tmr());
|
|
14
|
-
};
|
|
1
|
+
/*!
|
|
2
|
+
* dpHelper <https://github.com/passariello/dpHelper>
|
|
3
|
+
*
|
|
4
|
+
* random number
|
|
5
|
+
*
|
|
6
|
+
* Copyright (c) 2021, Dario Passariello.
|
|
7
|
+
* Licensed under the Apache-2.0 License.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
/***********************************************************************/
|
|
11
|
+
|
|
12
|
+
window.dphelper.rnd = () => {
|
|
13
|
+
return Math.floor( 100000 + Math.random() * dphelper.tmr() );
|
|
14
|
+
};
|