dphelper 0.2.86 → 0.2.89
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/.editorconfig +13 -0
- package/.env +3 -0
- package/.eslintignore +13 -0
- package/.eslintrc.json +87 -0
- package/.eslintrc.legacy.json +91 -0
- package/.gitattributes +2 -0
- package/.hintrc +11 -0
- package/.jsbeautifyrc +25 -0
- package/.jshintrc +16 -0
- package/.prettierignore +2 -0
- package/.prettierrc.json +8 -0
- package/.stylelintignore +0 -0
- package/.stylelintrc.json +468 -0
- package/.vscode/launch.json +34 -0
- package/.vscode/settings.json +58 -0
- package/3party/shortcut.js +224 -0
- package/CHANGELOG.txt +4 -0
- package/SECURITY.md +3 -0
- package/__mocks__/fileMock.js +3 -0
- package/__mocks__/styleMock.js +3 -0
- package/babel.config.js +30 -0
- package/backup.bat +43 -0
- package/coverage/coverage-final.json +1 -0
- package/coverage/lcov-report/base.css +224 -0
- package/coverage/lcov-report/block-navigation.js +87 -0
- package/coverage/lcov-report/favicon.png +0 -0
- package/coverage/lcov-report/index.html +101 -0
- package/coverage/lcov-report/prettify.css +1 -0
- package/coverage/lcov-report/prettify.js +2 -0
- package/coverage/lcov-report/sort-arrow-sprite.png +0 -0
- package/coverage/lcov-report/sorter.js +196 -0
- package/coverage/lcov.info +0 -0
- package/data/list.json +19 -0
- package/dist/LICENSE.txt +209 -0
- package/dist/README.md +79 -0
- package/elements/button/component.js +0 -0
- package/elements/code/component.js +0 -0
- package/elements/costants.tsx +13 -0
- package/elements/fieldset/component.js +0 -0
- package/elements/input/checkbox/component.js +0 -0
- package/elements/input/date/component.js +27 -0
- package/elements/input/number/component.js +0 -0
- package/elements/input/radio/component.js +0 -0
- package/elements/input/search/component.js +0 -0
- package/elements/input/select/component.js +0 -0
- package/elements/input/slider/component.js +0 -0
- package/elements/input/switch/component.js +0 -0
- package/elements/tab/component.js +0 -0
- package/elements/table/component.js +0 -0
- package/elements/tags.less +0 -0
- package/elements/textarea/component.js +0 -0
- package/elements/x-foo/define.js +33 -0
- package/elements/x-foo/namespace.d.ts +7 -0
- package/index.js +12 -2
- package/init.js +87 -0
- package/jest.config.js +81 -0
- package/node/createTag.js +7 -0
- package/node/gitDeploy.js +7 -0
- package/node/goLive.js +7 -0
- package/package.json +27 -20
- package/{assets → public/assets}/images/banner.png +0 -0
- package/{assets → public/assets}/logos/logo.svg +0 -0
- package/{documents → public/documents}/iDB/list.html +0 -0
- package/{documents → public/documents}/iDB/toState.html +0 -0
- package/scripts/.OLD/import.js +48 -0
- package/scripts/anchor.js +73 -0
- package/scripts/array.js +203 -0
- package/scripts/avoid.js +48 -0
- package/scripts/browser.js +100 -0
- package/scripts/color.js +121 -0
- package/scripts/console.js +97 -0
- package/scripts/console.mapped.js +160 -0
- package/scripts/coods.js +57 -0
- package/scripts/cookie.js +105 -0
- package/scripts/date.js +179 -0
- package/scripts/disable.js +91 -0
- package/scripts/errors.js +3 -0
- package/scripts/event.js +57 -0
- package/scripts/font.js +60 -0
- package/scripts/form.js +211 -0
- package/scripts/format.js +71 -0
- package/scripts/function.js +55 -0
- package/scripts/iDB.js +688 -0
- package/scripts/json.js +84 -0
- package/scripts/load.js +112 -0
- package/scripts/math.js +100 -0
- package/scripts/obj.js +118 -0
- package/scripts/path.js +101 -0
- package/scripts/promise.js +56 -0
- package/scripts/screen.js +82 -0
- package/scripts/scrollbar.js +293 -0
- package/scripts/shortcut.js +83 -0
- package/scripts/socket.js +184 -0
- package/scripts/state.js +87 -0
- package/scripts/storage.js +93 -0
- package/scripts/store.js +115 -0
- package/scripts/svg.js +380 -0
- package/scripts/text.js +116 -0
- package/scripts/time.js +43 -0
- package/scripts/timer.js +54 -0
- package/scripts/tool.js +73 -0
- package/scripts/trigger.js +57 -0
- package/scripts/type.js +76 -0
- package/scripts/ui.js +41 -0
- package/scripts/window.js +244 -0
- package/styles/console.less +95 -0
- package/tests/setupJest.tsx +4 -0
- package/typings/dphelper.d.ts +26 -0
- package/typings/image.d.ts +5 -0
- package/typings/styles.d.ts +23 -0
- package/webpack.config.js +249 -0
- package/index.js.LICENSE.txt +0 -31
package/init.js
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
|
|
2
|
+
( () => {
|
|
3
|
+
|
|
4
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
5
|
+
// CUSTOM ELEMENTS
|
|
6
|
+
|
|
7
|
+
require("./elements/x-foo/define.js");
|
|
8
|
+
|
|
9
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
10
|
+
// DPH DECLARATIONS
|
|
11
|
+
|
|
12
|
+
require( __dirname + '/typings/dphelper.d.ts' );
|
|
13
|
+
|
|
14
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
15
|
+
// CONFIG
|
|
16
|
+
|
|
17
|
+
const pjson = require('./package.json');
|
|
18
|
+
var e = e || event;
|
|
19
|
+
|
|
20
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
21
|
+
// CREATE FULL LIST FOR DPHELPER MANAGER
|
|
22
|
+
|
|
23
|
+
dphelper._list = require('./data/list.json');
|
|
24
|
+
dphelper._list.scripts = [];
|
|
25
|
+
dphelper._list.version = pjson.version;
|
|
26
|
+
|
|
27
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
28
|
+
// CACHE
|
|
29
|
+
const cache = {};
|
|
30
|
+
|
|
31
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
32
|
+
// API
|
|
33
|
+
|
|
34
|
+
dphelper.api = {};
|
|
35
|
+
|
|
36
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
37
|
+
// INSTALL ON BODY
|
|
38
|
+
|
|
39
|
+
const $$ = document.querySelector('html')
|
|
40
|
+
|
|
41
|
+
if( !$( $$ ) ){
|
|
42
|
+
|
|
43
|
+
console.error('You need the primary node tag on your app')
|
|
44
|
+
|
|
45
|
+
}else{
|
|
46
|
+
|
|
47
|
+
$$.dphelper = {
|
|
48
|
+
test: ()=> console.log('test')
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// setTimeout( async ()=> {
|
|
52
|
+
// console.log( $( $$ ) )
|
|
53
|
+
// $$.dphelper.test()
|
|
54
|
+
// },2000)
|
|
55
|
+
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
59
|
+
// LOAD ALL SCRIPT AUTOMATICALLY
|
|
60
|
+
|
|
61
|
+
const importAll = ( cntx ) => {
|
|
62
|
+
cntx.keys().forEach(
|
|
63
|
+
( key ) => (
|
|
64
|
+
cache[ key ] = cntx( key )
|
|
65
|
+
)
|
|
66
|
+
);
|
|
67
|
+
};
|
|
68
|
+
var cntx = require.context( __dirname + '/scripts/', false , /\.js$/ );
|
|
69
|
+
importAll( cntx );
|
|
70
|
+
|
|
71
|
+
///////////////////////////////////////////////////////////////////////////////
|
|
72
|
+
// FIRST MESSAGE
|
|
73
|
+
|
|
74
|
+
console.groupCollapsed( `%c${pjson.name} v${pjson.version}%c`,"color:orange","" );
|
|
75
|
+
console.debug( `%c${pjson.name} v${pjson.version}%c by Dario Passariello started`,"color:orange","" );
|
|
76
|
+
console.debug( `%cType ${pjson.name} in this console to see it`, "color:gray","" );
|
|
77
|
+
console.debug( "%cFor help visit: " + pjson.repository.help, "color:gray","" );
|
|
78
|
+
console.debug( 'name: %c' + pjson.name,"color:orange","" );
|
|
79
|
+
console.debug( 'version: %c' + pjson.version,"color:orange","" );
|
|
80
|
+
console.debug( 'description: %c' + pjson.description,"color:orange","" );
|
|
81
|
+
console.debug( 'license: %c' + pjson.license,"color:orange","" );
|
|
82
|
+
console.debug( 'repository: %c' + pjson.repository.url,"color:orange","" );
|
|
83
|
+
console.debug( 'author: %c' + pjson.author.name,"color:orange","" );
|
|
84
|
+
console.debug( 'email: %c' + pjson.author.email,"color:orange","" );
|
|
85
|
+
console.groupEnd();
|
|
86
|
+
|
|
87
|
+
})();
|
package/jest.config.js
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
|
|
3
|
+
verbose: true,
|
|
4
|
+
|
|
5
|
+
testEnvironmentOptions: { url: "http://localhost/" },
|
|
6
|
+
|
|
7
|
+
automock: false,
|
|
8
|
+
|
|
9
|
+
collectCoverage: true,
|
|
10
|
+
|
|
11
|
+
"transform": {
|
|
12
|
+
"\\.tsx$": "<rootDir>/node_modules/babel-jest"
|
|
13
|
+
},
|
|
14
|
+
|
|
15
|
+
setupFilesAfterEnv: [
|
|
16
|
+
"./tests/setupJest.tsx"
|
|
17
|
+
],
|
|
18
|
+
|
|
19
|
+
moduleNameMapper: {
|
|
20
|
+
"\\.(jpg|jpeg|png|gif|eot|otf|webp|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga|html)$": "<rootDir>/__mocks__/fileMock.js",
|
|
21
|
+
"\\.(css|scss|svg)$": "identity-obj-proxy"
|
|
22
|
+
},
|
|
23
|
+
|
|
24
|
+
moduleFileExtensions: [
|
|
25
|
+
"js",
|
|
26
|
+
"jsx",
|
|
27
|
+
"ts",
|
|
28
|
+
"tsx"
|
|
29
|
+
],
|
|
30
|
+
|
|
31
|
+
transformIgnorePatterns: [
|
|
32
|
+
"/node_modules/",
|
|
33
|
+
"/node_modules/(?!(nrg-common)/)"
|
|
34
|
+
],
|
|
35
|
+
|
|
36
|
+
coveragePathIgnorePatterns: [
|
|
37
|
+
"/node_modules/",
|
|
38
|
+
"/node_modules/(?!(nrg-common)/)"
|
|
39
|
+
],
|
|
40
|
+
|
|
41
|
+
modulePathIgnorePatterns: [
|
|
42
|
+
"/node_modules/",
|
|
43
|
+
"/node_modules/(?!(nrg-common)/)"
|
|
44
|
+
],
|
|
45
|
+
|
|
46
|
+
unmockedModulePathPatterns: [
|
|
47
|
+
"./node_modules/react/",
|
|
48
|
+
"./node_modules/react-dom/"
|
|
49
|
+
],
|
|
50
|
+
|
|
51
|
+
coverageReporters: [
|
|
52
|
+
"json",
|
|
53
|
+
"lcov",
|
|
54
|
+
"text"
|
|
55
|
+
],
|
|
56
|
+
|
|
57
|
+
snapshotSerializers: [
|
|
58
|
+
"enzyme-to-json/serializer"
|
|
59
|
+
],
|
|
60
|
+
|
|
61
|
+
// transformIgnorePatterns: [
|
|
62
|
+
// "node_modules/enzyme"
|
|
63
|
+
// ],
|
|
64
|
+
|
|
65
|
+
testPathIgnorePatterns: [
|
|
66
|
+
"/node_modules/",
|
|
67
|
+
],
|
|
68
|
+
|
|
69
|
+
unmockedModulePathPatterns: [
|
|
70
|
+
"react",
|
|
71
|
+
"react-dom",
|
|
72
|
+
"react-native",
|
|
73
|
+
"react-addons-test-utils",
|
|
74
|
+
"promise",
|
|
75
|
+
"source-map",
|
|
76
|
+
"enzyme"
|
|
77
|
+
]
|
|
78
|
+
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
const moment = require('moment');
|
|
2
|
+
const execSync = require('child_process').execSync;
|
|
3
|
+
const dateTime = moment().format('YYYYMMDDHHmmss');
|
|
4
|
+
const pjson = require('../package.json');
|
|
5
|
+
|
|
6
|
+
//https://stackoverflow.com/questions/55021363/how-to-pass-current-datetime-in-npm-script-for-git-commit-message-in-windows-and
|
|
7
|
+
execSync(`git tag \"v${pjson.version}\" -am \"Modify content\" && git push --tags`, { stdio: [0, 1, 2]} );
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
const moment = require('moment');
|
|
2
|
+
const execSync = require('child_process').execSync;
|
|
3
|
+
const dateTime = moment().format('YYYYMMDDHHmmss');
|
|
4
|
+
const pjson = require('../package.json');
|
|
5
|
+
|
|
6
|
+
//https://stackoverflow.com/questions/55021363/how-to-pass-current-datetime-in-npm-script-for-git-commit-message-in-windows-and
|
|
7
|
+
execSync(`cd .. && git add . && git commit -m \"ver. ${pjson.version} / ${dateTime}\" && git pull && git push --all`, { stdio: [0, 1, 2]} );
|
package/node/goLive.js
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
const moment = require('moment');
|
|
2
|
+
const execSync = require('child_process').execSync;
|
|
3
|
+
const dateTime = moment().format('YYYYMMDDHHmmss');
|
|
4
|
+
const pjson = require('../package.json');
|
|
5
|
+
|
|
6
|
+
//https://stackoverflow.com/questions/55021363/how-to-pass-current-datetime-in-npm-script-for-git-commit-message-in-windows-and
|
|
7
|
+
execSync(`cli-confirm \"Do you want go live?\" && npm version patch --force && cd.. && webpack --progress --color --mode production --config webpack.config.js && cd dist && npm publish`, { stdio: [0, 1, 2]} );
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dphelper",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.89",
|
|
4
4
|
"description": "Developer Tools",
|
|
5
5
|
"deprecated": false,
|
|
6
6
|
"appCode": "dphelper",
|
|
@@ -30,7 +30,9 @@
|
|
|
30
30
|
"git": "cd node && node gitDeploy",
|
|
31
31
|
"git-tag": "cd node && node createTag",
|
|
32
32
|
"backup": "backup.bat",
|
|
33
|
-
"goLive": "cd node && node goLive"
|
|
33
|
+
"goLive": "cd node && node goLive",
|
|
34
|
+
"test_jest": "jest --watchAll --coverage --testEnvironment jsdom",
|
|
35
|
+
"test_lint": "eslint --fix"
|
|
34
36
|
},
|
|
35
37
|
"eslintConfig": {
|
|
36
38
|
"globals": {
|
|
@@ -85,47 +87,52 @@
|
|
|
85
87
|
"url": "https://github.com/passariello/dpHelper/issues"
|
|
86
88
|
},
|
|
87
89
|
"devDependencies": {
|
|
88
|
-
"@babel/plugin-transform-runtime": "7.
|
|
90
|
+
"@babel/plugin-transform-runtime": "7.18.0",
|
|
89
91
|
"css-loader": "6.7.1",
|
|
90
|
-
"eslint": "8.
|
|
92
|
+
"eslint": "8.16.0",
|
|
91
93
|
"file-loader": "6.2.0",
|
|
92
94
|
"jest": "27.5.1",
|
|
93
|
-
"less-loader": "
|
|
94
|
-
"sass-loader": "
|
|
95
|
+
"less-loader": "11.0.0",
|
|
96
|
+
"sass-loader": "13.0.0",
|
|
95
97
|
"style-loader": "3.3.1",
|
|
96
98
|
"webpack-cli": "4.9.2"
|
|
97
99
|
},
|
|
98
100
|
"dependencies": {
|
|
99
|
-
"@babel/plugin-proposal-class-properties": "7.
|
|
100
|
-
"@babel/preset-env": "7.
|
|
101
|
-
"@babel/preset-react": "7.
|
|
102
|
-
"@babel/preset-typescript": "7.
|
|
101
|
+
"@babel/plugin-proposal-class-properties": "7.17.12",
|
|
102
|
+
"@babel/preset-env": "7.18.0",
|
|
103
|
+
"@babel/preset-react": "7.17.12",
|
|
104
|
+
"@babel/preset-typescript": "7.18.6",
|
|
103
105
|
"@testing-library/jest-dom": "^5.16.2",
|
|
104
106
|
"@testing-library/user-event": "^14.0.0",
|
|
105
|
-
"
|
|
107
|
+
"@types/enzyme-adapter-react-16": "1.0.6",
|
|
108
|
+
"babel-loader": "8.2.5",
|
|
106
109
|
"child_process": "1.0.2",
|
|
107
110
|
"classnames": "2.3.1",
|
|
108
111
|
"cli-confirm": "1.0.1",
|
|
109
|
-
"compression-webpack-plugin": "
|
|
110
|
-
"concurrently": "7.
|
|
111
|
-
"copy-webpack-plugin": "
|
|
112
|
+
"compression-webpack-plugin": "10.0.0",
|
|
113
|
+
"concurrently": "7.2.2",
|
|
114
|
+
"copy-webpack-plugin": "11.0.0",
|
|
112
115
|
"css": "3.0.0",
|
|
113
|
-
"dotenv": "16.0.
|
|
116
|
+
"dotenv": "16.0.1",
|
|
117
|
+
"enzyme": "3.11.0",
|
|
118
|
+
"enzyme-adapter-react-16": "1.15.6",
|
|
119
|
+
"enzyme-to-json": "3.6.2",
|
|
114
120
|
"fs": "0.0.1-security",
|
|
115
121
|
"html-webpack-plugin": "5.5.0",
|
|
116
122
|
"jquery": "3.6.0",
|
|
117
123
|
"jsdom-worker": "0.2.1",
|
|
118
124
|
"jshint": "^2.13.4",
|
|
119
125
|
"less": "4.1.2",
|
|
120
|
-
"moment": "2.29.
|
|
126
|
+
"moment": "2.29.4",
|
|
121
127
|
"path": "0.12.7",
|
|
122
128
|
"progress-bar-webpack-plugin": "2.1.0",
|
|
123
|
-
"react": "18.
|
|
124
|
-
"react-dom": "18.
|
|
129
|
+
"react": "18.1.0",
|
|
130
|
+
"react-dom": "18.1.0",
|
|
125
131
|
"require": "2.4.20",
|
|
126
|
-
"sass": "1.
|
|
132
|
+
"sass": "1.53.0",
|
|
133
|
+
"socket.io-client": "4.5.1",
|
|
127
134
|
"ts-jest": "27.1.4",
|
|
128
135
|
"tslint": "6.1.3",
|
|
129
|
-
"webpack": "5.
|
|
136
|
+
"webpack": "5.72.1"
|
|
130
137
|
}
|
|
131
138
|
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,48 @@
|
|
|
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" : "Import",
|
|
11
|
+
"description" : "Import files by type from folder",
|
|
12
|
+
"version" : "0.0.1",
|
|
13
|
+
"command" : "cormat",
|
|
14
|
+
// "subCommand" : [
|
|
15
|
+
// {
|
|
16
|
+
// "name":"all",
|
|
17
|
+
// "description":"Import all file by type from folder"
|
|
18
|
+
// }
|
|
19
|
+
// ],
|
|
20
|
+
"example" : "dphelper.import.all( __dirname + '/scripts/', false , /\.js$/ )",
|
|
21
|
+
"author" : "Dario Passariello",
|
|
22
|
+
"active" : true
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
dphelper._list.scripts.push( description );
|
|
26
|
+
|
|
27
|
+
/***********************************************************************/
|
|
28
|
+
|
|
29
|
+
dphelper.import = {
|
|
30
|
+
|
|
31
|
+
// all: ( path ='' , mode = false , extension ='/\.js$/' ) => {
|
|
32
|
+
|
|
33
|
+
// // example: dphelper.import.all( __dirname + '/scripts/', false , /\.js$/ )
|
|
34
|
+
|
|
35
|
+
// const importAll = ( cntx ) => {
|
|
36
|
+
// cntx.keys().forEach(
|
|
37
|
+
// ( key ) => (
|
|
38
|
+
// cache[ key ] = cntx( key )
|
|
39
|
+
// )
|
|
40
|
+
// );
|
|
41
|
+
// };
|
|
42
|
+
|
|
43
|
+
// var cntx = require.context( path , mode , extension );
|
|
44
|
+
// importAll( cntx );
|
|
45
|
+
|
|
46
|
+
// }
|
|
47
|
+
|
|
48
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
dpHelper
|
|
3
|
+
Copyright (c) 2021 Dario Passariello <dariopassariello@gmail.com>
|
|
4
|
+
Licensed under the Apache-2.0, see
|
|
5
|
+
https://dario.passariello.ca
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/***********************************************************************/
|
|
9
|
+
|
|
10
|
+
var description = {
|
|
11
|
+
"name" : "Anchor",
|
|
12
|
+
"type" : "function",
|
|
13
|
+
"version" : "0.0.1",
|
|
14
|
+
"command" : "anchor",
|
|
15
|
+
"example" : "",
|
|
16
|
+
"author" : "Dario Passariello",
|
|
17
|
+
"creationDate" : "20110101",
|
|
18
|
+
"lastMod" : "20110101",
|
|
19
|
+
"active" : true,
|
|
20
|
+
"description" : `
|
|
21
|
+
This tools allows you to convert all links in an element to 'onclick'.
|
|
22
|
+
It allows you to avoid the message with the path relative to the requested address
|
|
23
|
+
and it is very useful when you work with SPA but you want to keep even older browsers.`,
|
|
24
|
+
"subCommand" : [
|
|
25
|
+
{
|
|
26
|
+
"name":"toOnClick",
|
|
27
|
+
"version" : "0.0.1",
|
|
28
|
+
"example" : "dphelper.anchor.toOnClick('nav') or ('.foo') or ('#foo')",
|
|
29
|
+
"type" : "function",
|
|
30
|
+
"active": true,
|
|
31
|
+
"description":"test",
|
|
32
|
+
"subCommand" : []
|
|
33
|
+
}
|
|
34
|
+
],
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
dphelper._list.scripts.push( description );
|
|
38
|
+
|
|
39
|
+
/***********************************************************************/
|
|
40
|
+
|
|
41
|
+
dphelper.anchor ={
|
|
42
|
+
|
|
43
|
+
toOnClick: ( el ) => {
|
|
44
|
+
|
|
45
|
+
$( el + ' a' ).each( function( index ) {
|
|
46
|
+
let elem = $( this );
|
|
47
|
+
let href = elem.attr( 'href' );
|
|
48
|
+
|
|
49
|
+
if( href ){
|
|
50
|
+
elem
|
|
51
|
+
.on( 'mouseup', function(){
|
|
52
|
+
Loader( 'body' , null );
|
|
53
|
+
})
|
|
54
|
+
.css('cursor','pointer')
|
|
55
|
+
.addClass( dphelper.pathRail()[3].replace(/\//g, '') )
|
|
56
|
+
.removeAttr( 'href' )
|
|
57
|
+
.on( 'click', function(){
|
|
58
|
+
dphelper.browser.href( href );
|
|
59
|
+
dphelper.browser.push( '', '', href );
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
Object.defineProperty( dphelper, 'anchor', {
|
|
69
|
+
writable: false,
|
|
70
|
+
configurable: false
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
//console.log( Object.getOwnPropertyDescriptor( dphelper, 'socket' ) )
|
package/scripts/array.js
ADDED
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
dpHelper
|
|
3
|
+
Copyright (c) 2021 Dario Passariello <dariopassariello@gmail.com>
|
|
4
|
+
Licensed under the Apache-2.0, see
|
|
5
|
+
https://dario.passariello.ca
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/***********************************************************************/
|
|
9
|
+
|
|
10
|
+
var description = {
|
|
11
|
+
"name" : "Array",
|
|
12
|
+
"version" : "0.0.1",
|
|
13
|
+
"command" : "array",
|
|
14
|
+
"example" : "",
|
|
15
|
+
"author" : "Dario Passariello",
|
|
16
|
+
"creationDate" : "20110101",
|
|
17
|
+
"lastMod" : "20110101",
|
|
18
|
+
"type" : "object",
|
|
19
|
+
"active" : true,
|
|
20
|
+
"description" : "",
|
|
21
|
+
"subCommand" : [
|
|
22
|
+
{
|
|
23
|
+
"name":"find",
|
|
24
|
+
"version" : "0.0.1",
|
|
25
|
+
"example" : "",
|
|
26
|
+
"type" : "function",
|
|
27
|
+
"active": true,
|
|
28
|
+
"description":"test",
|
|
29
|
+
"subCommand" : []
|
|
30
|
+
},{
|
|
31
|
+
"name":"unique",
|
|
32
|
+
"version" : "0.0.1",
|
|
33
|
+
"example" : "",
|
|
34
|
+
"type" : "function",
|
|
35
|
+
"active": true,
|
|
36
|
+
"description":"test",
|
|
37
|
+
"subCommand" : []
|
|
38
|
+
},{
|
|
39
|
+
"name":"delete",
|
|
40
|
+
"version" : "0.0.1",
|
|
41
|
+
"example" : "",
|
|
42
|
+
"type" : "function",
|
|
43
|
+
"active": true,
|
|
44
|
+
"description":"test",
|
|
45
|
+
"subCommand" : []
|
|
46
|
+
},{
|
|
47
|
+
"name":"merge",
|
|
48
|
+
"version" : "0.0.1",
|
|
49
|
+
"example" : "",
|
|
50
|
+
"type" : "function",
|
|
51
|
+
"active": true,
|
|
52
|
+
"description":"test",
|
|
53
|
+
"subCommand" : []
|
|
54
|
+
},{
|
|
55
|
+
"name":"asc",
|
|
56
|
+
"version" : "0.0.1",
|
|
57
|
+
"example" : "",
|
|
58
|
+
"type" : "function",
|
|
59
|
+
"active": true,
|
|
60
|
+
"description":"test",
|
|
61
|
+
"subCommand" : []
|
|
62
|
+
},{
|
|
63
|
+
"name":"desc",
|
|
64
|
+
"version" : "0.0.1",
|
|
65
|
+
"example" : "",
|
|
66
|
+
"type" : "function",
|
|
67
|
+
"active": true,
|
|
68
|
+
"description":"test",
|
|
69
|
+
"subCommand" : []
|
|
70
|
+
},{
|
|
71
|
+
"name":"duplicates",
|
|
72
|
+
"version" : "0.0.1",
|
|
73
|
+
"example" : "",
|
|
74
|
+
"type" : "function",
|
|
75
|
+
"active": true,
|
|
76
|
+
"description":"test",
|
|
77
|
+
"subCommand" : []
|
|
78
|
+
},{
|
|
79
|
+
"name":"even",
|
|
80
|
+
"version" : "0.0.1",
|
|
81
|
+
"example" : "",
|
|
82
|
+
"type" : "function",
|
|
83
|
+
"active": true,
|
|
84
|
+
"description":"test",
|
|
85
|
+
"subCommand" : []
|
|
86
|
+
},{
|
|
87
|
+
"name":"odd",
|
|
88
|
+
"version" : "0.0.1",
|
|
89
|
+
"example" : "",
|
|
90
|
+
"type" : "function",
|
|
91
|
+
"active": true,
|
|
92
|
+
"description":"test",
|
|
93
|
+
"subCommand" : []
|
|
94
|
+
}
|
|
95
|
+
],
|
|
96
|
+
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
dphelper._list.scripts.push( description );
|
|
100
|
+
|
|
101
|
+
/***********************************************************************/
|
|
102
|
+
|
|
103
|
+
dphelper.array = {
|
|
104
|
+
|
|
105
|
+
// FIND
|
|
106
|
+
find: ( id, array )=>{
|
|
107
|
+
for (let node of array) {
|
|
108
|
+
if (node.id === id) return node;
|
|
109
|
+
|
|
110
|
+
if (node.children) {
|
|
111
|
+
let finalNode = dphelper.array.find(id, node.children);
|
|
112
|
+
if (finalNode) return finalNode;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return false;
|
|
116
|
+
},
|
|
117
|
+
|
|
118
|
+
// UNIQUE
|
|
119
|
+
unique: ( array ) => {
|
|
120
|
+
let unique = [...new Set( array )];
|
|
121
|
+
return unique;
|
|
122
|
+
},
|
|
123
|
+
|
|
124
|
+
// DELETE
|
|
125
|
+
delete: ( array , id ) => {
|
|
126
|
+
array.some(function iter (o,i,a) {
|
|
127
|
+
|
|
128
|
+
if (o.Id === id) {
|
|
129
|
+
a.splice(i, 1);
|
|
130
|
+
return true;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
for (let key of Object.keys(o)) {
|
|
134
|
+
let value = o[key];
|
|
135
|
+
if(value.length && typeof value === 'object') return value && value.map(iter);
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// OLD SCHOOL WAY
|
|
139
|
+
//var key = Object.keys(o);
|
|
140
|
+
// for (var p=0; p < key.length; ++p){
|
|
141
|
+
// if( o[key[p]]?.length && typeof o[key[p]] === 'object') return o[key[p]] && o[key[p]].some(iter);
|
|
142
|
+
// }
|
|
143
|
+
|
|
144
|
+
});
|
|
145
|
+
|
|
146
|
+
},
|
|
147
|
+
|
|
148
|
+
// MERGE
|
|
149
|
+
merge: ( arrayA, arrayB ) => {
|
|
150
|
+
for (const key of Object.keys(arrayA)) {
|
|
151
|
+
if (arrayA[key] instanceof Object && arrayB[key]) Object.assign(arrayA[key], dphelper.mergeArrays(arrayB[key], arrayA[key]));
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
Object.assign(arrayB || {}, arrayA);
|
|
155
|
+
return arrayB;
|
|
156
|
+
},
|
|
157
|
+
|
|
158
|
+
// ASCENDING
|
|
159
|
+
asc: ( array ) => {
|
|
160
|
+
array.sort((a, b) => a - b);
|
|
161
|
+
return array;
|
|
162
|
+
},
|
|
163
|
+
|
|
164
|
+
// ASCENDING
|
|
165
|
+
desc: ( array ) => {
|
|
166
|
+
array.sort(function(a, b){ return b-a; });
|
|
167
|
+
return array;
|
|
168
|
+
},
|
|
169
|
+
|
|
170
|
+
// FIND DUPLICATES
|
|
171
|
+
duplicates: ( array ) => {
|
|
172
|
+
const toFindDuplicates = arr => arr.filter( (item, index) => arr.indexOf( item ) !== index);
|
|
173
|
+
const duplicateElements = toFindDuplicates( array );
|
|
174
|
+
return duplicateElements;
|
|
175
|
+
},
|
|
176
|
+
|
|
177
|
+
even: ( array ) => {
|
|
178
|
+
var cur = [];
|
|
179
|
+
for (var i = 0; i < array.length; i++) {
|
|
180
|
+
if (array[i] % 2 === 0 ) cur.push(array[i]);
|
|
181
|
+
} return cur;
|
|
182
|
+
},
|
|
183
|
+
|
|
184
|
+
odd: ( array ) => {
|
|
185
|
+
var cur = [];
|
|
186
|
+
for (var i = 0; i < array.length; i++) {
|
|
187
|
+
if (array[i] % 2) cur.push(array[i]);
|
|
188
|
+
} return cur;
|
|
189
|
+
},
|
|
190
|
+
|
|
191
|
+
toObj: ( array ) => {
|
|
192
|
+
return Object.assign({}, array);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
};
|
|
196
|
+
|
|
197
|
+
Object.defineProperty( dphelper, 'array', {
|
|
198
|
+
writable: false,
|
|
199
|
+
configurable: false
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
//console.log( Object.getOwnPropertyDescriptor( dphelper, 'socket' ) )
|
|
203
|
+
|
package/scripts/avoid.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
dpHelper
|
|
3
|
+
Copyright (c) 2021 Dario Passariello <dariopassariello@gmail.com>
|
|
4
|
+
Licensed under the Apache-2.0, see
|
|
5
|
+
https://dario.passariello.ca
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/***********************************************************************/
|
|
9
|
+
|
|
10
|
+
var description = {
|
|
11
|
+
"name" : "Avoid",
|
|
12
|
+
"description" : "",
|
|
13
|
+
"version" : "0.0.1",
|
|
14
|
+
"command" : "avoid",
|
|
15
|
+
"subCommand" : [
|
|
16
|
+
{
|
|
17
|
+
"name":"cache",
|
|
18
|
+
"version" : "0.0.1",
|
|
19
|
+
"example" : "dphelper.avoid.cache",
|
|
20
|
+
"type" : "function",
|
|
21
|
+
"active": true,
|
|
22
|
+
"description":"test",
|
|
23
|
+
"subCommand" : []
|
|
24
|
+
},
|
|
25
|
+
],
|
|
26
|
+
"example" : "",
|
|
27
|
+
"author" : "Dario Passariello",
|
|
28
|
+
"active" : true
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
dphelper._list.scripts.push( description );
|
|
32
|
+
|
|
33
|
+
/***********************************************************************/
|
|
34
|
+
|
|
35
|
+
dphelper.avoid = {
|
|
36
|
+
|
|
37
|
+
cache: (uri) => {
|
|
38
|
+
return uri.concat( /\?/.test(uri) ? '&' : '?', 't=', dphelper.rnd() );
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
Object.defineProperty( dphelper, 'avoid', {
|
|
44
|
+
writable: false,
|
|
45
|
+
configurable: false
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
//console.log( Object.getOwnPropertyDescriptor( dphelper, 'socket' ) )
|