dphelper 0.2.30 → 0.2.34

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 (82) hide show
  1. package/data/list.json +19 -39
  2. package/init.js +19 -5
  3. package/package.json +5 -7
  4. package/scripts/anchorToOnClick.js +15 -3
  5. package/scripts/array.js +29 -3
  6. package/scripts/console.js +86 -0
  7. package/scripts/cookie.js +97 -71
  8. package/scripts/currency.js +31 -11
  9. package/scripts/date.js +101 -0
  10. package/scripts/disable.js +90 -0
  11. package/scripts/event.js +39 -0
  12. package/scripts/font.js +52 -0
  13. package/scripts/form.js +113 -0
  14. package/scripts/indexedDB.js +47 -10
  15. package/scripts/json.js +42 -0
  16. package/scripts/load.js +70 -0
  17. package/scripts/noCache.js +26 -14
  18. package/scripts/number.js +42 -0
  19. package/scripts/obj.js +81 -0
  20. package/scripts/onBeforeUnLoad.js +120 -108
  21. package/scripts/parseBool.js +27 -15
  22. package/scripts/path.js +94 -0
  23. package/scripts/promise.js +35 -0
  24. package/scripts/purge.js +53 -41
  25. package/scripts/pushState.js +33 -14
  26. package/scripts/screen.js +64 -0
  27. package/scripts/scrollbar.js +226 -0
  28. package/scripts/{handleEvent.js → shortcut.js} +70 -59
  29. package/scripts/storage.js +29 -3
  30. package/scripts/svg.js +372 -0
  31. package/scripts/text.js +78 -0
  32. package/scripts/time.js +41 -0
  33. package/scripts/timer.js +35 -0
  34. package/scripts/trigger.js +37 -0
  35. package/scripts/uuid.js +33 -14
  36. package/scripts/window.js +50 -38
  37. package/#cmd.exe.lnk +0 -0
  38. package/.github/workflows/codeql-analysis.yml +0 -70
  39. package/scripts/.OLD/arrayDeleteItem.js +0 -35
  40. package/scripts/.OLD/arrayItemFinder.js +0 -22
  41. package/scripts/.OLD/arrayMerge.js +0 -20
  42. package/scripts/.OLD/arrayUnique.js +0 -15
  43. package/scripts/.OLD/loadAsset.js +0 -26
  44. package/scripts/addListenerMulti.js +0 -10
  45. package/scripts/camelCase.js +0 -29
  46. package/scripts/date2Iso.js +0 -20
  47. package/scripts/date2MMDDYYYY.js +0 -16
  48. package/scripts/dateConvert.js +0 -20
  49. package/scripts/dateIso2Epoch.js +0 -17
  50. package/scripts/dateLocal-ISOTime.js +0 -17
  51. package/scripts/dateUTC.js +0 -14
  52. package/scripts/disableSelect.js +0 -46
  53. package/scripts/disableSpellCheck.js +0 -21
  54. package/scripts/epoch.js +0 -14
  55. package/scripts/fontFit.js +0 -24
  56. package/scripts/fullScreen.js +0 -40
  57. package/scripts/isPromise.js +0 -14
  58. package/scripts/jsonCounter.js +0 -21
  59. package/scripts/loadFile.js +0 -17
  60. package/scripts/loadJson.js +0 -15
  61. package/scripts/loadJsonExternal.js +0 -32
  62. package/scripts/nl2br.js +0 -14
  63. package/scripts/object2array.js +0 -16
  64. package/scripts/parseDate.js +0 -19
  65. package/scripts/pathHash.js +0 -19
  66. package/scripts/pathQuery.js +0 -24
  67. package/scripts/pathRail.js +0 -25
  68. package/scripts/printInfo.js +0 -16
  69. package/scripts/randomNum.js +0 -14
  70. package/scripts/randomNumTmr.js +0 -14
  71. package/scripts/scrollCustom.js +0 -41
  72. package/scripts/scrollIndicator.js +0 -67
  73. package/scripts/scrollMemory.js +0 -26
  74. package/scripts/scrollSmooth.js +0 -74
  75. package/scripts/scrollToElement.js +0 -25
  76. package/scripts/serializeForm.js +0 -94
  77. package/scripts/serializeObj.js +0 -47
  78. package/scripts/sleep.js +0 -14
  79. package/scripts/stopConsole.js +0 -49
  80. package/scripts/svgSupport.js +0 -346
  81. package/scripts/textChanger.js +0 -24
  82. package/scripts/triggerClick.js +0 -16
