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.
- package/data/.OLD/~camelCase.js +41 -0
- package/{scripts/date2Iso.js → data/.OLD/~date2Iso.js} +31 -20
- package/{scripts/date2MMDDYYYY.js → data/.OLD/~date2MMDDYYYY.js} +27 -16
- package/{scripts/dateConvert.js → data/.OLD/~dateConvert.js} +31 -20
- package/{scripts/dateIso2Epoch.js → data/.OLD/~dateIso2Epoch.js} +28 -17
- package/{scripts/dateLocal-ISOTime.js → data/.OLD/~dateLocal-ISOTime.js} +28 -17
- package/data/.OLD/~dateUTC.js +25 -0
- package/{scripts/disableSpellCheck.js → data/.OLD/~disableSpellCheck.js} +32 -21
- package/data/.OLD/~loadJson.js +27 -0
- package/{scripts/loadJsonExternal.js → data/.OLD/~loadJsonExternal.js} +44 -32
- package/data/.OLD/~nl2br.js +26 -0
- package/{scripts/object2array.js → data/.OLD/~object2array.js} +15 -3
- package/data/.OLD/~parseDate.js +30 -0
- package/data/.OLD/~pathHash.js +27 -0
- package/data/.OLD/~pathQuery.js +28 -0
- package/data/.OLD/~pathRail.js +27 -0
- package/data/.OLD/~randomNumTmr.js +26 -0
- package/{scripts/scrollIndicator.js → data/.OLD/~scrollIndicator.js} +0 -0
- package/{scripts/scrollMemory.js → data/.OLD/~scrollMemory.js} +0 -0
- package/{scripts/scrollSmooth.js → data/.OLD/~scrollSmooth.js} +0 -0
- package/{scripts/scrollToElement.js → data/.OLD/~scrollToElement.js} +0 -0
- package/{scripts/svgSupport.js → data/.OLD/~svgSupport.js} +0 -0
- package/data/list.json +19 -26
- package/init.js +19 -5
- package/package.json +7 -9
- package/scripts/anchorToOnClick.js +15 -3
- package/scripts/array.js +29 -3
- package/scripts/console.js +86 -0
- package/scripts/cookie.js +97 -71
- package/scripts/currency.js +31 -11
- package/scripts/date.js +101 -0
- package/scripts/disable.js +88 -0
- package/scripts/event.js +39 -0
- package/scripts/font.js +52 -0
- package/scripts/form.js +113 -0
- package/scripts/indexedDB.js +47 -10
- package/scripts/isPromise.js +26 -14
- package/scripts/json.js +42 -0
- package/scripts/load.js +70 -0
- package/scripts/noCache.js +26 -14
- package/scripts/number.js +42 -0
- package/scripts/obj.js +81 -0
- package/scripts/onBeforeUnLoad.js +120 -108
- package/scripts/parseBool.js +27 -15
- package/scripts/path.js +94 -0
- package/scripts/printInfo.js +28 -16
- package/scripts/purge.js +53 -41
- package/scripts/pushState.js +33 -14
- package/scripts/screen.js +64 -0
- package/scripts/scrollbar.js +226 -0
- package/scripts/{handleEvent.js → shortcut.js} +70 -59
- package/scripts/storage.js +29 -3
- package/scripts/svg.js +372 -0
- package/scripts/text.js +78 -0
- package/scripts/time.js +41 -0
- package/scripts/timer.js +35 -0
- package/scripts/trigger.js +37 -0
- package/scripts/uuid.js +33 -14
- package/scripts/window.js +50 -38
- package/#cmd.exe.lnk +0 -0
- package/.github/workflows/codeql-analysis.yml +0 -70
- package/README.md.bak +0 -70
- package/scripts/.OLD/arrayDeleteItem.js +0 -35
- package/scripts/.OLD/arrayItemFinder.js +0 -22
- package/scripts/.OLD/arrayMerge.js +0 -20
- package/scripts/.OLD/arrayUnique.js +0 -15
- package/scripts/.OLD/loadAsset.js +0 -26
- package/scripts/addListenerMulti.js +0 -10
- package/scripts/camelCase.js +0 -29
- package/scripts/dateUTC.js +0 -14
- package/scripts/disableSelect.js +0 -46
- package/scripts/epoch.js +0 -14
- package/scripts/fontFit.js +0 -24
- package/scripts/fullScreen.js +0 -40
- package/scripts/jsonCounter.js +0 -21
- package/scripts/loadFile.js +0 -17
- package/scripts/loadJson.js +0 -15
- package/scripts/nl2br.js +0 -14
- package/scripts/parseDate.js +0 -19
- package/scripts/pathHash.js +0 -20
- package/scripts/pathQuery.js +0 -24
- package/scripts/pathRail.js +0 -26
- package/scripts/randomNum.js +0 -14
- package/scripts/randomNumTmr.js +0 -14
- package/scripts/scrollCustom.js +0 -41
- package/scripts/serializeForm.js +0 -94
- package/scripts/serializeObj.js +0 -47
- package/scripts/sleep.js +0 -14
- package/scripts/stopConsole.js +0 -49
- package/scripts/textChanger.js +0 -24
- package/scripts/triggerClick.js +0 -16
package/scripts/svg.js
ADDED
|
@@ -0,0 +1,372 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,78 @@
|
|
|
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 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
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
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" : "Handle 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
ADDED
|
@@ -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" : "Timer Options",
|
|
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
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
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 Trigger",
|
|
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
|
+
};
|
package/scripts/uuid.js
CHANGED
|
@@ -1,14 +1,33 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* dpHelper <https://github.com/passariello/dpHelper>
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
+
};
|