dphelper 0.2.88 → 0.2.89

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 (116) hide show
  1. package/.editorconfig +13 -0
  2. package/.env +3 -0
  3. package/.eslintignore +13 -0
  4. package/.eslintrc.json +87 -0
  5. package/.eslintrc.legacy.json +91 -0
  6. package/.gitattributes +2 -0
  7. package/.hintrc +11 -0
  8. package/.jsbeautifyrc +25 -0
  9. package/.jshintrc +16 -0
  10. package/.prettierignore +2 -0
  11. package/.prettierrc.json +8 -0
  12. package/.stylelintignore +0 -0
  13. package/.stylelintrc.json +468 -0
  14. package/.vscode/launch.json +34 -0
  15. package/.vscode/settings.json +58 -0
  16. package/3party/shortcut.js +224 -0
  17. package/__mocks__/fileMock.js +3 -0
  18. package/__mocks__/styleMock.js +3 -0
  19. package/babel.config.js +30 -0
  20. package/backup.bat +43 -0
  21. package/coverage/coverage-final.json +1 -0
  22. package/coverage/lcov-report/base.css +224 -0
  23. package/coverage/lcov-report/block-navigation.js +87 -0
  24. package/coverage/lcov-report/favicon.png +0 -0
  25. package/coverage/lcov-report/index.html +101 -0
  26. package/coverage/lcov-report/prettify.css +1 -0
  27. package/coverage/lcov-report/prettify.js +2 -0
  28. package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
  29. package/coverage/lcov-report/sorter.js +196 -0
  30. package/coverage/lcov.info +0 -0
  31. package/data/list.json +19 -0
  32. package/dist/LICENSE.txt +209 -0
  33. package/dist/README.md +79 -0
  34. package/elements/button/component.js +0 -0
  35. package/elements/code/component.js +0 -0
  36. package/elements/costants.tsx +13 -0
  37. package/elements/fieldset/component.js +0 -0
  38. package/elements/input/checkbox/component.js +0 -0
  39. package/elements/input/date/component.js +27 -0
  40. package/elements/input/number/component.js +0 -0
  41. package/elements/input/radio/component.js +0 -0
  42. package/elements/input/search/component.js +0 -0
  43. package/elements/input/select/component.js +0 -0
  44. package/elements/input/slider/component.js +0 -0
  45. package/elements/input/switch/component.js +0 -0
  46. package/elements/tab/component.js +0 -0
  47. package/elements/table/component.js +0 -0
  48. package/elements/tags.less +0 -0
  49. package/elements/textarea/component.js +0 -0
  50. package/elements/x-foo/define.js +33 -0
  51. package/elements/x-foo/namespace.d.ts +7 -0
  52. package/index.js +12 -2
  53. package/init.js +87 -0
  54. package/jest.config.js +81 -0
  55. package/node/createTag.js +7 -0
  56. package/node/gitDeploy.js +7 -0
  57. package/node/goLive.js +7 -0
  58. package/package.json +7 -7
  59. package/{assets → public/assets}/images/banner.png +0 -0
  60. package/{assets → public/assets}/logos/logo.svg +0 -0
  61. package/{documents → public/documents}/iDB/list.html +0 -0
  62. package/{documents → public/documents}/iDB/toState.html +0 -0
  63. package/scripts/.OLD/import.js +48 -0
  64. package/scripts/.OLD/onBeforeUnLoad.js +120 -0
  65. package/scripts/.OLD/purge.js +53 -0
  66. package/scripts/.OLD/string.js +27 -0
  67. package/scripts/anchor.js +73 -0
  68. package/scripts/array.js +203 -0
  69. package/scripts/avoid.js +48 -0
  70. package/scripts/browser.js +100 -0
  71. package/scripts/color.js +121 -0
  72. package/scripts/console.js +97 -0
  73. package/scripts/console.mapped.js +160 -0
  74. package/scripts/coods.js +57 -0
  75. package/scripts/cookie.js +105 -0
  76. package/scripts/date.js +179 -0
  77. package/scripts/disable.js +91 -0
  78. package/scripts/errors.js +3 -0
  79. package/scripts/event.js +57 -0
  80. package/scripts/font.js +60 -0
  81. package/scripts/form.js +211 -0
  82. package/scripts/format.js +71 -0
  83. package/scripts/function.js +55 -0
  84. package/scripts/iDB.js +688 -0
  85. package/scripts/json.js +84 -0
  86. package/scripts/load.js +112 -0
  87. package/scripts/math.js +100 -0
  88. package/scripts/obj.js +118 -0
  89. package/scripts/path.js +101 -0
  90. package/scripts/promise.js +56 -0
  91. package/scripts/screen.js +82 -0
  92. package/scripts/scrollbar.js +293 -0
  93. package/scripts/shortcut.js +83 -0
  94. package/scripts/socket.js +184 -0
  95. package/scripts/state.js +87 -0
  96. package/scripts/storage.js +93 -0
  97. package/scripts/store.js +115 -0
  98. package/scripts/svg.js +380 -0
  99. package/scripts/text.js +116 -0
  100. package/scripts/time.js +43 -0
  101. package/scripts/timer.js +54 -0
  102. package/scripts/tool.js +73 -0
  103. package/scripts/trigger.js +57 -0
  104. package/scripts/type.js +76 -0
  105. package/scripts/ui.js +41 -0
  106. package/scripts/window.js +244 -0
  107. package/styles/console.less +95 -0
  108. package/tests/setupJest.tsx +4 -0
  109. package/typings/.OLD/cordova.d.ts +12 -0
  110. package/typings/.OLD/layerpro.d.ts +20 -0
  111. package/typings/.OLD/menupro.d.ts +20 -0
  112. package/typings/dphelper.d.ts +26 -0
  113. package/typings/image.d.ts +5 -0
  114. package/typings/styles.d.ts +23 -0
  115. package/webpack.config.js +249 -0
  116. package/index.js.LICENSE.txt +0 -31
