dphelper 0.2.49 → 0.2.55

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.
Files changed (63) hide show
  1. package/.editorconfig +15 -0
  2. package/.env +3 -0
  3. package/.eslintignore +8 -0
  4. package/.eslintrc.json +36 -0
  5. package/.gitattributes +2 -0
  6. package/.hintrc +11 -0
  7. package/.jsbeautifyrc +25 -0
  8. package/.jshintrc +14 -0
  9. package/.prettierignore +2 -0
  10. package/.prettierrc +7 -0
  11. package/.vscode/settings.json +54 -0
  12. package/3party/shortcut.js +224 -0
  13. package/backup.bat +43 -0
  14. package/data/list.json +19 -0
  15. package/dist/LICENSE +201 -0
  16. package/dist/README.md +176 -0
  17. package/index.d.ts +14 -0
  18. package/index.js +10 -2
  19. package/init.js +48 -0
  20. package/jest.config.js +18 -0
  21. package/package.json +127 -75
  22. package/public/assets/images/banner.png +0 -0
  23. package/public/assets/logos/logo.svg +64 -0
  24. package/scripts/anchorToOnClick.js +47 -0
  25. package/scripts/array.js +142 -0
  26. package/scripts/browser.js +65 -0
  27. package/scripts/console.js +86 -0
  28. package/scripts/coodinates.js +41 -0
  29. package/scripts/cookie.js +97 -0
  30. package/scripts/currency.js +41 -0
  31. package/scripts/date.js +101 -0
  32. package/scripts/disable.js +90 -0
  33. package/scripts/event.js +39 -0
  34. package/scripts/font.js +52 -0
  35. package/scripts/form.js +113 -0
  36. package/scripts/function.js +47 -0
  37. package/scripts/indexedDB.js +222 -0
  38. package/scripts/json.js +42 -0
  39. package/scripts/load.js +85 -0
  40. package/scripts/noCache.js +26 -0
  41. package/scripts/number.js +66 -0
  42. package/scripts/obj.js +81 -0
  43. package/scripts/onBeforeUnLoad.js +120 -0
  44. package/scripts/parseBool.js +27 -0
  45. package/scripts/path.js +94 -0
  46. package/scripts/promise.js +35 -0
  47. package/scripts/purge.js +53 -0
  48. package/scripts/screen.js +64 -0
  49. package/scripts/scrollbar.js +245 -0
  50. package/scripts/shortcut.js +70 -0
  51. package/scripts/storage.js +62 -0
  52. package/scripts/svg.js +372 -0
  53. package/scripts/text.js +78 -0
  54. package/scripts/time.js +41 -0
  55. package/scripts/timer.js +35 -0
  56. package/scripts/trigger.js +46 -0
  57. package/scripts/type.js +56 -0
  58. package/scripts/uuid.js +33 -0
  59. package/scripts/window.js +50 -0
  60. package/tests/ld-json-funtions.test.ts +21 -0
  61. package/tests/ld-json.test.ts +46 -0
  62. package/webpack.config.js +240 -0
  63. package/index.js.LICENSE.txt +0 -24
