dwv 0.37.0-beta.8 → 0.37.0
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/dist/assets/workers/jpeg2000.worker.min.js +1 -1
- package/dist/assets/workers/jpeg2000.worker.min.js.map +1 -1
- package/dist/assets/workers/jpegbaseline.worker.min.js +1 -1
- package/dist/assets/workers/jpegbaseline.worker.min.js.map +1 -1
- package/dist/assets/workers/jpegloss.worker.min.js +1 -1
- package/dist/assets/workers/jpegloss.worker.min.js.map +1 -1
- package/dist/assets/workers/labeling.worker.min.js +1 -1
- package/dist/assets/workers/labeling.worker.min.js.map +1 -1
- package/dist/assets/workers/resampling.worker.min.js +1 -1
- package/dist/assets/workers/resampling.worker.min.js.map +1 -1
- package/dist/assets/workers/rle.worker.min.js +1 -1
- package/dist/assets/workers/rle.worker.min.js.map +1 -1
- package/dist/dwv.d.ts +1333 -314
- package/dist/dwv.min.js +1 -1
- package/dist/dwv.min.js.map +1 -1
- package/dist/dwv.node.min.js +1 -1
- package/dist/dwv.node.min.js.map +1 -1
- package/package.json +21 -23
- package/readme.md +7 -3
- package/dev/bench/bench.html +0 -94
- package/dev/bench/bench.js +0 -316
- package/dev/bench/benchFunctionRunner.js +0 -83
- package/dev/bench/dataRunner.js +0 -171
- package/dev/bench/gui.js +0 -184
- package/dev/bench/listen.js +0 -70
- package/dev/bench/parsers/dwv-current.html +0 -45
- package/dev/bench/parsers/dwv-previous.html +0 -45
- package/dev/dicom/binaryPixGenerator.js +0 -108
- package/dev/dicom/dicomGenerator.js +0 -215
- package/dev/dicom/filePixGenerator.js +0 -96
- package/dev/dicom/gradSquarePixGenerator.js +0 -107
- package/dev/dicom/mprPixGenerator.js +0 -247
- package/dev/dicom/pages/anonymiser.html +0 -86
- package/dev/dicom/pages/anonymiser.js +0 -154
- package/dev/dicom/pages/diff.html +0 -34
- package/dev/dicom/pages/diff.js +0 -97
- package/dev/dicom/pages/generator.html +0 -92
- package/dev/dicom/pages/generator.js +0 -329
- package/dev/dicom/pages/synthetic-data.html +0 -19
- package/dev/dicom/pages/synthetic-data.js +0 -164
- package/dev/dicom/squarePixGenerator.js +0 -233
- package/dev/favicon.ico +0 -0
- package/dev/image/pages/colourmaps.html +0 -16
- package/dev/image/pages/colourmaps.js +0 -65
- package/dev/index.html +0 -38
- package/dev/pacs/dcmweb.html +0 -80
- package/dev/pacs/dcmweb.js +0 -577
- package/dev/pacs/images/acute_leukemia.png +0 -0
- package/dev/pacs/images/babymri-dcmdir.png +0 -0
- package/dev/pacs/images/babymri-rect.png +0 -0
- package/dev/pacs/images/babymri-zip.png +0 -0
- package/dev/pacs/images/babymri.png +0 -0
- package/dev/pacs/images/brainmri-png.png +0 -0
- package/dev/pacs/images/brainpet-jpg.png +0 -0
- package/dev/pacs/images/cerebrix.png +0 -0
- package/dev/pacs/images/goudurix.png +0 -0
- package/dev/pacs/images/multiframe-test1.png +0 -0
- package/dev/pacs/images/toutatix.png +0 -0
- package/dev/pacs/images/us.png +0 -0
- package/dev/pacs/index.html +0 -97
- package/dev/pacs/index.js +0 -287
- package/dev/pacs/overlays.js +0 -51
- package/dev/pacs/viewer.html +0 -401
- package/dev/pacs/viewer.js +0 -1275
- package/dev/pacs/viewer.rendertest.js +0 -96
- package/dev/pacs/viewer.ui.annot.js +0 -607
- package/dev/pacs/viewer.ui.brush.js +0 -181
- package/dev/pacs/viewer.ui.datatable.js +0 -674
- package/dev/pacs/viewer.ui.draw.js +0 -141
- package/dev/pacs/viewer.ui.icons.js +0 -88
- package/dev/pacs/viewer.ui.js +0 -198
- package/dev/pacs/viewer.ui.segment.js +0 -1369
- package/dev/visual/appgui.js +0 -125
- package/dev/visual/images/dicompyler-ct.0.jpg +0 -0
- package/dev/visual/images/gdcm-CR-MONO1-10-chest.jpg +0 -0
- package/dev/visual/images/gdcm-CT-MONO2-8-abdo.jpg +0 -0
- package/dev/visual/images/gdcm-US-RGB-8-epicard.jpg +0 -0
- package/dev/visual/images/gdcm-US-RGB-8-esopecho.jpg +0 -0
- package/dev/visual/images/leadtools-8BitsJpegLossyGrayScale.jpg +0 -0
- package/dev/visual/images/leadtools-flowers-16-mono2-rle.jpg +0 -0
- package/dev/visual/images/leadtools-flowers-8-mono2-rle.jpg +0 -0
- package/dev/visual/images/nema-ct1_j2ki.jpg +0 -0
- package/dev/visual/images/nema-ct1_jpll.jpg +0 -0
- package/dev/visual/images/nema-mr1_jply.jpg +0 -0
- package/dev/visual/images/nema-nm1_j2kr.jpg +0 -0
- package/dev/visual/images/nema-nm1_jpll.jpg +0 -0
- package/dev/visual/images/nema-nm1_jply.jpg +0 -0
- package/dev/visual/images/nema-us1_j2ki.jpg +0 -0
- package/dev/visual/images/nema-vl2_j2kr.jpg +0 -0
- package/dev/visual/images/osirix-cerebrix.jpg +0 -0
- package/dev/visual/images/osirix-goudurix.jpg +0 -0
- package/dev/visual/images/osirix-toutatix-100.jpg +0 -0
- package/dev/visual/index-jpeg.js +0 -104
- package/dev/visual/index-jpeg2000.js +0 -103
- package/dev/visual/index-rle.js +0 -70
- package/dev/visual/index.html +0 -20
- package/dev/visual/index.js +0 -123
- package/dev/visual/style.css +0 -37
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
import {DicomCode} from '../../src/dicom/dicomCode.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* @import {App} from '../../src/app/application.js';
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Draw tool UI.
|
|
9
|
-
*/
|
|
10
|
-
export class DrawToolUI {
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* The associated application.
|
|
14
|
-
*
|
|
15
|
-
* @type {App}
|
|
16
|
-
*/
|
|
17
|
-
#app;
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* The tool configuration.
|
|
21
|
-
*
|
|
22
|
-
* @type {object}
|
|
23
|
-
*/
|
|
24
|
-
#toolConfig;
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* @param {App} app The associated application.
|
|
28
|
-
* @param {object} toolConfig The tool configuration.
|
|
29
|
-
*/
|
|
30
|
-
constructor(app, toolConfig) {
|
|
31
|
-
this.#app = app;
|
|
32
|
-
this.#toolConfig = toolConfig;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Bind app to ui.
|
|
37
|
-
*/
|
|
38
|
-
registerListeners() {};
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Get the value of the tool UI.
|
|
42
|
-
*
|
|
43
|
-
* @returns {object|undefined} The value.
|
|
44
|
-
*/
|
|
45
|
-
getValue() {
|
|
46
|
-
const shapeSelect = document.getElementById('draw-shape-select');
|
|
47
|
-
// example annotation meta data added at draw time
|
|
48
|
-
// (not sure of the concept-value association)
|
|
49
|
-
const concept0 = new DicomCode('Processing type');
|
|
50
|
-
concept0.schemeDesignator = 'DCM';
|
|
51
|
-
concept0.value = '111701';
|
|
52
|
-
const value0 = new DicomCode('Manual Processing');
|
|
53
|
-
value0.schemeDesignator = 'DCM';
|
|
54
|
-
value0.value = '123109';
|
|
55
|
-
// example draw meta validator
|
|
56
|
-
const drawMetaValidator = function (/*meta*/) {
|
|
57
|
-
//return meta.StationName === 'web browser';
|
|
58
|
-
return true;
|
|
59
|
-
};
|
|
60
|
-
// example ref meta validator
|
|
61
|
-
const refMetaValidator = function (/*meta*/) {
|
|
62
|
-
//return meta.Modality === 'CT';
|
|
63
|
-
return true;
|
|
64
|
-
};
|
|
65
|
-
return {
|
|
66
|
-
shapeName: shapeSelect.value,
|
|
67
|
-
annotationMeta: [
|
|
68
|
-
{concept: concept0, value: value0}
|
|
69
|
-
],
|
|
70
|
-
annotationGroupMeta: [
|
|
71
|
-
// {concept: 'StationName', value: 'web browser'}
|
|
72
|
-
],
|
|
73
|
-
drawMetaValidator,
|
|
74
|
-
refMetaValidator
|
|
75
|
-
};
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Get the HTML element of the tool UI.
|
|
80
|
-
*
|
|
81
|
-
* @returns {HTMLElement|undefined} The element.
|
|
82
|
-
*/
|
|
83
|
-
getHtml() {
|
|
84
|
-
const shapeSelect = document.createElement('select');
|
|
85
|
-
shapeSelect.id = 'draw-shape-select';
|
|
86
|
-
|
|
87
|
-
const shapeNames = this.#toolConfig.options;
|
|
88
|
-
if (typeof shapeNames === 'undefined') {
|
|
89
|
-
return;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
for (const shapeName of shapeNames) {
|
|
93
|
-
const opt = document.createElement('option');
|
|
94
|
-
opt.id = `shape-${shapeName}`;
|
|
95
|
-
opt.value = shapeName;
|
|
96
|
-
opt.appendChild(document.createTextNode(shapeName));
|
|
97
|
-
shapeSelect.appendChild(opt);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
shapeSelect.onchange = (event) => {
|
|
101
|
-
const element = event.target;
|
|
102
|
-
this.#app.setToolFeatures({shapeName: element.value});
|
|
103
|
-
};
|
|
104
|
-
|
|
105
|
-
const autoColourInput = document.createElement('input');
|
|
106
|
-
autoColourInput.type = 'checkbox';
|
|
107
|
-
autoColourInput.id = 'draw-auto-colour';
|
|
108
|
-
autoColourInput.checked = false;
|
|
109
|
-
|
|
110
|
-
const autoLabel = document.createElement('label');
|
|
111
|
-
autoLabel.htmlFor = autoColourInput.id;
|
|
112
|
-
autoLabel.appendChild(document.createTextNode('auto colour'));
|
|
113
|
-
|
|
114
|
-
const colourInput = document.createElement('input');
|
|
115
|
-
colourInput.type = 'color';
|
|
116
|
-
colourInput.id = 'draw-colour-chooser';
|
|
117
|
-
colourInput.value = '#ffff80';
|
|
118
|
-
|
|
119
|
-
autoColourInput.onchange = (event) => {
|
|
120
|
-
const element = event.target;
|
|
121
|
-
this.#app.setToolFeatures({autoShapeColour: element.checked});
|
|
122
|
-
colourInput.disabled = element.checked;
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
colourInput.onchange = (event) => {
|
|
126
|
-
const element = event.target;
|
|
127
|
-
this.#app.setToolFeatures({shapeColour: element.value});
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
const res = document.createElement('span');
|
|
131
|
-
res.id = 'toolFeatures';
|
|
132
|
-
res.className = 'toolFeatures';
|
|
133
|
-
res.appendChild(shapeSelect);
|
|
134
|
-
res.appendChild(autoColourInput);
|
|
135
|
-
res.appendChild(autoLabel);
|
|
136
|
-
res.appendChild(colourInput);
|
|
137
|
-
|
|
138
|
-
return res;
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
}; // DrawToolUI
|
|
@@ -1,88 +0,0 @@
|
|
|
1
|
-
// list of icons as emoji
|
|
2
|
-
const icons = {
|
|
3
|
-
// plus
|
|
4
|
-
add: '\u2795',
|
|
5
|
-
// floppy
|
|
6
|
-
save: '\u{1F4BE}',
|
|
7
|
-
// eye
|
|
8
|
-
view: '\u{1F441}\u{FE0F}',
|
|
9
|
-
// cross
|
|
10
|
-
delete: '\u{274C}',
|
|
11
|
-
// label
|
|
12
|
-
label: '\u{1F3F7}\u{FE0F}',
|
|
13
|
-
// lock
|
|
14
|
-
lock: '\u{1F512}',
|
|
15
|
-
// information
|
|
16
|
-
info: '\u{2139}',
|
|
17
|
-
|
|
18
|
-
// north east arrow
|
|
19
|
-
arrow: '\u{2197}',
|
|
20
|
-
// straight ruler
|
|
21
|
-
ruler: '\u{1F4CF}',
|
|
22
|
-
// black large square
|
|
23
|
-
rectangle: '\u{2B1B}',
|
|
24
|
-
// medium black circle
|
|
25
|
-
circle: '\u{26AB}',
|
|
26
|
-
// rugby footbal
|
|
27
|
-
ellipse: '\u{1F3C9}',
|
|
28
|
-
// triangular ruler
|
|
29
|
-
protractor: '\u{1F4D0}',
|
|
30
|
-
// wavy dash
|
|
31
|
-
roi: '\u{3030}',
|
|
32
|
-
//FALLING DIAGONAL CROSSING NORTH EAST ARROW
|
|
33
|
-
bidimensional: '\u{292F}',
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Get an HTML element representing the input concept.
|
|
38
|
-
*
|
|
39
|
-
* @param {string} name The concept.
|
|
40
|
-
* @returns {HTMLElement} The element.
|
|
41
|
-
*/
|
|
42
|
-
export function getIconElement(name) {
|
|
43
|
-
let text = icons[name.toLowerCase()];
|
|
44
|
-
if (typeof text === 'undefined') {
|
|
45
|
-
text = name;
|
|
46
|
-
}
|
|
47
|
-
return document.createTextNode(text);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Get a button for a given name.
|
|
52
|
-
*
|
|
53
|
-
* @param {string} name The name of the button.
|
|
54
|
-
* @returns {HTMLButtonElement} The button element.
|
|
55
|
-
*/
|
|
56
|
-
export function getButton(name) {
|
|
57
|
-
const button = document.createElement('button');
|
|
58
|
-
button.title = name;
|
|
59
|
-
button.name = name;
|
|
60
|
-
button.appendChild(getIconElement(name));
|
|
61
|
-
return button;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Set a button as pressed or not.
|
|
66
|
-
*
|
|
67
|
-
* @param {HTMLButtonElement} button The button to set state.
|
|
68
|
-
* @param {boolean} state True to set as pressed.
|
|
69
|
-
*/
|
|
70
|
-
export function setButtonPressed(button, state) {
|
|
71
|
-
if (state) {
|
|
72
|
-
button.value = '1';
|
|
73
|
-
button.style.borderStyle = 'inset';
|
|
74
|
-
} else {
|
|
75
|
-
button.value = '0';
|
|
76
|
-
button.style.borderStyle = 'outset';
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Get a button pressed state.
|
|
82
|
-
*
|
|
83
|
-
* @param {HTMLButtonElement} button The button to get state.
|
|
84
|
-
* @returns {boolean} True if pressed.
|
|
85
|
-
*/
|
|
86
|
-
export function isButtonPressed(button) {
|
|
87
|
-
return button.value === '1';
|
|
88
|
-
}
|
package/dev/pacs/viewer.ui.js
DELETED
|
@@ -1,198 +0,0 @@
|
|
|
1
|
-
import {ViewConfig} from '../../src/app/application.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Layout protocol class.
|
|
5
|
-
*/
|
|
6
|
-
export class LayoutProtocol {
|
|
7
|
-
/**
|
|
8
|
-
* @type {string}
|
|
9
|
-
*/
|
|
10
|
-
#id;
|
|
11
|
-
/**
|
|
12
|
-
* @type {object[]}
|
|
13
|
-
*/
|
|
14
|
-
#displaySets;
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* @param {object} config As
|
|
18
|
-
* {id, displaySets: [{divId, dataSelector, orientation}]}.
|
|
19
|
-
*/
|
|
20
|
-
constructor(config) {
|
|
21
|
-
this.#id = config.id;
|
|
22
|
-
this.#displaySets = config.displaySets;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Get the layout id.
|
|
27
|
-
*
|
|
28
|
-
* @returns {string} The id.
|
|
29
|
-
*/
|
|
30
|
-
getId() {
|
|
31
|
-
return this.#id;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Get the layer groups div ids from this layout.
|
|
36
|
-
*
|
|
37
|
-
* @returns {string[]} The ids.
|
|
38
|
-
*/
|
|
39
|
-
getLayerGroupDivIds() {
|
|
40
|
-
const ids = [];
|
|
41
|
-
for (const set of this.#displaySets) {
|
|
42
|
-
const id = set.divId;
|
|
43
|
-
if (!ids.includes(id)) {
|
|
44
|
-
ids.push(id);
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
return ids;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* Convert a display set into a view config.
|
|
52
|
-
*
|
|
53
|
-
* @param {object} set The display set.
|
|
54
|
-
* @returns {ViewConfig} The view config.
|
|
55
|
-
*/
|
|
56
|
-
#displaySetToViewConfig(set) {
|
|
57
|
-
const config = new ViewConfig(set.divId);
|
|
58
|
-
config.orientation = set.orientation;
|
|
59
|
-
return config;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Get the first view config for the given div id.
|
|
63
|
-
*
|
|
64
|
-
* @param {string} divId The div id.
|
|
65
|
-
* @returns {ViewConfig} The config.
|
|
66
|
-
*/
|
|
67
|
-
getViewConfigsByDivId(divId) {
|
|
68
|
-
const set = this.#displaySets.find((elem) => elem.divId === divId);
|
|
69
|
-
return this.#displaySetToViewConfig(set);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Get the view configs for the given data id.
|
|
74
|
-
*
|
|
75
|
-
* @param {string} dataId The data id.
|
|
76
|
-
* @returns {ViewConfig[]} The view configs.
|
|
77
|
-
*/
|
|
78
|
-
getViewConfigsByDataId(dataId) {
|
|
79
|
-
const sets =
|
|
80
|
-
this.#displaySets.filter((elem) => elem.dataSelector(dataId));
|
|
81
|
-
if (sets.length === 0) {
|
|
82
|
-
console.warn(`Data not selected for display: ${dataId}`);
|
|
83
|
-
}
|
|
84
|
-
const res = [];
|
|
85
|
-
for (const set of sets) {
|
|
86
|
-
res.push(this.#displaySetToViewConfig(set));
|
|
87
|
-
}
|
|
88
|
-
return res;
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Get the data view configs for the given data ids.
|
|
93
|
-
*
|
|
94
|
-
* @param {string[]} dataIds The data id.
|
|
95
|
-
* @returns {Record<string, ViewConfig[]>} The data view configs.
|
|
96
|
-
*/
|
|
97
|
-
getDataViewConfigs(dataIds) {
|
|
98
|
-
const res = {};
|
|
99
|
-
for (const dataId of dataIds) {
|
|
100
|
-
res[dataId] = this.getViewConfigsByDataId(dataId);
|
|
101
|
-
}
|
|
102
|
-
return res;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Get a HTML id from a prefix and root part.
|
|
108
|
-
*
|
|
109
|
-
* @param {string} prefix The id prefix.
|
|
110
|
-
* @param {string} root The root.
|
|
111
|
-
* @returns {string} The HTML id.
|
|
112
|
-
*/
|
|
113
|
-
export function getHtmlId(prefix, root) {
|
|
114
|
-
return prefix + root;
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* Get the root part from an HTML id.
|
|
119
|
-
*
|
|
120
|
-
* @param {string} prefix The id prefix.
|
|
121
|
-
* @param {string} htmlId The HTML id.
|
|
122
|
-
* @returns {string} The root.
|
|
123
|
-
*/
|
|
124
|
-
export function getRootFromHtmlId(prefix, htmlId) {
|
|
125
|
-
return htmlId.substring(prefix.length);
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* Get a control div: label, range and number field.
|
|
130
|
-
*
|
|
131
|
-
* @param {string} id The control id.
|
|
132
|
-
* @param {string} name The control name.
|
|
133
|
-
* @param {number} min The control minimum value.
|
|
134
|
-
* @param {number} max The control maximum value.
|
|
135
|
-
* @param {number} value The control value.
|
|
136
|
-
* @param {Function} callback The callback on control value change.
|
|
137
|
-
* @param {number} precision Number field float precision.
|
|
138
|
-
* @param {number} step The control step.
|
|
139
|
-
* @returns {HTMLDivElement} The control div.
|
|
140
|
-
*/
|
|
141
|
-
export function getControlDiv(
|
|
142
|
-
id,
|
|
143
|
-
name,
|
|
144
|
-
min,
|
|
145
|
-
max,
|
|
146
|
-
value,
|
|
147
|
-
callback,
|
|
148
|
-
precision,
|
|
149
|
-
step) {
|
|
150
|
-
const range = document.createElement('input');
|
|
151
|
-
range.id = `${id}-range`;
|
|
152
|
-
range.className = 'ctrl-range';
|
|
153
|
-
range.type = 'range';
|
|
154
|
-
range.min = min.toPrecision(precision);
|
|
155
|
-
range.max = max.toPrecision(precision);
|
|
156
|
-
if (typeof step !== 'undefined') {
|
|
157
|
-
range.step = step;
|
|
158
|
-
} else {
|
|
159
|
-
range.step = ((max - min) * 0.01).toPrecision(precision);
|
|
160
|
-
}
|
|
161
|
-
range.value = value.toString();
|
|
162
|
-
|
|
163
|
-
const label = document.createElement('label');
|
|
164
|
-
label.id = `${id}-label`;
|
|
165
|
-
label.className = 'ctrl-label';
|
|
166
|
-
label.htmlFor = range.id;
|
|
167
|
-
label.appendChild(document.createTextNode(name));
|
|
168
|
-
|
|
169
|
-
const number = document.createElement('input');
|
|
170
|
-
number.id = `${id}-number`;
|
|
171
|
-
number.className = 'ctrl-number';
|
|
172
|
-
number.type = 'number';
|
|
173
|
-
number.min = range.min;
|
|
174
|
-
number.max = range.max;
|
|
175
|
-
number.step = range.step;
|
|
176
|
-
number.value = value.toPrecision(precision);
|
|
177
|
-
|
|
178
|
-
// callback and bind range and number
|
|
179
|
-
number.oninput = function (event) {
|
|
180
|
-
const element = event.target;
|
|
181
|
-
range.value = element.value;
|
|
182
|
-
callback(element.value);
|
|
183
|
-
};
|
|
184
|
-
range.oninput = function (event) {
|
|
185
|
-
const element = event.target;
|
|
186
|
-
number.value = parseFloat(element.value).toPrecision(precision);
|
|
187
|
-
callback(element.value);
|
|
188
|
-
};
|
|
189
|
-
|
|
190
|
-
const div = document.createElement('div');
|
|
191
|
-
div.id = `${id}-ctrl`;
|
|
192
|
-
div.className = 'ctrl';
|
|
193
|
-
div.appendChild(label);
|
|
194
|
-
div.appendChild(range);
|
|
195
|
-
div.appendChild(number);
|
|
196
|
-
|
|
197
|
-
return div;
|
|
198
|
-
};
|