dphelper 0.2.28 → 0.2.32

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 (91) hide show
  1. package/data/.OLD/~camelCase.js +41 -0
  2. package/{scripts/date2Iso.js → data/.OLD/~date2Iso.js} +31 -20
  3. package/{scripts/date2MMDDYYYY.js → data/.OLD/~date2MMDDYYYY.js} +27 -16
  4. package/{scripts/dateConvert.js → data/.OLD/~dateConvert.js} +31 -20
  5. package/{scripts/dateIso2Epoch.js → data/.OLD/~dateIso2Epoch.js} +28 -17
  6. package/{scripts/dateLocal-ISOTime.js → data/.OLD/~dateLocal-ISOTime.js} +28 -17
  7. package/data/.OLD/~dateUTC.js +25 -0
  8. package/{scripts/disableSpellCheck.js → data/.OLD/~disableSpellCheck.js} +32 -21
  9. package/data/.OLD/~loadJson.js +27 -0
  10. package/{scripts/loadJsonExternal.js → data/.OLD/~loadJsonExternal.js} +44 -32
  11. package/data/.OLD/~nl2br.js +26 -0
  12. package/{scripts/object2array.js → data/.OLD/~object2array.js} +15 -3
  13. package/data/.OLD/~parseDate.js +30 -0
  14. package/data/.OLD/~pathHash.js +27 -0
  15. package/data/.OLD/~pathQuery.js +28 -0
  16. package/data/.OLD/~pathRail.js +27 -0
  17. package/data/.OLD/~randomNumTmr.js +26 -0
  18. package/{scripts/scrollIndicator.js → data/.OLD/~scrollIndicator.js} +0 -0
  19. package/{scripts/scrollMemory.js → data/.OLD/~scrollMemory.js} +0 -0
  20. package/{scripts/scrollSmooth.js → data/.OLD/~scrollSmooth.js} +0 -0
  21. package/{scripts/scrollToElement.js → data/.OLD/~scrollToElement.js} +0 -0
  22. package/{scripts/svgSupport.js → data/.OLD/~svgSupport.js} +0 -0
  23. package/data/list.json +19 -26
  24. package/init.js +19 -5
  25. package/package.json +7 -9
  26. package/scripts/anchorToOnClick.js +15 -3
  27. package/scripts/array.js +29 -3
  28. package/scripts/console.js +86 -0
  29. package/scripts/cookie.js +97 -71
  30. package/scripts/currency.js +31 -11
  31. package/scripts/date.js +101 -0
  32. package/scripts/disable.js +88 -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/indexedDB.js +47 -10
  37. package/scripts/isPromise.js +26 -14
  38. package/scripts/json.js +42 -0
  39. package/scripts/load.js +70 -0
  40. package/scripts/noCache.js +26 -14
  41. package/scripts/number.js +42 -0
  42. package/scripts/obj.js +81 -0
  43. package/scripts/onBeforeUnLoad.js +120 -108
  44. package/scripts/parseBool.js +27 -15
  45. package/scripts/path.js +94 -0
  46. package/scripts/printInfo.js +28 -16
  47. package/scripts/purge.js +53 -41
  48. package/scripts/pushState.js +33 -14
  49. package/scripts/screen.js +64 -0
  50. package/scripts/scrollbar.js +226 -0
  51. package/scripts/{handleEvent.js → shortcut.js} +70 -59
  52. package/scripts/storage.js +29 -3
  53. package/scripts/svg.js +372 -0
  54. package/scripts/text.js +78 -0
  55. package/scripts/time.js +41 -0
  56. package/scripts/timer.js +35 -0
  57. package/scripts/trigger.js +37 -0
  58. package/scripts/uuid.js +33 -14
  59. package/scripts/window.js +50 -38
  60. package/#cmd.exe.lnk +0 -0
  61. package/.github/workflows/codeql-analysis.yml +0 -70
  62. package/README.md.bak +0 -70
  63. package/scripts/.OLD/arrayDeleteItem.js +0 -35
  64. package/scripts/.OLD/arrayItemFinder.js +0 -22
  65. package/scripts/.OLD/arrayMerge.js +0 -20
  66. package/scripts/.OLD/arrayUnique.js +0 -15
  67. package/scripts/.OLD/loadAsset.js +0 -26
  68. package/scripts/addListenerMulti.js +0 -10
  69. package/scripts/camelCase.js +0 -29
  70. package/scripts/dateUTC.js +0 -14
  71. package/scripts/disableSelect.js +0 -46
  72. package/scripts/epoch.js +0 -14
  73. package/scripts/fontFit.js +0 -24
  74. package/scripts/fullScreen.js +0 -40
  75. package/scripts/jsonCounter.js +0 -21
  76. package/scripts/loadFile.js +0 -17
  77. package/scripts/loadJson.js +0 -15
  78. package/scripts/nl2br.js +0 -14
  79. package/scripts/parseDate.js +0 -19
  80. package/scripts/pathHash.js +0 -20
  81. package/scripts/pathQuery.js +0 -24
  82. package/scripts/pathRail.js +0 -26
  83. package/scripts/randomNum.js +0 -14
  84. package/scripts/randomNumTmr.js +0 -14
  85. package/scripts/scrollCustom.js +0 -41
  86. package/scripts/serializeForm.js +0 -94
  87. package/scripts/serializeObj.js +0 -47
  88. package/scripts/sleep.js +0 -14
  89. package/scripts/stopConsole.js +0 -49
  90. package/scripts/textChanger.js +0 -24
  91. package/scripts/triggerClick.js +0 -16
