@datagrok/api-samples 1.0.5 → 1.0.7
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/.eslintrc.json +47 -0
- package/CHANGELOG.md +9 -0
- package/README.md +11 -9
- package/dist/package-test.js +2 -519
- package/dist/package.js +2 -30
- package/layouts/demog-table-layout.json +236 -0
- package/package.json +15 -13
- package/scripts/dapi/files.js +12 -12
- package/scripts/dapi/groups.js +3 -0
- package/scripts/dapi/users.js +1 -1
- package/scripts/data-access/db/db-edit.js +27 -0
- package/scripts/data-access/db-master-details-manual.js +3 -3
- package/scripts/data-access/dynamic-query.js +13 -0
- package/scripts/data-access/output-layouts.js +5 -0
- package/scripts/data-access/parameterized-query.js +3 -3
- package/scripts/data-frame/bitset/similarity-metrics.js +3 -3
- package/scripts/data-frame/construction/create-from-csv-format.js +3 -3
- package/scripts/data-frame/events/calculated-columns/update.js +1 -1
- package/scripts/data-frame/join-link/join-tables.js +5 -6
- package/scripts/data-frame/modification/remove-where.js +8 -0
- package/scripts/data-frame/row-matching/patterns.js +1 -3
- package/scripts/domains/chem/chem-benchmark.js +26 -26
- package/scripts/domains/chem/descriptors.js +1 -2
- package/scripts/domains/chem/diversity-search.js +3 -5
- package/scripts/domains/chem/inspect-molecule.js +1 -1
- package/scripts/domains/chem/mcs.js +2 -3
- package/scripts/domains/chem/mol-atoms-bonds.js +1 -2
- package/scripts/domains/chem/mol-panel.js +0 -1
- package/scripts/domains/chem/mol-rendering-canvas.js +4 -6
- package/scripts/domains/chem/mol-rendering.js +0 -1
- package/scripts/domains/chem/r-group.js +3 -5
- package/scripts/domains/chem/similarity-scoring-scores.js +0 -3
- package/scripts/domains/chem/similarity-scoring-sorted.js +0 -3
- package/scripts/domains/chem/substructure-search-benchmark.js +5 -8
- package/scripts/domains/chem/substructure-search-smarts-molfile-als.js +6 -9
- package/scripts/domains/chem/substructure-search-smarts.js +4 -7
- package/scripts/domains/chem/substructure-search.js +1 -4
- package/scripts/domains/data-science/predictive-model.js +2 -3
- package/scripts/functions/caching-results.js +36 -0
- package/scripts/functions/calling.js +2 -2
- package/scripts/functions/discover-functions.js +1 -1
- package/scripts/functions/func-call.js +18 -0
- package/scripts/functions/progress.js +2 -7
- package/scripts/grid/advanced/charts-in-cells.js +16 -14
- package/scripts/grid/advanced/link-click.js +19 -0
- package/scripts/grid/advanced/pinned-columns.js +7 -0
- package/scripts/grid/advanced/pinned-rows.js +8 -0
- package/scripts/grid/advanced/visible-cells.js +3 -4
- package/scripts/grid/scroll-to-pixels.js +9 -4
- package/scripts/misc/audit/activity-today.js +3 -3
- package/scripts/misc/audit/errors-summary.js +2 -4
- package/scripts/misc/audit/test-tracking.js +2 -4
- package/scripts/misc/audit/users-today.js +6 -7
- package/scripts/misc/package-credentials.js +2 -4
- package/scripts/misc/paint/paint.js +14 -0
- package/scripts/misc/sdtm.js +8 -10
- package/scripts/misc/utils/hide-empty-columns.js +19 -0
- package/scripts/scripting/grok-scripting.js +1 -1
- package/scripts/scripting/scripting.js +2 -2
- package/scripts/shell/current-object.js +1 -1
- package/scripts/shell/last-error.js +0 -4
- package/scripts/shell/windows/shell-windows.js +6 -0
- package/scripts/ui/components/balloons.js +9 -0
- package/scripts/ui/components/breadcrumbs.js +4 -0
- package/scripts/ui/{elements → components}/color-palettes.js +4 -4
- package/scripts/ui/components/drop-down.js +7 -0
- package/scripts/ui/components/html-tables.js +27 -0
- package/scripts/ui/components/loading-indicators.js +4 -6
- package/scripts/ui/components/menu-customization.js +18 -0
- package/scripts/ui/components/property-grid.js +10 -10
- package/scripts/ui/{layouts → containers}/splitters.js +3 -3
- package/scripts/ui/css.js +20 -0
- package/scripts/ui/docking/README.md +3 -3
- package/scripts/ui/handlers/handlers.js +1 -1
- package/scripts/ui/inputs/advanced/all-input-types.js +47 -0
- package/scripts/ui/inputs/{for-properties.js → advanced/for-properties.js} +17 -2
- package/scripts/ui/inputs/advanced/input-form.js +10 -0
- package/scripts/ui/inputs/forms.js +35 -0
- package/scripts/ui/inputs/grid-input.js +14 -0
- package/scripts/ui/inputs/inputs.js +24 -0
- package/scripts/ui/{elements/inputs → inputs}/table-input.js +1 -2
- package/scripts/ui/inputs/tags-input.js +12 -0
- package/scripts/ui/inputs/typeahead-input.js +19 -0
- package/scripts/ui/interactivity/hints.js +25 -0
- package/scripts/ui/interactivity/wizard-hints.js +15 -0
- package/scripts/ui/viewers/advanced/sketch-form.js +9 -0
- package/scripts/ui/viewers/custom-scatterplot-rendering.js +1 -1
- package/scripts/ui/viewers/custom-viewer-properties.js +5 -5
- package/scripts/ui/viewers/filters/custom-filters.js +8 -3
- package/scripts/ui/viewers/js viewers/chord-viewer.js +3 -0
- package/scripts/ui/viewers/js viewers/globe-viewer.js +13 -0
- package/scripts/ui/viewers/js viewers/radar-viewer.js +9 -0
- package/scripts/ui/viewers/js viewers/sankey-viewer.js +4 -0
- package/scripts/ui/viewers/js viewers/sunburst-viewer.js +3 -0
- package/scripts/ui/viewers/js viewers/surface-plot.js +2 -0
- package/scripts/ui/viewers/js viewers/timelines-viewer.js +3 -0
- package/scripts/ui/viewers/js viewers/tree-viewer.js +3 -0
- package/scripts/ui/viewers/js viewers/word-cloud.js +5 -0
- package/scripts/ui/viewers/trellis-plot-with-summary-viewer.js +14 -0
- package/scripts/ui/viewers/types/form-advanced.js +7 -0
- package/scripts/ui/views/currently-open-views.js +5 -5
- package/src/package-test.ts +31 -1
- package/tsconfig.json +1 -1
- package/scripts/misc/audit/errors.js +0 -4
- package/scripts/misc/audit/event-types-summary.js +0 -4
- package/scripts/misc/audit/rolling-events.js +0 -11
- package/scripts/ui/apps/color-checker.js +0 -328
- package/scripts/ui/components/panels.js +0 -19
- package/scripts/ui/elements/html-tables.js +0 -24
- package/scripts/ui/elements/inputs/inputs.js +0 -46
- package/scripts/ui/layouts/templates/2 Column.js +0 -14
- package/scripts/ui/layouts/templates/3 Column.js +0 -15
- package/scripts/ui/layouts/templates/Flex box.js +0 -16
- package/scripts/ui/layouts/templates/Fluid layout.js +0 -19
- package/scripts/ui/layouts/templates/Gallery grid.js +0 -18
- package/scripts/ui/layouts/templates/Splitter (1 Column 2 Row).js +0 -19
- package/scripts/ui/layouts/templates/Splitter (2 Column).js +0 -16
- package/scripts/ui/layouts/templates/Splitter (2 Row).js +0 -18
- package/scripts/ui/layouts/templates/Splitter (2-3 Column).js +0 -23
- package/scripts/ui/layouts/templates/Tabs 2 column.js +0 -19
- package/scripts/ui/layouts/templates/Tabs navbar.js +0 -16
- package/scripts/ui/viewers/types/google-map.js +0 -5
- package/scripts/ux/Dialogs/add-new-column-dlg.js +0 -58
- package/scripts/ux/Dialogs/link-table-dlg.js +0 -23
- package/scripts/ux/Filters/data-filtering.js +0 -99
- package/scripts/ux/Input forms/form-types.js +0 -133
- package/scripts/ux/Input forms/misc.js +0 -52
- package/scripts/ux/Interactivity/hints.js +0 -22
- package/scripts/ux/Layouts/example-1.js +0 -50
- package/scripts/ux/Layouts/example-2.js +0 -63
- package/scripts/ux/Layouts/example-3.js +0 -192
- package/scripts/ux/Layouts/example-4.js +0 -51
- package/scripts/ux/Managing Collections/datasource-view.js +0 -47
- package/scripts/ux/Views/property-panel.js +0 -120
- package/scripts/ux/Views/toolbar.js +0 -146
- package/scripts/ux/Views/toolbox.js +0 -124
- /package/scripts/ui/{elements → components}/buttons.js +0 -0
- /package/scripts/ui/{elements → components}/icons.js +0 -0
- /package/scripts/ui/{elements → components}/image.js +0 -0
- /package/scripts/ui/{elements → components}/list.js +0 -0
- /package/scripts/ui/{elements → components}/range-slider.js +0 -0
- /package/scripts/ui/{cards → components}/summary-card.js +0 -0
- /package/scripts/ui/{elements → components}/typography.js +0 -0
- /package/scripts/ui/{layouts → containers}/blocks.js +0 -0
- /package/scripts/ui/{layouts → containers}/box.js +0 -0
- /package/scripts/ui/{layouts → containers}/containers.js +0 -0
- /package/scripts/ui/{layouts → containers}/flexbox.js +0 -0
- /package/scripts/ui/{layouts → containers}/panels.js +0 -0
- /package/scripts/ui/inputs/{custom-inputs.js → advanced/custom-inputs.js} +0 -0
- /package/scripts/ui/inputs/{for-columns.js → advanced/for-columns.js} +0 -0
- /package/scripts/ui/inputs/{input-events.js → advanced/input-events.js} +0 -0
- /package/scripts/ui/inputs/{master-details.js → advanced/master-details.js} +0 -0
- /package/scripts/ui/{elements/inputs → inputs}/choice-input.js +0 -0
- /package/scripts/ui/{elements/inputs → inputs}/column-combo-box.js +0 -0
- /package/scripts/ui/{elements/inputs → inputs}/column-inputs.js +0 -0
- /package/scripts/ui/{elements/inputs → inputs}/inputs-events.js +0 -0
- /package/scripts/ui/{elements/inputs → inputs}/inputs-extended.js +0 -0
- /package/scripts/ui/{elements/inputs → inputs}/molecule-input.js +0 -0
- /package/scripts/{ux/Interactivity → ui/interactivity}/drag-and-drop.js +0 -0
- /package/scripts/{ux/Rendering → ui/rendering}/render-items.js +0 -0
- /package/scripts/ui/{components/tooltips → tooltips}/row-group-tooltips.js +0 -0
- /package/scripts/ui/{components/tooltips → tooltips}/tooltip-events.js +0 -0
- /package/scripts/ui/{components/tooltips → tooltips}/tooltips.js +0 -0
- /package/scripts/{ux/Navigations → ui/views}/navigation.js +0 -0
- /package/scripts/{ux/Managing Collections → ui/views}/virtual-view.js +0 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// https://datagrok.ai/help/visualize/viewers/globe
|
|
2
|
+
|
|
3
|
+
let view = grok.shell.addTableView(grok.data.demo.geo());
|
|
4
|
+
|
|
5
|
+
view.addViewer('globe', {
|
|
6
|
+
"latitudeColumnName": "lat",
|
|
7
|
+
"longitudeColumnName": "lng",
|
|
8
|
+
"magnitudeColumnName": "",
|
|
9
|
+
"colorByColumnName": "value",
|
|
10
|
+
"pointRadius": 15,
|
|
11
|
+
"pointAltitude": 50,
|
|
12
|
+
"autorotation": false
|
|
13
|
+
});
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
const df = grok.data.demo.demog();
|
|
2
|
+
const tv = grok.shell.addTableView(df);
|
|
3
|
+
|
|
4
|
+
tv.addViewer(DG.VIEWER.TRELLIS_PLOT, {
|
|
5
|
+
viewerType: 'Summary',
|
|
6
|
+
innerViewerLook: {
|
|
7
|
+
columnNames: ['weight', 'height'],
|
|
8
|
+
aggregations: [DG.STATS.MIN, DG.STATS.MED],
|
|
9
|
+
visualizationType: 'bars',
|
|
10
|
+
colorColumnName: 'age',
|
|
11
|
+
colorAggrType: 'stdev',
|
|
12
|
+
invertColorScheme: true
|
|
13
|
+
}
|
|
14
|
+
});
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
//tags: View
|
|
2
2
|
// Table views
|
|
3
|
-
grok.shell.
|
|
4
|
-
grok.shell.
|
|
3
|
+
grok.shell.addTableView(grok.data.demo.demog());
|
|
4
|
+
grok.shell.addTableView(grok.data.demo.wells());
|
|
5
5
|
|
|
6
6
|
// Views
|
|
7
7
|
grok.shell.newView('Test', [ui.h1('Regular View')]);
|
|
8
8
|
grok.shell.addView(DG.View.createByType(DG.View.FUNCTIONS));
|
|
9
9
|
|
|
10
10
|
// Iterate over table views and all views
|
|
11
|
-
for (
|
|
11
|
+
for (const tv of grok.shell.tableViews)
|
|
12
12
|
grok.shell.info(`Table view: ${tv.name}`);
|
|
13
13
|
|
|
14
|
-
for (
|
|
15
|
-
grok.shell.info(`View: ${v.name}`);
|
|
14
|
+
for (const v of grok.shell.views)
|
|
15
|
+
grok.shell.info(`View: ${v.name}`);
|
package/src/package-test.ts
CHANGED
|
@@ -1,17 +1,47 @@
|
|
|
1
1
|
import * as DG from 'datagrok-api/dg';
|
|
2
2
|
import * as grok from 'datagrok-api/grok';
|
|
3
|
-
import {runTests, tests, TestContext} from '@datagrok-libraries/utils/src/test';
|
|
3
|
+
import {runTests, tests, TestContext, category, test as _test, delay} from '@datagrok-libraries/utils/src/test';
|
|
4
4
|
export const _package = new DG.Package();
|
|
5
5
|
export {tests};
|
|
6
6
|
|
|
7
7
|
import './tests/test';
|
|
8
8
|
|
|
9
|
+
const skip = [
|
|
10
|
+
'function-events', 'demo', 'ui-events', 'last-error', 'chem-benchmark', 'menu-customization',
|
|
11
|
+
'README', '10k-columns-updates',
|
|
12
|
+
// To fix
|
|
13
|
+
'scatter-plot-3d', 'network-diagram', 'chord-viewer', 'sankey-viewer', 'word-cloud',
|
|
14
|
+
'100-million-rows', 'custom-viewer-properties', // Break
|
|
15
|
+
'files', 'open-table-by-id', 'all-chembl-structures', 'charts-in-cells',
|
|
16
|
+
'property-grid', 'tree-view-adv', 'attached-properties', 'all-input-types',
|
|
17
|
+
'add-single-filter', 'custom-filters', 'filter-group', 'dynamic-loading'
|
|
18
|
+
];
|
|
19
|
+
|
|
9
20
|
//name: test
|
|
10
21
|
//input: string category {optional: true}
|
|
11
22
|
//input: string test {optional: true}
|
|
12
23
|
//input: object testContext {optional: true}
|
|
13
24
|
//output: dataframe result
|
|
14
25
|
export async function test(category: string, test: string, testContext: TestContext): Promise<DG.DataFrame> {
|
|
26
|
+
testContext = new TestContext(false, false);
|
|
15
27
|
const data = await runTests({category, test, testContext});
|
|
16
28
|
return DG.DataFrame.fromObjects(data)!;
|
|
17
29
|
}
|
|
30
|
+
|
|
31
|
+
//tags: init
|
|
32
|
+
export async function initTests() {
|
|
33
|
+
const scripts = await grok.dapi.scripts.filter('package.shortName = "ApiSamples"').list();
|
|
34
|
+
for (const script of scripts) {
|
|
35
|
+
category(('Scripts:' + script.options.path as string).replaceAll('/', ':'), () => {
|
|
36
|
+
_test(script.friendlyName, async () => {
|
|
37
|
+
await script.apply();
|
|
38
|
+
await delay(300);
|
|
39
|
+
// if (grok.shell.lastError) {
|
|
40
|
+
// const err = grok.shell.lastError;
|
|
41
|
+
// grok.shell.lastError = '';
|
|
42
|
+
// throw new Error(err);
|
|
43
|
+
// }
|
|
44
|
+
}, skip.includes(script.friendlyName) ? {skipReason: 'skip'} : undefined);
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
}
|
package/tsconfig.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
// "incremental": true, /* Enable incremental compilation */
|
|
7
7
|
"target": "es6", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020', or 'ESNEXT'. */
|
|
8
8
|
"module": "es2020", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', 'es2020', or 'ESNext'. */
|
|
9
|
-
"lib": ["
|
|
9
|
+
"lib": ["ES2022", "dom"], /* Specify library files to be included in the compilation. */
|
|
10
10
|
// "allowJs": true, /* Allow javascript files to be compiled. */
|
|
11
11
|
// "checkJs": true, /* Report errors in .js files. */
|
|
12
12
|
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', 'react', 'react-jsx' or 'react-jsxdev'. */
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
let view = grok.shell.newView('Usage');
|
|
2
|
-
|
|
3
|
-
let last = new Date();
|
|
4
|
-
last.setHours(last.getHours() - 5);
|
|
5
|
-
|
|
6
|
-
let timer = setInterval(function () {
|
|
7
|
-
grok.data.query('UsageAnalysis:EventsOnDate', {'date': ('after ' + last.toLocaleString().replace(',', ''))})
|
|
8
|
-
.then((t) => {
|
|
9
|
-
grok.shell.addTableView(t);
|
|
10
|
-
});
|
|
11
|
-
}, 5000);
|
|
@@ -1,328 +0,0 @@
|
|
|
1
|
-
//name: color-checker
|
|
2
|
-
//description: color contrast and blindness check
|
|
3
|
-
//language: javascript
|
|
4
|
-
|
|
5
|
-
let view = grok.shell.newView('HexToRGB');
|
|
6
|
-
view.box = true;
|
|
7
|
-
|
|
8
|
-
let contrastBox = ui.div();
|
|
9
|
-
contrastBox.style.padding = '5px';
|
|
10
|
-
contrastBox.style.maxWidth = '150px';
|
|
11
|
-
contrastBox.style.marginBottom = '10px';
|
|
12
|
-
|
|
13
|
-
let hexActive = ui.boolInput('', true, v=>{
|
|
14
|
-
if (v)
|
|
15
|
-
colorHex.enabled = true;
|
|
16
|
-
else
|
|
17
|
-
colorHex.enabled = false;
|
|
18
|
-
if ((v)&&(rgbActive.value)){
|
|
19
|
-
rgbActive.value = false;
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
let rgbActive = ui.boolInput('', false, v=>{
|
|
24
|
-
if (v)
|
|
25
|
-
colorRgb.enabled = true;
|
|
26
|
-
else
|
|
27
|
-
colorRgb.enabled = false;
|
|
28
|
-
if ((v)&&(hexActive.value)){
|
|
29
|
-
hexActive.value = false;
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
let colorBox = ui.div();
|
|
34
|
-
colorBox.style.marginBottom = '10px';
|
|
35
|
-
colorBox.style.padding = '5px';
|
|
36
|
-
colorBox.style.maxWidth = '150px';
|
|
37
|
-
|
|
38
|
-
let colorBlidnessBox = ui.div();
|
|
39
|
-
colorBlidnessBox.style.marginBottom = '10px';
|
|
40
|
-
colorBlidnessBox.style.maxWidth = '150px';
|
|
41
|
-
|
|
42
|
-
let inputColor = ui.element('input');
|
|
43
|
-
inputColor.type = 'color';
|
|
44
|
-
inputColor.style.width = '40px';
|
|
45
|
-
inputColor.style.height = '20px';
|
|
46
|
-
inputColor.style.marginLeft = '10px';
|
|
47
|
-
|
|
48
|
-
inputColor.onchange = (e) =>{
|
|
49
|
-
if (colorHex.enabled){
|
|
50
|
-
colorHex.value = inputColor.value.substring(1);
|
|
51
|
-
}else{
|
|
52
|
-
let rgb = hexToRGB(inputColor.value.substring(1));
|
|
53
|
-
colorRgb.value = rgb.R+','+rgb.G+','+rgb.B;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
let colorHex = ui.stringInput('HEX:', '', v=>{
|
|
60
|
-
let result = colorHex.value.match(/[\d\w]{6}/);
|
|
61
|
-
colorBox.innerHTML = '';
|
|
62
|
-
contrastBox.innerHTML = '';
|
|
63
|
-
saveBox.innerHTML = '';
|
|
64
|
-
contrastBox.style.backgroundColor = 'white';
|
|
65
|
-
colorBox.style.backgroundColor = 'white';
|
|
66
|
-
|
|
67
|
-
if (result!=null){
|
|
68
|
-
let rgb = hexToRGB(colorHex.value);
|
|
69
|
-
if (colorHex.enabled){
|
|
70
|
-
colorRgb.value = rgb.R+','+rgb.G+','+rgb.B;
|
|
71
|
-
calcRatio(rgb);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
if ((colorHex.value =='')&&(colorRgb.value.length>0))
|
|
75
|
-
colorRgb.value = '';
|
|
76
|
-
});
|
|
77
|
-
|
|
78
|
-
let colorRgb = ui.stringInput('RGB:', '', v=>{
|
|
79
|
-
let result = colorRgb.value.match(/([\d]{1,3}\,[\d]{1,3}\,[\d]{1,3}){1,12}/);
|
|
80
|
-
colorBox.innerHTML = '';
|
|
81
|
-
contrastBox.innerHTML = '';
|
|
82
|
-
saveBox.innerHTML = '';
|
|
83
|
-
contrastBox.style.backgroundColor = 'white';
|
|
84
|
-
colorBox.style.backgroundColor = 'white';
|
|
85
|
-
|
|
86
|
-
if (result!=null){
|
|
87
|
-
let hex = rgbToHex(result[0]);
|
|
88
|
-
let rgbresult = colorRgb.value.split(',');
|
|
89
|
-
let rgb = {
|
|
90
|
-
'R': rgbresult[0],
|
|
91
|
-
'G': rgbresult[1],
|
|
92
|
-
'B': rgbresult[2]
|
|
93
|
-
};
|
|
94
|
-
if (colorRgb.enabled){
|
|
95
|
-
colorHex.value = hex;
|
|
96
|
-
calcRatio(rgb);
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
if (colorRgb.value == '')
|
|
100
|
-
colorHex.value = '';
|
|
101
|
-
});
|
|
102
|
-
colorRgb.enabled = false;
|
|
103
|
-
colorRgb.input.setAttribute('maxlength','11');
|
|
104
|
-
|
|
105
|
-
let copyRGB = ui.button(ui.iconFA('copy'), ()=>{
|
|
106
|
-
copyToClipboard(colorRgb.value);
|
|
107
|
-
grok.shell.info(colorRgb.value);
|
|
108
|
-
})
|
|
109
|
-
|
|
110
|
-
let copyHEX = ui.button(ui.iconFA('copy'), ()=>{
|
|
111
|
-
copyToClipboard(colorHex.value);
|
|
112
|
-
grok.shell.info(colorHex.value);
|
|
113
|
-
})
|
|
114
|
-
|
|
115
|
-
view.box = true;
|
|
116
|
-
let palette = ui.panel([
|
|
117
|
-
ui.h2('Palette')
|
|
118
|
-
]);
|
|
119
|
-
let saveBox = ui.div();
|
|
120
|
-
view.append(ui.splitH([
|
|
121
|
-
ui.panel([
|
|
122
|
-
ui.divH([
|
|
123
|
-
hexActive,
|
|
124
|
-
colorHex,
|
|
125
|
-
copyHEX
|
|
126
|
-
]),
|
|
127
|
-
ui.divH([
|
|
128
|
-
rgbActive,
|
|
129
|
-
colorRgb,
|
|
130
|
-
copyRGB
|
|
131
|
-
]),
|
|
132
|
-
ui.divH([
|
|
133
|
-
ui.div([],{style:{width:'35px'}}),
|
|
134
|
-
ui.label('Picker'),
|
|
135
|
-
inputColor
|
|
136
|
-
],{style:{alignItems:'center',margin:'10px 0'}}),
|
|
137
|
-
ui.div([
|
|
138
|
-
ui.label('Color:'),
|
|
139
|
-
colorBox,
|
|
140
|
-
ui.label('Contrast:'),
|
|
141
|
-
contrastBox,
|
|
142
|
-
ui.label('Color blindness:'),
|
|
143
|
-
colorBlidnessBox,
|
|
144
|
-
saveBox
|
|
145
|
-
],{style:{margin:'10px 0 0 35px'}})
|
|
146
|
-
]),
|
|
147
|
-
palette
|
|
148
|
-
]));
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
//calculation process
|
|
152
|
-
|
|
153
|
-
function calcRatio(rgb){
|
|
154
|
-
|
|
155
|
-
let textColor = colorBalance(rgb);
|
|
156
|
-
let flag = '';
|
|
157
|
-
colorBox.innerHTML = 'Text color';
|
|
158
|
-
colorBlidnessBox.innerHTML = '';
|
|
159
|
-
colorBox.style.color = textColor;
|
|
160
|
-
colorBox.style.backgroundColor = '#'+colorHex.value;
|
|
161
|
-
|
|
162
|
-
if (textColor == 'black'){
|
|
163
|
-
textColor = [0,0,0];
|
|
164
|
-
}else{
|
|
165
|
-
textColor = [255,255,255];
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
let ratio = contrast(rgb, textColor).toFixed(2);
|
|
169
|
-
let ratioResult = ui.h1(ratio);
|
|
170
|
-
ratioResult.style.margin = '0px';
|
|
171
|
-
if(ratio>7){
|
|
172
|
-
flag = 'Good';
|
|
173
|
-
contrastBox.style.color = 'var(--green-2)';
|
|
174
|
-
contrastBox.style.backgroundColor = 'var(--green-1)';
|
|
175
|
-
}else if ((ratio>4.5)&&(ratio<7)){
|
|
176
|
-
flag = 'Avarage';
|
|
177
|
-
contrastBox.style.color = 'var(--orange-2)';
|
|
178
|
-
contrastBox.style.backgroundColor = 'var(--orange-1)';
|
|
179
|
-
}else if(ratio<4.5){
|
|
180
|
-
flag = 'Bad';
|
|
181
|
-
contrastBox.style.color = 'var(--red-2)';
|
|
182
|
-
contrastBox.style.backgroundColor = 'var(--red-1)';
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
contrastBox.append(
|
|
186
|
-
ui.div([
|
|
187
|
-
ratioResult,
|
|
188
|
-
ui.divText(flag)
|
|
189
|
-
]));
|
|
190
|
-
|
|
191
|
-
let protanopia = ColorMatrix({R:rgb.R,G:rgb.G,B:rgb.B,A:1},Blind('Protanopia'));
|
|
192
|
-
let protanomaly = ColorMatrix({R:rgb.R,G:rgb.G,B:rgb.B,A:1},Blind('Protanomaly'));
|
|
193
|
-
let deuteranopia = ColorMatrix({R:rgb.R,G:rgb.G,B:rgb.B,A:1},Blind('Deuteranopia'));
|
|
194
|
-
let deuteranomaly = ColorMatrix({R:rgb.R,G:rgb.G,B:rgb.B,A:1},Blind('Deuteranomaly'));
|
|
195
|
-
let tritanopia = ColorMatrix({R:rgb.R,G:rgb.G,B:rgb.B,A:1},Blind('Tritanopia'));
|
|
196
|
-
let tritanomaly = ColorMatrix({R:rgb.R,G:rgb.G,B:rgb.B,A:1},Blind('Tritanomaly'));
|
|
197
|
-
let achromatopsia = ColorMatrix({R:rgb.R,G:rgb.G,B:rgb.B,A:1},Blind('Achromatopsia'));
|
|
198
|
-
let achromatomaly = ColorMatrix({R:rgb.R,G:rgb.G,B:rgb.B,A:1},Blind('Achromatomaly'));
|
|
199
|
-
|
|
200
|
-
colorBlidnessBox.append(
|
|
201
|
-
ui.divH([
|
|
202
|
-
ui.div(['Protanopia ('+contrast(protanopia, textColor).toFixed(2)+')'],{style:{margin:'0 10px'}}),
|
|
203
|
-
],{style:{minWidth:'200px',color:'rgb('+textColor+')',alignItems:'center',padding:'5px 0', backgroundColor:'rgb('+protanopia.R+','+protanopia.G+','+protanopia.B+')'}}),
|
|
204
|
-
ui.divH([
|
|
205
|
-
ui.div(['Protanomaly ('+contrast(protanomaly, textColor).toFixed(2)+')'],{style:{margin:'0 10px'}}),
|
|
206
|
-
],{style:{minWidth:'200px',color:'rgb('+textColor+')',alignItems:'center',padding:'5px 0', backgroundColor:'rgb('+protanomaly.R+','+protanomaly.G+','+protanomaly.B+')'}}),
|
|
207
|
-
ui.divH([
|
|
208
|
-
ui.div(['Deuteranopia ('+contrast(deuteranopia, textColor).toFixed(2)+')'],{style:{margin:'0 10px'}}),
|
|
209
|
-
],{style:{minWidth:'200px',color:'rgb('+textColor+')',alignItems:'center',padding:'5px 0', backgroundColor:'rgb('+deuteranopia.R+','+deuteranopia.G+','+deuteranopia.B+')'}}),
|
|
210
|
-
ui.divH([
|
|
211
|
-
ui.div(['Deuteranomaly ('+contrast(deuteranomaly, textColor).toFixed(2)+')'],{style:{margin:'0 10px'}}),
|
|
212
|
-
],{style:{minWidth:'200px',color:'rgb('+textColor+')',alignItems:'center',padding:'5px 0', backgroundColor:'rgb('+deuteranomaly.R+','+deuteranomaly.G+','+deuteranomaly.B+')'}}),
|
|
213
|
-
ui.divH([
|
|
214
|
-
ui.div(['Achromatopsia ('+contrast(achromatopsia, textColor).toFixed(2)+')'],{style:{margin:'0 10px'}}),
|
|
215
|
-
],{style:{minWidth:'200px',color:'rgb('+textColor+')',alignItems:'center',padding:'5px 0', backgroundColor:'rgb('+achromatopsia.R+','+achromatopsia.G+','+achromatopsia.B+')'}}),
|
|
216
|
-
ui.divH([
|
|
217
|
-
ui.div(['Achromatomaly ('+contrast(achromatomaly, textColor).toFixed(2)+')'],{style:{margin:'0 10px'}}),
|
|
218
|
-
],{style:{minWidth:'200px',color:'rgb('+textColor+')',alignItems:'center',padding:'5px 0', backgroundColor:'rgb('+achromatomaly.R+','+achromatomaly.G+','+achromatomaly.B+')'}}),
|
|
219
|
-
);
|
|
220
|
-
|
|
221
|
-
saveBox.append(ui.bigButton('Save color',()=>{
|
|
222
|
-
let color = ui.divH([
|
|
223
|
-
ui.div(['#'+colorHex.value],{style:{marginLeft:'10px'}}),
|
|
224
|
-
ui.div([ratio+' - '+flag],{style:{margin:'0 20px'}}),
|
|
225
|
-
],{style:{alignItems:'center', minWidth:'200px', padding:'5px 0', backgroundColor:'#'+colorHex.value}});
|
|
226
|
-
$(color).attr('data-id',colorHex.value);
|
|
227
|
-
$(color).css('color','rgb('+textColor+')');
|
|
228
|
-
|
|
229
|
-
palette.append(ui.divH([
|
|
230
|
-
color,
|
|
231
|
-
ui.button(ui.iconFA('copy'),()=>{
|
|
232
|
-
copyToClipboard($(color).children().first().text().substring(1));
|
|
233
|
-
grok.shell.info($(color).children().first().text().substring(1));
|
|
234
|
-
}),
|
|
235
|
-
ui.button(ui.iconFA('trash-alt'),()=>{
|
|
236
|
-
$(color).parent().detach();
|
|
237
|
-
})
|
|
238
|
-
]))
|
|
239
|
-
}))
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
//color converting
|
|
243
|
-
function hexToRGB(h) {
|
|
244
|
-
let aRgbHex = [];
|
|
245
|
-
if (h.length==3){
|
|
246
|
-
aRgbHex = h.match(/.{1,1}/g);
|
|
247
|
-
aRgbHex[0] = aRgbHex[0].toString().repeat(2);
|
|
248
|
-
aRgbHex[1] = aRgbHex[1].toString().repeat(2);
|
|
249
|
-
aRgbHex[2] = aRgbHex[2].toString().repeat(2);
|
|
250
|
-
}
|
|
251
|
-
else if (h.length==6)
|
|
252
|
-
aRgbHex = h.match(/.{1,2}/g);
|
|
253
|
-
var aRgb = {
|
|
254
|
-
'R': parseInt(aRgbHex[0], 16),
|
|
255
|
-
'G': parseInt(aRgbHex[1], 16),
|
|
256
|
-
'B': parseInt(aRgbHex[2], 16)
|
|
257
|
-
};
|
|
258
|
-
return aRgb
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
function rgbToHex(color) {
|
|
262
|
-
let rgb = color.split(',')
|
|
263
|
-
let hex = parseInt(rgb[0]).toString(16) + parseInt(rgb[1]).toString(16) + parseInt(rgb[2]).toString(16);
|
|
264
|
-
return hex
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
//colorbalance
|
|
268
|
-
function colorBalance(Color){
|
|
269
|
-
let luma = ((0.299 * Color.R) + (0.587 * Color.G) + (0.114 * Color.B)) / 255;
|
|
270
|
-
return luma > 0.5 ? 'black' : 'white';
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
//copy to clipboard
|
|
274
|
-
function copyToClipboard(text) {
|
|
275
|
-
var dummy = document.createElement("textarea");
|
|
276
|
-
document.body.appendChild(dummy);
|
|
277
|
-
dummy.value = text;
|
|
278
|
-
dummy.select();
|
|
279
|
-
document.execCommand("copy");
|
|
280
|
-
document.body.removeChild(dummy);
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
//Contrast ratio
|
|
284
|
-
function luminance(r, g, b) {
|
|
285
|
-
var a = [r, g, b].map(function (v) {
|
|
286
|
-
v /= 255;
|
|
287
|
-
return v <= 0.03928
|
|
288
|
-
? v / 12.92
|
|
289
|
-
: Math.pow( (v + 0.055) / 1.055, 2.4 );
|
|
290
|
-
});
|
|
291
|
-
return a[0] * 0.2126 + a[1] * 0.7152 + a[2] * 0.0722;
|
|
292
|
-
}
|
|
293
|
-
function contrast(rgbBg, rgbText) {
|
|
294
|
-
var lum1 = luminance(rgbBg.R, rgbBg.G, rgbBg.B);
|
|
295
|
-
var lum2 = luminance(rgbText[0], rgbText[1], rgbText[2]);
|
|
296
|
-
var brightest = Math.max(lum1, lum2);
|
|
297
|
-
var darkest = Math.min(lum1, lum2);
|
|
298
|
-
return (brightest + 0.05)
|
|
299
|
-
/ (darkest + 0.05);
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
//*****************
|
|
303
|
-
function ColorMatrix(o,m) { // takes: RGBA object, Matrix array
|
|
304
|
-
|
|
305
|
-
function fu(n) { return(n<0?0:(n<255?n:255)); }
|
|
306
|
-
|
|
307
|
-
var r=((o.R*m[0])+(o.G*m[1])+(o.B*m[2])+(o.A*m[3])+m[4]);
|
|
308
|
-
var g=((o.R*m[5])+(o.G*m[6])+(o.B*m[7])+(o.A*m[8])+m[9]);
|
|
309
|
-
var b=((o.R*m[10])+(o.G*m[11])+(o.B*m[12])+(o.A*m[13])+m[14]);
|
|
310
|
-
var a=((o.R*m[15])+(o.G*m[16])+(o.B*m[17])+(o.A*m[18])+m[19]);
|
|
311
|
-
|
|
312
|
-
return({'R':fu(r), 'G':fu(g), 'B':fu(b), 'A':fu(a)});
|
|
313
|
-
|
|
314
|
-
};
|
|
315
|
-
|
|
316
|
-
function Blind (v) { // this function just returns the Matrix
|
|
317
|
-
|
|
318
|
-
return({'Normal':[1,0,0,0,0, 0,1,0,0,0, 0,0,1,0,0, 0,0,0,1,0, 0,0,0,0,1],
|
|
319
|
-
'Protanopia':[0.567,0.433,0,0,0, 0.558,0.442,0,0,0, 0,0.242,0.758,0,0, 0,0,0,1,0, 0,0,0,0,1],
|
|
320
|
-
'Protanomaly':[0.817,0.183,0,0,0, 0.333,0.667,0,0,0, 0,0.125,0.875,0,0, 0,0,0,1,0, 0,0,0,0,1],
|
|
321
|
-
'Deuteranopia':[0.625,0.375,0,0,0, 0.7,0.3,0,0,0, 0,0.3,0.7,0,0, 0,0,0,1,0, 0,0,0,0,1],
|
|
322
|
-
'Deuteranomaly':[0.8,0.2,0,0,0, 0.258,0.742,0,0,0, 0,0.142,0.858,0,0, 0,0,0,1,0, 0,0,0,0,1],
|
|
323
|
-
'Tritanopia':[0.95,0.05,0,0,0, 0,0.433,0.567,0,0, 0,0.475,0.525,0,0, 0,0,0,1,0, 0,0,0,0,1],
|
|
324
|
-
'Tritanomaly':[0.967,0.033,0,0,0, 0,0.733,0.267,0,0, 0,0.183,0.817,0,0, 0,0,0,1,0, 0,0,0,0,1],
|
|
325
|
-
'Achromatopsia':[0.299,0.587,0.114,0,0, 0.299,0.587,0.114,0,0, 0.299,0.587,0.114,0,0, 0,0,0,1,0, 0,0,0,0,1],
|
|
326
|
-
'Achromatomaly':[0.618,0.320,0.062,0,0, 0.163,0.775,0.062,0,0, 0.163,0.320,0.516,0,0,0,0,0,1,0,0,0,0,0]}[v]);
|
|
327
|
-
|
|
328
|
-
};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
// Panels
|
|
2
|
-
|
|
3
|
-
let v = grok.shell.newView('Tabs');
|
|
4
|
-
|
|
5
|
-
// Simple API
|
|
6
|
-
v.append(ui.div([
|
|
7
|
-
ui.h1('First panel'),
|
|
8
|
-
'Panel content'
|
|
9
|
-
]));
|
|
10
|
-
|
|
11
|
-
v.append(ui.div([
|
|
12
|
-
ui.h1('Second panel'),
|
|
13
|
-
ui.inputs([
|
|
14
|
-
ui.stringInput('Name', 5),
|
|
15
|
-
ui.choiceInput('Algorithm', 'SPE', ['SPE', 'PCA']),
|
|
16
|
-
ui.intInput('Number of steps', 5)
|
|
17
|
-
]),
|
|
18
|
-
ui.bigButton('RUN')
|
|
19
|
-
]));
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
// Creating HTML-driven tables
|
|
2
|
-
// For high-performance grid, check out samples under /grid
|
|
3
|
-
|
|
4
|
-
grok.shell.newView('table from map', [
|
|
5
|
-
ui.tableFromMap({
|
|
6
|
-
user: grok.shell.user.toMarkup(),
|
|
7
|
-
project: grok.shell.project.toMarkup(),
|
|
8
|
-
time: new Date(),
|
|
9
|
-
})
|
|
10
|
-
]);
|
|
11
|
-
|
|
12
|
-
let view = grok.shell.newView('table with renderer');
|
|
13
|
-
var myList = [
|
|
14
|
-
{key: 'first object', value: 5},
|
|
15
|
-
{key: 'second object', value: false},
|
|
16
|
-
{key: 'third object', value: false},
|
|
17
|
-
];
|
|
18
|
-
|
|
19
|
-
let table = DG.HtmlTable.create(myList, (item, idx) => [item.key, item.value]);
|
|
20
|
-
|
|
21
|
-
//and let's remove the third object from the table
|
|
22
|
-
table.remove(myList[2]);
|
|
23
|
-
|
|
24
|
-
view.root.appendChild(table.root);
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
// Different input types
|
|
2
|
-
|
|
3
|
-
// Adding an icon to each input that lets you inspect the value
|
|
4
|
-
// grok.events.onInputCreated.subscribe(
|
|
5
|
-
// (i) => i.root.appendChild(ui.iconFA('eye', () => grok.shell.o = i.value)));
|
|
6
|
-
|
|
7
|
-
// Different input types
|
|
8
|
-
|
|
9
|
-
// Adding an icon to each input that lets you inspect the value
|
|
10
|
-
// grok.events.onInputCreated.subscribe(
|
|
11
|
-
// (i) => i.root.appendChild(ui.iconFA('eye', () => grok.shell.o = i.value)));
|
|
12
|
-
|
|
13
|
-
let v = grok.shell.newView('demo: inputs');
|
|
14
|
-
|
|
15
|
-
let type = ui.choiceInput('Form type', 'Default', ['Default', 'Left', 'Wide', 'Condensed'], (x)=>{
|
|
16
|
-
switch (x){
|
|
17
|
-
case 'Default':
|
|
18
|
-
form.className = 'ui-form';
|
|
19
|
-
break;
|
|
20
|
-
case 'Left':
|
|
21
|
-
form.className = 'ui-form ui-form-left';
|
|
22
|
-
break;
|
|
23
|
-
case 'Wide':
|
|
24
|
-
form.className = 'ui-form ui-form-wide';
|
|
25
|
-
break;
|
|
26
|
-
case 'Condensed':
|
|
27
|
-
form.className = 'ui-form ui-form-condensed';
|
|
28
|
-
break;
|
|
29
|
-
default: form.className = '.ui-form';
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
let name = ui.stringInput('Name', 'Arthur Dent');
|
|
34
|
-
let age = ui.intInput('Age', 30);
|
|
35
|
-
let date = ui.dateInput('Birthday', dayjs('1970-5-10'));
|
|
36
|
-
let alien = ui.boolInput('Alien', false);
|
|
37
|
-
let friends = ui.multiChoiceInput('Friends', ['Ford', 'Fenchurch'], ['Ford', 'Fenchurch', 'Zaphod', 'Slartibartfast']);
|
|
38
|
-
let active = ui.switchInput('Active', true);
|
|
39
|
-
let color = ui.colorInput('Favorite color', '#ff0000');
|
|
40
|
-
let data = ui.tableInput('Details', null);
|
|
41
|
-
let memo = ui.textInput('Memo', '');
|
|
42
|
-
|
|
43
|
-
let form = ui.form([type, name, age, date, alien, friends, active, color, data, memo]);
|
|
44
|
-
|
|
45
|
-
form.append(ui.buttonsInput([ui.bigButton('Submit', ()=>{grok.shell.info(form.className)})]));
|
|
46
|
-
v.append(form);
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
//Layout: 2 Column
|
|
2
|
-
|
|
3
|
-
let windows = grok.shell.windows;
|
|
4
|
-
windows.showToolbox = false; //*hide tool box
|
|
5
|
-
windows.showProperties = false; //*hide property panel
|
|
6
|
-
|
|
7
|
-
let view = grok.shell.newView('2 Column', [
|
|
8
|
-
ui.block25(['Column 1 (25%)']),
|
|
9
|
-
ui.block75(['Column 2 (75%)']),
|
|
10
|
-
],'layout');
|
|
11
|
-
|
|
12
|
-
view.box = true;
|
|
13
|
-
|
|
14
|
-
$('.layout div').css('border','1px dashed var(--grey-2)');
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
//Layout: 3 Column
|
|
2
|
-
|
|
3
|
-
let windows = grok.shell.windows;
|
|
4
|
-
windows.showToolbox = false; //*hide tool box
|
|
5
|
-
windows.showProperties = false; //*hide property panel
|
|
6
|
-
|
|
7
|
-
let view = grok.shell.newView('3 Column', [
|
|
8
|
-
ui.block50(['Column 1']),
|
|
9
|
-
ui.block(['Column 2']),
|
|
10
|
-
ui.block(['Column 3'])
|
|
11
|
-
],'layout');
|
|
12
|
-
|
|
13
|
-
view.box = true;
|
|
14
|
-
|
|
15
|
-
$('.layout div').css('border','1px dashed var(--grey-2)');
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
//Layout: Flex box
|
|
2
|
-
|
|
3
|
-
let windows = grok.shell.windows;
|
|
4
|
-
windows.showToolbox = false; //*hide tool box
|
|
5
|
-
windows.showProperties = false; //*hide property panel
|
|
6
|
-
|
|
7
|
-
let view = grok.shell.newView('Flex box', [
|
|
8
|
-
ui.divV([
|
|
9
|
-
ui.divH([ui.divText('item 1'), ui.divText('item 2')]),
|
|
10
|
-
ui.divH([ui.divText('item 3'), ui.divText('item 4'),ui.divText('item 5')]),
|
|
11
|
-
ui.divH([ui.divText('item 6'), ui.divText('item 7'),ui.divText('item 8'), ui.divText('item 9')]),
|
|
12
|
-
]),
|
|
13
|
-
],'layout');
|
|
14
|
-
|
|
15
|
-
$('.layout div:not(.d4-flex-col)').css('border','1px dashed var(--grey-2)');
|
|
16
|
-
$('.layout div:not(.d4-flex-col)').css('padding','10px');
|