@decidables/detectable-elements 0.0.3
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/CHANGELOG.md +29 -0
- package/LICENSE.md +1112 -0
- package/README.md +1218 -0
- package/lib/detectableElements.esm.js +18385 -0
- package/lib/detectableElements.esm.js.map +1 -0
- package/lib/detectableElements.esm.min.js +13 -0
- package/lib/detectableElements.esm.min.js.map +1 -0
- package/lib/detectableElements.umd.js +18413 -0
- package/lib/detectableElements.umd.js.map +1 -0
- package/lib/detectableElements.umd.min.js +13 -0
- package/lib/detectableElements.umd.min.js.map +1 -0
- package/package.json +58 -0
- package/src/components/detectable-control.js +272 -0
- package/src/components/detectable-response.js +414 -0
- package/src/components/detectable-table.js +602 -0
- package/src/components/index.js +7 -0
- package/src/components/rdk-task.js +586 -0
- package/src/components/roc-space.js +1220 -0
- package/src/components/sdt-model.js +1835 -0
- package/src/detectable-element.js +121 -0
- package/src/equations/dc2far.js +182 -0
- package/src/equations/dc2hr.js +191 -0
- package/src/equations/facr2far.js +120 -0
- package/src/equations/hm2hr.js +121 -0
- package/src/equations/hmfacr2acc.js +161 -0
- package/src/equations/hrfar2c.js +179 -0
- package/src/equations/hrfar2d.js +162 -0
- package/src/equations/index.js +8 -0
- package/src/equations/sdt-equation.js +141 -0
- package/src/examples/double-interactive.js +171 -0
- package/src/examples/human.js +184 -0
- package/src/examples/index.js +6 -0
- package/src/examples/interactive.js +131 -0
- package/src/examples/model.js +203 -0
- package/src/examples/sdt-example.js +76 -0
- package/src/examples/unequal.js +43 -0
- package/src/index.js +6 -0
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
|
|
2
|
+
import {css} from 'lit';
|
|
3
|
+
|
|
4
|
+
import DetectableElement from '../detectable-element';
|
|
5
|
+
|
|
6
|
+
/*
|
|
7
|
+
SDTEquation Base Class - Not intended for instantiation!
|
|
8
|
+
<sdt-equation>
|
|
9
|
+
*/
|
|
10
|
+
export default class SDTEquation extends DetectableElement {
|
|
11
|
+
static get properties() {
|
|
12
|
+
return {
|
|
13
|
+
numeric: {
|
|
14
|
+
attribute: 'numeric',
|
|
15
|
+
type: Boolean,
|
|
16
|
+
reflect: true,
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
constructor() {
|
|
22
|
+
super();
|
|
23
|
+
this.numeric = false;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
static get styles() {
|
|
27
|
+
return [
|
|
28
|
+
super.styles,
|
|
29
|
+
css`
|
|
30
|
+
:host {
|
|
31
|
+
display: block;
|
|
32
|
+
|
|
33
|
+
margin: 1rem;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/* Containing <div> */
|
|
37
|
+
.holder {
|
|
38
|
+
display: flex;
|
|
39
|
+
|
|
40
|
+
flex-direction: row;
|
|
41
|
+
|
|
42
|
+
justify-content: left;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/* Overall <table> */
|
|
46
|
+
.equation {
|
|
47
|
+
text-align: center;
|
|
48
|
+
|
|
49
|
+
border-collapse: collapse;
|
|
50
|
+
|
|
51
|
+
border: 0;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/* Modifies <td> */
|
|
55
|
+
.underline {
|
|
56
|
+
border-bottom: 1px solid var(---color-text);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/* Basic <span> and <var> w/modifiers */
|
|
60
|
+
span,
|
|
61
|
+
var {
|
|
62
|
+
padding: 0 0.25rem;
|
|
63
|
+
|
|
64
|
+
font-style: normal;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.tight {
|
|
68
|
+
padding: 0;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.paren {
|
|
72
|
+
font-size: 150%;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.bracket {
|
|
76
|
+
font-size: 175%;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.exp {
|
|
80
|
+
font-size: 0.75rem;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/* Input wrapping <label> */
|
|
84
|
+
decidables-spinner {
|
|
85
|
+
--decidables-spinner-input-width: 4rem;
|
|
86
|
+
|
|
87
|
+
display: inline-block;
|
|
88
|
+
|
|
89
|
+
padding: 0.125rem 0.375rem 0.375rem;
|
|
90
|
+
|
|
91
|
+
vertical-align: middle;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.bottom {
|
|
95
|
+
vertical-align: bottom;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/* Color scheme */
|
|
99
|
+
.h {
|
|
100
|
+
background: var(---color-h-light);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.m {
|
|
104
|
+
background: var(---color-m-light);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.hr {
|
|
108
|
+
background: var(---color-hr-light);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.fa {
|
|
112
|
+
background: var(---color-fa-light);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
.acc {
|
|
116
|
+
background: var(---color-acc-light);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.cr {
|
|
120
|
+
background: var(---color-cr-light);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
.far {
|
|
124
|
+
background: var(---color-far-light);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.d {
|
|
128
|
+
background: var(---color-d-light);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.c {
|
|
132
|
+
background: var(---color-c-light);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.s {
|
|
136
|
+
background: var(---color-s-light);
|
|
137
|
+
}
|
|
138
|
+
`,
|
|
139
|
+
];
|
|
140
|
+
}
|
|
141
|
+
}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
|
|
2
|
+
import SDTMath from '@decidables/detectable-math';
|
|
3
|
+
|
|
4
|
+
import SDTExample from './sdt-example';
|
|
5
|
+
|
|
6
|
+
/*
|
|
7
|
+
SDTExample_DoubleInteractive element
|
|
8
|
+
<sdt-example-interactive>
|
|
9
|
+
*/
|
|
10
|
+
export default class SDTExampleDoubleInteractive extends SDTExample {
|
|
11
|
+
firstUpdated(/* changedProperties */) {
|
|
12
|
+
this.one = {};
|
|
13
|
+
this.one.h = 95;
|
|
14
|
+
this.one.m = 5;
|
|
15
|
+
this.one.fa = 35;
|
|
16
|
+
this.one.cr = 65;
|
|
17
|
+
this.one.hr = SDTMath.hM2Hr(this.one.h, this.one.m);
|
|
18
|
+
this.one.far = SDTMath.faCr2Far(this.one.fa, this.one.cr);
|
|
19
|
+
this.one.d = SDTMath.hrFar2D(this.one.hr, this.one.far);
|
|
20
|
+
this.one.c = SDTMath.hrFar2C(this.one.hr, this.one.far);
|
|
21
|
+
|
|
22
|
+
this.two = {};
|
|
23
|
+
this.two.h = 40;
|
|
24
|
+
this.two.m = 60;
|
|
25
|
+
this.two.fa = 20;
|
|
26
|
+
this.two.cr = 80;
|
|
27
|
+
this.two.hr = SDTMath.hM2Hr(this.two.h, this.two.m);
|
|
28
|
+
this.two.far = SDTMath.faCr2Far(this.two.fa, this.two.cr);
|
|
29
|
+
this.two.d = SDTMath.hrFar2D(this.two.hr, this.two.far);
|
|
30
|
+
this.two.c = SDTMath.hrFar2C(this.two.hr, this.two.far);
|
|
31
|
+
|
|
32
|
+
this.detectableTableOne = this.querySelector('detectable-table:nth-of-type(1)');
|
|
33
|
+
this.detectableTableTwo = this.querySelector('detectable-table:nth-of-type(2)');
|
|
34
|
+
this.rocSpace = this.querySelector('roc-space');
|
|
35
|
+
this.sdtModelOne = this.querySelector('sdt-model:nth-of-type(1)');
|
|
36
|
+
this.sdtModelTwo = this.querySelector('sdt-model:nth-of-type(2)');
|
|
37
|
+
|
|
38
|
+
if (this.detectableTableOne) {
|
|
39
|
+
this.detectableTableOne.h = this.one.h;
|
|
40
|
+
this.detectableTableOne.m = this.one.m;
|
|
41
|
+
this.detectableTableOne.fa = this.one.fa;
|
|
42
|
+
this.detectableTableOne.cr = this.one.cr;
|
|
43
|
+
|
|
44
|
+
this.detectableTableOne.addEventListener('detectable-table-change', (event) => {
|
|
45
|
+
if (this.rocSpace) {
|
|
46
|
+
this.rocSpace.set(event.detail.hr, event.detail.far, 'default', '↑');
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (this.sdtModelOne) {
|
|
50
|
+
this.sdtModelOne.d = SDTMath.hrFar2D(event.detail.hr, event.detail.far);
|
|
51
|
+
this.sdtModelOne.c = SDTMath.hrFar2C(event.detail.hr, event.detail.far);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (this.detectableTableTwo) {
|
|
57
|
+
this.detectableTableTwo.h = this.two.h;
|
|
58
|
+
this.detectableTableTwo.m = this.two.m;
|
|
59
|
+
this.detectableTableTwo.fa = this.two.fa;
|
|
60
|
+
this.detectableTableTwo.cr = this.two.cr;
|
|
61
|
+
|
|
62
|
+
this.detectableTableTwo.addEventListener('detectable-table-change', (event) => {
|
|
63
|
+
if (this.rocSpace) {
|
|
64
|
+
this.rocSpace.set(event.detail.hr, event.detail.far, 'two', '↓');
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (this.sdtModelTwo) {
|
|
68
|
+
this.sdtModelTwo.d = SDTMath.hrFar2D(event.detail.hr, event.detail.far);
|
|
69
|
+
this.sdtModelTwo.c = SDTMath.hrFar2C(event.detail.hr, event.detail.far);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (this.rocSpace) {
|
|
75
|
+
this.rocSpace.set(this.one.hr, this.one.far, 'default', '↑');
|
|
76
|
+
this.rocSpace.set(this.two.hr, this.two.far, 'two', '↓');
|
|
77
|
+
|
|
78
|
+
this.rocSpace.addEventListener('roc-point-change', (event) => {
|
|
79
|
+
if (event.detail.name === 'default' && this.sdtModelOne) {
|
|
80
|
+
this.sdtModelOne.d = event.detail.d;
|
|
81
|
+
this.sdtModelOne.c = event.detail.c;
|
|
82
|
+
} else if (event.detail.name === 'two' && this.sdtModelTwo) {
|
|
83
|
+
this.sdtModelTwo.d = event.detail.d;
|
|
84
|
+
this.sdtModelTwo.c = event.detail.c;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (event.detail.name === 'default' && this.detectableTableOne) {
|
|
88
|
+
const newh = Math.round(
|
|
89
|
+
(this.detectableTableOne.h + this.detectableTableOne.m) * event.detail.hr,
|
|
90
|
+
);
|
|
91
|
+
const newm = (this.detectableTableOne.h + this.detectableTableOne.m) - newh;
|
|
92
|
+
const newfa = Math.round(
|
|
93
|
+
(this.detectableTableOne.fa + this.detectableTableOne.cr) * event.detail.far,
|
|
94
|
+
);
|
|
95
|
+
const newcr = (this.detectableTableOne.fa + this.detectableTableOne.cr) - newfa;
|
|
96
|
+
this.detectableTableOne.h = newh;
|
|
97
|
+
this.detectableTableOne.m = newm;
|
|
98
|
+
this.detectableTableOne.fa = newfa;
|
|
99
|
+
this.detectableTableOne.cr = newcr;
|
|
100
|
+
} else if (event.detail.name === 'two' && this.detectableTableTwo) {
|
|
101
|
+
const newh = Math.round(
|
|
102
|
+
(this.detectableTableTwo.h + this.detectableTableTwo.m) * event.detail.hr,
|
|
103
|
+
);
|
|
104
|
+
const newm = (this.detectableTableTwo.h + this.detectableTableTwo.m) - newh;
|
|
105
|
+
const newfa = Math.round(
|
|
106
|
+
(this.detectableTableTwo.fa + this.detectableTableTwo.cr) * event.detail.far,
|
|
107
|
+
);
|
|
108
|
+
const newcr = (this.detectableTableTwo.fa + this.detectableTableTwo.cr) - newfa;
|
|
109
|
+
this.detectableTableTwo.h = newh;
|
|
110
|
+
this.detectableTableTwo.m = newm;
|
|
111
|
+
this.detectableTableTwo.fa = newfa;
|
|
112
|
+
this.detectableTableTwo.cr = newcr;
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (this.sdtModelOne) {
|
|
118
|
+
this.sdtModelOne.d = this.one.d;
|
|
119
|
+
this.sdtModelOne.c = this.one.c;
|
|
120
|
+
|
|
121
|
+
this.sdtModelOne.addEventListener('sdt-model-change', (event) => {
|
|
122
|
+
if (this.rocSpace) {
|
|
123
|
+
this.rocSpace.setWithSDT(event.detail.d, event.detail.c, 'default', '↑');
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (this.detectableTableOne) {
|
|
127
|
+
const newh = Math.round(
|
|
128
|
+
(this.detectableTableOne.h + this.detectableTableOne.m) * event.detail.hr,
|
|
129
|
+
);
|
|
130
|
+
const newm = (this.detectableTableOne.h + this.detectableTableOne.m) - newh;
|
|
131
|
+
const newfa = Math.round(
|
|
132
|
+
(this.detectableTableOne.fa + this.detectableTableOne.cr) * event.detail.far,
|
|
133
|
+
);
|
|
134
|
+
const newcr = (this.detectableTableOne.fa + this.detectableTableOne.cr) - newfa;
|
|
135
|
+
this.detectableTableOne.h = newh;
|
|
136
|
+
this.detectableTableOne.m = newm;
|
|
137
|
+
this.detectableTableOne.fa = newfa;
|
|
138
|
+
this.detectableTableOne.cr = newcr;
|
|
139
|
+
}
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
if (this.sdtModelTwo) {
|
|
144
|
+
this.sdtModelTwo.d = this.two.d;
|
|
145
|
+
this.sdtModelTwo.c = this.two.c;
|
|
146
|
+
|
|
147
|
+
this.sdtModelTwo.addEventListener('sdt-model-change', (event) => {
|
|
148
|
+
if (this.rocSpace) {
|
|
149
|
+
this.rocSpace.setWithSDT(event.detail.d, event.detail.c, 'two', '↓');
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (this.detectableTableTwo) {
|
|
153
|
+
const newh = Math.round(
|
|
154
|
+
(this.detectableTableTwo.h + this.detectableTableTwo.m) * event.detail.hr,
|
|
155
|
+
);
|
|
156
|
+
const newm = (this.detectableTableTwo.h + this.detectableTableTwo.m) - newh;
|
|
157
|
+
const newfa = Math.round(
|
|
158
|
+
(this.detectableTableTwo.fa + this.detectableTableTwo.cr) * event.detail.far,
|
|
159
|
+
);
|
|
160
|
+
const newcr = (this.detectableTableTwo.fa + this.detectableTableTwo.cr) - newfa;
|
|
161
|
+
this.detectableTableTwo.h = newh;
|
|
162
|
+
this.detectableTableTwo.m = newm;
|
|
163
|
+
this.detectableTableTwo.fa = newfa;
|
|
164
|
+
this.detectableTableTwo.cr = newcr;
|
|
165
|
+
}
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
customElements.define('sdt-example-double-interactive', SDTExampleDoubleInteractive);
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
|
|
2
|
+
import SDTMath from '@decidables/detectable-math';
|
|
3
|
+
|
|
4
|
+
import SDTExample from './sdt-example';
|
|
5
|
+
|
|
6
|
+
/*
|
|
7
|
+
SDTExample_Human element
|
|
8
|
+
<sdt-example-human>
|
|
9
|
+
*/
|
|
10
|
+
export default class SDTExampleHuman extends SDTExample {
|
|
11
|
+
firstUpdated(/* changedProperties */) {
|
|
12
|
+
this.count = 1;
|
|
13
|
+
|
|
14
|
+
this.detectableControl = this.querySelector('detectable-control');
|
|
15
|
+
this.rdkTask = this.querySelector('rdk-task');
|
|
16
|
+
this.detectableResponse = this.querySelector('detectable-response');
|
|
17
|
+
this.detectableTable = this.querySelector('detectable-table');
|
|
18
|
+
this.rocSpace = this.querySelector('roc-space');
|
|
19
|
+
this.sdtModel = this.querySelector('sdt-model');
|
|
20
|
+
|
|
21
|
+
if (this.rocSpace) {
|
|
22
|
+
if (this.rocSpace.hasAttribute('history')) {
|
|
23
|
+
this.rocSpace.set(0.5, 0.5, 'default', this.count);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
if (this.detectableControl && this.detectableControl.hasAttribute('trials')) {
|
|
28
|
+
this.detectableControl.addEventListener('detectable-control-trials', (event) => {
|
|
29
|
+
if (this.rdkTask) {
|
|
30
|
+
this.rdkTask.trials = event.detail.trials;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
if (this.detectableResponse) {
|
|
34
|
+
this.detectableResponse.trialTotal = event.detail.trials;
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (this.detectableControl && this.detectableControl.hasAttribute('duration')) {
|
|
40
|
+
this.detectableControl.addEventListener('detectable-control-duration', (event) => {
|
|
41
|
+
if (this.rdkTask) {
|
|
42
|
+
this.rdkTask.duration = event.detail.duration;
|
|
43
|
+
this.rdkTask.wait = event.detail.duration;
|
|
44
|
+
this.rdkTask.iti = event.detail.duration;
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (this.detectableControl && this.detectableControl.hasAttribute('coherence')) {
|
|
50
|
+
this.detectableControl.addEventListener('detectable-control-coherence', (event) => {
|
|
51
|
+
if (this.rdkTask) {
|
|
52
|
+
this.rdkTask.coherence = event.detail.coherence;
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
if (this.detectableControl && this.detectableControl.hasAttribute('payoff')) {
|
|
58
|
+
this.detectableControl.addEventListener('detectable-control-payoff', (event) => {
|
|
59
|
+
if (this.detectableResponse) {
|
|
60
|
+
this.detectableResponse.hPayoff = event.detail.payoff;
|
|
61
|
+
this.detectableResponse.mPayoff = -event.detail.payoff + 0; // Get rid of -0
|
|
62
|
+
this.detectableResponse.faPayoff = -(100 - event.detail.payoff) + 0; // Get rid of -0
|
|
63
|
+
this.detectableResponse.crPayoff = (100 - event.detail.payoff);
|
|
64
|
+
}
|
|
65
|
+
if (this.detectableTable) {
|
|
66
|
+
this.detectableTable.hPayoff = event.detail.payoff;
|
|
67
|
+
this.detectableTable.mPayoff = -event.detail.payoff + 0; // Get rid of -0
|
|
68
|
+
this.detectableTable.faPayoff = -(100 - event.detail.payoff) + 0; // Get rid of -0
|
|
69
|
+
this.detectableTable.crPayoff = (100 - event.detail.payoff);
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (this.detectableControl && this.detectableControl.hasAttribute('run')) {
|
|
75
|
+
this.detectableControl.addEventListener('detectable-control-run', (/* event */) => {
|
|
76
|
+
if (this.rdkTask) {
|
|
77
|
+
this.rdkTask.running = true;
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (this.detectableControl && this.detectableControl.hasAttribute('pause')) {
|
|
83
|
+
this.detectableControl.addEventListener('detectable-control-pause', (/* event */) => {
|
|
84
|
+
if (this.rdkTask) {
|
|
85
|
+
this.rdkTask.running = false;
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
if (this.detectableControl && this.detectableControl.hasAttribute('reset')) {
|
|
91
|
+
this.detectableControl.addEventListener('detectable-control-reset', (/* event */) => {
|
|
92
|
+
if (this.rdkTask) {
|
|
93
|
+
this.rdkTask.reset();
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (this.detectableResponse) {
|
|
97
|
+
this.detectableResponse.reset();
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
if (this.detectableTable) {
|
|
101
|
+
this.detectableTable.h = 0;
|
|
102
|
+
this.detectableTable.m = 0;
|
|
103
|
+
this.detectableTable.fa = 0;
|
|
104
|
+
this.detectableTable.cr = 0;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (this.rocSpace) {
|
|
108
|
+
if (this.rocSpace.hasAttribute('history')) {
|
|
109
|
+
this.count += 1;
|
|
110
|
+
this.rocSpace.set(0.5, 0.5, `point${this.count}`, this.count);
|
|
111
|
+
} else {
|
|
112
|
+
this.rocSpace.hr = 0.5;
|
|
113
|
+
this.rocSpace.far = 0.5;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (this.sdtModel) {
|
|
118
|
+
this.sdtModel.d = 0;
|
|
119
|
+
this.sdtModel.c = 0;
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
if (this.rdkTask) {
|
|
125
|
+
if (this.detectableResponse) {
|
|
126
|
+
this.detectableResponse.trialTotal = this.rdkTask.trials;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
if (this.rdkTask) {
|
|
131
|
+
this.rdkTask.addEventListener('rdk-trial-start', (event) => {
|
|
132
|
+
if (this.detectableResponse) {
|
|
133
|
+
this.detectableResponse.start(event.detail.signal, event.detail.trial);
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
if (this.rdkTask) {
|
|
139
|
+
this.rdkTask.addEventListener('rdk-trial-end', (/* event */) => {
|
|
140
|
+
if (this.detectableResponse) {
|
|
141
|
+
this.detectableResponse.stop();
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
if (this.rdkTask) {
|
|
147
|
+
this.rdkTask.addEventListener('rdk-block-end', (/* event */) => {
|
|
148
|
+
if (this.detectableControl) {
|
|
149
|
+
this.detectableControl.complete();
|
|
150
|
+
}
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
if (this.detectableResponse) {
|
|
155
|
+
this.detectableResponse.addEventListener('detectable-response', (event) => {
|
|
156
|
+
if (this.detectableTable) {
|
|
157
|
+
this.detectableTable.h = event.detail.h;
|
|
158
|
+
this.detectableTable.m = event.detail.m;
|
|
159
|
+
this.detectableTable.fa = event.detail.fa;
|
|
160
|
+
this.detectableTable.cr = event.detail.cr;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
const newhr = SDTMath.hM2Hr((event.detail.h + 1), (event.detail.m + 1));
|
|
164
|
+
const newfar = SDTMath.faCr2Far((event.detail.fa + 1), (event.detail.cr + 1));
|
|
165
|
+
|
|
166
|
+
if (this.rocSpace) {
|
|
167
|
+
if (this.rocSpace.hasAttribute('history')) {
|
|
168
|
+
this.rocSpace.set(newhr, newfar, (this.count === 1) ? 'default' : `point${this.count}`, this.count);
|
|
169
|
+
} else {
|
|
170
|
+
this.rocSpace.hr = newhr;
|
|
171
|
+
this.rocSpace.far = newfar;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
if (this.sdtModel) {
|
|
176
|
+
this.sdtModel.d = SDTMath.hrFar2D(newhr, newfar);
|
|
177
|
+
this.sdtModel.c = SDTMath.hrFar2C(newhr, newfar);
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
customElements.define('sdt-example-human', SDTExampleHuman);
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
|
|
2
|
+
export {default as SDTExampleDoubleInteractive} from './double-interactive';
|
|
3
|
+
export {default as SDTExampleHuman} from './human';
|
|
4
|
+
export {default as SDTExampleInteractive} from './interactive';
|
|
5
|
+
export {default as SDTExampleModel} from './model';
|
|
6
|
+
export {default as SDTExampleUnequal} from './unequal';
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
|
|
2
|
+
import SDTMath from '@decidables/detectable-math';
|
|
3
|
+
|
|
4
|
+
import SDTExample from './sdt-example';
|
|
5
|
+
|
|
6
|
+
/*
|
|
7
|
+
SDTExample_Interactive element
|
|
8
|
+
<sdt-example-interactive>
|
|
9
|
+
*/
|
|
10
|
+
export default class SDTExampleInteractive extends SDTExample {
|
|
11
|
+
firstUpdated(/* changedProperties */) {
|
|
12
|
+
this.detectableControl = this.querySelector('detectable-control');
|
|
13
|
+
this.detectableTable = this.querySelector('detectable-table');
|
|
14
|
+
this.rocSpace = this.querySelector('roc-space');
|
|
15
|
+
this.sdtModel = this.querySelector('sdt-model');
|
|
16
|
+
|
|
17
|
+
this.rocSpaces = this.querySelectorAll('roc-space');
|
|
18
|
+
|
|
19
|
+
if (this.detectableControl && this.detectableControl.hasAttribute('color')) {
|
|
20
|
+
this.detectableControl.addEventListener('detectable-control-color', (event) => {
|
|
21
|
+
if (this.sdtModel) {
|
|
22
|
+
this.sdtModel.color = event.detail.color;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (this.detectableTable) {
|
|
26
|
+
this.detectableTable.color = event.detail.color;
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
if (this.detectableControl) {
|
|
32
|
+
this.detectableControl.addEventListener('detectable-control-z-roc', (event) => {
|
|
33
|
+
if (this.rocSpaces.length > 0) {
|
|
34
|
+
this.rocSpaces.forEach((rocSpace) => {
|
|
35
|
+
rocSpace.zRoc = event.detail.zRoc;
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (this.detectableTable) {
|
|
42
|
+
if (this.rocSpace) {
|
|
43
|
+
this.rocSpace.hr = SDTMath.hM2Hr(this.detectableTable.h, this.detectableTable.m);
|
|
44
|
+
this.rocSpace.far = SDTMath.faCr2Far(this.detectableTable.fa, this.detectableTable.cr);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (this.sdtModel) {
|
|
48
|
+
this.sdtModel.d = SDTMath.hrFar2D(
|
|
49
|
+
SDTMath.hM2Hr(this.detectableTable.h, this.detectableTable.m),
|
|
50
|
+
SDTMath.faCr2Far(this.detectableTable.fa, this.detectableTable.cr),
|
|
51
|
+
this.sdtModel.s,
|
|
52
|
+
);
|
|
53
|
+
this.sdtModel.c = SDTMath.hrFar2C(
|
|
54
|
+
SDTMath.hM2Hr(this.detectableTable.h, this.detectableTable.m),
|
|
55
|
+
SDTMath.faCr2Far(this.detectableTable.fa, this.detectableTable.cr),
|
|
56
|
+
this.sdtModel.s,
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
this.detectableTable.addEventListener('detectable-table-change', (event) => {
|
|
61
|
+
if (this.rocSpace) {
|
|
62
|
+
this.rocSpace.far = event.detail.far;
|
|
63
|
+
this.rocSpace.hr = event.detail.hr;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (this.sdtModel) {
|
|
67
|
+
this.sdtModel.d = SDTMath.hrFar2D(event.detail.hr, event.detail.far, this.sdtModel.s);
|
|
68
|
+
this.sdtModel.c = SDTMath.hrFar2C(event.detail.hr, event.detail.far, this.sdtModel.s);
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (this.rocSpace) {
|
|
74
|
+
if (this.sdtModel && !this.detectableTable) {
|
|
75
|
+
this.sdtModel.d = SDTMath.hrFar2D(this.rocSpace.hr, this.rocSpace.far, this.rocSpace.s);
|
|
76
|
+
this.sdtModel.c = SDTMath.hrFar2C(this.rocSpace.hr, this.rocSpace.far, this.rocSpace.s);
|
|
77
|
+
this.sdtModel.s = this.rocSpace.s;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
this.rocSpace.addEventListener('roc-point-change', (event) => {
|
|
81
|
+
if (this.sdtModel) {
|
|
82
|
+
this.sdtModel.d = event.detail.d;
|
|
83
|
+
this.sdtModel.c = event.detail.c;
|
|
84
|
+
this.sdtModel.s = event.detail.s;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
if (this.detectableTable) {
|
|
88
|
+
const newh = Math.round(
|
|
89
|
+
(this.detectableTable.h + this.detectableTable.m) * event.detail.hr,
|
|
90
|
+
);
|
|
91
|
+
const newm = (this.detectableTable.h + this.detectableTable.m) - newh;
|
|
92
|
+
const newfa = Math.round(
|
|
93
|
+
(this.detectableTable.fa + this.detectableTable.cr) * event.detail.far,
|
|
94
|
+
);
|
|
95
|
+
const newcr = (this.detectableTable.fa + this.detectableTable.cr) - newfa;
|
|
96
|
+
this.detectableTable.h = newh;
|
|
97
|
+
this.detectableTable.m = newm;
|
|
98
|
+
this.detectableTable.fa = newfa;
|
|
99
|
+
this.detectableTable.cr = newcr;
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (this.sdtModel) {
|
|
105
|
+
this.sdtModel.addEventListener('sdt-model-change', (event) => {
|
|
106
|
+
if (this.rocSpaces.length > 0) {
|
|
107
|
+
this.rocSpaces.forEach((rocSpace) => {
|
|
108
|
+
rocSpace.setWithSDT(event.detail.d, event.detail.c, 'default', '', event.detail.s);
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
if (this.detectableTable) {
|
|
113
|
+
const newh = Math.round(
|
|
114
|
+
(this.detectableTable.h + this.detectableTable.m) * event.detail.hr,
|
|
115
|
+
);
|
|
116
|
+
const newm = (this.detectableTable.h + this.detectableTable.m) - newh;
|
|
117
|
+
const newfa = Math.round(
|
|
118
|
+
(this.detectableTable.fa + this.detectableTable.cr) * event.detail.far,
|
|
119
|
+
);
|
|
120
|
+
const newcr = (this.detectableTable.fa + this.detectableTable.cr) - newfa;
|
|
121
|
+
this.detectableTable.h = newh;
|
|
122
|
+
this.detectableTable.m = newm;
|
|
123
|
+
this.detectableTable.fa = newfa;
|
|
124
|
+
this.detectableTable.cr = newcr;
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
customElements.define('sdt-example-interactive', SDTExampleInteractive);
|