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.
Files changed (82) hide show
  1. package/data/list.json +19 -39
  2. package/init.js +19 -5
  3. package/package.json +5 -7
  4. package/scripts/anchorToOnClick.js +15 -3
  5. package/scripts/array.js +29 -3
  6. package/scripts/console.js +86 -0
  7. package/scripts/cookie.js +97 -71
  8. package/scripts/currency.js +31 -11
  9. package/scripts/date.js +101 -0
  10. package/scripts/disable.js +90 -0
  11. package/scripts/event.js +39 -0
  12. package/scripts/font.js +52 -0
  13. package/scripts/form.js +113 -0
  14. package/scripts/indexedDB.js +47 -10
  15. package/scripts/json.js +42 -0
  16. package/scripts/load.js +70 -0
  17. package/scripts/noCache.js +26 -14
  18. package/scripts/number.js +42 -0
  19. package/scripts/obj.js +81 -0
  20. package/scripts/onBeforeUnLoad.js +120 -108
  21. package/scripts/parseBool.js +27 -15
  22. package/scripts/path.js +94 -0
  23. package/scripts/promise.js +35 -0
  24. package/scripts/purge.js +53 -41
  25. package/scripts/pushState.js +33 -14
  26. package/scripts/screen.js +64 -0
  27. package/scripts/scrollbar.js +226 -0
  28. package/scripts/{handleEvent.js → shortcut.js} +70 -59
  29. package/scripts/storage.js +29 -3
  30. package/scripts/svg.js +372 -0
  31. package/scripts/text.js +78 -0
  32. package/scripts/time.js +41 -0
  33. package/scripts/timer.js +35 -0
  34. package/scripts/trigger.js +37 -0
  35. package/scripts/uuid.js +33 -14
  36. package/scripts/window.js +50 -38
  37. package/#cmd.exe.lnk +0 -0
  38. package/.github/workflows/codeql-analysis.yml +0 -70
  39. package/scripts/.OLD/arrayDeleteItem.js +0 -35
  40. package/scripts/.OLD/arrayItemFinder.js +0 -22
  41. package/scripts/.OLD/arrayMerge.js +0 -20
  42. package/scripts/.OLD/arrayUnique.js +0 -15
  43. package/scripts/.OLD/loadAsset.js +0 -26
  44. package/scripts/addListenerMulti.js +0 -10
  45. package/scripts/camelCase.js +0 -29
  46. package/scripts/date2Iso.js +0 -20
  47. package/scripts/date2MMDDYYYY.js +0 -16
  48. package/scripts/dateConvert.js +0 -20
  49. package/scripts/dateIso2Epoch.js +0 -17
  50. package/scripts/dateLocal-ISOTime.js +0 -17
  51. package/scripts/dateUTC.js +0 -14
  52. package/scripts/disableSelect.js +0 -46
  53. package/scripts/disableSpellCheck.js +0 -21
  54. package/scripts/epoch.js +0 -14
  55. package/scripts/fontFit.js +0 -24
  56. package/scripts/fullScreen.js +0 -40
  57. package/scripts/isPromise.js +0 -14
  58. package/scripts/jsonCounter.js +0 -21
  59. package/scripts/loadFile.js +0 -17
  60. package/scripts/loadJson.js +0 -15
  61. package/scripts/loadJsonExternal.js +0 -32
  62. package/scripts/nl2br.js +0 -14
  63. package/scripts/object2array.js +0 -16
  64. package/scripts/parseDate.js +0 -19
  65. package/scripts/pathHash.js +0 -19
  66. package/scripts/pathQuery.js +0 -24
  67. package/scripts/pathRail.js +0 -25
  68. package/scripts/printInfo.js +0 -16
  69. package/scripts/randomNum.js +0 -14
  70. package/scripts/randomNumTmr.js +0 -14
  71. package/scripts/scrollCustom.js +0 -41
  72. package/scripts/scrollIndicator.js +0 -67
  73. package/scripts/scrollMemory.js +0 -26
  74. package/scripts/scrollSmooth.js +0 -74
  75. package/scripts/scrollToElement.js +0 -25
  76. package/scripts/serializeForm.js +0 -94
  77. package/scripts/serializeObj.js +0 -47
  78. package/scripts/sleep.js +0 -14
  79. package/scripts/stopConsole.js +0 -49
  80. package/scripts/svgSupport.js +0 -346
  81. package/scripts/textChanger.js +0 -24
  82. package/scripts/triggerClick.js +0 -16