@@ -0,0 +1,94 @@
1
+ /*!
2
+ * dpHelper <https://github.com/passariello/dpHelper>
3
+ * Copyright (c) 2021, Dario Passariello.
4
+ * Licensed under the Apache-2.0 License.
5
+ */
6
+
7
+ /***********************************************************************/
8
+
9
+ var description = {
10
+ "name" : "Path To Array",
11
+ "description" : "test",
12
+ "version" : "0.0.1",
13
+ "command" : "path",
14
+ "subCommand" : [
15
+ {
16
+ "name":"rail",
17
+ "description":"test"
18
+ },{
19
+ "name":"hash",
20
+ "description":"test"
21
+ },{
22
+ "name":"query",
23
+ "description":"test"
24
+ }
25
+ ],
26
+ "example" : "",
27
+ "author" : "Dario Passariello",
28
+ "active" : true
29
+ };
30
+
31
+ dphelper._list.scripts.push( description );
32
+
33
+ /***********************************************************************/
34
+
35
+ // // ALIAS
36
+ // dphelper.pathHash = () => {
37
+ // console.debug( 'dpHelper: Please use "dphelper.path.hash()"' );
38
+ // return dphelper.path.hash();
39
+ // };
40
+
41
+ // dphelper.pathQuery = () => {
42
+ // console.debug( 'dpHelper: Please use "dphelper.path.query()"' );
43
+ // return dphelper.path.query();
44
+ // };
45
+
46
+ // dphelper.pathRail = () => {
47
+ // console.debug( 'dpHelper: Please use "dphelper.path.rail()"' );
48
+ // return dphelper.path.rail();
49
+ // };
50
+
51
+ /***********************************************************************/
52
+
53
+ dphelper.path = {
54
+
55
+ rail: () => {
56
+ const array = location.href
57
+ .split("?")[0]
58
+ .replace(location.protocol, '')
59
+ .replace(location.host, '')
60
+ .replace(location.hash, '')
61
+ .split('/');
62
+ if ( array.length > 0 ) {
63
+ const arrayFinal = array.filter(item => item);
64
+ return arrayFinal;
65
+ } else {
66
+ return;
67
+ }
68
+ },
69
+
70
+ hash: () => {
71
+ const array = location.hash.replace('#', '').split('/');
72
+ if (array.length) {
73
+ return array.filter(item => item);
74
+ } else {
75
+ return ["empty"];
76
+ }
77
+ },
78
+
79
+ query: () => {
80
+ let x, y, array = [], search = location.search;
81
+ if (search) {
82
+ search.replace("?", '').split('&')
83
+ .map(x => {
84
+ y = x.split('=');
85
+ array[y[0]] = y[1];
86
+ });
87
+ return array;
88
+ } else {
89
+ return ["empty"];
90
+ }
91
+ }
92
+
93
+ };
94
+
@@ -0,0 +1,35 @@
1
+ /*!
2
+ * dpHelper <https://github.com/passariello/dpHelper>
3
+ * Copyright (c) 2021, Dario Passariello.
4
+ * Licensed under the Apache-2.0 License.
5
+ */
6
+
7
+ /***********************************************************************/
8
+
9
+ var description = {
10
+ "name" : "Promises",
11
+ "description" : "test",
12
+ "version" : "0.0.1",
13
+ "command" : "promise",
14
+ "subCommand" : [
15
+ {
16
+ name:"check",
17
+ description:"test"
18
+ }
19
+ ],
20
+ "example" : "",
21
+ "author" : "Dario Passariello",
22
+ "active" : true
23
+ };
24
+
25
+ dphelper._list.scripts.push( description );
26
+
27
+ /***********************************************************************/
28
+
29
+ dphelper.promise = {
30
+
31
+ check: (p) => {
32
+ return p && Object.prototype.toString.call(p) === "[object Promise]";
33
+ }
34
+
35
+ };
@@ -0,0 +1,53 @@
1
+ /*!
2
+ * dpHelper <https://github.com/passariello/dpHelper>
3
+ * Copyright (c) 2021, Dario Passariello.
4
+ * Licensed under the Apache-2.0 License.
5
+ */
6
+
7
+ /***********************************************************************/
8
+
9
+ var description = {
10
+ "name" : "Purge From Memory",
11
+ "description" : "test",
12
+ "version" : "0.0.1",
13
+ "command" : "purge",
14
+ "subCommand" : [],
15
+ "example" : "",
16
+ "author" : "Dario Passariello",
17
+ "active" : true
18
+ };
19
+
20
+ dphelper._list.scripts.push( description );
21
+
22
+ /***********************************************************************/
23
+
24
+ dphelper.purge = ( d = body, time = 10000 ) => {
25
+
26
+ setTimeout(() => {
27
+ if( d === undefined ) return null;
28
+
29
+ let a = d.attributes, i, l, n;
30
+
31
+ if (a) {
32
+ l = a.length;
33
+ for( i = 0; i < l; i += 1 ) {
34
+ n = a[i].name;
35
+ if( typeof d[n] === 'function' ) { d[n] = null; }
36
+ if( typeof d[n] === 'undefined' ) { d[n] = null; }
37
+ }
38
+
39
+ }
40
+
41
+ a = d.childNodes;
42
+
43
+ if (a) {
44
+ l = a.length;
45
+ for( i = 0; i < l; i += 1 ) {
46
+ Purge( d.childNodes[i] );
47
+ }
48
+ }
49
+ }, time );
50
+
51
+ };
52
+
53
+ // purge()
@@ -0,0 +1,64 @@
1
+ /*!
2
+ * dpHelper <https://github.com/passariello/dpHelper>
3
+ * Copyright (c) 2021, Dario Passariello.
4
+ * Licensed under the Apache-2.0 License.
5
+ */
6
+
7
+ /***********************************************************************/
8
+
9
+ var description = {
10
+ "name" : "Screen Options",
11
+ "description" : "test",
12
+ "version" : "0.0.1",
13
+ "command" : "screen",
14
+ "subCommand" : [
15
+ {
16
+ "name":"fullScreen",
17
+ "description":"test"
18
+ },{
19
+ "name":"toggle",
20
+ "description":"test"
21
+ }
22
+ ],
23
+ "example" : "",
24
+ "author" : "Dario Passariello",
25
+ "active" : true
26
+ };
27
+
28
+ dphelper._list.scripts.push( description );
29
+
30
+ /***********************************************************************/
31
+
32
+ dphelper.screen = {
33
+
34
+ fullScreen: function( el ){
35
+
36
+ if ( el.requestFullScreen ) {
37
+ el.requestFullScreen();
38
+ } else if ( el.mozRequestFullScreen ) {
39
+ el.mozRequestFullScreen();
40
+ } else if ( el.webkitRequestFullScreen ) {
41
+ el.webkitRequestFullScreen();
42
+ }
43
+
44
+ },
45
+
46
+ toggle: function( el ) {
47
+
48
+ let requestFullScreen = el.requestFullscreen || el.mozRequestFullScreen || el.webkitRequestFullScreen || el.msRequestFullscreen;
49
+ let cancelFullScreen = el.exitFullscreen || el.mozCancelFullScreen || el.webkitExitFullscreen || el.msExitFullscreen;
50
+
51
+ if( !doc.fullscreenElement && !el.mozFullScreenElement && !el.webkitFullscreenElement && !el.msFullscreenElement ) {
52
+ requestFullScreen.call( el );
53
+ }else{
54
+ cancelFullScreen.call( el );
55
+ }
56
+
57
+ }
58
+
59
+ };
60
+
61
+ // dphelper.fullScreen.go( document.body )
62
+ // dphelper.fullScreen.toggle( document.body )
63
+
64
+
@@ -0,0 +1,245 @@
1
+ /*!
2
+ * dpHelper <https://github.com/passariello/dpHelper>
3
+ * Copyright (c) 2021, Dario Passariello.
4
+ * Licensed under the Apache-2.0 License.
5
+ */
6
+
7
+ /***********************************************************************/
8
+
9
+ var description = {
10
+ "name" : "Scrollbar",
11
+ "description" : "test",
12
+ "version" : "0.0.1",
13
+ "command" : "scrollbar",
14
+ "subCommand" : [
15
+ {
16
+ "name":"custom",
17
+ "description":"test"
18
+ },{
19
+ "name":"indicator",
20
+ "description":"test"
21
+ },{
22
+ "name":"position.get",
23
+ "description":"test"
24
+ },{
25
+ "name":"position.set",
26
+ "description":"test"
27
+ },{
28
+ "name":"smooth",
29
+ "description":"test"
30
+ },{
31
+ "name":"scrollTo",
32
+ "description":"test"
33
+ }
34
+ ],
35
+ "example" : "",
36
+ "author" : "Dario Passariello",
37
+ "active" : true
38
+ };
39
+
40
+ dphelper._list.scripts.push( description );
41
+
42
+ /***********************************************************************/
43
+
44
+ dphelper.scrollbar = {
45
+
46
+ custom: ( el, options ) => {
47
+
48
+ if(!options['color_1']) options['color_1'] = "black";
49
+ if(!options['color_2']) options['color_2'] = "transparent";
50
+ if(!options['color_3']) options['color_3'] = "rgba(30,150,255,.5)";
51
+ if(!options['type']) options['type'] = "thin";
52
+ if(!options['behavior']) options['behavior'] = "smooth";
53
+ if(!options['width']) options['width'] = "8px";
54
+ if(!options['height']) options['height'] = "8px";
55
+ if(!options['rounded']) options['rounded'] = "25px";
56
+ if(!options['margin']) options['margin'] = "5px";
57
+ if(!options['border']) options['border'] = "5px solid transparent";
58
+
59
+ const $style = `${el}{
60
+ scrollbar-width:auto;
61
+ scrollbar-color:${options['color_1']} ${options['color_2']};
62
+ scrollbar-width: ${options['type']};
63
+ scroll-behavior: ${options['behavior']};
64
+ scroll-margin: ${options['margin']};
65
+ -ms-overflow-style: -ms-autohiding-scrollbar;
66
+ }
67
+ ${el}::-webkit-scrollbar {
68
+ scroll-behavior: ${options['behavior']};
69
+ width: ${options['width']};
70
+ height: ${options['height']};
71
+ }
72
+ ${el}::-webkit-scrollbar-track {
73
+ background: ${options['color_2']};
74
+ border-radius: ${options['rounded']};
75
+ }
76
+ ${el}::-webkit-scrollbar-thumb {
77
+ -webkit-border-radius: ${options['rounded']};
78
+ border-radius: ${options['rounded']};
79
+ background: ${options['color_1']};
80
+ border:
81
+ }
82
+
83
+ /* ${el}::-webkit-scrollbar-thumb:window-inactive {
84
+ background: ${options['color_3']}
85
+ }*/
86
+ `;
87
+
88
+ let styleToHead = document.createElement( "style" );
89
+ document.head.appendChild( styleToHead );
90
+ styleToHead.innerHTML = $style;
91
+
92
+ },
93
+
94
+ indicator: ( props ) => {
95
+
96
+ /**
97
+ /* This timeout it's to be suse that whole UI is loaded
98
+ /* Just smaller trick!
99
+ */
100
+
101
+ let cont = document.querySelector( props.el );
102
+ let sc = document.querySelector('.scrollindicator');
103
+
104
+ if( !sc ){
105
+
106
+ const createEl = document.createElement('div');
107
+ createEl.classList.add("scrollindicator");
108
+ document.querySelector('header').appendChild(createEl);
109
+
110
+ createEl.style.cssText = `
111
+ height:5px;
112
+ background:#65c45c;
113
+ position:absolute;
114
+ bottom:0;
115
+ left:0;
116
+ z-index:2
117
+ `;
118
+ }
119
+
120
+ if( !props.el && sc) {
121
+ sc.style.width = 0 + '%';
122
+ return null;
123
+ }
124
+
125
+ try{
126
+ let sc = document.querySelector('.scrollindicator');
127
+ cont.addEventListener( 'scroll' , function ( e ) {
128
+
129
+ sc.style.width = 0 + '%';
130
+ let winScroll = this.scrollTop || this.scrollTop;
131
+ let height = this.scrollHeight - this.clientHeight;
132
+ let scrolled = Math.min(Math.max(parseInt( (winScroll / height) * 100 ), 0), 100);
133
+ sc.style.width = scrolled + '%';
134
+
135
+ sc.click();
136
+
137
+ });
138
+
139
+ window.addEventListener('popstate', function ( e ) {
140
+ sc.style.width = 0;
141
+ });
142
+
143
+ }catch( e ){
144
+ return;
145
+ }
146
+
147
+ return null;
148
+
149
+ },
150
+
151
+ position: {
152
+
153
+ set: ( el ) => {
154
+ let ar = [ $( el ).scrollTop() , $( el ).scrollLeft() ];
155
+ if( ar[0] != null && ar[1] != null ){ dphelper.storage.set( el , ar ); }
156
+ },
157
+
158
+ get: ( el ) => {
159
+ if( !dphelper.storage.get( el ) ) return;
160
+ let ar = dphelper.storage.get( el ).trim().split(',');
161
+ $( el ).scrollTop( ar[0] );
162
+ $( el ).scrollLeft( ar[1] );
163
+ }
164
+
165
+ },
166
+
167
+ smooth: (target, speed, smooth) => {
168
+
169
+ if (target === document)
170
+ target = (document.scrollingElement || document.documentElement || document.body.parentNode || document.body); // cross browser support for document scrolling
171
+
172
+ let moving = false;
173
+ let pos = target.scrollTop;
174
+ let frame = target === document.body && document.documentElement ? document.documentElement : target; // safari is the new IE
175
+
176
+ target.addEventListener('mousewheel', scrolled, { passive: false });
177
+ target.addEventListener('DOMMouseScroll', scrolled, { passive: false });
178
+
179
+ function scrolled( e ) {
180
+ e.preventDefault(); // disable default scrolling
181
+
182
+ let delta = normalizeWheelDelta( e );
183
+
184
+ pos += -delta * speed;
185
+ pos = Math.max(0, Math.min(pos, target.scrollHeight - frame.clientHeight)); // limit scrolling
186
+
187
+ if (!moving) update();
188
+ }
189
+
190
+ function normalizeWheelDelta( e ){
191
+ if(e.detail){
192
+ if(e.wheelDelta)
193
+ return e.wheelDelta/e.detail/40 * (e.detail>0 ? 1 : -1); // Opera
194
+ else
195
+ return -e.detail/3; // Firefox
196
+ }else
197
+ return e.wheelDelta/120; // IE,Safari,Chrome
198
+ }
199
+
200
+ function update() {
201
+ moving = true;
202
+
203
+ let delta = (pos - target.scrollTop) / smooth;
204
+
205
+ target.scrollTop += delta;
206
+
207
+ if (Math.abs(delta) > 0.5)
208
+ requestFrame(update);
209
+ else
210
+ moving = false;
211
+ }
212
+
213
+ let requestFrame = function() { // requestAnimationFrame cross browser
214
+ return (
215
+ window.requestAnimationFrame ||
216
+ window.webkitRequestAnimationFrame ||
217
+ window.mozRequestAnimationFrame ||
218
+ window.oRequestAnimationFrame ||
219
+ window.msRequestAnimationFrame ||
220
+ function(func) {
221
+ window.setTimeout(func, 1000 / 50);
222
+ }
223
+ );
224
+ }();
225
+
226
+ },
227
+
228
+ scrollTo: function( container, element, gap = 0 ) {
229
+
230
+ let el1 = document.querySelector( container );
231
+ let el2 = document.querySelector( element );
232
+ let el3 = gap; // DIVERGENCE
233
+
234
+ if( !el1 || !el2 || !el3 ) return;
235
+
236
+ el1.scrollTo({
237
+ top: el2.offsetTop,
238
+ behavior: "smooth"
239
+ });
240
+
241
+ }
242
+
243
+ };
244
+
245
+ //example: dphelper.scrollbar.custom('*')
@@ -0,0 +1,70 @@
1
+ /*!
2
+ * dpHelper <https://github.com/passariello/dpHelper>
3
+ * Copyright (c) 2021, Dario Passariello.
4
+ * Licensed under the Apache-2.0 License.
5
+ */
6
+
7
+ /***********************************************************************/
8
+
9
+ var description = {
10
+ "name" : "Handle Shortcut",
11
+ "description" : "test",
12
+ "version" : "0.0.1",
13
+ "command" : "shortcut",
14
+ "example" : "",
15
+ "author" : "Dario Passariello",
16
+ "active" : true
17
+ };
18
+
19
+ dphelper._list.scripts.push( description );
20
+
21
+ /***********************************************************************/
22
+
23
+ dphelper.shortcut = ( e, trigger ) => {
24
+ const code = e.which ? e.which : e.keyCode;
25
+
26
+ if( !trigger ) trigger = {
27
+ // EXAMPLES:
28
+ "data" : [
29
+ {
30
+ "key" : "83",
31
+ "ctrl" : true,
32
+ "active" : true,
33
+ "description" : "CTRL+S",
34
+ //"element" : "#formSave",
35
+ "function" : ""
36
+ },
37
+ {
38
+ "key" : "27",
39
+ "ctrl" : false,
40
+ "active" : true,
41
+ "description" : "ESC",
42
+ "element" : "",
43
+ "function" : ""
44
+ },
45
+ {
46
+ "key" : "80",
47
+ "ctrl" : true,
48
+ "active" : true,
49
+ "description" : "CTRL+P",
50
+ "element" : "",
51
+ "function" : "function(){ Print }"
52
+ }
53
+ ]
54
+ };
55
+
56
+ trigger.map( list => {
57
+
58
+ // IF CTRL COMMAND
59
+ if ( e.ctrlKey || e.metaKey && list.ctrl === true ) {
60
+ if( code === parseInt(list.key) && list.active === true ){
61
+ if( list.element ) simulateClick( list.element );
62
+ if( list.function ) JSON.stringify( list.function );
63
+ e.preventDefault();
64
+ return;
65
+ }
66
+ }
67
+
68
+ });
69
+
70
+ };
@@ -0,0 +1,62 @@
1
+ /*!
2
+ * dpHelper <https://github.com/passariello/dpHelper>
3
+ * Copyright (c) 2021, Dario Passariello.
4
+ * Licensed under the Apache-2.0 License.
5
+ */
6
+
7
+ /***********************************************************************/
8
+
9
+ var description = {
10
+ "name" : "Local Storage Manager",
11
+ "description" : "test",
12
+ "version" : "0.0.1",
13
+ "command" : "storage",
14
+ "subCommand" : [
15
+ {
16
+ "name":"get",
17
+ "description":"test"
18
+ },{
19
+ "name":"set",
20
+ "description":"test"
21
+ },{
22
+ "name":"delete",
23
+ "description":"test"
24
+ },{
25
+ "name":"clearAll",
26
+ "description":"test"
27
+ }
28
+ ],
29
+ "example" : "",
30
+ "author" : "Dario Passariello",
31
+ "active" : true
32
+ };
33
+
34
+ dphelper._list.scripts.push( description );
35
+
36
+ /***********************************************************************/
37
+
38
+ dphelper.storage = {
39
+
40
+ get: function( name ) {
41
+ if(!name) return;
42
+ return window.localStorage.getItem( name );
43
+ },
44
+
45
+ set: function( name, value ) {
46
+ if(!name || !value) return;
47
+ window.localStorage.setItem( name, JSON.stringify(value) );
48
+ },
49
+
50
+ delete: function( name ) {
51
+ if(!name) return;
52
+ window.localStorage.removeItem( name );
53
+ },
54
+
55
+ clearAll: function() {
56
+ window.localStorage.clear();
57
+ }
58
+
59
+ };
60
+
61
+ // START STORAGE DB
62
+ // dphelper.storage.set( "dpHelper", 'active' );