dphelper 0.2.42 → 0.2.43

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 (51) hide show
  1. package/index.js +2 -12
  2. package/index.js.LICENSE.txt +24 -0
  3. package/package.json +2 -5
  4. package/.editorconfig +0 -14
  5. package/.eslintrc.json +0 -36
  6. package/.gitattributes +0 -2
  7. package/.jshintrc +0 -13
  8. package/.prettierignore +0 -2
  9. package/.prettierrc +0 -7
  10. package/.vscode/settings.json +0 -19
  11. package/3party/shortcut.js +0 -224
  12. package/data/list.json +0 -19
  13. package/index.d.ts +0 -9
  14. package/init.js +0 -51
  15. package/scripts/anchorToOnClick.js +0 -47
  16. package/scripts/array.js +0 -142
  17. package/scripts/browser.js +0 -65
  18. package/scripts/console.js +0 -86
  19. package/scripts/coodinates.js +0 -41
  20. package/scripts/cookie.js +0 -97
  21. package/scripts/currency.js +0 -41
  22. package/scripts/date.js +0 -101
  23. package/scripts/disable.js +0 -90
  24. package/scripts/event.js +0 -39
  25. package/scripts/font.js +0 -52
  26. package/scripts/form.js +0 -113
  27. package/scripts/function.js +0 -47
  28. package/scripts/indexedDB.js +0 -222
  29. package/scripts/json.js +0 -42
  30. package/scripts/load.js +0 -85
  31. package/scripts/noCache.js +0 -26
  32. package/scripts/number.js +0 -66
  33. package/scripts/obj.js +0 -81
  34. package/scripts/onBeforeUnLoad.js +0 -120
  35. package/scripts/parseBool.js +0 -27
  36. package/scripts/path.js +0 -94
  37. package/scripts/promise.js +0 -35
  38. package/scripts/purge.js +0 -53
  39. package/scripts/screen.js +0 -64
  40. package/scripts/scrollbar.js +0 -226
  41. package/scripts/shortcut.js +0 -70
  42. package/scripts/storage.js +0 -62
  43. package/scripts/svg.js +0 -372
  44. package/scripts/text.js +0 -78
  45. package/scripts/time.js +0 -41
  46. package/scripts/timer.js +0 -35
  47. package/scripts/trigger.js +0 -46
  48. package/scripts/type.js +0 -56
  49. package/scripts/uuid.js +0 -33
  50. package/scripts/window.js +0 -50
  51. package/ws.code-workspace +0 -73