@@ -1,108 +1,120 @@
1
- /*!
2
- * dpHelper <https://github.com/passariello/dpHelper>
3
- *
4
- * onBeforeUnLoad
5
- *
6
- * Copyright (c) 2021, Dario Passariello.
7
- * Licensed under the Apache-2.0 License.
8
- */
9
-
10
- /***********************************************************************/
11
-
12
- window.dphelper.onBeforeUnLoad = () => {
13
-
14
- let is_dirty = false;
15
- let answer = null;
16
- let mex = "You have made some changes which you might want to save.";
17
- let loadOnce = false;
18
- let save_button = document.querySelector("#save_button");
19
-
20
- const beforeUnloadListener = ( event ) => {
21
- event.preventDefault();
22
- return mex;
23
- };
24
-
25
- const nameInput = document.querySelector("#name");
26
-
27
- if( nameInput ){
28
- nameInput.addEventListener( "input" , (event) => {
29
- if (event.target.value !== "") {
30
- addEventListener("beforeunload", beforeUnloadListener, { capture: true });
31
- } else {
32
- removeEventListener("beforeunload", beforeUnloadListener, { capture: true });
33
- }
34
- });
35
- }
36
-
37
- /****************************************************************************** */
38
-
39
- let handleEvent = function( event ){
40
-
41
- if( event.target.type === 'textarea' || event.target.type === 'input' ){
42
- if( is_dirty === false ){
43
- return is_dirty = true;
44
- }
45
- }
46
-
47
- };
48
-
49
- /****************************************************************************** */
50
-
51
- let TEST = function (){
52
- // CHANGE ON KEY
53
- document.body.addEventListener( "keyup" , handleEvent );
54
- }();
55
-
56
- /****************************************************************************** */
57
-
58
- // CHANGE ON ASIDE CLICK
59
- if( loadOnce === false ){
60
- document.body.addEventListener( "click" , function( event ){
61
-
62
- if( event.target.tagName === 'IMG'){
63
-
64
- if( is_dirty === true ) {
65
-
66
- // if the user navigates away from this page via an anchor link,
67
- // popup a new boxy confirmation.
68
- answer = confirm( mex );
69
- if ( answer === true ) {
70
- return is_dirty = false;
71
- }else{
72
- event.preventDefault();
73
- }
74
- }
75
- }
76
-
77
- });
78
- loadOnce = true;
79
- }
80
-
81
- /****************************************************************************** */
82
-
83
- addEventListener('popstate', function(event) {
84
-
85
- if( is_dirty === true ){
86
- answer = confirm( mex );
87
- if ( answer === true ) {
88
- return is_dirty = false;
89
- } else {
90
- event.stopImmediatePropagation();
91
- event.preventDefault();
92
- return mex;
93
- }
94
- }
95
-
96
- });
97
-
98
- /****************************************************************************** */
99
-
100
- window.onbeforeunload = function( event ) {
101
- if( ( is_dirty === true ) && ( answer === null ) ){
102
- event.preventDefault();
103
- return event.returnValue = mex;
104
- //return mex
105
- }
106
- };
107
-
108
- };
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" : "BeforeUnLoad",
11
+ "description" : "test",
12
+ "version" : "0.0.1",
13
+ "command" : "onBeforeUnLoad",
14
+ "subCommand" : [],
15
+ "example" : "",
16
+ "author" : "Dario Passariello",
17
+ "active" : true
18
+ };
19
+
20
+ window.dphelper._list.scripts.push( description );
21
+
22
+ /***********************************************************************/
23
+
24
+ window.dphelper.onBeforeUnLoad = () => {
25
+
26
+ let is_dirty = false;
27
+ let answer = null;
28
+ let mex = "You have made some changes which you might want to save.";
29
+ let loadOnce = false;
30
+ let save_button = document.querySelector("#save_button");
31
+
32
+ const beforeUnloadListener = ( event ) => {
33
+ event.preventDefault();
34
+ return mex;
35
+ };
36
+
37
+ const nameInput = document.querySelector("#name");
38
+
39
+ if( nameInput ){
40
+ nameInput.addEventListener( "input" , (event) => {
41
+ if (event.target.value !== "") {
42
+ addEventListener("beforeunload", beforeUnloadListener, { capture: true });
43
+ } else {
44
+ removeEventListener("beforeunload", beforeUnloadListener, { capture: true });
45
+ }
46
+ });
47
+ }
48
+
49
+ /****************************************************************************** */
50
+
51
+ let handleEvent = function( event ){
52
+
53
+ if( event.target.type === 'textarea' || event.target.type === 'input' ){
54
+ if( is_dirty === false ){
55
+ return is_dirty = true;
56
+ }
57
+ }
58
+
59
+ };
60
+
61
+ /****************************************************************************** */
62
+
63
+ let TEST = function (){
64
+ // CHANGE ON KEY
65
+ document.body.addEventListener( "keyup" , handleEvent );
66
+ }();
67
+
68
+ /****************************************************************************** */
69
+
70
+ // CHANGE ON ASIDE CLICK
71
+ if( loadOnce === false ){
72
+ document.body.addEventListener( "click" , function( event ){
73
+
74
+ if( event.target.tagName === 'IMG'){
75
+
76
+ if( is_dirty === true ) {
77
+
78
+ // if the user navigates away from this page via an anchor link,
79
+ // popup a new boxy confirmation.
80
+ answer = confirm( mex );
81
+ if ( answer === true ) {
82
+ return is_dirty = false;
83
+ }else{
84
+ event.preventDefault();
85
+ }
86
+ }
87
+ }
88
+
89
+ });
90
+ loadOnce = true;
91
+ }
92
+
93
+ /****************************************************************************** */
94
+
95
+ addEventListener('popstate', function(event) {
96
+
97
+ if( is_dirty === true ){
98
+ answer = confirm( mex );
99
+ if ( answer === true ) {
100
+ return is_dirty = false;
101
+ } else {
102
+ event.stopImmediatePropagation();
103
+ event.preventDefault();
104
+ return mex;
105
+ }
106
+ }
107
+
108
+ });
109
+
110
+ /****************************************************************************** */
111
+
112
+ window.onbeforeunload = function( event ) {
113
+ if( ( is_dirty === true ) && ( answer === null ) ){
114
+ event.preventDefault();
115
+ return event.returnValue = mex;
116
+ //return mex
117
+ }
118
+ };
119
+
120
+ };
@@ -1,15 +1,27 @@
1
- /*!
2
- * dpHelper <https://github.com/passariello/dpHelper>
3
- *
4
- * parse Bool
5
- *
6
- * Copyright (c) 2021, Dario Passariello.
7
- * Licensed under the Apache-2.0 License.
8
- */
9
-
10
- /***********************************************************************/
11
-
12
- window.dphelper.parseBool = (val) => {
13
- if (!val || val.length == null) return true;
14
- return val == '1' ? true : false;
15
- };
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" : "String To Boolean",
11
+ "description" : "test",
12
+ "version" : "0.0.1",
13
+ "command" : "parseBool",
14
+ "subCommand" : [],
15
+ "example" : "",
16
+ "author" : "Dario Passariello",
17
+ "active" : true
18
+ };
19
+
20
+ window.dphelper._list.scripts.push( description );
21
+
22
+ /***********************************************************************/
23
+
24
+ window.dphelper.parseBool = ( val ) => {
25
+ if ( !val || val.length == null ) return true;
26
+ return val == '1' ? true : false;
27
+ };
@@ -0,0 +1,94 @@
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" : "Path To Array",
11
+ "description" : "test",
12
+ "version" : "0.0.1",
13
+ "command" : "path",
14
+ "subCommand" : [
15
+ {
16
+ "name":"rail",
17
+ "description":"test"
18
+ },{
19
+ "name":"hash",
20
+ "description":"test"
21
+ },{
22
+ "name":"query",
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
+ // // ALIAS
36
+ // window.dphelper.pathHash = () => {
37
+ // console.debug( 'dpHelper: Please use "dphelper.path.hash()"' );
38
+ // return window.dphelper.path.hash();
39
+ // };
40
+
41
+ // window.dphelper.pathQuery = () => {
42
+ // console.debug( 'dpHelper: Please use "dphelper.path.query()"' );
43
+ // return window.dphelper.path.query();
44
+ // };
45
+
46
+ // window.dphelper.pathRail = () => {
47
+ // console.debug( 'dpHelper: Please use "dphelper.path.rail()"' );
48
+ // return window.dphelper.path.rail();
49
+ // };
50
+
51
+ /***********************************************************************/
52
+
53
+ window.dphelper.path = {
54
+
55
+ rail: () => {
56
+ const array = location.href
57
+ .split("?")[0]
58
+ .replace(location.protocol, '')
59
+ .replace(location.host, '')
60
+ .replace(location.hash, '')
61
+ .split('/');
62
+ if ( array.length > 0 ) {
63
+ const arrayFinal = array.filter(item => item);
64
+ return arrayFinal;
65
+ } else {
66
+ return;
67
+ }
68
+ },
69
+
70
+ hash: () => {
71
+ const array = location.hash.replace('#', '').split('/');
72
+ if (array.length) {
73
+ return array.filter(item => item);
74
+ } else {
75
+ return ["empty"];
76
+ }
77
+ },
78
+
79
+ query: () => {
80
+ let x, y, array = [], search = location.search;
81
+ if (search) {
82
+ search.replace("?", '').split('&')
83
+ .map(x => {
84
+ y = x.split('=');
85
+ array[y[0]] = y[1];
86
+ });
87
+ return array;
88
+ } else {
89
+ return ["empty"];
90
+ }
91
+ }
92
+
93
+ };
94
+
@@ -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" : "Promises",
11
+ "description" : "test",
12
+ "version" : "0.0.1",
13
+ "command" : "promise",
14
+ "subCommand" : [
15
+ {
16
+ name:"check",
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.promise = {
30
+
31
+ check: (p) => {
32
+ return p && Object.prototype.toString.call(p) === "[object Promise]";
33
+ }
34
+
35
+ };
package/scripts/purge.js CHANGED
@@ -1,41 +1,53 @@
1
- /*!
2
- * dpHelper <https://github.com/passariello/dpHelper>
3
- *
4
- * purge
5
- *
6
- * Copyright (c) 2021, Dario Passariello.
7
- * Licensed under the Apache-2.0 License.
8
- */
9
-
10
- /***********************************************************************/
11
-
12
- window.dphelper.purge = ( d = body, time = 10000 ) => {
13
-
14
- setTimeout(() => {
15
- if( d === undefined ) return null;
16
-
17
- let a = d.attributes, i, l, n;
18
-
19
- if (a) {
20
- l = a.length;
21
- for( i = 0; i < l; i += 1 ) {
22
- n = a[i].name;
23
- if( typeof d[n] === 'function' ) { d[n] = null; }
24
- if( typeof d[n] === 'undefined' ) { d[n] = null; }
25
- }
26
-
27
- }
28
-
29
- a = d.childNodes;
30
-
31
- if (a) {
32
- l = a.length;
33
- for( i = 0; i < l; i += 1 ) {
34
- Purge( d.childNodes[i] );
35
- }
36
- }
37
- }, time );
38
-
39
- };
40
-
41
- // purge()
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" : "Purge From Memory",
11
+ "description" : "test",
12
+ "version" : "0.0.1",
13
+ "command" : "purge",
14
+ "subCommand" : [],
15
+ "example" : "",
16
+ "author" : "Dario Passariello",
17
+ "active" : true
18
+ };
19
+
20
+ window.dphelper._list.scripts.push( description );
21
+
22
+ /***********************************************************************/
23
+
24
+ window.dphelper.purge = ( d = body, time = 10000 ) => {
25
+
26
+ setTimeout(() => {
27
+ if( d === undefined ) return null;
28
+
29
+ let a = d.attributes, i, l, n;
30
+
31
+ if (a) {
32
+ l = a.length;
33
+ for( i = 0; i < l; i += 1 ) {
34
+ n = a[i].name;
35
+ if( typeof d[n] === 'function' ) { d[n] = null; }
36
+ if( typeof d[n] === 'undefined' ) { d[n] = null; }
37
+ }
38
+
39
+ }
40
+
41
+ a = d.childNodes;
42
+
43
+ if (a) {
44
+ l = a.length;
45
+ for( i = 0; i < l; i += 1 ) {
46
+ Purge( d.childNodes[i] );
47
+ }
48
+ }
49
+ }, time );
50
+
51
+ };
52
+
53
+ // purge()
@@ -1,14 +1,33 @@
1
- /*!
2
- * dpHelper <https://github.com/passariello/dpHelper>
3
- *
4
- * pushState
5
- *
6
- * Copyright (c) 2021, Dario Passariello.
7
- * Licensed under the Apache-2.0 License.
8
- */
9
-
10
- /***********************************************************************/
11
-
12
- window.dphelper.pushState = (state, title, url) => {
13
- return history.pushState( state, title, url );
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" : "PushState Browser (Ajax)",
11
+ "description" : "test",
12
+ "version" : "0.0.1",
13
+ "command" : "push",
14
+ "subCommand" : [
15
+ {
16
+ "name":"state",
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.push = {
30
+ state: (state, title, url) => {
31
+ return history.pushState( state, title, url );
32
+ }
33
+ };
@@ -0,0 +1,64 @@
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" : "Screen Options",
11
+ "description" : "test",
12
+ "version" : "0.0.1",
13
+ "command" : "screen",
14
+ "subCommand" : [
15
+ {
16
+ "name":"fullScreen",
17
+ "description":"test"
18
+ },{
19
+ "name":"toggle",
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.screen = {
33
+
34
+ fullScreen: function( el ){
35
+
36
+ if ( el.requestFullScreen ) {
37
+ el.requestFullScreen();
38
+ } else if ( el.mozRequestFullScreen ) {
39
+ el.mozRequestFullScreen();
40
+ } else if ( el.webkitRequestFullScreen ) {
41
+ el.webkitRequestFullScreen();
42
+ }
43
+
44
+ },
45
+
46
+ toggle: function( el ) {
47
+
48
+ let requestFullScreen = el.requestFullscreen || el.mozRequestFullScreen || el.webkitRequestFullScreen || el.msRequestFullscreen;
49
+ let cancelFullScreen = el.exitFullscreen || el.mozCancelFullScreen || el.webkitExitFullscreen || el.msExitFullscreen;
50
+
51
+ if( !doc.fullscreenElement && !el.mozFullScreenElement && !el.webkitFullscreenElement && !el.msFullscreenElement ) {
52
+ requestFullScreen.call( el );
53
+ }else{
54
+ cancelFullScreen.call( el );
55
+ }
56
+
57
+ }
58
+
59
+ };
60
+
61
+ // window.dphelper.fullScreen.go( document.body )
62
+ // window.dphelper.fullScreen.toggle( document.body )
63
+
64
+