dphelper 0.2.32 → 0.2.33

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dphelper",
3
- "version": "0.2.32",
3
+ "version": "0.2.33",
4
4
  "description": "Developer Tools",
5
5
  "main": "index.js",
6
6
  "publishConfig": {},
@@ -29,11 +29,13 @@ window.dphelper._list.scripts.push( description );
29
29
 
30
30
  /***********************************************************************/
31
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
- };
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
+ /***********************************************************************/
37
39
 
38
40
  window.dphelper.disable = {
39
41
 
package/scripts/path.js CHANGED
@@ -32,21 +32,21 @@
32
32
 
33
33
  /***********************************************************************/
34
34
 
35
- // ALIAS
36
- window.dphelper.pathHash = () => {
37
- console.debug( 'dpHelper: Please use "dphelper.path.hash()"' );
38
- return window.dphelper.path.hash();
39
- };
35
+ // // ALIAS
36
+ // window.dphelper.pathHash = () => {
37
+ // console.debug( 'dpHelper: Please use "dphelper.path.hash()"' );
38
+ // return window.dphelper.path.hash();
39
+ // };
40
40
 
41
- window.dphelper.pathQuery = () => {
42
- console.debug( 'dpHelper: Please use "dphelper.path.query()"' );
43
- return window.dphelper.path.query();
44
- };
41
+ // window.dphelper.pathQuery = () => {
42
+ // console.debug( 'dpHelper: Please use "dphelper.path.query()"' );
43
+ // return window.dphelper.path.query();
44
+ // };
45
45
 
46
- window.dphelper.pathRail = () => {
47
- console.debug( 'dpHelper: Please use "dphelper.path.rail()"' );
48
- return window.dphelper.path.rail();
49
- };
46
+ // window.dphelper.pathRail = () => {
47
+ // console.debug( 'dpHelper: Please use "dphelper.path.rail()"' );
48
+ // return window.dphelper.path.rail();
49
+ // };
50
50
 
51
51
  /***********************************************************************/
52
52
 
package/scripts/screen.js CHANGED
@@ -16,7 +16,7 @@
16
16
  "name":"fullScreen",
17
17
  "description":"test"
18
18
  },{
19
- "name":"fullScreenToggle",
19
+ "name":"toggle",
20
20
  "description":"test"
21
21
  }
22
22
  ],
@@ -29,7 +29,7 @@
29
29
 
30
30
  /***********************************************************************/
31
31
 
