dphelper 0.2.36 → 0.2.41

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.
@@ -0,0 +1,13 @@
1
+ # These are supported funding model platforms
2
+
3
+ github: passariello
4
+ patreon: passariello
5
+ open_collective: # Replace with a single Open Collective username
6
+ ko_fi: passariello
7
+ indiegogo: passariello
8
+ tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
9
+ community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
10
+ liberapay: passariello
11
+ issuehunt: passariello
12
+ otechie: # Replace with a single Otechie username
13
+ custom: ["https://dario.passariello.ca", "https://www.paypal.me/dariopassariello", "https://www.indiegogo.com/individuals/28513718"]
package/README.md CHANGED
@@ -16,12 +16,21 @@ Please visit the github repository @ [dpHelper on Github](https://github.com/pas
16
16
 
17
17
  ```js
18
18
  npm i dphelper
19
+
20
+ or update:
21
+
22
+ npm i dphelper@latest
23
+
19
24
  ```
20
25
 
21
26
  in the index (and only there):
22
27
 
23
28
  ```js
24
29
  import "dphelper"
30
+
31
+ or
32
+
33
+ require("dphelper")
25
34
  ```
26
35
 
27
36
  ## check
package/init.js CHANGED
@@ -17,23 +17,22 @@
17
17
 
18
18
  // CREATE ROOT STORE
19
19
  const dphelper = window.dphelper = {};
20
-
21
- window.dphelper._list = require('./data/list.json');
20
+
21
+ window.dphelper._list = require('./data/list.json');
22
22
  window.dphelper._list.scripts = [];
23
23
  window.dphelper._list.version = pjson.version;
24
24
 
25
25
  const cache = {};
26
26
 
27
- function importAll(r){
28
- r.keys().forEach(
29
- (key) => (
30
- cache[key] = r(key)
27
+ const importAll = ( cntx ) => {
28
+ cntx.keys().forEach(
29
+ ( key ) => (
30
+ cache[ key ] = cntx( key )
31
31
  )
32
- );
33
- }
34
-
35
- importAll( require.context( __dirname + '/scripts/', false, /\.js$/) );
36
-
32
+ );
33
+ };
34
+ var cntx = require.context( __dirname + '/scripts/', false , /\.js$/ );
35
+ importAll( cntx );
37
36
 
38
37
  // FIRST MESSAGE
39
38
  console.groupCollapsed( `%c${pjson.name} v${pjson.version}%c`,"color:orange","" );
@@ -49,88 +48,4 @@
49
48
  console.debug( 'email: %c' + pjson.author.email,"color:orange","" );
50
49
  console.groupEnd();
51
50
 
52
- /*
53
- // SYSTEM
54
- require('./scripts/addListenerMulti.js');
55
-
56
- // 3party
57
- require('./3party/shortcut.js');
58
-
59
- // CURRENCY
60
- require('./scripts/currency.js');
61
-
62
- // MEMORY
63
- require('./scripts/storage.js');
64
- require('./scripts/cookie.js');
65
- require('./scripts/indexedDB.js');
66
-
67
- // NUMBERS
68
- require('./scripts/randomNum.js');
69
- require('./scripts/randomNumTmr.js');
70
-
71
- // TIME
72
- require('./scripts/epoch.js');
73
- require('./scripts/parseDate.js');
74
- require('./scripts/dateUTC.js');
75
- require('./scripts/dateIso2Epoch.js');
76
- require('./scripts/dateConvert.js');
77
- require('./scripts/date2MMDDYYYY.js');
78
- require('./scripts/date2Iso.js');
79
- require('./scripts/dateLocal-ISOTime.js');
80
-
81
- // PATH
82
- require('./scripts/pathRail.js');
83
- require('./scripts/pathQuery.js');
84
- require('./scripts/pathHash.js');
85
- require('./scripts/pushState.js');
86
- require('./scripts/anchorToOnClick.js');
87
-
88
- // FILE
89
- require('./scripts/loadFile.js');
90
- //require('./scripts/loadAsset.js');
91
- require('./scripts/loadJson.js');
92
- require('./scripts/loadJsonExternal.js');
93
-
94
- // FORMS
95
- require('./scripts/serializeForm.js');
96
- require('./scripts/serializeObj.js');
97
-
98
- // ARRAY
99
- // require('./scripts/arrayItemFinder.js');
100
- // require('./scripts/arrayDeleteItem.js');
101
- // require('./scripts/arrayMerge.js');
102
- // require('./scripts/arrayUnique.js');
103
- require('./scripts/array.js');
104
- require('./scripts/object2array.js');
105
-
106
- // SCROLL
107
- require('./scripts/scrollToElement.js');
108
- require('./scripts/scrollSmooth.js');
109
- require('./scripts/scrollIndicator.js');
110
- require('./scripts/scrollMemory.js');
111
- require('./scripts/scrollCustom.js');
112
-
113
- // OTHER
114
- require('./scripts/camelCase.js');
115
- require('./scripts/fontFit.js');
116
- require('./scripts/uuid.js');
117
- require('./scripts/noCache.js');
118
- require('./scripts/parseBool.js');
119
- require('./scripts/isPromise.js');
120
- require('./scripts/textChanger.js');
121
- require('./scripts/nl2br.js');
122
- require('./scripts/sleep.js');
123
- require('./scripts/printInfo.js');
124
- require('./scripts/disableSelect.js');
125
- require('./scripts/fullScreen.js');
126
- require('./scripts/disableSpellCheck.js');
127
- require('./scripts/triggerClick.js');
128
- require('./scripts/handleEvent.js');
129
- require('./scripts/window.js');
130
- require('./scripts/purge.js');
131
- require('./scripts/svgSupport.js');
132
- require('./scripts/stopConsole.js');
133
- require('./scripts/onBeforeUnLoad.js');
134
- */
135
-
136
51
  })();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dphelper",