@@ -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":"fullScreenToggle",
20
+ "description":"test"
21
+ }
22
+ ],
23
+ "example" : "",
24
+ "author" : "Dario Passariello",
25
+ "active" : true
26
+ };
27
+
28
+ window.dphelper._list.scripts.push( description );
29
+
30
+ /***********************************************************************/
31
+
32
+ window.dphelper.fullScreen = {
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
+ fullScreenToggle: 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
+ // window.dphelper.fullScreen.go( document.body )
62
+ // window.dphelper.fullScreen.toggle( document.body )
63
+
64
+
@@ -0,0 +1,226 @@
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" : "Random Number From Timer",
11
+ "description" : "test",
12
+ "version" : "0.0.1",
13
+ "command" : "tmr",
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
+ window.dphelper._list.scripts.push( description );
41
+
42
+ /***********************************************************************/
43
+
44
+ window.dphelper.scrollbar = {
45
+
46
+ custom: ( el, colors, size ) => {
47
+
48
+ if(!colors) colors =[ "black", "transparent" ];
49
+ if(!size) size =[ "6px", "6px" ];
50
+
51
+ const $style = `${el}{
52
+ scrollbar-width:auto;
53
+ scrollbar-color:${colors[0]} ${colors[1]};
54
+ scrollbar-width: thin;
55
+ -ms-overflow-style: -ms-autohiding-scrollbar;
56
+ }
57
+ ${el}::-webkit-scrollbar {
58
+ width: ${size[0]};
59
+ height: ${size[0]};
60
+ }
61
+ ${el}::-webkit-scrollbar-track {
62
+ background: ${colors[1]};
63
+ }
64
+ ${el}::-webkit-scrollbar-thumb {
65
+ background: ${colors[0]};
66
+ }
67
+ `;
68
+
69
+ let styleToHead = document.createElement( "style" );
70
+ document.head.appendChild( styleToHead );
71
+ styleToHead.innerHTML = $style;
72
+
73
+ },
74
+
75
+ indicator: ( props ) => {
76
+
77
+ /**
78
+ /* This timeout it's to be suse that whole UI is loaded
79
+ /* Just smaller trick!
80
+ */
81
+
82
+ let cont = document.querySelector( props.el );
83
+ let sc = document.querySelector('.scrollindicator');
84
+
85
+ if( !sc ){
86
+
87
+ const createEl = document.createElement('div');
88
+ createEl.classList.add("scrollindicator");
89
+ document.querySelector('header').appendChild(createEl);
90
+
91
+ createEl.style.cssText = `
92
+ height:5px;
93
+ background:#65c45c;
94
+ position:absolute;
95
+ bottom:0;
96
+ left:0;
97
+ z-index:2
98
+ `;
99
+ }
100
+
101
+ if( !props.el && sc) {
102
+ sc.style.width = 0 + '%';
103
+ return null;
104
+ }
105
+
106
+ try{
107
+ let sc = document.querySelector('.scrollindicator');
108
+ cont.addEventListener( 'scroll' , function ( e ) {
109
+
110
+ sc.style.width = 0 + '%';
111
+ let winScroll = this.scrollTop || this.scrollTop;
112
+ let height = this.scrollHeight - this.clientHeight;
113
+ let scrolled = Math.min(Math.max(parseInt( (winScroll / height) * 100 ), 0), 100);
114
+ sc.style.width = scrolled + '%';
115
+
116
+ sc.click();
117
+
118
+ });
119
+
120
+ window.addEventListener('popstate', function ( e ) {
121
+ sc.style.width = 0;
122
+ });
123
+
124
+ }catch( e ){
125
+ return;
126
+ }
127
+
128
+ return null;
129
+
130
+ },
131
+
132
+ position: {
133
+
134
+ set: ( el ) => {
135
+ let ar = [ $( el ).scrollTop() , $( el ).scrollLeft() ];
136
+ if( ar[0] != null && ar[1] != null ){ window.dphelper.storage.set( el , ar ); }
137
+ },
138
+
139
+ get: ( el ) => {
140
+ if( !window.dphelper.storage.get( el ) ) return;
141
+ let ar = window.dphelper.storage.get( el ).trim().split(',');
142
+ $( el ).scrollTop( ar[0] );
143
+ $( el ).scrollLeft( ar[1] );
144
+ }
145
+
146
+ },
147
+
148
+ smooth: (target, speed, smooth) => {
149
+
150
+ if (target === document)
151
+ target = (document.scrollingElement || document.documentElement || document.body.parentNode || document.body); // cross browser support for document scrolling
152
+
153
+ let moving = false;
154
+ let pos = target.scrollTop;
155
+ let frame = target === document.body && document.documentElement ? document.documentElement : target; // safari is the new IE
156
+
157
+ target.addEventListener('mousewheel', scrolled, { passive: false });
158
+ target.addEventListener('DOMMouseScroll', scrolled, { passive: false });
159
+
160
+ function scrolled( e ) {
161
+ e.preventDefault(); // disable default scrolling
162
+
163
+ let delta = normalizeWheelDelta( e );
164
+
165
+ pos += -delta * speed;
166
+ pos = Math.max(0, Math.min(pos, target.scrollHeight - frame.clientHeight)); // limit scrolling
167
+
168
+ if (!moving) update();
169
+ }
170
+
171
+ function normalizeWheelDelta( e ){
172
+ if(e.detail){
173
+ if(e.wheelDelta)
174
+ return e.wheelDelta/e.detail/40 * (e.detail>0 ? 1 : -1); // Opera
175
+ else
176
+ return -e.detail/3; // Firefox
177
+ }else
178
+ return e.wheelDelta/120; // IE,Safari,Chrome
179
+ }
180
+
181
+ function update() {
182
+ moving = true;
183
+
184
+ let delta = (pos - target.scrollTop) / smooth;
185
+
186
+ target.scrollTop += delta;
187
+
188
+ if (Math.abs(delta) > 0.5)
189
+ requestFrame(update);
190
+ else
191
+ moving = false;
192
+ }
193
+
194
+ let requestFrame = function() { // requestAnimationFrame cross browser
195
+ return (
196
+ window.requestAnimationFrame ||
197
+ window.webkitRequestAnimationFrame ||
198
+ window.mozRequestAnimationFrame ||
199
+ window.oRequestAnimationFrame ||
200
+ window.msRequestAnimationFrame ||
201
+ function(func) {
202
+ window.setTimeout(func, 1000 / 50);
203
+ }
204
+ );
205
+ }();
206
+
207
+ },
208
+
209
+ scrollTo: function( container, element, gap = 0 ) {
210
+
211
+ let el1 = document.querySelector( container );
212
+ let el2 = document.querySelector( element );
213
+ let el3 = gap; // DIVERGENCE
214
+
215
+ if( !el1 || !el2 || !el3 ) return;
216
+
217
+ el1.scrollTo({
218
+ top: el2.offsetTop,
219
+ behavior: "smooth"
220
+ });
221
+
222
+ }
223
+
224
+ };
225
+
226
+ //example: window.dphelper.scrollbar.custom('*')
@@ -1,59 +1,70 @@
1
- /*!
2
- * dpHelper <https://github.com/passariello/dpHelper>
3
- *
4
- * handleEvent
5
- *
6
- * Copyright (c) 2021, Dario Passariello.
7
- * Licensed under the Apache-2.0 License.
8
- */
9
-
10
- /***********************************************************************/
11
-
12
- window.dphelper.handleEvent = ( e, trigger ) => {
13
- const code = e.which ? e.which : e.keyCode;
14
-
15
- if( !trigger ) trigger = {
16
- // EXAMPLES:
17
- "data" : [
18
- {
19
- "key" : "83",
20
- "ctrl" : true,
21
- "active" : true,
22
- "description" : "CTRL+S",
23
- //"element" : "#formSave",
24
- "function" : ""
25
- },
26
- {
27
- "key" : "27",
28
- "ctrl" : false,
29
- "active" : true,
30
- "description" : "ESC",
31
- "element" : "",
32
- "function" : ""
33
- },
34
- {
35
- "key" : "80",
36
- "ctrl" : true,
37
- "active" : true,
38
- "description" : "CTRL+P",
39
- "element" : "",
40
- //"function" : "function(){ Print }"
41
- }
42
- ]
43
- };
44
-
45
- trigger.map( list => {
46
-
47
- // IF CTRL COMMAND
48
- if ( e.ctrlKey || e.metaKey && list.ctrl === true ) {
49
- if( code === parseInt(list.key) && list.active === true ){
50
- if( list.element > '' ) simulateClick( list.element );
51
- if( list.function > '' ) list.function;
52
- e.preventDefault();
53
- return;
54
- }
55
- }
56
-
57
- });
58
-
59
- };
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
+ window.dphelper._list.scripts.push( description );
20
+
21
+ /***********************************************************************/
22
+
23
+ window.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
+ };
@@ -1,12 +1,38 @@
1
1
  /*!
2
2
  * dpHelper <https://github.com/passariello/dpHelper>
3
- *
4
- * storage
5
- *
6
3
  * Copyright (c) 2021, Dario Passariello.
7
4
  * Licensed under the Apache-2.0 License.
8
5
  */
9
6
 
7
+ /***********************************************************************/
8
+
9
+ var description = {
10
+ "name" : "Handle Local Storage",
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
+ window.dphelper._list.scripts.push( description );
35
+
10
36
  /***********************************************************************/
11
37
 
12
38
  window.dphelper.storage = {