32
- window.dphelper.fullScreen = {
32
+ window.dphelper.screen = {
33
33
 
34
34
  fullScreen: function( el ){
35
35
 
@@ -43,7 +43,7 @@
43
43
 
44
44
  },
45
45
 
46
- fullScreenToggle: function( el ) {
46
+ toggle: function( el ) {
47
47
 
48
48
  let requestFullScreen = el.requestFullscreen || el.mozRequestFullScreen || el.webkitRequestFullScreen || el.msRequestFullscreen;
49
49
  let cancelFullScreen = el.exitFullscreen || el.mozCancelFullScreen || el.webkitExitFullscreen || el.msExitFullscreen;
@@ -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" : "Camel Case / Pascal Case",
11
- "description" : "test",
12
- "version" : "0.0.1",
13
- "command" : "camelCase",
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.camelCase = {
25
-
26
- // toSpace
27
- toSpace: ( string ) => {
28
- return string
29
- .replace(/([A-Z])/g, ' $1')
30
- .replace(/^./, function(str){ return str.toUpperCase(); })
31
- },
32
-
33
- // toUnderscore
34
- toUnderscore: ( string ) => {
35
- return string
36
- .replace(/\.?([A-Z])/g, function (x,y){ return "_" + y.toLowerCase()})
37
- .replace(/^_/, "");
38
- },
39
-
40
- };
41
-
@@ -1,31 +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 To Iso",
11
- "description" : "test",
12
- "version" : "0.0.1",
13
- "command" : "date2Iso",
14
- "example" : "",
15
- "author" : "Dario Passariello",
16
- "active" : true
17
- };
18
-
19
- window.dphelper._list.scripts.push( description );
20
-
21
- /***********************************************************************/
22
-
23
- window.dphelper.date2Iso = (value , int = 'en' ) => {
24
- if (!value) value = '';
25
- let date = new Date(value);
26
- if (date == 'Invalid Date') return null; //date = new Date()
27
- const dateTimeFormat = new Intl.DateTimeFormat( int , {
28
- year: 'numeric', month: 'long', day: 'numeric',
29
- });
30
- return dateTimeFormat.format(date);
31
- };
@@ -1,27 +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 To MMDDYYYY",
11
- "description" : "test",
12
- "version" : "0.0.1",
13
- "command" : "date2MMDDYYYY",
14
- "example" : "",
15
- "author" : "Dario Passariello",
16
- "active" : true
17
- };
18
-
19
- window.dphelper._list.scripts.push( description );
20
-
21
- /***********************************************************************/
22
-
23
- window.dphelper.date2MMDDYYYY = (value) => {
24
- if (!value) value = '';
25
- let date = new Date(value);
26
- return ('0' + (date.getMonth() + 1)).slice(-2) + "" + ('0' + date.getDate()).slice(-2) + "" + date.getFullYear();
27
- };
@@ -1,31 +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" : "Convert Date",
11
- "description" : "test",
12
- "version" : "0.0.1",
13
- "command" : "dateConvert",
14
- "example" : "",
15
- "author" : "Dario Passariello",
16
- "active" : true
17
- };
18
-
19
- window.dphelper._list.scripts.push( description );
20
-
21
- /***********************************************************************/
22
-
23
- window.dphelper.dateConvert = (value , format ) => {
24
- if( !format) format = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
25
- if (!value) return null;
26
- let monthNames = format;
27
- let month = value.substring(0, 2).replace('0', '');
28
- let day = value.substring(2, 4);
29
- let year = value.substring(value.length - 4);
30
- return day + ' ' + monthNames[Number(month) - 1] + ' ' + year;
31
- };
@@ -1,28 +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 Iso To Epoch",
11
- "description" : "test",
12
- "version" : "0.0.1",
13
- "command" : "dateIso2Epoch",
14
- "example" : "",
15
- "author" : "Dario Passariello",
16
- "active" : true
17
- };
18
-
19
- window.dphelper._list.scripts.push( description );
20
-
21
- /***********************************************************************/
22
-
23
- window.dphelper.dateIso2Epoch = (value) => {
24
- if (!value) value = '';
25
- let date = new Date(value);
26
- let milliseconds = date.getTime();
27
- return milliseconds;
28
- };
@@ -1,28 +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" : "Local Iso Time",
11
- "description" : "test",
12
- "version" : "0.0.1",
13
- "command" : "localISOTime",
14
- "example" : "",
15
- "author" : "Dario Passariello",
16
- "active" : true
17
- };
18
-
19
- window.dphelper._list.scripts.push( description );
20
-
21
- /***********************************************************************/
22
-
23
- window.dphelper.localISOTime = (value) => {
24
- if (!value) value = '';
25
- let tzoffset = (new Date(value)).getTimezoneOffset() * 60000;
26
- let localISOTime = (new Date(Date.now() - tzoffset)).toISOString().slice(0, -1);
27
- return localISOTime;
28
- };
@@ -1,25 +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 UTC",
11
- "description" : "test",
12
- "version" : "0.0.1",
13
- "command" : "dateUTC",
14
- "example" : "",
15
- "author" : "Dario Passariello",
16
- "active" : true
17
- };
18
-
19
- window.dphelper._list.scripts.push( description );
20
-
21
- /***********************************************************************/
22
-
23
- window.dphelper.dateUTC = () => {
24
- return moment().toISOString();
25
- };
@@ -1,32 +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 SpellCheck",
11
- "description" : "test",
12
- "version" : "0.0.1",
13
- "command" : "disableSpellCheck",
14
- "example" : "",
15
- "author" : "Dario Passariello",
16
- "active" : true
17
- };
18
-
19
- window.dphelper._list.scripts.push( description );
20
-
21
- /***********************************************************************/
22
-
23
- window.dphelper.disableSpellCheck = ( tmr = 5000 ) => {
24
- setInterval( () => {
25
- let inputs = document.querySelectorAll("input[type=text], textarea");
26
- for(let i = 0; i < inputs.length; i++){
27
- if( !inputs[i].getAttribute("spellcheck") ){
28
- inputs[i].setAttribute("spellcheck", "false");
29
- }
30
- }
31
- }, tmr );
32
- };
@@ -1,27 +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" : "Load Internal Json",
11
- "description" : "test",
12
- "version" : "0.0.1",
13
- "command" : "loadJson",
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.loadJson = function( file ){
25
- if ( file.match(/.(json)$/i ) ) return require( '' + file + '' );
26
- };
27
-
@@ -1,44 +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" : "Load External Json",
11
- "description" : "test",
12
- "version" : "0.0.1",
13
- "command" : "loadJsonExternal",
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.loadJsonExternal = ( path, method='GET', type='application/json' ) => {
25
-
26
- fetch( path ,{
27
- method: method,
28
- headers : {
29
- 'Content-Type': type
30
- }
31
- })
32
- .then(
33
- function(response) {
34
- //return response.json();
35
- return response;
36
- }
37
- )
38
- .then(
39
- function( myFile ) {
40
- return myFile;
41
- }
42
- );
43
-
44
- };
@@ -1,26 +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" : "New Line To Break Line ( nl 2 br )",
11
- "description" : "test",
12
- "version" : "0.0.1",
13
- "command" : "nl2br",
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.nl2br = (str) => {
25
- return str.replace(/(?:\r\n|\r|\n)/g, '<br>');
26
- };
@@ -1,28 +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" : "Convert Object To Array",
11
- "description" : "test",
12
- "version" : "0.0.1",
13
- "command" : "obj2array",
14
- "sub-command" : [],
15
- "example" : "",
16
- "author" : "Dario Passariello",
17
- "active" : true
18
- };
19
-
20
- window.dphelper._list.scripts.push( description );
21
-
22
- /***********************************************************************/
23
-
24
- window.dphelper.obj2array = ( object ) => {
25
- return Object
26
- .entries( object )
27
- .map( ( [ key, value ] ) => Object.assign( { key } , value && typeof value === 'object' ? { forms: ObjToArray( value ) } : { value, forms: [] } ) );
28
- };
@@ -1,30 +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" : "MMDDYYYY To DD/MM/YYYY",
11
- "description" : "test",
12
- "version" : "0.0.1",
13
- "command" : "parseDate",
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.parseDate = ( value , separator = '/' ) => {
25
- if (!value) return null;
26
- let month = value.substring(0, 2);
27
- let day = value.substring(2, 4);
28
- let year = value.substring(4, 8);
29
- return month + separator + day + separator + year;
30
- };
@@ -1,27 +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" : "Array From Hash Path",
11
- "description" : "test",
12
- "version" : "0.0.1",
13
- "command" : "pathHash",
14
- "subCommand" : [],
15
- "example" : "",
16
- "author" : "Dario Passariello",
17
- "active" : true
18
- };
19
-
20
- window.dphelper._list.scripts.push( description );
21
-
22
- /***********************************************************************/
23
- // ALIAS
24
- window.dphelper.pathHash = () => {
25
- console.log( 'Please use "dphelper.path.hash()"' );
26
- return window.dphelper.path.hash();
27
- };
@@ -1,28 +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" : "Array From Query",
11
- "description" : "test",
12
- "version" : "0.0.1",
13
- "command" : "pathQuery",
14
- "subCommand" : [],
15
- "example" : "",
16
- "author" : "Dario Passariello",
17
- "active" : true
18
- };
19
-
20
- window.dphelper._list.scripts.push( description );
21
-
22
- /***********************************************************************/
23
- // ALIAS
24
-
25
- window.dphelper.pathQuery = () => {
26
- console.log( 'Please use "dphelper.path.query()"' );
27
- return window.dphelper.path.query();
28
- };
@@ -1,27 +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" : "Array From Rail",
11
- "description" : "test",
12
- "version" : "0.0.1",
13
- "command" : "pathRail",
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.pathRail = () => {
25
- console.log( 'Please use "dphelper.path.rail()"' );
26
- return window.dphelper.path.rail();
27
- };
@@ -1,26 +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" : "Random Number From Timer",
11
- "description" : "test",
12
- "version" : "0.0.1",
13
- "command" : "tmr",
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.tmr = () => {
25
- return Math.round(dphelper.epoch() / 1000);
26
- };
@@ -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
- };
@@ -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
- };
@@ -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
- };
@@ -1,346 +0,0 @@
1
- /*!
2
- * dpHelper <https://github.com/passariello/dpHelper>
3
- *
4
- * svgSupport
5
- *
6
- * Copyright (c) 2021, Dario Passariello.
7
- * Licensed under the Apache-2.0 License.
8
- */
9
-
10
- /***********************************************************************/
11
-
12
- window.dphelper.svg_supportsVml = function () {
13
-
14
- if ( typeof window.dphelper.svg_supportsVml.supported == "undefined" ) {
15
-
16
- let a = document.body.appendChild( document.createElement( 'div' ) );
17
- a.innerHTML = '<v:shape id="vml_flag1" adj="1" />';
18
-
19
- let b = a.firstChild;
20
- b.style.behavior = "url(#default#VML)";
21
- window.dphelper.svg_supportsVml.supported = b ? typeof b.adj == "object" : true;
22
- a.parentNode.removeChild( a );
23
-
24
- }
25
-
26
- return window.dphelper.svg_supportsVml.supported;
27
-
28
- };
29
-
30
- window.dphelper.svg_supportsVml();
31
-
32
- /**************************************************************************************************/
33
- /**************************************************************************************************/
34
-
35
- window.dphelper.svg_initConnection = function( container, source1, source2, cb ) {
36
-
37
- if( $( container ).find( 'svg' ) ) {
38
- window.dphelper.svg_removeConnection( container );
39
- }
40
-
41
- source1 = window.dphelper.svg_setConnector( source1[ 0 ], source1[ 1 ] );
42
- source2 = window.dphelper.svg_setConnector( source2[ 0 ], source2[ 1 ] );
43
-
44
- let parentCoords = container.getBoundingClientRect();
45
-
46
- let xmlns = "http://www.w3.org/2000/svg";
47
- let boxWidth = container.offsetWidth * 10;
48
- let boxHeight = container.offsetHeight * 10;
49
-
50
- // create svg container
51
- let svgElem = document.createElementNS( xmlns, "svg" );
52
-
53
- svgElem.setAttribute( "xmlns" , xmlns );
54
- svgElem.setAttributeNS( null , "id" , "pathConnection" );
55
- svgElem.setAttributeNS( null , "viewBox" , "0 0 " + boxWidth + " " + boxHeight );
56
- svgElem.setAttributeNS( null , "width" , boxWidth );
57
- svgElem.setAttributeNS( null , "height" , boxHeight );
58
- svgElem.style.display = "block";
59
-
60
- /*
61
- // TO DO: smaller cyrcle
62
- // DARIO: probably is too invasive on UI, I change just border on parts_container_
63
-
64
- // create arrow
65
- let defs = document.createElementNS(xmlns, "defs");
66
- let marker = document.createElementNS(xmlns, "marker");
67
- let path = document.createElementNS(xmlns, "path");
68
- marker.setAttributeNS(null, 'id', 'head');
69
- marker.setAttributeNS(null, 'orient', 'auto');
70
- marker.setAttributeNS(null, 'markerWidth', '20');
71
- marker.setAttributeNS(null, 'markerHeight', '40');
72
- marker.setAttributeNS(null, 'refX', '0');
73
- marker.setAttributeNS(null, 'refY', '3');
74
- path.setAttributeNS(null, 'd', 'M0,0 V6 L3,3 Z');
75
- marker.appendChild(path);
76
- defs.appendChild(marker);
77
- svgElem.appendChild(defs);
78
- */
79
-
80
- // create rect which overlaps source1
81
- let rect1 = document.createElementNS( xmlns , "rect" );
82
- let coords = source1.getBoundingClientRect();
83
-
84
- rect1.setAttributeNS( null, 'x', coords.left - parentCoords.left );
85
- rect1.setAttributeNS( null, 'y', coords.top - parentCoords.top );
86
- rect1.setAttributeNS( null, 'width', coords.width );
87
- rect1.setAttributeNS( null, 'height', coords.height );
88
- svgElem.appendChild( rect1 );
89
-
90
- // create rect which overlaps source2
91
- let rect2 = document.createElementNS( xmlns, "rect" );
92
- coords = source2.getBoundingClientRect();
93
-
94
- rect2.setAttributeNS( null, 'x', coords.left - parentCoords.left );
95
- rect2.setAttributeNS( null, 'y', coords.top - parentCoords.top );
96
- rect2.setAttributeNS( null, 'width', coords.width );
97
- rect2.setAttributeNS( null, 'height', coords.height );
98
- svgElem.appendChild( rect2 );
99
-
100
- // create path connecting both rects
101
- let path = document.createElementNS( xmlns, "path" );
102
-
103
- path.setAttributeNS( null, 'id', 'connection' );
104
- path.setAttributeNS( null, 'marker-end', 'url(#head)' );
105
- svgElem.appendChild( path );
106
-
107
- container.appendChild( svgElem );
108
-
109
- window.dphelper.svg_updateConnection( $( rect1 )[0], $( rect2 )[0], $( '#connection' )[0]);
110
-
111
- if( typeof cb == 'function' ) {
112
- cb( source1, source2 );
113
- }
114
-
115
- };
116
-
117
- /**************************************************************************************************/
118
-
119
- window.dphelper.svg_updateConnection = function( rect1 , rect2 , cxn ) {
120
-
121
- // Top left coordinates
122
- let x1 = parseFloat( rect1.getAttribute( 'x' ) );
123
- let y1 = parseFloat( rect1.getAttribute( 'y' ) );
124
- let x2 = parseFloat( rect2.getAttribute( 'x') );
125
- let y2 = parseFloat( rect2.getAttribute( 'y' ) );
126
-
127
- // Half widths and half heights
128
- let w1 = parseFloat( rect1.getAttribute( 'width' ) ) / 2;
129
- let h1 = parseFloat( rect1.getAttribute( 'height' ) ) / 2;
130
- let w2 = parseFloat( rect2.getAttribute( 'width' ) ) / 2;
131
- let h2 = parseFloat( rect2.getAttribute( 'height' ) ) / 2;
132
-
133
- // Center coordinates
134
- let cx1 = x1 + w1;
135
- let cy1 = y1 + h1;
136
- let cx2 = x2 + w2;
137
- let cy2 = y2 + h2;
138
-
139
- // Distance between centers
140
- let dx = cx2 - cx1;
141
- let dy = cy2 - cy1;
142
-
143
- let p1 = window.dphelper.svg_getIntersection( dx , dy , cx1 , cy1 , w1 , h1 );
144
- let p2 = window.dphelper.svg_getIntersection( -dx , -dy , cx2 , cy2 , w2 , h2 );
145
-
146
- // Distance between edges
147
- let dx1 = p2[ 0 ] - p1[ 0 ];
148
-
149
- let d = window.dphelper.svg_getCurve( p1 , p2 , dx1 );
150
-
151
- // Set a path connector
152
- cxn.setAttributeNS( null , 'd' , "M" + cx1 + "," + cy1 + d + cx2 + "," + cy2 );
153
-
154
- // Set a line connector
155
- // cxn.setAttributeNS( null , 'x1' , p1[0] );
156
- // cxn.setAttributeNS( null , 'y1' , p1[1] );
157
- // cxn.setAttributeNS( null , 'x2' , p2[0] );
158
- // cxn.setAttributeNS( null , 'y2' , p2[1] );
159
-
160
- };
161
-
162
- /**************************************************************************************************/
163
-
164
- window.dphelper.svg_getCurve = function( p1 , p2 , dx ) {
165
-
166
- let curve = dx / 2;
167
- let d = " C" + ( curve + p1[0] ) + "," + p1[1] + " " + ( p2[0] - curve ) + "," + p2[1] + " ";
168
- return d;
169
-
170
- };
171
-
172
- window.dphelper.svg_getIntersection = function( dx , dy , cx , cy , w , h ) {
173
-
174
- if ( Math.abs( dy / dx ) < h / w )
175
- return [ cx + ( dx > 0 ? w : -w ), cy + dy * w / Math.abs( dx ) ];
176
- else
177
- return [ cx + dx * h / Math.abs( dy ), cy + ( dy > 0 ? h : -h ) ];
178
-
179
- };
180
-
181
- /**************************************************************************************************/
182
-
183
- window.dphelper.svg_makeScrollable = function( svgContainer , scrollContainer , elm1 , elm2 , rect1 , rect2 ) {
184
-
185
- //let scrollCoords = scrollContainer.getBoundingClientRect();
186
- let svgCoords = svgContainer.getBoundingClientRect();
187
-
188
- let el = [ elm1 , elm2 ];
189
- let rec = [ rect1 , rect2 ];
190
- let coords = [];
191
-
192
- for( let i = 0; i < el.length; i++ ){
193
-
194
- coords[ i ] = el[ i ].getBoundingClientRect();
195
-
196
- rec[ i ].setAttributeNS( null, 'x', coords[ i ].left - svgCoords.left );
197
- rec[ i ].setAttributeNS( null, 'y', coords[ i ].top - svgCoords.top );
198
- rec[ i ].setAttributeNS( null, 'width', coords[ i ].width );
199
- rec[ i ].setAttributeNS( null, 'height', coords[ i ].height );
200
-
201
- }
202
-
203
- //***************************************************************
204
-
205
- window.dphelper.svg_updateConnection( $( rect1 )[ 0 ], $( rect2 )[ 0 ], $( '#connection' )[ 0 ]);
206
-
207
- };
208
-
209
- /**************************************************************************************************/
210
-
211
- window.dphelper.svg_makeDraggable = function( evt ) {
212
-
213
- let svg = evt.target;
214
- svg.addEventListener( 'mousedown' , startDrag );
215
- svg.addEventListener( 'mousemove' , drag );
216
- svg.addEventListener( 'mouseup' , endDrag );
217
-
218
- function getMousePosition( e ) {
219
- let CTM = svg.getScreenCTM();
220
- return {
221
- x: ( evt.clientX - CTM.e ) / CTM.a,
222
- y: ( evt.clientY - CTM.f ) / CTM.d
223
- };
224
- }
225
-
226
- let selectedElement, offset;
227
-
228
- function startDrag( evt ) {
229
-
230
- if ( evt.target.classList.contains( 'draggable' ) ) {
231
- selectedElement = evt.target;
232
- offset = getMousePosition( evt );
233
- offset.x -= parseFloat( selectedElement.getAttributeNS( null , "x" ) );
234
- offset.y -= parseFloat( selectedElement.getAttributeNS( null , "y" ) );
235
- }
236
-
237
- }
238
-
239
- function drag( evt ) {
240
-
241
- if ( selectedElement ) {
242
- let coord = getMousePosition( evt );
243
- selectedElement.setAttributeNS( null, "x" , coord.x - offset.x );
244
- selectedElement.setAttributeNS( null, "y" , coord.y - offset.y );
245
- window.dphelper.svg_updateConnection();
246
- }
247
-
248
- }
249
-
250
- function endDrag( evt ) {
251
- selectedElement = null;
252
- }
253
-
254
- };
255
-
256
- /**************************************************************************************************/
257
-
258
- window.dphelper.svg_setConnector = function( source , side ) {
259
-
260
- let style;
261
- let span = $( '<span class="connector"></span>' );
262
-
263
- $( source ).css( 'position' , 'relative' );
264
-
265
- span.css({
266
- position: 'absolute',
267
- width: '5px',
268
- height: '5px',
269
- });
270
-
271
- switch( side ) {
272
- case 'top':
273
- style = {
274
- left: '50%',
275
- top: '2.5px',
276
- marginLeft: '2.5px'
277
- };
278
- break;
279
- case 'right':
280
- style = {
281
- top: '50%',
282
- right: '2.5px',
283
- marginTop: '-2.5px'
284
- };
285
- break;
286
- case 'bottom':
287
- style = {
288
- left: '50%',
289
- bottom: '-2.5px',
290
- marginLeft: '2.5px'
291
- };
292
- break;
293
- case 'left':
294
- style = {
295
- top: '50%',
296
- left: '-2.5px',
297
- marginTop: '-2.5px'
298
- };
299
- break;
300
- default:
301
- style = {};
302
- }
303
-
304
- span.css( style );
305
-
306
- $( source ).append( span );
307
-
308
- return $( span )[ 0 ];
309
- };
310
-
311
- /**************************************************************************************************/
312
-
313
- window.dphelper.svg_handleSvgToggle = function( evt , container , source1 , source2 ) {
314
-
315
- if( $( evt.target ).prop( 'checked' ) && $( source1 ).length && $( source2 ).length ) {
316
-
317
- window.dphelper.cookie.set( $( evt.target ).attr( 'id' ), 1, 365 );
318
-
319
- window.dphelper.svg_initConnection( container[0], [ $( source1 )[0], 'right' ], [ $( source2 )[0], 'left' ], function( source1 , source2 ) {
320
-
321
- $( '#parts-left-body' ).on( 'scroll', function( evt ){
322
- window.dphelper.svg_makeScrollable( $( container )[0], $( '#parts-left-body' )[0], $( source1 )[0],
323
- $( source2 )[0], $( '#parts svg rect' )[0], $( '#parts svg rect' )[ 1 ] );
324
- });
325
-
326
- });
327
-
328
- } else {
329
-
330
- window.dphelper.svg_removeConnection( container );
331
- $( '#parts-left-body' ).unbind( 'scroll' );
332
- window.dphelper.cookie.set( $( evt.target ).attr( 'id' ), 0, 365 );
333
-
334
- }
335
-
336
- };
337
-
338
- /**************************************************************************************************/
339
-
340
- window.dphelper.svg_removeConnection = function( container ) {
341
-
342
- $( container ).find( 'svg#pathConnection' ).each( function( i , elm ) {
343
- $( elm ).remove();
344
- });
345
-
346
- };
@@ -1,28 +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" : "Print Console Info About dpHelper",
11
- "description" : "test",
12
- "version" : "0.0.1",
13
- "command" : "printInfo",
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.printInfo = () => {
25
- console.groupCollapsed('%cApi:%c', "color:orange", "");
26
- console.debug(dphelper.api);
27
- console.groupEnd();
28
- };