3
- "version": "0.2.36",
3
+ "version": "0.2.41",
4
4
  "description": "Developer Tools",
5
5
  "main": "index.js",
6
6
  "publishConfig": {},
@@ -61,7 +61,6 @@
61
61
  "license": "Apache-2.0",
62
62
  "dependencies": {
63
63
  "jquery": "^3.6.0",
64
- "jshint": "^2.13.1",
65
64
  "require": "^0.4.4",
66
65
  "uglify-js": "^3.14.5"
67
66
  },
package/scripts/array.js CHANGED
@@ -24,6 +24,15 @@
24
24
  },{
25
25
  "name":"merge",
26
26
  "description":"test"
27
+ },{
28
+ "name":"asc",
29
+ "description":"test"
30
+ },{
31
+ "name":"desc",
32
+ "description":"test"
33
+ },{
34
+ "name":"duplicates",
35
+ "description":"test"
27
36
  }
28
37
  ],
29
38
  "example" : "",
@@ -65,14 +74,13 @@ window.dphelper.array = {
65
74
  return true;
66
75
  }
67
76
 
68
- var key = Object.keys(o);
69
-
70
77
  for (let key of Object.keys(o)) {
71
78
  let value = o[key];
72
79
  if(value.length && typeof value === 'object') return value && value.map(iter);
73
80
  }
74
81
 
75
82
  // OLD SCHOOL WAY
83
+ //var key = Object.keys(o);
76
84
  // for (var p=0; p < key.length; ++p){
77
85
  // if( o[key[p]]?.length && typeof o[key[p]] === 'object') return o[key[p]] && o[key[p]].some(iter);
78
86
  // }
@@ -83,12 +91,31 @@ window.dphelper.array = {
83
91
 
84
92
  // MERGE
85
93
  merge: ( arrayA, arrayB ) => {
86
- for (const key of Object.keys(source)) {
87
- if (source[key] instanceof Object && target[key]) Object.assign(source[key], window.dphelper.mergeArrays(target[key], source[key]));
94
+ for (const key of Object.keys(arrayA)) {
95
+ if (arrayA[key] instanceof Object && arrayB[key]) Object.assign(arrayA[key], window.dphelper.mergeArrays(arrayB[key], arrayA[key]));
88
96
  }
89
97
 
90
- Object.assign(target || {}, source);
91
- return target;
98
+ Object.assign(arrayB || {}, arrayA);
99
+ return arrayB;
100
+ },
101
+
102
+ // ASCENDING
103
+ asc: ( array ) => {
104
+ array.sort((a, b) => a - b);
105
+ return array;
106
+ },
107
+
108
+ // ASCENDING
109
+ desc: ( array ) => {
110
+ array.sort(function(a, b){ return b-a; });
111
+ return array;
112
+ },
113
+
114
+ // FIND DUPLICATES
115
+ duplicates: ( array ) => {
116
+ const toFindDuplicates = arr => arr.filter( (item, index) => arr.indexOf( item ) !== index);
117
+ const duplicateElements = toFindDuplicates( array );
118
+ return duplicateElements;
92
119
  }
93
120
 
94
121
  };
@@ -39,10 +39,6 @@
39
39
  /***********************************************************************/
40
40
 
41
41
  window.dphelper.browser = {
42
-
43
- state: (state, title, url) => {
44
- return history.pushState( state, title, url );
45
- },
46
42
 
47
43
  state: (state, title, url) => {
48
44
  return history.pushState( state, title, url );
@@ -54,16 +50,16 @@
54
50
 
55
51
  back: ( times ) => {
56
52
  return history.go( -Math.abs( times ) );
57
- },
58
-
53
+ },
54
+
59
55
  reload: () => {
60
56
  // DISCARD POST
61
57
  return window.location.href = window.location.href;
62
- },
63
-
58
+ },
59
+
64
60
  href: ( url ) => {
65
61
  // DISCARD POST
66
62
  return window.location.href = url;
67
63
  }
68
-
64
+
69
65
  };
