dphelper 0.2.49 → 0.2.55

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 (63) hide show
  1. package/.editorconfig +15 -0
  2. package/.env +3 -0
  3. package/.eslintignore +8 -0
  4. package/.eslintrc.json +36 -0
  5. package/.gitattributes +2 -0
  6. package/.hintrc +11 -0
  7. package/.jsbeautifyrc +25 -0
  8. package/.jshintrc +14 -0
  9. package/.prettierignore +2 -0
  10. package/.prettierrc +7 -0
  11. package/.vscode/settings.json +54 -0
  12. package/3party/shortcut.js +224 -0
  13. package/backup.bat +43 -0
  14. package/data/list.json +19 -0
  15. package/dist/LICENSE +201 -0
  16. package/dist/README.md +176 -0
  17. package/index.d.ts +14 -0
  18. package/index.js +10 -2
  19. package/init.js +48 -0
  20. package/jest.config.js +18 -0
  21. package/package.json +127 -75
  22. package/public/assets/images/banner.png +0 -0
  23. package/public/assets/logos/logo.svg +64 -0
  24. package/scripts/anchorToOnClick.js +47 -0
  25. package/scripts/array.js +142 -0
  26. package/scripts/browser.js +65 -0
  27. package/scripts/console.js +86 -0
  28. package/scripts/coodinates.js +41 -0
  29. package/scripts/cookie.js +97 -0
  30. package/scripts/currency.js +41 -0
  31. package/scripts/date.js +101 -0
  32. package/scripts/disable.js +90 -0
  33. package/scripts/event.js +39 -0
  34. package/scripts/font.js +52 -0
  35. package/scripts/form.js +113 -0
  36. package/scripts/function.js +47 -0
  37. package/scripts/indexedDB.js +222 -0
  38. package/scripts/json.js +42 -0
  39. package/scripts/load.js +85 -0
  40. package/scripts/noCache.js +26 -0
  41. package/scripts/number.js +66 -0
  42. package/scripts/obj.js +81 -0
  43. package/scripts/onBeforeUnLoad.js +120 -0
  44. package/scripts/parseBool.js +27 -0
  45. package/scripts/path.js +94 -0
  46. package/scripts/promise.js +35 -0
  47. package/scripts/purge.js +53 -0
  48. package/scripts/screen.js +64 -0
  49. package/scripts/scrollbar.js +245 -0
  50. package/scripts/shortcut.js +70 -0
  51. package/scripts/storage.js +62 -0
  52. package/scripts/svg.js +372 -0
  53. package/scripts/text.js +78 -0
  54. package/scripts/time.js +41 -0
  55. package/scripts/timer.js +35 -0
  56. package/scripts/trigger.js +46 -0
  57. package/scripts/type.js +56 -0
  58. package/scripts/uuid.js +33 -0
  59. package/scripts/window.js +50 -0
  60. package/tests/ld-json-funtions.test.ts +21 -0
  61. package/tests/ld-json.test.ts +46 -0
  62. package/webpack.config.js +240 -0
  63. package/index.js.LICENSE.txt +0 -24
@@ -0,0 +1,97 @@
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
+ 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
+ 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
+ dphelper.cookie.set( "dpHelper", 'active' );
@@ -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
+
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
+ dphelper._list.scripts.push( description );
26
+
27
+ /***********************************************************************/
28
+
29
+ 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
+ };
@@ -0,0 +1,101 @@
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
+ dphelper._list.scripts.push( description );
44
+
45
+ /***********************************************************************/
46
+
47
+ 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
+ };
@@ -0,0 +1,90 @@
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
+ dphelper._list.scripts.push( description );
29
+
30
+ /***********************************************************************/
31
+
32
+ // // ALIAS
33
+ // dphelper.disableSelect = ( el = 'body' ) => {
34
+ // console.debug( "Please, use 'dphelper.disable.select' instead dphelper.disableSelect" );
35
+ // dphelper.disable.select( el = 'body' );
36
+ // };
37
+
38
+ /***********************************************************************/
39
+
40
+ 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
+ };
@@ -0,0 +1,39 @@
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
+ dphelper._list.scripts.push( description );
26
+
27
+ /***********************************************************************/
28
+
29
+ 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
+ };
@@ -0,0 +1,52 @@
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
+ dphelper._list.scripts.push( description );
26
+
27
+ /***********************************************************************/
28
+
29
+ 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
+ dphelper.addListenerMulti( window , 'load resize', () => {
44
+ fitStart( name );
45
+ });
46
+
47
+ }
48
+
49
+ };
50
+
51
+
52
+
@@ -0,0 +1,113 @@
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
+ dphelper._list.scripts.push( description );
26
+
27
+ /***********************************************************************/
28
+
29
+ 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
+ };
@@ -0,0 +1,47 @@
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
+ dphelper._list.scripts.push( description );
29
+
30
+ /***********************************************************************/
31
+
32
+ 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
+ };