@@ -1,346 +0,0 @@
1
- /*!
2
- * dpHelper <https://github.com/passariello/dpHelper>
3
- *
4
- * svgSupport
5
- *
6
- * Copyright (c) 2021, Dario Passariello.
7
- * Licensed under the Apache-2.0 License.
8
- */
9
-
10
- /***********************************************************************/
11
-
12
- window.dphelper.svg_supportsVml = function () {
13
-
14
- if ( typeof window.dphelper.svg_supportsVml.supported == "undefined" ) {
15
-
16
- let a = document.body.appendChild( document.createElement( 'div' ) );
17
- a.innerHTML = '<v:shape id="vml_flag1" adj="1" />';
18
-
19
- let b = a.firstChild;
20
- b.style.behavior = "url(#default#VML)";
21
- window.dphelper.svg_supportsVml.supported = b ? typeof b.adj == "object" : true;
22
- a.parentNode.removeChild( a );
23
-
24
- }
25
-
26
- return window.dphelper.svg_supportsVml.supported;
27
-
28
- };
29
-
30
- window.dphelper.svg_supportsVml();
31
-
32
- /**************************************************************************************************/
33
- /**************************************************************************************************/
34
-
35
- window.dphelper.svg_initConnection = function( container, source1, source2, cb ) {
36
-
37
- if( $( container ).find( 'svg' ) ) {
38
- window.dphelper.svg_removeConnection( container );
39
- }
40
-
41
- source1 = window.dphelper.svg_setConnector( source1[ 0 ], source1[ 1 ] );
42
- source2 = window.dphelper.svg_setConnector( source2[ 0 ], source2[ 1 ] );
43
-
44
- let parentCoords = container.getBoundingClientRect();
45
-
46
- let xmlns = "http://www.w3.org/2000/svg";
47
- let boxWidth = container.offsetWidth * 10;
48
- let boxHeight = container.offsetHeight * 10;
49
-
50
- // create svg container
51
- let svgElem = document.createElementNS( xmlns, "svg" );
52
-
53
- svgElem.setAttribute( "xmlns" , xmlns );
54
- svgElem.setAttributeNS( null , "id" , "pathConnection" );
55
- svgElem.setAttributeNS( null , "viewBox" , "0 0 " + boxWidth + " " + boxHeight );
56
- svgElem.setAttributeNS( null , "width" , boxWidth );
57
- svgElem.setAttributeNS( null , "height" , boxHeight );
58
- svgElem.style.display = "block";
59
-
60
- /*
61
- // TO DO: smaller cyrcle
62
- // DARIO: probably is too invasive on UI, I change just border on parts_container_
63
-
64
- // create arrow
65
- let defs = document.createElementNS(xmlns, "defs");
66
- let marker = document.createElementNS(xmlns, "marker");
67
- let path = document.createElementNS(xmlns, "path");
68
- marker.setAttributeNS(null, 'id', 'head');
69
- marker.setAttributeNS(null, 'orient', 'auto');
70
- marker.setAttributeNS(null, 'markerWidth', '20');
71
- marker.setAttributeNS(null, 'markerHeight', '40');
72
- marker.setAttributeNS(null, 'refX', '0');
73
- marker.setAttributeNS(null, 'refY', '3');
74
- path.setAttributeNS(null, 'd', 'M0,0 V6 L3,3 Z');
75
- marker.appendChild(path);
76
- defs.appendChild(marker);
77
- svgElem.appendChild(defs);
78
- */
79
-
80
- // create rect which overlaps source1
81
- let rect1 = document.createElementNS( xmlns , "rect" );
82
- let coords = source1.getBoundingClientRect();
83
-
84
- rect1.setAttributeNS( null, 'x', coords.left - parentCoords.left );
85
- rect1.setAttributeNS( null, 'y', coords.top - parentCoords.top );
86
- rect1.setAttributeNS( null, 'width', coords.width );
87
- rect1.setAttributeNS( null, 'height', coords.height );
88
- svgElem.appendChild( rect1 );
89
-
90
- // create rect which overlaps source2
91
- let rect2 = document.createElementNS( xmlns, "rect" );
92
- coords = source2.getBoundingClientRect();
93
-
94
- rect2.setAttributeNS( null, 'x', coords.left - parentCoords.left );
95
- rect2.setAttributeNS( null, 'y', coords.top - parentCoords.top );
96
- rect2.setAttributeNS( null, 'width', coords.width );
97
- rect2.setAttributeNS( null, 'height', coords.height );
98
- svgElem.appendChild( rect2 );
99
-
100
- // create path connecting both rects
101
- let path = document.createElementNS( xmlns, "path" );
102
-
103
- path.setAttributeNS( null, 'id', 'connection' );
104
- path.setAttributeNS( null, 'marker-end', 'url(#head)' );
105
- svgElem.appendChild( path );
106
-
107
- container.appendChild( svgElem );
108
-
109
- window.dphelper.svg_updateConnection( $( rect1 )[0], $( rect2 )[0], $( '#connection' )[0]);
110
-
111
- if( typeof cb == 'function' ) {
112
- cb( source1, source2 );
113
- }
114
-
115
- };
116
-
117
- /**************************************************************************************************/
118
-
119
- window.dphelper.svg_updateConnection = function( rect1 , rect2 , cxn ) {
120
-
121
- // Top left coordinates
122
- let x1 = parseFloat( rect1.getAttribute( 'x' ) );
123
- let y1 = parseFloat( rect1.getAttribute( 'y' ) );
124
- let x2 = parseFloat( rect2.getAttribute( 'x') );
125
- let y2 = parseFloat( rect2.getAttribute( 'y' ) );
126
-
127
- // Half widths and half heights
128
- let w1 = parseFloat( rect1.getAttribute( 'width' ) ) / 2;
129
- let h1 = parseFloat( rect1.getAttribute( 'height' ) ) / 2;
130
- let w2 = parseFloat( rect2.getAttribute( 'width' ) ) / 2;
131
- let h2 = parseFloat( rect2.getAttribute( 'height' ) ) / 2;
132
-
133
- // Center coordinates
134
- let cx1 = x1 + w1;
135
- let cy1 = y1 + h1;
136
- let cx2 = x2 + w2;
137
- let cy2 = y2 + h2;
138
-
139
- // Distance between centers
140
- let dx = cx2 - cx1;
141
- let dy = cy2 - cy1;
142
-
143
- let p1 = window.dphelper.svg_getIntersection( dx , dy , cx1 , cy1 , w1 , h1 );
144
- let p2 = window.dphelper.svg_getIntersection( -dx , -dy , cx2 , cy2 , w2 , h2 );
145
-
146
- // Distance between edges
147
- let dx1 = p2[ 0 ] - p1[ 0 ];
148
-
149
- let d = window.dphelper.svg_getCurve( p1 , p2 , dx1 );
150
-
151
- // Set a path connector
152
- cxn.setAttributeNS( null , 'd' , "M" + cx1 + "," + cy1 + d + cx2 + "," + cy2 );
153
-
154
- // Set a line connector
155
- // cxn.setAttributeNS( null , 'x1' , p1[0] );
156
- // cxn.setAttributeNS( null , 'y1' , p1[1] );
157
- // cxn.setAttributeNS( null , 'x2' , p2[0] );
158
- // cxn.setAttributeNS( null , 'y2' , p2[1] );
159
-
160
- };
161
-
162
- /**************************************************************************************************/
163
-
164
- window.dphelper.svg_getCurve = function( p1 , p2 , dx ) {
165
-
166
- let curve = dx / 2;
167
- let d = " C" + ( curve + p1[0] ) + "," + p1[1] + " " + ( p2[0] - curve ) + "," + p2[1] + " ";
168
- return d;
169
-
170
- };
171
-
172
- window.dphelper.svg_getIntersection = function( dx , dy , cx , cy , w , h ) {
173
-
174
- if ( Math.abs( dy / dx ) < h / w )
175
- return [ cx + ( dx > 0 ? w : -w ), cy + dy * w / Math.abs( dx ) ];
176
- else
177
- return [ cx + dx * h / Math.abs( dy ), cy + ( dy > 0 ? h : -h ) ];
178
-
179
- };
180
-
181
- /**************************************************************************************************/
182
-
183
- window.dphelper.svg_makeScrollable = function( svgContainer , scrollContainer , elm1 , elm2 , rect1 , rect2 ) {
184
-
185
- //let scrollCoords = scrollContainer.getBoundingClientRect();
186
- let svgCoords = svgContainer.getBoundingClientRect();
187
-
188
- let el = [ elm1 , elm2 ];
189
- let rec = [ rect1 , rect2 ];
190
- let coords = [];
191
-
192
- for( let i = 0; i < el.length; i++ ){
193
-
194
- coords[ i ] = el[ i ].getBoundingClientRect();
195
-
196
- rec[ i ].setAttributeNS( null, 'x', coords[ i ].left - svgCoords.left );
197
- rec[ i ].setAttributeNS( null, 'y', coords[ i ].top - svgCoords.top );
198
- rec[ i ].setAttributeNS( null, 'width', coords[ i ].width );
199
- rec[ i ].setAttributeNS( null, 'height', coords[ i ].height );
200
-
201
- }
202
-
203
- //***************************************************************
204
-
205
- window.dphelper.svg_updateConnection( $( rect1 )[ 0 ], $( rect2 )[ 0 ], $( '#connection' )[ 0 ]);
206
-
207
- };
208
-
209
- /**************************************************************************************************/
210
-
211
- window.dphelper.svg_makeDraggable = function( evt ) {
212
-
213
- let svg = evt.target;
214
- svg.addEventListener( 'mousedown' , startDrag );
215
- svg.addEventListener( 'mousemove' , drag );
216
- svg.addEventListener( 'mouseup' , endDrag );
217
-
218
- function getMousePosition( e ) {
219
- let CTM = svg.getScreenCTM();
220
- return {
221
- x: ( evt.clientX - CTM.e ) / CTM.a,
222
- y: ( evt.clientY - CTM.f ) / CTM.d
223
- };
224
- }
225
-
226
- let selectedElement, offset;
227
-
228
- function startDrag( evt ) {
229
-
230
- if ( evt.target.classList.contains( 'draggable' ) ) {
231
- selectedElement = evt.target;
232
- offset = getMousePosition( evt );
233
- offset.x -= parseFloat( selectedElement.getAttributeNS( null , "x" ) );
234
- offset.y -= parseFloat( selectedElement.getAttributeNS( null , "y" ) );
235
- }
236
-
237
- }
238
-
239
- function drag( evt ) {
240
-
241
- if ( selectedElement ) {
242
- let coord = getMousePosition( evt );
243
- selectedElement.setAttributeNS( null, "x" , coord.x - offset.x );
244
- selectedElement.setAttributeNS( null, "y" , coord.y - offset.y );
245
- window.dphelper.svg_updateConnection();
246
- }
247
-
248
- }
249
-
250
- function endDrag( evt ) {
251
- selectedElement = null;
252
- }
253
-
254
- };
255
-
256
- /**************************************************************************************************/
257
-
258
- window.dphelper.svg_setConnector = function( source , side ) {
259
-
260
- let style;
261
- let span = $( '<span class="connector"></span>' );
262
-
263
- $( source ).css( 'position' , 'relative' );
264
-
265
- span.css({
266
- position: 'absolute',
267
- width: '5px',
268
- height: '5px',
269
- });
270
-
271
- switch( side ) {
272
- case 'top':
273
- style = {
274
- left: '50%',
275
- top: '2.5px',
276
- marginLeft: '2.5px'
277
- };
278
- break;
279
- case 'right':
280
- style = {
281
- top: '50%',
282
- right: '2.5px',
283
- marginTop: '-2.5px'
284
- };
285
- break;
286
- case 'bottom':
287
- style = {
288
- left: '50%',
289
- bottom: '-2.5px',
290
- marginLeft: '2.5px'
291
- };
292
- break;
293
- case 'left':
294
- style = {
295
- top: '50%',
296
- left: '-2.5px',
297
- marginTop: '-2.5px'
298
- };
299
- break;
300
- default:
301
- style = {};
302
- }
303
-
304
- span.css( style );
305
-
306
- $( source ).append( span );
307
-
308
- return $( span )[ 0 ];
309
- };
310
-
311
- /**************************************************************************************************/
312
-
313
- window.dphelper.svg_handleSvgToggle = function( evt , container , source1 , source2 ) {
314
-
315
- if( $( evt.target ).prop( 'checked' ) && $( source1 ).length && $( source2 ).length ) {
316
-
317
- window.dphelper.cookie.set( $( evt.target ).attr( 'id' ), 1, 365 );
318
-
319
- window.dphelper.svg_initConnection( container[0], [ $( source1 )[0], 'right' ], [ $( source2 )[0], 'left' ], function( source1 , source2 ) {
320
-
321
- $( '#parts-left-body' ).on( 'scroll', function( evt ){
322
- window.dphelper.svg_makeScrollable( $( container )[0], $( '#parts-left-body' )[0], $( source1 )[0],
323
- $( source2 )[0], $( '#parts svg rect' )[0], $( '#parts svg rect' )[ 1 ] );
324
- });
325
-
326
- });
327
-
328
- } else {
329
-
330
- window.dphelper.svg_removeConnection( container );
331
- $( '#parts-left-body' ).unbind( 'scroll' );
332
- window.dphelper.cookie.set( $( evt.target ).attr( 'id' ), 0, 365 );
333
-
334
- }
335
-
336
- };
337
-
338
- /**************************************************************************************************/
339
-
340
- window.dphelper.svg_removeConnection = function( container ) {
341
-
342
- $( container ).find( 'svg#pathConnection' ).each( function( i , elm ) {
343
- $( elm ).remove();
344
- });
345
-
346
- };
@@ -1,24 +0,0 @@
1
- /*!
2
- * dpHelper <https://github.com/passariello/dpHelper>
3
- *
4
- * capitalize, lower, upper
5
- *
6
- * Copyright (c) 2021, Dario Passariello.
7
- * Licensed under the Apache-2.0 License.
8
- */
9
-
10
- /***********************************************************************/
11
-
12
- window.dphelper.capitalize = (txt) => {
13
- return txt.toLowerCase().replace(/\b\w/g, function (l) { return l.toUpperCase(); });
14
- };
15
-
16
- /******************************************************************************/
17
- window.dphelper.lower = (txt) => {
18
- return txt.toLowerCase();
19
- };
20
-
21
- /******************************************************************************/
22
- window.dphelper.upper = (txt) => {
23
- return txt.toUpperCase();
24
- };
@@ -1,16 +0,0 @@
1
- /*!
2
- * dpHelper <https://github.com/passariello/dpHelper>
3
- *
4
- * triggerClick
5
- *
6
- * Copyright (c) 2021, Dario Passariello.
7
- * Licensed under the Apache-2.0 License.
8
- */
9
-
10
- /***********************************************************************/
11
-
12
- window.dphelper.triggerClick = function ( elem ) {
13
- let selector = document.querySelector( elem );
14
- if( selector ) selector.click();
15
- return;
16
- };