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.
- package/data/list.json +19 -39
- package/init.js +19 -5
- package/package.json +5 -7
- 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 +90 -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/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/promise.js +35 -0
- 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/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/date2Iso.js +0 -20
- package/scripts/date2MMDDYYYY.js +0 -16
- package/scripts/dateConvert.js +0 -20
- package/scripts/dateIso2Epoch.js +0 -17
- package/scripts/dateLocal-ISOTime.js +0 -17
- package/scripts/dateUTC.js +0 -14
- package/scripts/disableSelect.js +0 -46
- package/scripts/disableSpellCheck.js +0 -21
- package/scripts/epoch.js +0 -14
- package/scripts/fontFit.js +0 -24
- package/scripts/fullScreen.js +0 -40
- package/scripts/isPromise.js +0 -14
- package/scripts/jsonCounter.js +0 -21
- package/scripts/loadFile.js +0 -17
- package/scripts/loadJson.js +0 -15
- package/scripts/loadJsonExternal.js +0 -32
- package/scripts/nl2br.js +0 -14
- package/scripts/object2array.js +0 -16
- package/scripts/parseDate.js +0 -19
- package/scripts/pathHash.js +0 -19
- package/scripts/pathQuery.js +0 -24
- package/scripts/pathRail.js +0 -25
- package/scripts/printInfo.js +0 -16
- package/scripts/randomNum.js +0 -14
- package/scripts/randomNumTmr.js +0 -14
- package/scripts/scrollCustom.js +0 -41
- package/scripts/scrollIndicator.js +0 -67
- package/scripts/scrollMemory.js +0 -26
- package/scripts/scrollSmooth.js +0 -74
- package/scripts/scrollToElement.js +0 -25
- 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/svgSupport.js +0 -346
- package/scripts/textChanger.js +0 -24
- package/scripts/triggerClick.js +0 -16
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* dpHelper <https://github.com/passariello/dpHelper>
|
|
3
|
-
*
|
|
4
|
-
* loadJsonExternal
|
|
5
|
-
*
|
|
6
|
-
* Copyright (c) 2021, Dario Passariello.
|
|
7
|
-
* Licensed under the Apache-2.0 License.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
/***********************************************************************/
|
|
11
|
-
|
|
12
|
-
window.dphelper.loadJsonExternal = ( path, method='GET', type='application/json' ) => {
|
|
13
|
-
|
|
14
|
-
fetch( path ,{
|
|
15
|
-
method: method,
|
|
16
|
-
headers : {
|
|
17
|
-
'Content-Type': type
|
|
18
|
-
}
|
|
19
|
-
})
|
|
20
|
-
.then(
|
|
21
|
-
function(response) {
|
|
22
|
-
//return response.json();
|
|
23
|
-
return response;
|
|
24
|
-
}
|
|
25
|
-
)
|
|
26
|
-
.then(
|
|
27
|
-
function( myFile ) {
|
|
28
|
-
return myFile;
|
|
29
|
-
}
|
|
30
|
-
);
|
|
31
|
-
|
|
32
|
-
};
|
package/scripts/nl2br.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* dpHelper <https://github.com/passariello/dpHelper>
|
|
3
|
-
*
|
|
4
|
-
* nl2br
|
|
5
|
-
*
|
|
6
|
-
* Copyright (c) 2021, Dario Passariello.
|
|
7
|
-
* Licensed under the Apache-2.0 License.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
/***********************************************************************/
|
|
11
|
-
|
|
12
|
-
window.dphelper.nl2br = (str) => {
|
|
13
|
-
return str.replace(/(?:\r\n|\r|\n)/g, '<br>');
|
|
14
|
-
};
|
package/scripts/object2array.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* dpHelper <https://github.com/passariello/dpHelper>
|
|
3
|
-
*
|
|
4
|
-
* object2array
|
|
5
|
-
*
|
|
6
|
-
* Copyright (c) 2021, Dario Passariello.
|
|
7
|
-
* Licensed under the Apache-2.0 License.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
/***********************************************************************/
|
|
11
|
-
|
|
12
|
-
window.dphelper.obj2array = ( object ) => {
|
|
13
|
-
return Object
|
|
14
|
-
.entries( object )
|
|
15
|
-
.map( ( [ key, value ] ) => Object.assign( { key } , value && typeof value === 'object' ? { forms: ObjToArray( value ) } : { value, forms: [] } ) );
|
|
16
|
-
};
|
package/scripts/parseDate.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* dpHelper <https://github.com/passariello/dpHelper>
|
|
3
|
-
*
|
|
4
|
-
* parse date
|
|
5
|
-
*
|
|
6
|
-
* Copyright (c) 2021, Dario Passariello.
|
|
7
|
-
* Licensed under the Apache-2.0 License.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
/***********************************************************************/
|
|
11
|
-
|
|
12
|
-
window.dphelper.parseDate = (value) => {
|
|
13
|
-
if (!value) return null;
|
|
14
|
-
let separator = '/';
|
|
15
|
-
let month = value.substring(0, 2);
|
|
16
|
-
let day = value.substring(2, 4);
|
|
17
|
-
let year = value.substring(4, 8);
|
|
18
|
-
return month + separator + day + separator + year;
|
|
19
|
-
};
|
package/scripts/pathHash.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* dpHelper <https://github.com/passariello/dpHelper>
|
|
3
|
-
*
|
|
4
|
-
* path Hash
|
|
5
|
-
*
|
|
6
|
-
* Copyright (c) 2021, Dario Passariello.
|
|
7
|
-
* Licensed under the Apache-2.0 License.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
/***********************************************************************/
|
|
11
|
-
|
|
12
|
-
window.dphelper.pathHash = () => {
|
|
13
|
-
const array = location.hash.replace('#', '').split('/');
|
|
14
|
-
if (array.length) {
|
|
15
|
-
return array.filter(item => item);
|
|
16
|
-
} else {
|
|
17
|
-
return ["empty"];
|
|
18
|
-
}
|
|
19
|
-
};
|
package/scripts/pathQuery.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* dpHelper <https://github.com/passariello/dpHelper>
|
|
3
|
-
*
|
|
4
|
-
* path Query
|
|
5
|
-
*
|
|
6
|
-
* Copyright (c) 2021, Dario Passariello.
|
|
7
|
-
* Licensed under the Apache-2.0 License.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
/***********************************************************************/
|
|
11
|
-
|
|
12
|
-
window.dphelper.pathQuery = () => {
|
|
13
|
-
let x, y, array = [], search = location.search;
|
|
14
|
-
if (search) {
|
|
15
|
-
search.replace("?", '').split('&')
|
|
16
|
-
.map(x => {
|
|
17
|
-
y = x.split('=');
|
|
18
|
-
array[y[0]] = y[1];
|
|
19
|
-
});
|
|
20
|
-
return array;
|
|
21
|
-
} else {
|
|
22
|
-
return ["empty"];
|
|
23
|
-
}
|
|
24
|
-
};
|
package/scripts/pathRail.js
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* dpHelper <https://github.com/passariello/dpHelper>
|
|
3
|
-
*
|
|
4
|
-
* path Rails
|
|
5
|
-
*
|
|
6
|
-
* Copyright (c) 2021, Dario Passariello.
|
|
7
|
-
* Licensed under the Apache-2.0 License.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
/***********************************************************************/
|
|
11
|
-
|
|
12
|
-
window.dphelper.pathRail = () => {
|
|
13
|
-
const array = location.href
|
|
14
|
-
.split("?")[0]
|
|
15
|
-
.replace(location.protocol, '')
|
|
16
|
-
.replace(location.host, '')
|
|
17
|
-
.replace(location.hash, '')
|
|
18
|
-
.split('/');
|
|
19
|
-
if ( array.length > 0 ) {
|
|
20
|
-
const arrayFinal = array.filter(item => item);
|
|
21
|
-
return arrayFinal;
|
|
22
|
-
} else {
|
|
23
|
-
return;
|
|
24
|
-
}
|
|
25
|
-
};
|
package/scripts/printInfo.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* dpHelper <https://github.com/passariello/dpHelper>
|
|
3
|
-
*
|
|
4
|
-
* printInfo
|
|
5
|
-
*
|
|
6
|
-
* Copyright (c) 2021, Dario Passariello.
|
|
7
|
-
* Licensed under the Apache-2.0 License.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
/***********************************************************************/
|
|
11
|
-
|
|
12
|
-
window.dphelper.printInfo = () => {
|
|
13
|
-
console.groupCollapsed('%cApi:%c', "color:orange", "");
|
|
14
|
-
console.debug(dphelper.api);
|
|
15
|
-
console.groupEnd();
|
|
16
|
-
};
|
package/scripts/randomNum.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* dpHelper <https://github.com/passariello/dpHelper>
|
|
3
|
-
*
|
|
4
|
-
* random number
|
|
5
|
-
*
|
|
6
|
-
* Copyright (c) 2021, Dario Passariello.
|
|
7
|
-
* Licensed under the Apache-2.0 License.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
/***********************************************************************/
|
|
11
|
-
|
|
12
|
-
window.dphelper.rnd = () => {
|
|
13
|
-
return Math.floor( 100000 + Math.random() * dphelper.tmr() );
|
|
14
|
-
};
|
package/scripts/randomNumTmr.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* dpHelper <https://github.com/passariello/dpHelper>
|
|
3
|
-
*
|
|
4
|
-
* random number tmr
|
|
5
|
-
*
|
|
6
|
-
* Copyright (c) 2021, Dario Passariello.
|
|
7
|
-
* Licensed under the Apache-2.0 License.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
/***********************************************************************/
|
|
11
|
-
|
|
12
|
-
window.dphelper.tmr = () => {
|
|
13
|
-
return Math.round(dphelper.epoch() / 1000);
|
|
14
|
-
};
|
package/scripts/scrollCustom.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* dpHelper <https://github.com/passariello/dpHelper>
|
|
3
|
-
*
|
|
4
|
-
* scrollCustom
|
|
5
|
-
*
|
|
6
|
-
* Copyright (c) 2021, Dario Passariello.
|
|
7
|
-
* Licensed under the Apache-2.0 License.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
/***********************************************************************/
|
|
11
|
-
|
|
12
|
-
window.dphelper.scrollCustom = ( el, colors, size ) => {
|
|
13
|
-
|
|
14
|
-
if(!colors) colors =[ "black", "transparent" ];
|
|
15
|
-
if(!size) size =[ "6px", "6px" ];
|
|
16
|
-
|
|
17
|
-
const $style = `${el}{
|
|
18
|
-
scrollbar-width:auto;
|
|
19
|
-
scrollbar-color:${colors[0]} ${colors[1]};
|
|
20
|
-
scrollbar-width: thin;
|
|
21
|
-
-ms-overflow-style: -ms-autohiding-scrollbar;
|
|
22
|
-
}
|
|
23
|
-
${el}::-webkit-scrollbar {
|
|
24
|
-
width: ${size[0]};
|
|
25
|
-
height: ${size[0]};
|
|
26
|
-
}
|
|
27
|
-
${el}::-webkit-scrollbar-track {
|
|
28
|
-
background: ${colors[1]};
|
|
29
|
-
}
|
|
30
|
-
${el}::-webkit-scrollbar-thumb {
|
|
31
|
-
background: ${colors[0]};
|
|
32
|
-
}
|
|
33
|
-
`;
|
|
34
|
-
|
|
35
|
-
let styleToHead = document.createElement( "style" );
|
|
36
|
-
document.head.appendChild( styleToHead );
|
|
37
|
-
styleToHead.innerHTML = $style;
|
|
38
|
-
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
//example: window.dphelper.scrollCustom('*')
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* dpHelper <https://github.com/passariello/dpHelper>
|
|
3
|
-
*
|
|
4
|
-
* scrollIndicator
|
|
5
|
-
*
|
|
6
|
-
* Copyright (c) 2021, Dario Passariello.
|
|
7
|
-
* Licensed under the Apache-2.0 License.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
/***********************************************************************/
|
|
11
|
-
|
|
12
|
-
window.dphelper.scrollIndicator = ( props ) => {
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
/* This timeout it's to be suse that whole UI is loaded
|
|
16
|
-
/* Just smaller trick!
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
let cont = document.querySelector( props.el );
|
|
20
|
-
let sc = document.querySelector('.scrollindicator');
|
|
21
|
-
|
|
22
|
-
if( !sc ){
|
|
23
|
-
|
|
24
|
-
const createEl = document.createElement('div');
|
|
25
|
-
createEl.classList.add("scrollindicator");
|
|
26
|
-
document.querySelector('header').appendChild(createEl);
|
|
27
|
-
|
|
28
|
-
createEl.style.cssText = `
|
|
29
|
-
height:5px;
|
|
30
|
-
background:#65c45c;
|
|
31
|
-
position:absolute;
|
|
32
|
-
bottom:0;
|
|
33
|
-
left:0;
|
|
34
|
-
z-index:2
|
|
35
|
-
`;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
if( !props.el && sc) {
|
|
39
|
-
sc.style.width = 0 + '%';
|
|
40
|
-
return null;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
try{
|
|
44
|
-
let sc = document.querySelector('.scrollindicator');
|
|
45
|
-
cont.addEventListener( 'scroll' , function ( e ) {
|
|
46
|
-
|
|
47
|
-
sc.style.width = 0 + '%';
|
|
48
|
-
let winScroll = this.scrollTop || this.scrollTop;
|
|
49
|
-
let height = this.scrollHeight - this.clientHeight;
|
|
50
|
-
let scrolled = Math.min(Math.max(parseInt( (winScroll / height) * 100 ), 0), 100);
|
|
51
|
-
sc.style.width = scrolled + '%';
|
|
52
|
-
|
|
53
|
-
sc.click();
|
|
54
|
-
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
window.addEventListener('popstate', function ( e ) {
|
|
58
|
-
sc.style.width = 0;
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
}catch( e ){
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
return null;
|
|
66
|
-
|
|
67
|
-
};
|
package/scripts/scrollMemory.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* dpHelper <https://github.com/passariello/dpHelper>
|
|
3
|
-
*
|
|
4
|
-
* setScrollPos, getScrollPos
|
|
5
|
-
*
|
|
6
|
-
* Copyright (c) 2021, Dario Passariello.
|
|
7
|
-
* Licensed under the Apache-2.0 License.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
/*****************************************************************************************/
|
|
11
|
-
// SAVE OLD SCROLL POSITION
|
|
12
|
-
|
|
13
|
-
window.dphelper.setScrollPos = ( el ) => {
|
|
14
|
-
let ar = [ $( el ).scrollTop() , $( el ).scrollLeft() ];
|
|
15
|
-
if( ar[0] != null && ar[1] != null ){ window.dphelper.storage.set( el , ar ); }
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
/*****************************************************************************************/
|
|
19
|
-
// LOAD OLD SCROLL POSITION
|
|
20
|
-
|
|
21
|
-
window.dphelper.getScrollPos = ( el ) => {
|
|
22
|
-
if( !window.dphelper.storage.get( el ) ) return;
|
|
23
|
-
let ar = window.dphelper.storage.get( el ).trim().split(',');
|
|
24
|
-
$( el ).scrollTop( ar[0] );
|
|
25
|
-
$( el ).scrollLeft( ar[1] );
|
|
26
|
-
};
|
package/scripts/scrollSmooth.js
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* dpHelper <https://github.com/passariello/dpHelper>
|
|
3
|
-
*
|
|
4
|
-
* scrollSmooth
|
|
5
|
-
*
|
|
6
|
-
* Copyright (c) 2021, Dario Passariello.
|
|
7
|
-
* Licensed under the Apache-2.0 License.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
/***********************************************************************/
|
|
11
|
-
|
|
12
|
-
// function init(){
|
|
13
|
-
// new scrollSmooth(document,120,12);
|
|
14
|
-
// }
|
|
15
|
-
|
|
16
|
-
window.dphelper.scrollSmooth = (target, speed, smooth) => {
|
|
17
|
-
if (target === document)
|
|
18
|
-
target = (document.scrollingElement || document.documentElement || document.body.parentNode || document.body); // cross browser support for document scrolling
|
|
19
|
-
|
|
20
|
-
let moving = false;
|
|
21
|
-
let pos = target.scrollTop;
|
|
22
|
-
let frame = target === document.body && document.documentElement ? document.documentElement : target; // safari is the new IE
|
|
23
|
-
|
|
24
|
-
target.addEventListener('mousewheel', scrolled, { passive: false });
|
|
25
|
-
target.addEventListener('DOMMouseScroll', scrolled, { passive: false });
|
|
26
|
-
|
|
27
|
-
function scrolled( e ) {
|
|
28
|
-
e.preventDefault(); // disable default scrolling
|
|
29
|
-
|
|
30
|
-
let delta = normalizeWheelDelta( e );
|
|
31
|
-
|
|
32
|
-
pos += -delta * speed;
|
|
33
|
-
pos = Math.max(0, Math.min(pos, target.scrollHeight - frame.clientHeight)); // limit scrolling
|
|
34
|
-
|
|
35
|
-
if (!moving) update();
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function normalizeWheelDelta( e ){
|
|
39
|
-
if(e.detail){
|
|
40
|
-
if(e.wheelDelta)
|
|
41
|
-
return e.wheelDelta/e.detail/40 * (e.detail>0 ? 1 : -1); // Opera
|
|
42
|
-
else
|
|
43
|
-
return -e.detail/3; // Firefox
|
|
44
|
-
}else
|
|
45
|
-
return e.wheelDelta/120; // IE,Safari,Chrome
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function update() {
|
|
49
|
-
moving = true;
|
|
50
|
-
|
|
51
|
-
let delta = (pos - target.scrollTop) / smooth;
|
|
52
|
-
|
|
53
|
-
target.scrollTop += delta;
|
|
54
|
-
|
|
55
|
-
if (Math.abs(delta) > 0.5)
|
|
56
|
-
requestFrame(update);
|
|
57
|
-
else
|
|
58
|
-
moving = false;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
let requestFrame = function() { // requestAnimationFrame cross browser
|
|
62
|
-
return (
|
|
63
|
-
window.requestAnimationFrame ||
|
|
64
|
-
window.webkitRequestAnimationFrame ||
|
|
65
|
-
window.mozRequestAnimationFrame ||
|
|
66
|
-
window.oRequestAnimationFrame ||
|
|
67
|
-
window.msRequestAnimationFrame ||
|
|
68
|
-
function(func) {
|
|
69
|
-
window.setTimeout(func, 1000 / 50);
|
|
70
|
-
}
|
|
71
|
-
);
|
|
72
|
-
}();
|
|
73
|
-
|
|
74
|
-
};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* dpHelper <https://github.com/passariello/dpHelper>
|
|
3
|
-
*
|
|
4
|
-
* scrollToElement
|
|
5
|
-
*
|
|
6
|
-
* Copyright (c) 2021, Dario Passariello.
|
|
7
|
-
* Licensed under the Apache-2.0 License.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
/***********************************************************************/
|
|
11
|
-
|
|
12
|
-
window.dphelper.scrollToElement = function( container, element, gap = 0 ) {
|
|
13
|
-
|
|
14
|
-
let el1 = document.querySelector( container );
|
|
15
|
-
let el2 = document.querySelector( element );
|
|
16
|
-
let el3 = gap; // DIVERGENCE
|
|
17
|
-
|
|
18
|
-
if( !el1 || !el2 || !el3 ) return;
|
|
19
|
-
|
|
20
|
-
el1.scrollTo({
|
|
21
|
-
top: el2.offsetTop,
|
|
22
|
-
behavior: "smooth"
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
};
|
package/scripts/serializeForm.js
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* dpHelper <https://github.com/passariello/dpHelper>
|
|
3
|
-
*
|
|
4
|
-
* serializeForm
|
|
5
|
-
*
|
|
6
|
-
* Copyright (c) 2021, Dario Passariello.
|
|
7
|
-
* Licensed under the Apache-2.0 License.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
/***********************************************************************/
|
|
11
|
-
|
|
12
|
-
window.dphelper.serializeForm = function( form ) {
|
|
13
|
-
|
|
14
|
-
const $ = require("jquery");
|
|
15
|
-
const el = this;
|
|
16
|
-
//const el = $( form );
|
|
17
|
-
|
|
18
|
-
var self = el,
|
|
19
|
-
|
|
20
|
-
json = {},
|
|
21
|
-
push_counters = {},
|
|
22
|
-
|
|
23
|
-
patterns = {
|
|
24
|
-
//"validate": /^[a-zA-Z][a-zA-Z0-9_]*(?:\[(?:\d*|[a-zA-Z0-9_]+)\])*$/,
|
|
25
|
-
"validate": /[a-zA-Z][a-zA-Z0-9-_.]/, //{1,200}
|
|
26
|
-
"key": /[a-zA-Z0-9_]+|(?=\[\])/g,
|
|
27
|
-
"push": /^$/,
|
|
28
|
-
"fixed": /^\d+$/,
|
|
29
|
-
"named": /^[a-zA-Z0-9_]+$/
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
//console.log( el )
|
|
33
|
-
|
|
34
|
-
el.build = function(base, key, value) {
|
|
35
|
-
base[key] = isNaN(value) || Array.isArray(value) ? value : Number(value);
|
|
36
|
-
return base;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
el.push_counter = function(key) {
|
|
40
|
-
if (push_counters[key] === undefined) {
|
|
41
|
-
push_counters[key] = 0;
|
|
42
|
-
}
|
|
43
|
-
return push_counters[key]++;
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
$.each( $(el).serializeArray(), function() {
|
|
47
|
-
|
|
48
|
-
// skip invalid keys
|
|
49
|
-
if (!patterns.validate.test(el.name)) {
|
|
50
|
-
return;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
var k,
|
|
54
|
-
keys = el.name.match(patterns.key),
|
|
55
|
-
merge = el.value,
|
|
56
|
-
reverse_key = el.name;
|
|
57
|
-
|
|
58
|
-
if( merge === 'false' ) merge = Boolean(false);
|
|
59
|
-
if( merge === 'true' ) merge = Boolean(true);
|
|
60
|
-
if( merge === 'off' ) merge = Boolean(false);
|
|
61
|
-
if( merge === 'on' ) merge = Boolean(true);
|
|
62
|
-
if( merge === '[]' ) merge = [];
|
|
63
|
-
if( merge === '{}' ) merge = {};
|
|
64
|
-
if( merge === 'undefined' ) merge = undefined;
|
|
65
|
-
if( merge === 'null' ) merge = null;
|
|
66
|
-
if( merge === '' ) merge = '';
|
|
67
|
-
|
|
68
|
-
while ((k = keys.pop()) !== undefined) {
|
|
69
|
-
|
|
70
|
-
// adjust reverse_key
|
|
71
|
-
reverse_key = reverse_key.replace(new RegExp("\\[" + k + "\\]$"), '');
|
|
72
|
-
|
|
73
|
-
// push
|
|
74
|
-
if (k.match(patterns.push)) {
|
|
75
|
-
merge = self.build([], self.push_counter(reverse_key), merge);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
// fixed
|
|
79
|
-
else if (k.match(patterns.fixed)) {
|
|
80
|
-
merge = self.build([], k, merge);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// named
|
|
84
|
-
else if (k.match(patterns.named)) {
|
|
85
|
-
merge = self.build({}, k, merge);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
json = $.extend(true, json, merge);
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
return json;
|
|
94
|
-
};
|
package/scripts/serializeObj.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* dpHelper <https://github.com/passariello/dpHelper>
|
|
3
|
-
*
|
|
4
|
-
* objSerialize, objDeSerialize
|
|
5
|
-
*
|
|
6
|
-
* Copyright (c) 2021, Dario Passariello.
|
|
7
|
-
* Licensed under the Apache-2.0 License.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
/***********************************************************************/
|
|
11
|
-
|
|
12
|
-
window.dphelper.objSerialize = (value) => {
|
|
13
|
-
|
|
14
|
-
if (typeof value === 'function') {
|
|
15
|
-
return value.toString();
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
if (typeof value === 'object') {
|
|
19
|
-
let serializeObject = {};
|
|
20
|
-
for (const [objectKey, objectValue] of Object.entries(value)) {
|
|
21
|
-
console.info( `objectKey=${objectKey} value=${objectValue}` );
|
|
22
|
-
serializeObject[objectKey] = window.dphelper.objSerialize(objectValue);
|
|
23
|
-
}
|
|
24
|
-
return serializeObject;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return value;
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
window.dphelper.objDeSerialize = (valueNew) => {
|
|
32
|
-
|
|
33
|
-
if (valueNew.toLowerCase().startsWith( 'function(' ) ) {
|
|
34
|
-
return Function('"use strict";return ' + valueNew);
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
if (typeof valueNew === 'object') {
|
|
38
|
-
let deserializeObject = {};
|
|
39
|
-
for (const [objectKey, objectValue] of Object.entries(valueNew)) {
|
|
40
|
-
console.info( `objectKey=${objectKey} value=${objectValue}` );
|
|
41
|
-
deserializeObject[objectKey] = window.dphelper.objDeSerialize(objectValue);
|
|
42
|
-
}
|
|
43
|
-
return deserializeObject;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return value;
|
|
47
|
-
};
|
package/scripts/sleep.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* dpHelper <https://github.com/passariello/dpHelper>
|
|
3
|
-
*
|
|
4
|
-
* sleep
|
|
5
|
-
*
|
|
6
|
-
* Copyright (c) 2021, Dario Passariello.
|
|
7
|
-
* Licensed under the Apache-2.0 License.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
/***********************************************************************/
|
|
11
|
-
|
|
12
|
-
window.dphelper.sleep = (ms) => {
|
|
13
|
-
return new Promise( resolve => setTimeout( resolve, ms) );
|
|
14
|
-
};
|
package/scripts/stopConsole.js
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* dpHelper <https://github.com/passariello/dpHelper>
|
|
3
|
-
*
|
|
4
|
-
* stopConsole
|
|
5
|
-
*
|
|
6
|
-
* Copyright (c) 2021, Dario Passariello.
|
|
7
|
-
* Licensed under the Apache-2.0 License.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
/***********************************************************************/
|
|
11
|
-
|
|
12
|
-
window.dphelper.stopConsole = () => {
|
|
13
|
-
|
|
14
|
-
let console = {};
|
|
15
|
-
console.log = function(){};
|
|
16
|
-
window.console = console;
|
|
17
|
-
if(!window.console) window.console = {};
|
|
18
|
-
|
|
19
|
-
const noop = () => {}
|
|
20
|
-
[
|
|
21
|
-
'assert',
|
|
22
|
-
'clear',
|
|
23
|
-
'count',
|
|
24
|
-
'debug',
|
|
25
|
-
'dir',
|
|
26
|
-
'dirxml',
|
|
27
|
-
'error',
|
|
28
|
-
'exception',
|
|
29
|
-
'group',
|
|
30
|
-
'groupCollapsed',
|
|
31
|
-
'groupEnd',
|
|
32
|
-
'info',
|
|
33
|
-
'log',
|
|
34
|
-
'markTimeline',
|
|
35
|
-
'profile',
|
|
36
|
-
'profileEnd',
|
|
37
|
-
'table',
|
|
38
|
-
'time',
|
|
39
|
-
'timeEnd',
|
|
40
|
-
'timeline',
|
|
41
|
-
'timelineEnd',
|
|
42
|
-
'timeStamp',
|
|
43
|
-
'trace',
|
|
44
|
-
'warn'
|
|
45
|
-
].forEach((method) => {
|
|
46
|
-
window.console[method] = noop;
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
};
|