package/scripts/svg.js DELETED
@@ -1,372 +0,0 @@
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" : "Realtime SVG",
11
- "description" : "test",
12
- "version" : "0.0.1",
13
- "command" : "svg",
14
- "subCommand" : [
15
- {
16
- "name":"check",
17
- "description":"test"
18
- },{
19
- "name":"init",
20
- "description":"test"
21
- },{
22
- "name":"update",
23
- "description":"test"
24
- },{
25
- "name":"getCurve",
26
- "description":"test"
27
- },{
28
- "name":"getIntersection",
29
- "description":"test"
30
- },{
31
- "name":"setConnector",
32
- "description":"test"
33
- },{
34
- "name":"removeConnection",
35
- "description":"test"
36
- },{
37
- "name":"makeScrollable",
38
- "description":"test"
39
- },{
40
- "name":"makeDraggable",
41
- "description":"test"
42
- },{
43
- "name":"toggle",
44
- "description":"test"
45
- }
46
- ],
47
- "example" : "",
48
- "author" : "Dario Passariello",
49
- "active" : true
50
- };
51
-
52
- window.dphelper._list.scripts.push( description );
53
-
54
- /***********************************************************************/
55
-
56
- window.dphelper.svg = {
57
-
58
- check: () => {
59
- if ( typeof window.dphelper.svg.check.supported == "undefined" ) {
60
- let a = document.body.appendChild( document.createElement( 'div' ) );
61
- a.innerHTML = '<v:shape id="vml_flag1" adj="1" />';
62
- let b = a.firstChild;
63
- b.style.behavior = "url(#default#VML)";
64
- window.dphelper.svg.check.supported = b ? typeof b.adj == "object" : true;
65
- a.parentNode.removeChild( a );
66
- }
67
- return window.dphelper.svg.check.supported;
68
- },
69
-
70
- init: function( container, source1, source2, cb ) {
71
-
72
- if( $( container ).find( 'svg' ) ) {
73
- window.dphelper.svg_removeConnection( container );
74
- }
75
-
76
- source1 = window.dphelper.svg.setConnector( source1[ 0 ], source1[ 1 ] );
77
- source2 = window.dphelper.svg.setConnector( source2[ 0 ], source2[ 1 ] );
78
-
79
- let parentCoords = container.getBoundingClientRect();
80
-
81
- let xmlns = "http://www.w3.org/2000/svg";
82
- let boxWidth = container.offsetWidth * 10;
83
- let boxHeight = container.offsetHeight * 10;
84
-
85
- // create svg container
86
- let svgElem = document.createElementNS( xmlns, "svg" );
87
-
88
- svgElem.setAttribute( "xmlns" , xmlns );
89
- svgElem.setAttributeNS( null , "id" , "pathConnection" );
90
- svgElem.setAttributeNS( null , "viewBox" , "0 0 " + boxWidth + " " + boxHeight );
91
- svgElem.setAttributeNS( null , "width" , boxWidth );
92
- svgElem.setAttributeNS( null , "height" , boxHeight );
93
- svgElem.style.display = "block";
94
-
95
- /*
96
- // TO DO: smaller cyrcle
97
- // DARIO: probably is too invasive on UI, I change just border on parts_container_
98
-
99
- // create arrow
100
- let defs = document.createElementNS(xmlns, "defs");
101
- let marker = document.createElementNS(xmlns, "marker");
102
- let path = document.createElementNS(xmlns, "path");
103
- marker.setAttributeNS(null, 'id', 'head');
104
- marker.setAttributeNS(null, 'orient', 'auto');
105
- marker.setAttributeNS(null, 'markerWidth', '20');
106
- marker.setAttributeNS(null, 'markerHeight', '40');
107
- marker.setAttributeNS(null, 'refX', '0');
108
- marker.setAttributeNS(null, 'refY', '3');
109
- path.setAttributeNS(null, 'd', 'M0,0 V6 L3,3 Z');
110
- marker.appendChild(path);
111
- defs.appendChild(marker);
112
- svgElem.appendChild(defs);
113
- */
114
-
115
- // create rect which overlaps source1
116
- let rect1 = document.createElementNS( xmlns , "rect" );
117
- let coords = source1.getBoundingClientRect();
118
-
119
- rect1.setAttributeNS( null, 'x', coords.left - parentCoords.left );
120
- rect1.setAttributeNS( null, 'y', coords.top - parentCoords.top );
121
- rect1.setAttributeNS( null, 'width', coords.width );
122
- rect1.setAttributeNS( null, 'height', coords.height );
123
- svgElem.appendChild( rect1 );
124
-
125
- // create rect which overlaps source2
126
- let rect2 = document.createElementNS( xmlns, "rect" );
127
- coords = source2.getBoundingClientRect();
128
-
129
- rect2.setAttributeNS( null, 'x', coords.left - parentCoords.left );
130
- rect2.setAttributeNS( null, 'y', coords.top - parentCoords.top );
131
- rect2.setAttributeNS( null, 'width', coords.width );
132
- rect2.setAttributeNS( null, 'height', coords.height );
133
- svgElem.appendChild( rect2 );
134
-
135
- // create path connecting both rects
136
- let path = document.createElementNS( xmlns, "path" );
137
-
138
- path.setAttributeNS( null, 'id', 'connection' );
139
- path.setAttributeNS( null, 'marker-end', 'url(#head)' );
140
- svgElem.appendChild( path );
141
-
142
- container.appendChild( svgElem );
143
-
144
- window.dphelper.svg.update( $( rect1 )[0], $( rect2 )[0], $( '#connection' )[0]);
145
-
146
- if( typeof cb == 'function' ) {
147
- cb( source1, source2 );
148
- }
149
-
150
- },
151
-
152
- update: function( rect1 , rect2 , cxn ) {
153
-
154
- // Top left coordinates
155
- let x1 = parseFloat( rect1.getAttribute( 'x' ) );
156
- let y1 = parseFloat( rect1.getAttribute( 'y' ) );
157
- let x2 = parseFloat( rect2.getAttribute( 'x') );
158
- let y2 = parseFloat( rect2.getAttribute( 'y' ) );
159
-
160
- // Half widths and half heights
161
- let w1 = parseFloat( rect1.getAttribute( 'width' ) ) / 2;
162
- let h1 = parseFloat( rect1.getAttribute( 'height' ) ) / 2;
163
- let w2 = parseFloat( rect2.getAttribute( 'width' ) ) / 2;
164
- let h2 = parseFloat( rect2.getAttribute( 'height' ) ) / 2;
165
-
166
- // Center coordinates
167
- let cx1 = x1 + w1;
168
- let cy1 = y1 + h1;
169
- let cx2 = x2 + w2;
170
- let cy2 = y2 + h2;
171
-
172
- // Distance between centers
173
- let dx = cx2 - cx1;
174
- let dy = cy2 - cy1;
175
-
176
- let p1 = window.dphelper.svg.getIntersection( dx , dy , cx1 , cy1 , w1 , h1 );
177
- let p2 = window.dphelper.svg.getIntersection( -dx , -dy , cx2 , cy2 , w2 , h2 );
178
-
179
- // Distance between edges
180
- let dx1 = p2[ 0 ] - p1[ 0 ];
181
-
182
- let d = window.dphelper.svg.getCurve( p1 , p2 , dx1 );
183
-
184
- // Set a path connector
185
- cxn.setAttributeNS( null , 'd' , "M" + cx1 + "," + cy1 + d + cx2 + "," + cy2 );
186
-
187
- // Set a line connector
188
- // cxn.setAttributeNS( null , 'x1' , p1[0] );
189
- // cxn.setAttributeNS( null , 'y1' , p1[1] );
190
- // cxn.setAttributeNS( null , 'x2' , p2[0] );
191
- // cxn.setAttributeNS( null , 'y2' , p2[1] );
192
-
193
- },
194
-
195
- getCurve: function( p1 , p2 , dx ) {
196
-
197
- let curve = dx / 2;
198
- let d = " C" + ( curve + p1[0] ) + "," + p1[1] + " " + ( p2[0] - curve ) + "," + p2[1] + " ";
199
- return d;
200
-
201
- },
202
-
203
- getIntersection: function( dx , dy , cx , cy , w , h ) {
204
-
205
- if ( Math.abs( dy / dx ) < h / w )
206
- return [ cx + ( dx > 0 ? w : -w ), cy + dy * w / Math.abs( dx ) ];
207
- else
208
- return [ cx + dx * h / Math.abs( dy ), cy + ( dy > 0 ? h : -h ) ];
209
-
210
- },
211
-
212
- setConnector: function( source , side ) {
213
-
214
- let style;
215
- let span = $( '<span class="connector"></span>' );
216
-
217
- $( source ).css( 'position' , 'relative' );
218
-
219
- span.css({
220
- position: 'absolute',
221
- width: '5px',
222
- height: '5px',
223
- });
224
-
225
- switch( side ) {
226
- case 'top':
227
- style = {
228
- left: '50%',
229
- top: '2.5px',
230
- marginLeft: '2.5px'
231
- };
232
- break;
233
- case 'right':
234
- style = {
235
- top: '50%',
236
- right: '2.5px',
237
- marginTop: '-2.5px'
238
- };
239
- break;
240
- case 'bottom':
241
- style = {
242
- left: '50%',
243
- bottom: '-2.5px',
244
- marginLeft: '2.5px'
245
- };
246
- break;
247
- case 'left':
248
- style = {
249
- top: '50%',
250
- left: '-2.5px',
251
- marginTop: '-2.5px'
252
- };
253
- break;
254
- default:
255
- style = {};
256
- }
257
-
258
- span.css( style );
259
-
260
- $( source ).append( span );
261
-
262
- return $( span )[ 0 ];
263
- },
264
-
265
- removeConnection: function( container ) {
266
-
267
- $( container ).find( 'svg#pathConnection' ).each( function( i , elm ) {
268
- $( elm ).remove();
269
- });
270
-
271
- },
272
-
273
- makeScrollable: function( svgContainer , scrollContainer , elm1 , elm2 , rect1 , rect2 ) {
274
-
275
- //let scrollCoords = scrollContainer.getBoundingClientRect();
276
- let svgCoords = svgContainer.getBoundingClientRect();
277
-
278
- let el = [ elm1 , elm2 ];
279
- let rec = [ rect1 , rect2 ];
280
- let coords = [];
281
-
282
- for( let i = 0; i < el.length; i++ ){
283
-
284
- coords[ i ] = el[ i ].getBoundingClientRect();
285
-
286
- rec[ i ].setAttributeNS( null, 'x', coords[ i ].left - svgCoords.left );
287
- rec[ i ].setAttributeNS( null, 'y', coords[ i ].top - svgCoords.top );
288
- rec[ i ].setAttributeNS( null, 'width', coords[ i ].width );
289
- rec[ i ].setAttributeNS( null, 'height', coords[ i ].height );
290
-
291
- }
292
-
293
- //***************************************************************
294
-
295
- window.dphelper.svg.update( $( rect1 )[ 0 ], $( rect2 )[ 0 ], $( '#connection' )[ 0 ]);
296
-
297
- },
298
-
299
- makeDraggable: function( evt ) {
300
-
301
- let svg = evt.target;
302
- svg.addEventListener( 'mousedown' , startDrag );
303
- svg.addEventListener( 'mousemove' , drag );
304
- svg.addEventListener( 'mouseup' , endDrag );
305
-
306
- function getMousePosition( e ) {
307
- let CTM = svg.getScreenCTM();
308
- return {
309
- x: ( evt.clientX - CTM.e ) / CTM.a,
310
- y: ( evt.clientY - CTM.f ) / CTM.d
311
- };
312
- }
313
-
314
- let selectedElement, offset;
315
-
316
- function startDrag( evt ) {
317
-
318
- if ( evt.target.classList.contains( 'draggable' ) ) {
319
- selectedElement = evt.target;
320
- offset = getMousePosition( evt );
321
- offset.x -= parseFloat( selectedElement.getAttributeNS( null , "x" ) );
322
- offset.y -= parseFloat( selectedElement.getAttributeNS( null , "y" ) );
323
- }
324
-
325
- }
326
-
327
- function drag( evt ) {
328
-
329
- if ( selectedElement ) {
330
- let coord = getMousePosition( evt );
331
- selectedElement.setAttributeNS( null, "x" , coord.x - offset.x );
332
- selectedElement.setAttributeNS( null, "y" , coord.y - offset.y );
333
- window.dphelper.svg.update();
334
- }
335
-
336
- }
337
-
338
- function endDrag( evt ) {
339
- selectedElement = null;
340
- }
341
-
342
- },
343
-
344
- toggle: function( evt , container , source1 , source2 ) {
345
-
346
- if( $( evt.target ).prop( 'checked' ) && $( source1 ).length && $( source2 ).length ) {
347
-
348
- window.dphelper.cookie.set( $( evt.target ).attr( 'id' ), 1, 365 );
349
-
350
- window.dphelper.svg_initConnection( container[0], [ $( source1 )[0], 'right' ], [ $( source2 )[0], 'left' ], function( source1 , source2 ) {
351
-
352
- $( '#parts-left-body' ).on( 'scroll', function( evt ){
353
- window.dphelper.svg.makeScrollable( $( container )[0], $( '#parts-left-body' )[0], $( source1 )[0],
354
- $( source2 )[0], $( '#parts svg rect' )[0], $( '#parts svg rect' )[ 1 ] );
355
- });
356
-
357
- });
358
-
359
- } else {
360
-
361
- window.dphelper.svg_removeConnection( container );
362
- $( '#parts-left-body' ).unbind( 'scroll' );
363
- window.dphelper.cookie.set( $( evt.target ).attr( 'id' ), 0, 365 );
364
-
365
- }
366
-
367
- }
368
-
369
- };
370
-
371
- window.dphelper.svg.check();
372
-
package/scripts/text.js DELETED
@@ -1,78 +0,0 @@
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" : "Text",
11
- "description" : "test",
12
- "version" : "0.0.1",
13
- "command" : "text",
14
- "subCommand" : [
15
- {
16
- "name":"capitalize",
17
- "description":"test"
18
- },{
19
- "name":"lower",
20
- "description":"test"
21
- },{
22
- "name":"upper",
23
- "description":"test"
24
- },{
25
- "name":"nl2br",
26
- "description":"test"
27
- },{
28
- "name":"camelCase.toSpace",
29
- "description":"test"
30
- },{
31
- "name":"camelCase.toUnderscore",
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.text ={
45
-
46
- capitalize: (txt) => {
47
- return txt.toLowerCase().replace(/\b\w/g, function (l) { return l.toUpperCase(); });
48
- },
49
-
50
- lower: (txt) => {
51
- return txt.toLowerCase();
52
- },
53
-
54
- upper: (txt) => {
55
- return txt.toUpperCase();
56
- },
57
-
58
- nl2br: (str) => {
59
- return str.replace(/(?:\r\n|\r|\n)/g, '<br>');
60
- },
61
-
62
- camelCase: {
63
-
64
- toSpace: ( string ) => {
65
- return string
66
- .replace(/([A-Z])/g, ' $1')
67
- .replace(/^./, function(str){ return str.toUpperCase(); });
68
- },
69
-
70
- toUnderscore: ( string ) => {
71
- return string
72
- .replace(/\.?([A-Z])/g, function (x,y){ return "_" + y.toLowerCase(); })
73
- .replace(/^_/, "");
74
- },
75
-
76
- }
77
-
78
- };
package/scripts/time.js DELETED
@@ -1,41 +0,0 @@
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
- * dpHelper <https://github.com/passariello/dpHelper>
9
- * Copyright (c) 2021, Dario Passariello.
10
- * Licensed under the Apache-2.0 License.
11
- */
12
-
13
- /***********************************************************************/
14
-
15
- var description = {
16
- "name" : "Time",
17
- "description" : "test",
18
- "version" : "0.0.1",
19
- "command" : "time",
20
- "subCommand" : [
21
- {
22
- "name":"epoch",
23
- "description":"test"
24
- }
25
- ],
26
- "example" : "",
27
- "author" : "Dario Passariello",
28
- "active" : true
29
- };
30
-
31
- window.dphelper._list.scripts.push( description );
32
-
33
- /***********************************************************************/
34
-
35
- window.dphelper.time ={
36
-
37
- epoch: () => {
38
- return new Date().getTime();
39
- }
40
-
41
- };
package/scripts/timer.js DELETED
@@ -1,35 +0,0 @@
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" : "Timer",
11
- "description" : "test",
12
- "version" : "0.0.1",
13
- "command" : "timer",
14
- "subCommand" : [
15
- {
16
- "name":"sleep",
17
- "description":"test",
18
- }
19
- ],
20
- "example" : "",
21
- "author" : "Dario Passariello",
22
- "active" : true
23
- };
24
-
25
- window.dphelper._list.scripts.push( description );
26
-
27
- /***********************************************************************/
28
-
29
- window.dphelper.timer ={
30
-
31
- sleep: (ms) => {
32
- return new Promise( resolve => setTimeout( resolve, ms) );
33
- }
34
-
35
- };
@@ -1,46 +0,0 @@
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" : "Triggers",
11
- "description" : "test",
12
- "version" : "0.0.1",
13
- "command" : "trigger",
14
- "subCommand" : [
15
- {
16
- "name":"click",
17
- "description":"test"
18
- }
19
- ],
20
- "example" : "",
21
- "author" : "Dario Passariello",
22
- "active" : true
23
- };
24
-
25
- window.dphelper._list.scripts.push( description );
26
-
27
- /***********************************************************************/
28
-
29
- window.dphelper.trigger = {
30
-
31
- click: ( elem ) => {
32
- let selector = document.querySelector( elem );
33
- if( selector ) selector.click();
34
- return;
35
- },
36
-
37
- change: ( elem ) => {
38
- let selector = document.querySelector( elem );
39
- var ev = new Event('input', { bubbles: true} );
40
- ev.simulated = true;
41
- //selector.value = 'Something new';
42
- selector.dispatchEvent(ev);
43
- }
44
-
45
- };
46
-
package/scripts/type.js DELETED
@@ -1,56 +0,0 @@
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" : "Type",
11
- "description" : "test",
12
- "version" : "0.0.1",
13
- "command" : "type",
14
- "subCommand" : [
15
- {
16
- name:"typeOf",
17
- description:"test"
18
- },{
19
- name:"instOfObj",
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.type = {
33
-
34
- typeOf: (p) => { return typeof p; },
35
-
36
- instOfObj: (p) => { return p instanceof Object; },
37
-
38
- isNaN: (p) => { return function (i) { return !p(i); }; },
39
-
40
- isPrime: (number) => {
41
- var divisor = parseInt(number / 2, 10);
42
- var prime = true;
43
- while (divisor > 1) {
44
- if (number % divisor === 0) {
45
- prime = false;
46
- divisor = 0;
47
- } else {
48
- divisor -= 1;
49
- }
50
- }
51
- return prime === true;
52
- },
53
-
54
-
55
-
56
- };
package/scripts/uuid.js DELETED
@@ -1,33 +0,0 @@
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" : "uuid Generator",
11
- "description" : "test",
12
- "version" : "0.0.1",
13
- "command" : "uuid",
14
- "subCommand" : [
15
- {
16
- "name":"v5",
17
- "description":"test"
18
- }
19
- ],
20
- "example" : "",
21
- "author" : "Dario Passariello",
22
- "active" : true
23
- };
24
-
25
- window.dphelper._list.scripts.push( description );
26
-
27
- /***********************************************************************/
28
-
29
- window.dphelper.uuid = {
30
- v5: () => {
31
- return ( [1e7] + -1e3 + -4e3 + -8e3 + -1e11 ).replace( /[018]/g, ( a ) => ( a ^ ( ( Math.random() * 16) >> ( a / 4 ) ) ).toString( 16 ) );
32
- }
33
- };