@@ -0,0 +1,93 @@
1
+ /*!
2
+ dpHelper
3
+ Copyright (c) 2021 Dario Passariello <dariopassariello@gmail.com>
4
+ Licensed under the Apache-2.0, see
5
+ https://dario.passariello.ca
6
+ */
7
+
8
+ /***********************************************************************/
9
+
10
+ var description = {
11
+ "name" : "Storage",
12
+ "description" : "",
13
+ "version" : "0.0.1",
14
+ "command" : "storage",
15
+ "subCommand" : [
16
+ {
17
+ "name":"get",
18
+ "description":"test"
19
+ },{
20
+ "name":"set",
21
+ "description":"test"
22
+ },{
23
+ "name":"delete",
24
+ "description":"test"
25
+ },{
26
+ "name":"clearAll",
27
+ "description":"test"
28
+ },{
29
+ "name":"increaseQuota",
30
+ "description":"test"
31
+ }
32
+ ],
33
+ "example" : "",
34
+ "author" : "Dario Passariello",
35
+ "active" : true
36
+ };
37
+
38
+ dphelper._list.scripts.push( description );
39
+
40
+ /***********************************************************************/
41
+
42
+ dphelper.storage = {
43
+
44
+ get: ( name ) => {
45
+ if(!name) return;
46
+ return window.localStorage.getItem( name );
47
+ },
48
+
49
+ set: ( name, value ) => {
50
+ if(!name || !value) return;
51
+ window.localStorage.setItem( name, JSON.stringify(value) );
52
+ },
53
+
54
+ delete: ( name ) => {
55
+ if(!name) return;
56
+ window.localStorage.removeItem( name );
57
+ },
58
+
59
+ clearAll: () => {
60
+ window.localStorage.clear();
61
+ },
62
+
63
+ quota: () => {
64
+ if ('storage' in navigator && 'estimate' in navigator.storage) {
65
+ navigator.storage.estimate().then(({usage, quota}) => {
66
+ console.log(`Using ${usage/1024} out of ${quota/1024} Mb.`);
67
+ });
68
+ }
69
+ },
70
+
71
+ increaseQuota: ( quota ) => {
72
+ window.webkitStorageInfo.requestQuota(
73
+ window.PERSISTENT,
74
+ quota,
75
+ function( bytes ) {
76
+ alert( "Quota is available: " + bytes );
77
+ },
78
+ function( e ) {
79
+ alert( "Error allocating quota: " + e );
80
+ });
81
+ }
82
+
83
+ };
84
+
85
+ // START STORAGE DB
86
+ // dphelper.storage.set( "dpHelper", 'active' );
87
+
88
+ Object.defineProperty( dphelper, 'storage', {
89
+ writable: false,
90
+ configurable: false
91
+ });
92
+
93
+ //console.log( Object.getOwnPropertyDescriptor( dphelper, 'socket' ) )
@@ -0,0 +1,115 @@
1
+ /*!
2
+ dpHelper
3
+ Copyright (c) 2021 Dario Passariello <dariopassariello@gmail.com>
4
+ Licensed under the Apache-2.0, see
5
+ https://dario.passariello.ca
6
+ */
7
+
8
+ /***********************************************************************/
9
+
10
+ var description = {
11
+ "name" : "Store",
12
+ "description" : "",
13
+ "version" : "0.0.1",
14
+ "command" : "store",
15
+ "subCommand" : [
16
+ {
17
+ "name":"get",
18
+ "description":"test"
19
+ },{
20
+ "name":"set",
21
+ "description":"test"
22
+ },{
23
+ "name":"update",
24
+ "description":"test"
25
+ },{
26
+ "name":"clear",
27
+ "description":"test"
28
+ },{
29
+ "name":"delete",
30
+ "description":"test"
31
+ },
32
+ ],
33
+ "example" : "",
34
+ "author" : "Dario Passariello",
35
+ "active" : true
36
+ };
37
+
38
+ dphelper._list.scripts.push( description );
39
+
40
+ /***********************************************************************/
41
+
42
+ dphelper.store = {
43
+
44
+ data: [],
45
+
46
+ get: ( name ) => {
47
+ if(!name) return;
48
+ return window.store.data[name];
49
+ },
50
+
51
+ set: ( name , value , protect = false ) => {
52
+ if( !name ) return;
53
+ if( protect === true ) value = [...value, protect=true ];
54
+ window.store.data[ name ] = value;
55
+ },
56
+
57
+ update: ( name , value ) => {},
58
+
59
+ clear: () => {},
60
+
61
+ clearAll: () => {},
62
+
63
+ delete: () => {}
64
+
65
+ };
66
+
67
+ // SET STORE
68
+ window.store = dphelper.store;
69
+
70
+ /***********************************************************************/
71
+
72
+ // set: ( name, value, persist = true, protect = true )=>{
73
+ // let n = dphelper.text.sanitize( name );
74
+ // let data = window._dph_State[ name ];
75
+
76
+ // const persistent = ( name, value ) => {
77
+ // dphelper.indexedDB.create( 'dphelper', 'state' );
78
+ // dphelper.indexedDB.create( name, value );
79
+ // };
80
+
81
+ // // CHECK OVERRIDE
82
+ // if( data && data['protect'] === true ){
83
+ // console.debug( name + ' is data protected, please delete first' );
84
+ // return;
85
+ // }
86
+
87
+ // // OVERRIDE IF IT'S POSSIBLE
88
+ // if( !data || !data['protect'] || data['protect'] === false ){
89
+ // window._dph_State[ name ] = value;
90
+ // window._dph_State[ name ]['protected'] = protect;
91
+
92
+ // // SAVE AS PERSISTENT DATA INTO INDEXEDBD
93
+ // if( persist ){
94
+ // persistent( name, value );
95
+ // }
96
+ // }
97
+
98
+
99
+ // },
100
+
101
+ // get: ( name )=>{
102
+ // let data = window._dph_State[ name ];
103
+ // if(!data) console.debug( name + ' not in state memory' );
104
+ // else return data;
105
+ // },
106
+
107
+ // delete: ()=>{}
108
+ // },
109
+
110
+ Object.defineProperty( dphelper, 'store', {
111
+ writable: false,
112
+ configurable: false
113
+ });
114
+
115
+ //console.log( Object.getOwnPropertyDescriptor( dphelper, 'socket' ) )
package/scripts/svg.js ADDED
@@ -0,0 +1,380 @@
1
+ /*!
2
+ dpHelper
3
+ Copyright (c) 2021 Dario Passariello <dariopassariello@gmail.com>
4
+ Licensed under the Apache-2.0, see
5
+ https://dario.passariello.ca
6
+ */
7
+
8
+ /***********************************************************************/
9
+
10
+ var description = {
11
+ "name" : "Svg",
12
+ "description" : "realtime SVG",
13
+ "version" : "0.0.1",
14
+ "command" : "svg",
15
+ "subCommand" : [
16
+ {
17
+ "name":"check",
18
+ "description":"test"
19
+ },{
20
+ "name":"init",
21
+ "description":"test"
22
+ },{
23
+ "name":"update",
24
+ "description":"test"
25
+ },{
26
+ "name":"getCurve",
27
+ "description":"test"
28
+ },{
29
+ "name":"getIntersection",
30
+ "description":"test"
31
+ },{
32
+ "name":"setConnector",
33
+ "description":"test"
34
+ },{
35
+ "name":"removeConnection",
36
+ "description":"test"
37
+ },{
38
+ "name":"makeScrollable",
39
+ "description":"test"
40
+ },{
41
+ "name":"makeDraggable",
42
+ "description":"test"
43
+ },{
44
+ "name":"toggle",
45
+ "description":"test"
46
+ }
47
+ ],
48
+ "example" : "",
49
+ "author" : "Dario Passariello",
50
+ "active" : true
51
+ };
52
+
53
+ dphelper._list.scripts.push( description );
54
+
55
+ /***********************************************************************/
56
+
57
+ dphelper.svg = {
58
+
59
+ check: () => {
60
+ if ( typeof dphelper.svg.check.supported == "undefined" ) {
61
+ let a = document.body.appendChild( document.createElement( 'div' ) );
62
+ a.innerHTML = '<v:shape id="vml_flag1" adj="1" />';
63
+ let b = a.firstChild;
64
+ b.style.behavior = "url(#default#VML)";
65
+ dphelper.svg.check.supported = b ? typeof b.adj == "object" : true;
66
+ a.parentNode.removeChild( a );
67
+ }
68
+ return dphelper.svg.check.supported;
69
+ },
70
+
71
+ init: function( container, source1, source2, cb ) {
72
+
73
+ if( $( container ).find( 'svg' ) ) {
74
+ dphelper.svg_removeConnection( container );
75
+ }
76
+
77
+ source1 = dphelper.svg.setConnector( source1[ 0 ], source1[ 1 ] );
78
+ source2 = dphelper.svg.setConnector( source2[ 0 ], source2[ 1 ] );
79
+
80
+ let parentCoords = container.getBoundingClientRect();
81
+
82
+ let xmlns = "http://www.w3.org/2000/svg";
83
+ let boxWidth = container.offsetWidth * 10;
84
+ let boxHeight = container.offsetHeight * 10;
85
+
86
+ // create svg container
87
+ let svgElem = document.createElementNS( xmlns, "svg" );
88
+
89
+ svgElem.setAttribute( "xmlns" , xmlns );
90
+ svgElem.setAttributeNS( null , "id" , "pathConnection" );
91
+ svgElem.setAttributeNS( null , "viewBox" , "0 0 " + boxWidth + " " + boxHeight );
92
+ svgElem.setAttributeNS( null , "width" , boxWidth );
93
+ svgElem.setAttributeNS( null , "height" , boxHeight );
94
+ svgElem.style.display = "block";
95
+
96
+ /*
97
+ // TO DO: smaller cyrcle
98
+ // DARIO: probably is too invasive on UI, I change just border on parts_container_
99
+
100
+ // create arrow
101
+ let defs = document.createElementNS(xmlns, "defs");
102
+ let marker = document.createElementNS(xmlns, "marker");
103
+ let path = document.createElementNS(xmlns, "path");
104
+ marker.setAttributeNS(null, 'id', 'head');
105
+ marker.setAttributeNS(null, 'orient', 'auto');
106
+ marker.setAttributeNS(null, 'markerWidth', '20');
107
+ marker.setAttributeNS(null, 'markerHeight', '40');
108
+ marker.setAttributeNS(null, 'refX', '0');
109
+ marker.setAttributeNS(null, 'refY', '3');
110
+ path.setAttributeNS(null, 'd', 'M0,0 V6 L3,3 Z');
111
+ marker.appendChild(path);
112
+ defs.appendChild(marker);
113
+ svgElem.appendChild(defs);
114
+ */
115
+
116
+ // create rect which overlaps source1
117
+ let rect1 = document.createElementNS( xmlns , "rect" );
118
+ let coords = source1.getBoundingClientRect();
119
+
120
+ rect1.setAttributeNS( null, 'x', coords.left - parentCoords.left );
121
+ rect1.setAttributeNS( null, 'y', coords.top - parentCoords.top );
122
+ rect1.setAttributeNS( null, 'width', coords.width );
123
+ rect1.setAttributeNS( null, 'height', coords.height );
124
+ svgElem.appendChild( rect1 );
125
+
126
+ // create rect which overlaps source2
127
+ let rect2 = document.createElementNS( xmlns, "rect" );
128
+ coords = source2.getBoundingClientRect();
129
+
130
+ rect2.setAttributeNS( null, 'x', coords.left - parentCoords.left );
131
+ rect2.setAttributeNS( null, 'y', coords.top - parentCoords.top );
132
+ rect2.setAttributeNS( null, 'width', coords.width );
133
+ rect2.setAttributeNS( null, 'height', coords.height );
134
+ svgElem.appendChild( rect2 );
135
+
136
+ // create path connecting both rects
137
+ let path = document.createElementNS( xmlns, "path" );
138
+
139
+ path.setAttributeNS( null, 'id', 'connection' );
140
+ path.setAttributeNS( null, 'marker-end', 'url(#head)' );
141
+ svgElem.appendChild( path );
142
+
143
+ container.appendChild( svgElem );
144
+
145
+ dphelper.svg.update( $( rect1 )[0], $( rect2 )[0], $( '#connection' )[0]);
146
+
147
+ if( typeof cb == 'function' ) {
148
+ cb( source1, source2 );
149
+ }
150
+
151
+ },
152
+
153
+ update: function( rect1 , rect2 , cxn ) {
154
+
155
+ // Top left coordinates
156
+ let x1 = parseFloat( rect1.getAttribute( 'x' ) );
157
+ let y1 = parseFloat( rect1.getAttribute( 'y' ) );
158
+ let x2 = parseFloat( rect2.getAttribute( 'x') );
159
+ let y2 = parseFloat( rect2.getAttribute( 'y' ) );
160
+
161
+ // Half widths and half heights
162
+ let w1 = parseFloat( rect1.getAttribute( 'width' ) ) / 2;
163
+ let h1 = parseFloat( rect1.getAttribute( 'height' ) ) / 2;
164
+ let w2 = parseFloat( rect2.getAttribute( 'width' ) ) / 2;
165
+ let h2 = parseFloat( rect2.getAttribute( 'height' ) ) / 2;
166
+
167
+ // Center coordinates
168
+ let cx1 = x1 + w1;
169
+ let cy1 = y1 + h1;
170
+ let cx2 = x2 + w2;
171
+ let cy2 = y2 + h2;
172
+
173
+ // Distance between centers
174
+ let dx = cx2 - cx1;
175
+ let dy = cy2 - cy1;
176
+
177
+ let p1 = dphelper.svg.getIntersection( dx , dy , cx1 , cy1 , w1 , h1 );
178
+ let p2 = dphelper.svg.getIntersection( -dx , -dy , cx2 , cy2 , w2 , h2 );
179
+
180
+ // Distance between edges
181
+ let dx1 = p2[ 0 ] - p1[ 0 ];
182
+
183
+ let d = dphelper.svg.getCurve( p1 , p2 , dx1 );
184
+
185
+ // Set a path connector
186
+ cxn.setAttributeNS( null , 'd' , "M" + cx1 + "," + cy1 + d + cx2 + "," + cy2 );
187
+
188
+ // Set a line connector
189
+ // cxn.setAttributeNS( null , 'x1' , p1[0] );
190
+ // cxn.setAttributeNS( null , 'y1' , p1[1] );
191
+ // cxn.setAttributeNS( null , 'x2' , p2[0] );
192
+ // cxn.setAttributeNS( null , 'y2' , p2[1] );
193
+
194
+ },
195
+
196
+ getCurve: function( p1 , p2 , dx ) {
197
+
198
+ let curve = dx / 2;
199
+ let d = " C" + ( curve + p1[0] ) + "," + p1[1] + " " + ( p2[0] - curve ) + "," + p2[1] + " ";
200
+ return d;
201
+
202
+ },
203
+
204
+ getIntersection: function( dx , dy , cx , cy , w , h ) {
205
+
206
+ if ( Math.abs( dy / dx ) < h / w )
207
+ return [ cx + ( dx > 0 ? w : -w ), cy + dy * w / Math.abs( dx ) ];
208
+ else
209
+ return [ cx + dx * h / Math.abs( dy ), cy + ( dy > 0 ? h : -h ) ];
210
+
211
+ },
212
+
213
+ setConnector: function( source , side ) {
214
+
215
+ let style;
216
+ let span = $( '<span class="connector"></span>' );
217
+
218
+ $( source ).css( 'position' , 'relative' );
219
+
220
+ span.css({
221
+ position: 'absolute',
222
+ width: '5px',
223
+ height: '5px',
224
+ });
225
+
226
+ switch( side ) {
227
+ case 'top':
228
+ style = {
229
+ left: '50%',
230
+ top: '2.5px',
231
+ marginLeft: '2.5px'
232
+ };
233
+ break;
234
+ case 'right':
235
+ style = {
236
+ top: '50%',
237
+ right: '2.5px',
238
+ marginTop: '-2.5px'
239
+ };
240
+ break;
241
+ case 'bottom':
242
+ style = {
243
+ left: '50%',
244
+ bottom: '-2.5px',
245
+ marginLeft: '2.5px'
246
+ };
247
+ break;
248
+ case 'left':
249
+ style = {
250
+ top: '50%',
251
+ left: '-2.5px',
252
+ marginTop: '-2.5px'
253
+ };
254
+ break;
255
+ default:
256
+ style = {};
257
+ }
258
+
259
+ span.css( style );
260
+
261
+ $( source ).append( span );
262
+
263
+ return $( span )[ 0 ];
264
+ },
265
+
266
+ removeConnection: function( container ) {
267
+
268
+ $( container ).find( 'svg#pathConnection' ).each( function( i , elm ) {
269
+ $( elm ).remove();
270
+ });
271
+
272
+ },
273
+
274
+ makeScrollable: function( svgContainer , scrollContainer , elm1 , elm2 , rect1 , rect2 ) {
275
+
276
+ //let scrollCoords = scrollContainer.getBoundingClientRect();
277
+ let svgCoords = svgContainer.getBoundingClientRect();
278
+
279
+ let el = [ elm1 , elm2 ];
280
+ let rec = [ rect1 , rect2 ];
281
+ let coords = [];
282
+
283
+ for( let i = 0; i < el.length; i++ ){
284
+
285
+ coords[ i ] = el[ i ].getBoundingClientRect();
286
+
287
+ rec[ i ].setAttributeNS( null, 'x', coords[ i ].left - svgCoords.left );
288
+ rec[ i ].setAttributeNS( null, 'y', coords[ i ].top - svgCoords.top );
289
+ rec[ i ].setAttributeNS( null, 'width', coords[ i ].width );
290
+ rec[ i ].setAttributeNS( null, 'height', coords[ i ].height );
291
+
292
+ }
293
+
294
+ //***************************************************************
295
+
296
+ dphelper.svg.update( $( rect1 )[ 0 ], $( rect2 )[ 0 ], $( '#connection' )[ 0 ]);
297
+
298
+ },
299
+
300
+ makeDraggable: function( evt ) {
301
+
302
+ let svg = evt.target;
303
+ svg.addEventListener( 'mousedown' , startDrag );
304
+ svg.addEventListener( 'mousemove' , drag );
305
+ svg.addEventListener( 'mouseup' , endDrag );
306
+
307
+ function getMousePosition( e ) {
308
+ let CTM = svg.getScreenCTM();
309
+ return {
310
+ x: ( evt.clientX - CTM.e ) / CTM.a,
311
+ y: ( evt.clientY - CTM.f ) / CTM.d
312
+ };
313
+ }
314
+
315
+ let selectedElement, offset;
316
+
317
+ function startDrag( evt ) {
318
+
319
+ if ( evt.target.classList.contains( 'draggable' ) ) {
320
+ selectedElement = evt.target;
321
+ offset = getMousePosition( evt );
322
+ offset.x -= parseFloat( selectedElement.getAttributeNS( null , "x" ) );
323
+ offset.y -= parseFloat( selectedElement.getAttributeNS( null , "y" ) );
324
+ }
325
+
326
+ }
327
+
328
+ function drag( evt ) {
329
+
330
+ if ( selectedElement ) {
331
+ let coord = getMousePosition( evt );
332
+ selectedElement.setAttributeNS( null, "x" , coord.x - offset.x );
333
+ selectedElement.setAttributeNS( null, "y" , coord.y - offset.y );
334
+ dphelper.svg.update();
335
+ }
336
+
337
+ }
338
+
339
+ function endDrag( evt ) {
340
+ selectedElement = null;
341
+ }
342
+
343
+ },
344
+
345
+ toggle: function( evt , container , source1 , source2 ) {
346
+
347
+ if( $( evt.target ).prop( 'checked' ) && $( source1 ).length && $( source2 ).length ) {
348
+
349
+ dphelper.cookie.set( $( evt.target ).attr( 'id' ), 1, 365 );
350
+
351
+ dphelper.svg_initConnection( container[0], [ $( source1 )[0], 'right' ], [ $( source2 )[0], 'left' ], function( source1 , source2 ) {
352
+
353
+ $( '#parts-left-body' ).on( 'scroll', function( evt ){
354
+ dphelper.svg.makeScrollable( $( container )[0], $( '#parts-left-body' )[0], $( source1 )[0],
355
+ $( source2 )[0], $( '#parts svg rect' )[0], $( '#parts svg rect' )[ 1 ] );
356
+ });
357
+
358
+ });
359
+
360
+ } else {
361
+
362
+ dphelper.svg_removeConnection( container );
363
+ $( '#parts-left-body' ).unbind( 'scroll' );
364
+ dphelper.cookie.set( $( evt.target ).attr( 'id' ), 0, 365 );
365
+
366
+ }
367
+
368
+ }
369
+
370
+ };
371
+
372
+ dphelper.svg.check();
373
+
374
+ Object.defineProperty( dphelper, 'svg', {
375
+ writable: false,
376
+ configurable: false
377
+ });
378
+
379
+ //console.log( Object.getOwnPropertyDescriptor( dphelper, 'socket' ) )
380
+
@@ -0,0 +1,116 @@
1
+ /*!
2
+ dpHelper
3
+ Copyright (c) 2021 Dario Passariello <dariopassariello@gmail.com>
4
+ Licensed under the Apache-2.0, see
5
+ https://dario.passariello.ca
6
+ */
7
+
8
+ /***********************************************************************/
9
+
10
+ var description = {
11
+ "name" : "Text",
12
+ "description" : "",
13
+ "version" : "0.0.1",
14
+ "command" : "text",
15
+ "subCommand" : [
16
+ {
17
+ "name":"trim",
18
+ "description":"test"
19
+ },{
20
+ "name":"capitalize",
21
+ "description":"test"
22
+ },{
23
+ "name":"lower",
24
+ "description":"test"
25
+ },{
26
+ "name":"upper",
27
+ "description":"test"
28
+ },{
29
+ "name":"nl2br",
30
+ "description":"test"
31
+ },{
32
+ "name":"sanitize",
33
+ "description":"test"
34
+ },{
35
+ "name":"camelCase",
36
+ "description":"test",
37
+ "subCommand" : [
38
+ {
39
+ "name":"toSpace",
40
+ "description":"test",
41
+ "subCommand" : []
42
+ },{
43
+ "name":"toUnderscore",
44
+ "description":"test",
45
+ "subCommand" : []
46
+ }
47
+ ]
48
+ }
49
+ ],
50
+ "example" : "",
51
+ "author" : "Dario Passariello",
52
+ "active" : true
53
+ };
54
+
55
+ dphelper._list.scripts.push( description );
56
+
57
+ /***********************************************************************/
58
+
59
+ dphelper.text ={
60
+
61
+ trim: ( s, c, b, e ) => {
62
+ // trim(string, '#', 1, 7
63
+ return ( s.charAt(0) === c ) ? s.substring(b, e) : s;
64
+ },
65
+
66
+ capitalize: (txt) => {
67
+ return txt
68
+ .toLowerCase()
69
+ .replace(/\b\w/g, function (l) {
70
+ return l.toUpperCase();
71
+ });
72
+ },
73
+
74
+ lower: (txt) => {
75
+ return txt.toLowerCase();
76
+ },
77
+
78
+ upper: (txt) => {
79
+ return txt.toUpperCase();
80
+ },
81
+
82
+ nl2br: (str) => {
83
+ return str.replace(/(?:\r\n|\r|\n)/g, '<br>');
84
+ },
85
+
86
+ sanitize: (str) => {
87
+ return str.replace(/[^\w ]/g, '');
88
+ },
89
+
90
+ camelCase: {
91
+
92
+ toSpace: ( string ) => {
93
+ return string
94
+ .replace(/([A-Z])/g, ' $1')
95
+ .replace(/^./, function(str){
96
+ return str.toUpperCase();
97
+ });
98
+ },
99
+
100
+ toUnderscore: ( string ) => {
101
+ return string
102
+ .replace(/\.?([A-Z])/g, function (x,y){
103
+ return "_" + y.toLowerCase();
104
+ }).replace(/^_/, "");
105
+ },
106
+
107
+ }
108
+
109
+ };
110
+
111
+ Object.defineProperty( dphelper, 'text', {
112
+ writable: false,
113
+ configurable: false
114
+ });
115
+
116
+ //console.log( Object.getOwnPropertyDescriptor( dphelper, 'socket' ) )