@@ -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" : "Coordinates Tools",
11
+ "description" : "test",
12
+ "version" : "0.0.1",
13
+ "command" : "coords",
14
+ "subCommand" : [],
15
+ "example" : "",
16
+ "author" : "Dario Passariello",
17
+ "active" : true
18
+ };
19
+
20
+ window.dphelper._list.scripts.push( description );
21
+
22
+ /***********************************************************************/
23
+ //
24
+
25
+ let R = 6378.1;
26
+ window.dphelper.coords = {
27
+
28
+ degreesToRadians: ( degrees ) => {
29
+ var pi = Math.PI;
30
+ return degrees * (pi/180);
31
+ },
32
+
33
+ latToMeters: ( latitude , longitude ) => {
34
+ return R * Math.cos(latitude) * Math.cos(longitude);
35
+ },
36
+
37
+ lngToMeters: ( latitude , longitude ) => {
38
+ return R * Math.cos(latitude) * Math.sin(longitude);
39
+ }
40
+
41
+ };
package/scripts/cookie.js CHANGED
@@ -47,7 +47,7 @@
47
47
 
48
48
  // CREATE THE COOKIE
49
49
 
50
- set: function( cname , value , time , path = '/' ) {
50
+ set: ( cname , value , time , path = '/' ) => {
51
51
  var d = new Date();
52
52
  d.setTime( d.getTime() + 3600 * 1000 * 24 * 365 );
53
53
 
@@ -59,7 +59,7 @@
59
59
 
60
60
  // GET THE COOKIE
61
61
 
62
- get: function( cname ) {
62
+ get: ( cname ) => {
63
63
  var asCookies = document.cookie.split( "; " );
64
64
 
65
65
  for ( var i = 0; i < asCookies.length; i++ ){
@@ -72,13 +72,13 @@
72
72
 
73
73
  // DELETE THE COOKIE
74
74
 
75
- delete: function( cname ) {
75
+ delete: ( cname ) => {
76
76
  document.cookie = cname + '=;expires=Thu, 01 Jan 1970 00:00:01 GMT;path=/;SameSite=' + CookieSameSite + ';requireSSL='+ CookieSecure +';' + CookieSecure;
77
77
  },
78
78
 
79
79
  // CLEAR ALL COOKIE
80
80
 
81
- clearAll: function() {
81
+ clearAll: () => {
82
82
  var cookies = document.cookie.split(";");
83
83
 
84
84
  for ( var i = 0; i < cookies.length; i++ ) {
package/scripts/load.js CHANGED
@@ -34,6 +34,21 @@
34
34
 
35
35
  window.dphelper.load = {
36
36
 
37
+ /*
38
+ Example:
39
+ var cntx = require.context( __dirname + '/scripts/', false , /\.js$/ );
40
+ dphelper.load.import( cntx );
41
+ */
42
+ /*
43
+ import: ( dir , type = false , extension = /\.js$/ ) => {
44
+ let r = require.context( dir , type , extension );
45
+ r.keys().forEach(
46
+ ( key ) => (
47
+ cache[ key ] = r( key )
48
+ )
49
+ );
50
+ },
51
+ */
37
52
  file: (element, path) => {
38
53
  fetch(path).then(async function (response) {
39
54
  const text = await response.text();
@@ -46,7 +46,7 @@
46
46
  custom: ( el, colors, size ) => {
47
47
 
48
48
  if(!colors) colors =[ "black", "transparent" ];
49
- if(!size) size =[ "6px", "6px" ];
49
+ if(!size) size =[ "8px", "8px" ];
50
50
 
51
51
  const $style = `${el}{
52
52
  scrollbar-width:auto;
File without changes
File without changes
File without changes
File without changes