dphelper 0.2.42 → 0.2.46
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/index.js +2 -12
- package/index.js.LICENSE.txt +24 -0
- package/package.json +2 -5
- package/.editorconfig +0 -14
- package/.eslintrc.json +0 -36
- package/.gitattributes +0 -2
- package/.jshintrc +0 -13
- package/.prettierignore +0 -2
- package/.prettierrc +0 -7
- package/.vscode/settings.json +0 -19
- package/3party/shortcut.js +0 -224
- package/data/list.json +0 -19
- package/index.d.ts +0 -9
- package/init.js +0 -51
- package/scripts/anchorToOnClick.js +0 -47
- package/scripts/array.js +0 -142
- package/scripts/browser.js +0 -65
- package/scripts/console.js +0 -86
- package/scripts/coodinates.js +0 -41
- package/scripts/cookie.js +0 -97
- package/scripts/currency.js +0 -41
- package/scripts/date.js +0 -101
- package/scripts/disable.js +0 -90
- package/scripts/event.js +0 -39
- package/scripts/font.js +0 -52
- package/scripts/form.js +0 -113
- package/scripts/function.js +0 -47
- package/scripts/indexedDB.js +0 -222
- package/scripts/json.js +0 -42
- package/scripts/load.js +0 -85
- package/scripts/noCache.js +0 -26
- package/scripts/number.js +0 -66
- package/scripts/obj.js +0 -81
- package/scripts/onBeforeUnLoad.js +0 -120
- package/scripts/parseBool.js +0 -27
- package/scripts/path.js +0 -94
- package/scripts/promise.js +0 -35
- package/scripts/purge.js +0 -53
- package/scripts/screen.js +0 -64
- package/scripts/scrollbar.js +0 -226
- package/scripts/shortcut.js +0 -70
- package/scripts/storage.js +0 -62
- package/scripts/svg.js +0 -372
- package/scripts/text.js +0 -78
- package/scripts/time.js +0 -41
- package/scripts/timer.js +0 -35
- package/scripts/trigger.js +0 -46
- package/scripts/type.js +0 -56
- package/scripts/uuid.js +0 -33
- package/scripts/window.js +0 -50
- package/ws.code-workspace +0 -73
package/scripts/cookie.js
DELETED
|
@@ -1,97 +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" : "Cookie Manager",
|
|
11
|
-
"description" : "test",
|
|
12
|
-
"version" : "0.0.1",
|
|
13
|
-
"command" : "cookie",
|
|
14
|
-
"subCommand" : [
|
|
15
|
-
{
|
|
16
|
-
"name":"set",
|
|
17
|
-
"description":"test"
|
|
18
|
-
},{
|
|
19
|
-
"name":"get",
|
|
20
|
-
"description":"test"
|
|
21
|
-
},{
|
|
22
|
-
"name":"delete",
|
|
23
|
-
"description":"test"
|
|
24
|
-
},{
|
|
25
|
-
"name":"clearAll",
|
|
26
|
-
"description":"test"
|
|
27
|
-
}
|
|
28
|
-
],
|
|
29
|
-
"example" : "",
|
|
30
|
-
"author" : "Dario Passariello",
|
|
31
|
-
"active" : true
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
window.dphelper._list.scripts.push( description );
|
|
35
|
-
|
|
36
|
-
/***********************************************************************/
|
|
37
|
-
|
|
38
|
-
var CookieType = "Lax";
|
|
39
|
-
var CookieSecure = "false";
|
|
40
|
-
var CookieSameSite = "false";
|
|
41
|
-
|
|
42
|
-
if (location.protocol === 'https:') {
|
|
43
|
-
CookieSecure = "Secure";
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
window.dphelper.cookie = {
|
|
47
|
-
|
|
48
|
-
// CREATE THE COOKIE
|
|
49
|
-
|
|
50
|
-
set: ( cname , value , time , path = '/' ) => {
|
|
51
|
-
var d = new Date();
|
|
52
|
-
d.setTime( d.getTime() + 3600 * 1000 * 24 * 365 );
|
|
53
|
-
|
|
54
|
-
if( !time ) time = d.toGMTString();
|
|
55
|
-
if( cname ){
|
|
56
|
-
document.cookie = cname + '=' + value + ';expires=' + time + ';path=' + path + ';SameSite=' + CookieSameSite + ';requireSSL='+ CookieSecure +';' + CookieSecure;
|
|
57
|
-
}
|
|
58
|
-
},
|
|
59
|
-
|
|
60
|
-
// GET THE COOKIE
|
|
61
|
-
|
|
62
|
-
get: ( cname ) => {
|
|
63
|
-
var asCookies = document.cookie.split( "; " );
|
|
64
|
-
|
|
65
|
-
for ( var i = 0; i < asCookies.length; i++ ){
|
|
66
|
-
var asCookie = asCookies[ i ].split( "=" );
|
|
67
|
-
if ( cname === asCookie[0] ) return ( unescape( asCookie[1] ) );
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
return null;
|
|
71
|
-
},
|
|
72
|
-
|
|
73
|
-
// DELETE THE COOKIE
|
|
74
|
-
|
|
75
|
-
delete: ( cname ) => {
|
|
76
|
-
document.cookie = cname + '=;expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/;SameSite=' + CookieSameSite + ';requireSSL='+ CookieSecure +';' + CookieSecure;
|
|
77
|
-
},
|
|
78
|
-
|
|
79
|
-
// CLEAR ALL COOKIE
|
|
80
|
-
|
|
81
|
-
clearAll: () => {
|
|
82
|
-
var cookies = document.cookie.split(";");
|
|
83
|
-
|
|
84
|
-
for ( var i = 0; i < cookies.length; i++ ) {
|
|
85
|
-
|
|
86
|
-
var cookie = cookies[i];
|
|
87
|
-
var eqPos = cookie.indexOf("=");
|
|
88
|
-
var cname = eqPos > -1 ? cookie.slice( 0 , eqPos ) : cookie;
|
|
89
|
-
stpro.cookie.delete( cname );
|
|
90
|
-
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
// START COOKIE DB
|
|
97
|
-
window.dphelper.cookie.set( "dpHelper", 'active' );
|
package/scripts/currency.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
|
-
|
|
9
|
-
var description = {
|
|
10
|
-
"name" : "Financial & Currency",
|
|
11
|
-
"description" : "test",
|
|
12
|
-
"version" : "0.0.1",
|
|
13
|
-
"command" : "currency",
|
|
14
|
-
"subCommand" : [
|
|
15
|
-
{
|
|
16
|
-
"name":"convert",
|
|
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.currency = {
|
|
30
|
-
|
|
31
|
-
convert: ( val, int = 'en-US', cur = 'USD' ) => {
|
|
32
|
-
if( !val || isNaN( val ) ) val = 0;
|
|
33
|
-
var formatter = new Intl.NumberFormat( int , {
|
|
34
|
-
style: 'currency',
|
|
35
|
-
currency: cur,
|
|
36
|
-
});
|
|
37
|
-
// return ( val ).toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,')
|
|
38
|
-
return formatter.format( val );
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
};
|
package/scripts/date.js
DELETED
|
@@ -1,101 +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" : "Date",
|
|
11
|
-
"description" : "test",
|
|
12
|
-
"version" : "0.0.1",
|
|
13
|
-
"command" : "date",
|
|
14
|
-
"subCommand" : [
|
|
15
|
-
{
|
|
16
|
-
"name":"toIso",
|
|
17
|
-
"description":"test"
|
|
18
|
-
},{
|
|
19
|
-
"name":"toMMDDYYYY",
|
|
20
|
-
"description":"test"
|
|
21
|
-
},{
|
|
22
|
-
"name":"convert",
|
|
23
|
-
"description":"test"
|
|
24
|
-
},{
|
|
25
|
-
"name":"iso2Epoch",
|
|
26
|
-
"description":"test"
|
|
27
|
-
},{
|
|
28
|
-
"name":"localIsoTime",
|
|
29
|
-
"description":"test"
|
|
30
|
-
},{
|
|
31
|
-
"name":"utc",
|
|
32
|
-
"description":"test"
|
|
33
|
-
},{
|
|
34
|
-
"name":"parse",
|
|
35
|
-
"description":"test"
|
|
36
|
-
},
|
|
37
|
-
],
|
|
38
|
-
"example" : "",
|
|
39
|
-
"author" : "Dario Passariello",
|
|
40
|
-
"active" : true
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
window.dphelper._list.scripts.push( description );
|
|
44
|
-
|
|
45
|
-
/***********************************************************************/
|
|
46
|
-
|
|
47
|
-
window.dphelper.date = {
|
|
48
|
-
|
|
49
|
-
toIso: (value , int = 'en' ) => {
|
|
50
|
-
if (!value) value = '';
|
|
51
|
-
let date = new Date(value);
|
|
52
|
-
if (date == 'Invalid Date') return null; //date = new Date()
|
|
53
|
-
const dateTimeFormat = new Intl.DateTimeFormat( int , {
|
|
54
|
-
year: 'numeric', month: 'long', day: 'numeric',
|
|
55
|
-
});
|
|
56
|
-
return dateTimeFormat.format(date);
|
|
57
|
-
},
|
|
58
|
-
|
|
59
|
-
toMMDDYYYY: (value) => {
|
|
60
|
-
if (!value) value = '';
|
|
61
|
-
let date = new Date(value);
|
|
62
|
-
return ('0' + (date.getMonth() + 1)).slice(-2) + "" + ('0' + date.getDate()).slice(-2) + "" + date.getFullYear();
|
|
63
|
-
},
|
|
64
|
-
|
|
65
|
-
convert: (value , format ) => {
|
|
66
|
-
if( !format) format = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
|
|
67
|
-
if (!value) return null;
|
|
68
|
-
let monthNames = format;
|
|
69
|
-
let month = value.substring(0, 2).replace('0', '');
|
|
70
|
-
let day = value.substring(2, 4);
|
|
71
|
-
let year = value.substring(value.length - 4);
|
|
72
|
-
return day + ' ' + monthNames[Number(month) - 1] + ' ' + year;
|
|
73
|
-
},
|
|
74
|
-
|
|
75
|
-
iso2Epoch: (value) => {
|
|
76
|
-
if (!value) value = '';
|
|
77
|
-
let date = new Date(value);
|
|
78
|
-
let milliseconds = date.getTime();
|
|
79
|
-
return milliseconds;
|
|
80
|
-
},
|
|
81
|
-
|
|
82
|
-
localIsoTime: (value) => {
|
|
83
|
-
if (!value) value = '';
|
|
84
|
-
let tzoffset = (new Date(value)).getTimezoneOffset() * 60000;
|
|
85
|
-
let localISOTime = (new Date(Date.now() - tzoffset)).toISOString().slice(0, -1);
|
|
86
|
-
return localISOTime;
|
|
87
|
-
},
|
|
88
|
-
|
|
89
|
-
utc: () => {
|
|
90
|
-
return moment().toISOString();
|
|
91
|
-
},
|
|
92
|
-
|
|
93
|
-
parse: ( value , separator = '/' ) => {
|
|
94
|
-
if (!value) return null;
|
|
95
|
-
let month = value.substring(0, 2);
|
|
96
|
-
let day = value.substring(2, 4);
|
|
97
|
-
let year = value.substring(4, 8);
|
|
98
|
-
return month + separator + day + separator + year;
|
|
99
|
-
},
|
|
100
|
-
|
|
101
|
-
};
|
package/scripts/disable.js
DELETED
|
@@ -1,90 +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" : "Disable",
|
|
11
|
-
"description" : "test",
|
|
12
|
-
"version" : "0.0.1",
|
|
13
|
-
"command" : "disable",
|
|
14
|
-
"subCommand" : [
|
|
15
|
-
{
|
|
16
|
-
"name":"select",
|
|
17
|
-
"description":"test"
|
|
18
|
-
},{
|
|
19
|
-
"name":"spellCheck",
|
|
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
|
-
// // ALIAS
|
|
33
|
-
// window.dphelper.disableSelect = ( el = 'body' ) => {
|
|
34
|
-
// console.debug( "Please, use 'dphelper.disable.select' instead dphelper.disableSelect" );
|
|
35
|
-
// window.dphelper.disable.select( el = 'body' );
|
|
36
|
-
// };
|
|
37
|
-
|
|
38
|
-
/***********************************************************************/
|
|
39
|
-
|
|
40
|
-
window.dphelper.disable = {
|
|
41
|
-
|
|
42
|
-
select: function( el = 'body' ){
|
|
43
|
-
|
|
44
|
-
var $ = require( "jquery" );
|
|
45
|
-
var e = e || event;
|
|
46
|
-
|
|
47
|
-
const disabling = ( el ) => {
|
|
48
|
-
const $ = require( "jquery" );
|
|
49
|
-
|
|
50
|
-
$( el ).each( function( e ){
|
|
51
|
-
|
|
52
|
-
$( this )
|
|
53
|
-
.prop( "unselectable" , "on" )
|
|
54
|
-
.css( "MozUserSelect" , "none" )
|
|
55
|
-
.css( "WebKitUserSelect" , "none" )
|
|
56
|
-
.on( "select" , function(){ return false; })
|
|
57
|
-
.on( "selectstart" , function(){ return false; });
|
|
58
|
-
|
|
59
|
-
//this.onselectstart = function() { return false }
|
|
60
|
-
//this.oncontextmenu = function() { return false }
|
|
61
|
-
|
|
62
|
-
$( 'img, a, input, button' ).on( 'dragstart' , function( e ) {
|
|
63
|
-
e.preventDefault();
|
|
64
|
-
return false;
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
document.querySelector( el ).addEventListener( 'mousedown' , function( e ){ disabling( el ); }, false );
|
|
72
|
-
document.querySelector( el ).onmousedown = function( e ){ disabling( el ); };
|
|
73
|
-
console.debug("%cSelection Disabled:%c true", "color:gray", "");
|
|
74
|
-
|
|
75
|
-
},
|
|
76
|
-
|
|
77
|
-
spellCheck: ( tmr = 5000 ) => {
|
|
78
|
-
|
|
79
|
-
setInterval( () => {
|
|
80
|
-
let inputs = document.querySelectorAll("input[type=text], textarea");
|
|
81
|
-
for(let i = 0; i < inputs.length; i++){
|
|
82
|
-
if( !inputs[i].getAttribute("spellcheck") ){
|
|
83
|
-
inputs[i].setAttribute("spellcheck", "false");
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
}, tmr );
|
|
87
|
-
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
};
|
package/scripts/event.js
DELETED
|
@@ -1,39 +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" : "Events",
|
|
11
|
-
"description" : "test",
|
|
12
|
-
"version" : "0.0.1",
|
|
13
|
-
"command" : "event",
|
|
14
|
-
"subCommand" : [
|
|
15
|
-
{
|
|
16
|
-
"name":"multi",
|
|
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.event ={
|
|
30
|
-
|
|
31
|
-
multi: ( element, eventNames, listener ) => {
|
|
32
|
-
var events = eventNames.split(' ');
|
|
33
|
-
for (var i=0, iLen = events.length; i < iLen; ++i ) {
|
|
34
|
-
element.addEventListener( events[i], listener, false );
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
},
|
|
38
|
-
|
|
39
|
-
};
|
package/scripts/font.js
DELETED
|
@@ -1,52 +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" : "Fonts",
|
|
11
|
-
"description" : "test",
|
|
12
|
-
"version" : "0.0.1",
|
|
13
|
-
"command" : "font",
|
|
14
|
-
"subCommand" : [
|
|
15
|
-
{
|
|
16
|
-
"name":"fitContainer",
|
|
17
|
-
"description":""
|
|
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.font = {
|
|
30
|
-
|
|
31
|
-
fitContainer: ( name ) => {
|
|
32
|
-
if( !name ) return;
|
|
33
|
-
|
|
34
|
-
function fitStart(){
|
|
35
|
-
var divs = document.querySelectorAll( name );
|
|
36
|
-
if( divs.length <= 0 ) return;
|
|
37
|
-
for(var i = 0; i < divs.length; i++) {
|
|
38
|
-
var fontSize = divs[i].offsetWidth * 0.05;
|
|
39
|
-
divs[i].style.fontSize = fontSize+'px';
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
window.dphelper.addListenerMulti( window , 'load resize', () => {
|
|
44
|
-
fitStart( name );
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
package/scripts/form.js
DELETED
|
@@ -1,113 +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" : "Forms",
|
|
11
|
-
"description" : "test",
|
|
12
|
-
"version" : "0.0.1",
|
|
13
|
-
"command" : "form",
|
|
14
|
-
"subCommand" : [
|
|
15
|
-
{
|
|
16
|
-
"name":"serialize",
|
|
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.form = {
|
|
30
|
-
|
|
31
|
-
serialize: ( form ) => {
|
|
32
|
-
|
|
33
|
-
const $ = require("jquery");
|
|
34
|
-
const el = this;
|
|
35
|
-
//const el = $( form );
|
|
36
|
-
|
|
37
|
-
var self = el,
|
|
38
|
-
|
|
39
|
-
json = {},
|
|
40
|
-
push_counters = {},
|
|
41
|
-
|
|
42
|
-
patterns = {
|
|
43
|
-
//"validate": /^[a-zA-Z][a-zA-Z0-9_]*(?:\[(?:\d*|[a-zA-Z0-9_]+)\])*$/,
|
|
44
|
-
"validate": /[a-zA-Z][a-zA-Z0-9-_.]/, //{1,200}
|
|
45
|
-
"key": /[a-zA-Z0-9_]+|(?=\[\])/g,
|
|
46
|
-
"push": /^$/,
|
|
47
|
-
"fixed": /^\d+$/,
|
|
48
|
-
"named": /^[a-zA-Z0-9_]+$/
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
el.build = function(base, key, value) {
|
|
52
|
-
base[key] = isNaN(value) || Array.isArray(value) ? value : Number(value);
|
|
53
|
-
return base;
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
el.push_counter = function(key) {
|
|
57
|
-
if (push_counters[key] === undefined) {
|
|
58
|
-
push_counters[key] = 0;
|
|
59
|
-
}
|
|
60
|
-
return push_counters[key]++;
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
$.each( $(el).serializeArray(), function() {
|
|
64
|
-
|
|
65
|
-
// skip invalid keys
|
|
66
|
-
if (!patterns.validate.test(el.name)) {
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
var k,
|
|
71
|
-
keys = el.name.match(patterns.key),
|
|
72
|
-
merge = el.value,
|
|
73
|
-
reverse_key = el.name;
|
|
74
|
-
|
|
75
|
-
if( merge === 'false' ) merge = Boolean(false);
|
|
76
|
-
if( merge === 'true' ) merge = Boolean(true);
|
|
77
|
-
if( merge === 'off' ) merge = Boolean(false);
|
|
78
|
-
if( merge === 'on' ) merge = Boolean(true);
|
|
79
|
-
if( merge === '[]' ) merge = [];
|
|
80
|
-
if( merge === '{}' ) merge = {};
|
|
81
|
-
if( merge === 'undefined' ) merge = undefined;
|
|
82
|
-
if( merge === 'null' ) merge = null;
|
|
83
|
-
if( merge === '' ) merge = '';
|
|
84
|
-
|
|
85
|
-
while ((k = keys.pop()) !== undefined) {
|
|
86
|
-
|
|
87
|
-
// adjust reverse_key
|
|
88
|
-
reverse_key = reverse_key.replace(new RegExp("\\[" + k + "\\]$"), '');
|
|
89
|
-
|
|
90
|
-
// push
|
|
91
|
-
if (k.match(patterns.push)) {
|
|
92
|
-
merge = self.build([], self.push_counter(reverse_key), merge);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// fixed
|
|
96
|
-
else if (k.match(patterns.fixed)) {
|
|
97
|
-
merge = self.build([], k, merge);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
// named
|
|
101
|
-
else if (k.match(patterns.named)) {
|
|
102
|
-
merge = self.build({}, k, merge);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
json = $.extend(true, json, merge);
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
return json;
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
};
|
package/scripts/function.js
DELETED
|
@@ -1,47 +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" : "Functions",
|
|
11
|
-
"description" : "test",
|
|
12
|
-
"version" : "0.0.1",
|
|
13
|
-
"command" : "func",
|
|
14
|
-
"subCommand" : [
|
|
15
|
-
{
|
|
16
|
-
"name":"new",
|
|
17
|
-
"description":"test"
|
|
18
|
-
},{
|
|
19
|
-
"name":"toObj.set",
|
|
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.func = {
|
|
33
|
-
|
|
34
|
-
new: ( name , text ) => {
|
|
35
|
-
args = [ name , "return" + text ];
|
|
36
|
-
myFunc = Function.apply( null, args );
|
|
37
|
-
},
|
|
38
|
-
|
|
39
|
-
toObj: {
|
|
40
|
-
set: ( value , key ) => {
|
|
41
|
-
return [value , key];
|
|
42
|
-
}
|
|
43
|
-
// var dog = new dphelper.func.oop( "Dog", "Bobby" );
|
|
44
|
-
// console.log( dog.getDetails());
|
|
45
|
-
},
|
|
46
|
-
|
|
47
|
-
};
|