@decidables/discountable-elements 0.3.9 → 0.4.1
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 +30 -0
- package/README.md +62 -5
- package/lib/discountableElements.esm.js +1336 -983
- package/lib/discountableElements.esm.js.map +1 -1
- package/lib/discountableElements.esm.min.js +233 -87
- package/lib/discountableElements.esm.min.js.map +1 -1
- package/lib/discountableElements.umd.js +1336 -982
- package/lib/discountableElements.umd.js.map +1 -1
- package/lib/discountableElements.umd.min.js +234 -88
- package/lib/discountableElements.umd.min.js.map +1 -1
- package/package.json +8 -8
- package/src/components/discountable-control.js +2 -2
- package/src/components/discountable-response.js +24 -0
- package/src/components/htd-calculation.js +44 -8
- package/src/components/htd-curves.js +179 -37
- package/src/components/htd-fit-worker.js +1 -1
- package/src/components/htd-fit.js +32 -4
- package/src/components/htd-parameters.js +112 -0
- package/src/components/index.js +1 -0
- package/src/equations/adk2v.js +30 -5
- package/src/examples/human.js +110 -64
- package/src/examples/interactive.js +18 -1
- package/src/examples/model.js +89 -65
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
|
|
2
|
+
import {html, css} from 'lit';
|
|
3
|
+
|
|
4
|
+
import '@decidables/decidables-elements/slider';
|
|
5
|
+
import HTDMath from '@decidables/discountable-math';
|
|
6
|
+
|
|
7
|
+
import DiscountableElement from '../discountable-element';
|
|
8
|
+
|
|
9
|
+
/*
|
|
10
|
+
HTDParameters element
|
|
11
|
+
<htd-paramters>
|
|
12
|
+
|
|
13
|
+
Attributes:
|
|
14
|
+
|
|
15
|
+
*/
|
|
16
|
+
export default class HTDParameters extends DiscountableElement {
|
|
17
|
+
static get properties() {
|
|
18
|
+
return {
|
|
19
|
+
k: {
|
|
20
|
+
attribute: 'k',
|
|
21
|
+
type: Number,
|
|
22
|
+
reflect: true,
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
constructor() {
|
|
28
|
+
super();
|
|
29
|
+
|
|
30
|
+
// Attributes
|
|
31
|
+
this.k = undefined;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
updated(changedProperties) {
|
|
35
|
+
super.updated(changedProperties);
|
|
36
|
+
|
|
37
|
+
if ((this.k !== undefined) && (this.kSlider === undefined)) {
|
|
38
|
+
this.kSlider = this.shadowRoot.querySelector('decidables-slider.k');
|
|
39
|
+
this.kSlider.nonlinearRange(
|
|
40
|
+
true,
|
|
41
|
+
(k) => { return k ** (1 / 2) / (k ** (1 / 2) + 1); },
|
|
42
|
+
(r) => { return (r / (1 - r)) ** 2; },
|
|
43
|
+
);
|
|
44
|
+
} else if ((this.k === undefined) && (this.kSlider !== undefined)) {
|
|
45
|
+
this.kSlider = undefined;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
setK(e) {
|
|
50
|
+
this.k = +e.target.value;
|
|
51
|
+
this.dispatchEvent(new CustomEvent('htd-parameters-k', {
|
|
52
|
+
detail: {
|
|
53
|
+
k: this.k,
|
|
54
|
+
},
|
|
55
|
+
bubbles: true,
|
|
56
|
+
}));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
static get styles() {
|
|
60
|
+
return [
|
|
61
|
+
super.styles,
|
|
62
|
+
css`
|
|
63
|
+
:host {
|
|
64
|
+
display: inline-block;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.holder {
|
|
68
|
+
display: flex;
|
|
69
|
+
|
|
70
|
+
flex-direction: row;
|
|
71
|
+
|
|
72
|
+
align-items: stretch;
|
|
73
|
+
justify-content: center;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
decidables-slider {
|
|
77
|
+
line-height: 1;
|
|
78
|
+
text-align: center;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
decidables-slider div {
|
|
82
|
+
margin-bottom: 0.25rem;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
.k {
|
|
86
|
+
--decidables-slider-background-color: var(---color-k-light);
|
|
87
|
+
--decidables-slider-color: var(---color-k);
|
|
88
|
+
}
|
|
89
|
+
`,
|
|
90
|
+
];
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
render() {
|
|
94
|
+
return html`
|
|
95
|
+
<div class="holder">
|
|
96
|
+
${this.k != null
|
|
97
|
+
? html`<decidables-slider class="k"
|
|
98
|
+
?disabled=${!this.interactive}
|
|
99
|
+
scale
|
|
100
|
+
min=${HTDMath.k.MIN}
|
|
101
|
+
max=${HTDMath.k.MAX}
|
|
102
|
+
step=${HTDMath.k.STEP}
|
|
103
|
+
.value=${+this.k.toFixed(3)}
|
|
104
|
+
@change=${this.setK.bind(this)}
|
|
105
|
+
@input=${this.setK.bind(this)}
|
|
106
|
+
><div>Discounting Factor<br><span class="math-var">k</span></div></decidables-slider>`
|
|
107
|
+
: html``}
|
|
108
|
+
</div>`;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
customElements.define('htd-parameters', HTDParameters);
|
package/src/components/index.js
CHANGED
|
@@ -4,6 +4,7 @@ export {default as DiscountableResponse} from './discountable-response';
|
|
|
4
4
|
export {default as HTDCalculation} from './htd-calculation';
|
|
5
5
|
export {default as HTDCurves} from './htd-curves';
|
|
6
6
|
export {default as HTDFit} from './htd-fit';
|
|
7
|
+
export {default as HTDParameters} from './htd-parameters';
|
|
7
8
|
export {default as ITCChoice} from './itc-choice';
|
|
8
9
|
export {default as ITCOption} from './itc-option';
|
|
9
10
|
export {default as ITCTask} from './itc-task';
|
package/src/equations/adk2v.js
CHANGED
|
@@ -42,9 +42,12 @@ export default class HTDEquationADK2V extends HTDEquation {
|
|
|
42
42
|
|
|
43
43
|
constructor() {
|
|
44
44
|
super();
|
|
45
|
+
|
|
45
46
|
this.a = 100;
|
|
46
47
|
this.d = 30;
|
|
47
|
-
|
|
48
|
+
|
|
49
|
+
this.k = HTDMath.k.DEFAULT;
|
|
50
|
+
|
|
48
51
|
this.alignState();
|
|
49
52
|
}
|
|
50
53
|
|
|
@@ -92,16 +95,38 @@ export default class HTDEquationADK2V extends HTDEquation {
|
|
|
92
95
|
let k;
|
|
93
96
|
let v;
|
|
94
97
|
if (this.numeric) {
|
|
95
|
-
a = html`<decidables-spinner class="a bottom"
|
|
98
|
+
a = html`<decidables-spinner class="a bottom"
|
|
99
|
+
?disabled=${!this.interactive}
|
|
100
|
+
step="1"
|
|
101
|
+
.value=${this.a}
|
|
102
|
+
@input=${this.aInput.bind(this)}
|
|
103
|
+
>
|
|
96
104
|
<var class="math-var">A</var>
|
|
97
105
|
</decidables-spinner>`;
|
|
98
|
-
d = html`<decidables-spinner class="d bottom"
|
|
106
|
+
d = html`<decidables-spinner class="d bottom"
|
|
107
|
+
?disabled=${!this.interactive}
|
|
108
|
+
min="0"
|
|
109
|
+
step="1"
|
|
110
|
+
.value=${this.d}
|
|
111
|
+
@input=${this.dInput.bind(this)}
|
|
112
|
+
>
|
|
99
113
|
<var class="math-var">D</var>
|
|
100
114
|
</decidables-spinner>`;
|
|
101
|
-
k = html`<decidables-spinner class="k bottom"
|
|
115
|
+
k = html`<decidables-spinner class="k bottom"
|
|
116
|
+
?disabled=${!this.interactive}
|
|
117
|
+
min=${HTDMath.k.MIN}
|
|
118
|
+
max=${HTDMath.k.MAX}
|
|
119
|
+
step=${HTDMath.k.STEP}
|
|
120
|
+
.value=${this.k}
|
|
121
|
+
@input=${this.kInput.bind(this)}
|
|
122
|
+
>
|
|
102
123
|
<var class="math-var">k</var>
|
|
103
124
|
</decidables-spinner>`;
|
|
104
|
-
v = html`<decidables-spinner class="v bottom"
|
|
125
|
+
v = html`<decidables-spinner class="v bottom"
|
|
126
|
+
disabled
|
|
127
|
+
step=".001"
|
|
128
|
+
.value=${+this.v.toFixed(3)}
|
|
129
|
+
>
|
|
105
130
|
<var class="math-var">V</var>
|
|
106
131
|
</decidables-spinner>`;
|
|
107
132
|
} else {
|
package/src/examples/human.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
|
|
2
|
+
import HTDMath from '@decidables/discountable-math';
|
|
3
3
|
|
|
4
4
|
import HTDExample from './htd-example';
|
|
5
5
|
|
|
@@ -8,6 +8,43 @@ import HTDExample from './htd-example';
|
|
|
8
8
|
<htd-example-human>
|
|
9
9
|
*/
|
|
10
10
|
export default class HTDExampleHuman extends HTDExample {
|
|
11
|
+
static get properties() {
|
|
12
|
+
return {
|
|
13
|
+
trials: {
|
|
14
|
+
attribute: 'trials',
|
|
15
|
+
type: Number,
|
|
16
|
+
reflect: true,
|
|
17
|
+
},
|
|
18
|
+
duration: {
|
|
19
|
+
attribute: 'duration',
|
|
20
|
+
type: Number,
|
|
21
|
+
reflect: true,
|
|
22
|
+
},
|
|
23
|
+
|
|
24
|
+
k: {
|
|
25
|
+
attribute: false,
|
|
26
|
+
type: Number,
|
|
27
|
+
reflect: false,
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
constructor() {
|
|
33
|
+
super();
|
|
34
|
+
|
|
35
|
+
this.trials = 10;
|
|
36
|
+
this.duration = 2000;
|
|
37
|
+
|
|
38
|
+
this.k = HTDMath.k.DEFAULT;
|
|
39
|
+
|
|
40
|
+
this.discountableControl = null;
|
|
41
|
+
this.itcTask = null;
|
|
42
|
+
this.discountableResponse = null;
|
|
43
|
+
this.htdFit = null;
|
|
44
|
+
this.htdParameters = null;
|
|
45
|
+
this.htdCurves = null;
|
|
46
|
+
}
|
|
47
|
+
|
|
11
48
|
connectedCallback() {
|
|
12
49
|
super.connectedCallback();
|
|
13
50
|
|
|
@@ -16,72 +53,50 @@ export default class HTDExampleHuman extends HTDExample {
|
|
|
16
53
|
this.discountableResponse = this.querySelector('discountable-response');
|
|
17
54
|
|
|
18
55
|
this.htdFit = this.querySelector('htd-fit');
|
|
56
|
+
this.htdParameters = this.querySelector('htd-parameters');
|
|
19
57
|
this.htdCurves = this.querySelector('htd-curves');
|
|
20
58
|
|
|
21
59
|
if (this.discountableControl) {
|
|
22
|
-
|
|
23
|
-
this.
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
if (this.discountableControl.hasAttribute('reset')) {
|
|
60
|
-
this.discountableControl.addEventListener('discountable-control-reset', (/* event */) => {
|
|
61
|
-
if (this.itcTask) {
|
|
62
|
-
this.itcTask.reset();
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
if (this.discountableResponse) {
|
|
66
|
-
this.discountableResponse.reset();
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
if (this.htdFit) {
|
|
70
|
-
this.htdFit.clear();
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if (this.htdCurves) {
|
|
74
|
-
this.htdCurves.clearOptions();
|
|
75
|
-
}
|
|
76
|
-
});
|
|
77
|
-
}
|
|
60
|
+
this.discountableControl.addEventListener('discountable-control-trials', (event) => {
|
|
61
|
+
this.trials = event.detail.trials;
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
this.discountableControl.addEventListener('discountable-control-duration', (event) => {
|
|
65
|
+
this.duration = event.detail.duration;
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
this.discountableControl.addEventListener('discountable-control-run', (/* event */) => {
|
|
69
|
+
if (this.itcTask) {
|
|
70
|
+
this.itcTask.running = true;
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
this.discountableControl.addEventListener('discountable-control-pause', (/* event */) => {
|
|
75
|
+
if (this.itcTask) {
|
|
76
|
+
this.itcTask.running = false;
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
this.discountableControl.addEventListener('discountable-control-reset', (/* event */) => {
|
|
81
|
+
if (this.itcTask) {
|
|
82
|
+
this.itcTask.reset();
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (this.discountableResponse) {
|
|
86
|
+
this.discountableResponse.reset();
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
if (this.htdFit) {
|
|
90
|
+
this.htdFit.clear();
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
if (this.htdCurves) {
|
|
94
|
+
this.htdCurves.clearOptions();
|
|
95
|
+
}
|
|
96
|
+
});
|
|
78
97
|
}
|
|
79
98
|
|
|
80
99
|
if (this.itcTask) {
|
|
81
|
-
if (this.discountableResponse) {
|
|
82
|
-
this.discountableResponse.trialTotal = this.itcTask.trials;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
100
|
this.itcTask.addEventListener('itc-trial-start', (event) => {
|
|
86
101
|
if (this.discountableResponse) {
|
|
87
102
|
this.discountableResponse.start(
|
|
@@ -145,12 +160,43 @@ export default class HTDExampleHuman extends HTDExample {
|
|
|
145
160
|
|
|
146
161
|
if (this.htdFit) {
|
|
147
162
|
this.htdFit.addEventListener('htd-fit-update', (event) => {
|
|
148
|
-
|
|
149
|
-
this.htdCurves.k = event.detail.k;
|
|
150
|
-
}
|
|
163
|
+
this.k = event.detail.k;
|
|
151
164
|
});
|
|
152
165
|
}
|
|
153
166
|
}
|
|
167
|
+
|
|
168
|
+
update(changedProperties) {
|
|
169
|
+
super.update(changedProperties);
|
|
170
|
+
|
|
171
|
+
if (this.discountableControl) {
|
|
172
|
+
this.discountableControl.trials = (this.discountableControl.trials != null)
|
|
173
|
+
? this.trials
|
|
174
|
+
: undefined;
|
|
175
|
+
this.discountableControl.duration = (this.discountableControl.duration != null)
|
|
176
|
+
? this.duration
|
|
177
|
+
: undefined;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
if (this.discountableResponse) {
|
|
181
|
+
this.discountableResponse.trialTotal = this.trials;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
if (this.itcTask) {
|
|
185
|
+
this.itcTask.duration = this.duration;
|
|
186
|
+
this.itcTask.iti = this.duration;
|
|
187
|
+
this.itcTask.trials = this.trials;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
if (this.htdCurves) {
|
|
191
|
+
this.htdCurves.k = this.k;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
if (this.htdParameters) {
|
|
195
|
+
this.htdParameters.k = (this.htdParameters.k != null)
|
|
196
|
+
? this.k
|
|
197
|
+
: undefined;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
154
200
|
}
|
|
155
201
|
|
|
156
202
|
customElements.define('htd-example-human', HTDExampleHuman);
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
|
|
2
|
+
import HTDMath from '@decidables/discountable-math';
|
|
3
|
+
|
|
2
4
|
import HTDExample from './htd-example';
|
|
3
5
|
|
|
4
6
|
/*
|
|
@@ -44,10 +46,12 @@ export default class HTDExampleInteractive extends HTDExample {
|
|
|
44
46
|
this.ds = 1;
|
|
45
47
|
this.al = 50;
|
|
46
48
|
this.dl = 40;
|
|
47
|
-
|
|
49
|
+
|
|
50
|
+
this.k = HTDMath.k.DEFAULT;
|
|
48
51
|
|
|
49
52
|
this.htdCalculation = null;
|
|
50
53
|
this.htdCurves = null;
|
|
54
|
+
this.htdParameters = null;
|
|
51
55
|
this.itcChoice = null;
|
|
52
56
|
}
|
|
53
57
|
|
|
@@ -56,6 +60,7 @@ export default class HTDExampleInteractive extends HTDExample {
|
|
|
56
60
|
|
|
57
61
|
this.htdCalculation = this.querySelector('htd-calculation');
|
|
58
62
|
this.htdCurves = this.querySelector('htd-curves');
|
|
63
|
+
this.htdParameters = this.querySelector('htd-parameters');
|
|
59
64
|
this.itcChoice = this.querySelector('itc-choice');
|
|
60
65
|
|
|
61
66
|
if (this.htdCalculation) {
|
|
@@ -82,6 +87,12 @@ export default class HTDExampleInteractive extends HTDExample {
|
|
|
82
87
|
});
|
|
83
88
|
}
|
|
84
89
|
|
|
90
|
+
if (this.htdParameters) {
|
|
91
|
+
this.htdParameters.addEventListener('htd-parameters-k', (event) => {
|
|
92
|
+
this.k = event.detail.k;
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
85
96
|
if (this.itcChoice) {
|
|
86
97
|
this.itcChoice.addEventListener('itc-choice-change', (event) => {
|
|
87
98
|
this.as = event.detail.as;
|
|
@@ -113,6 +124,12 @@ export default class HTDExampleInteractive extends HTDExample {
|
|
|
113
124
|
this.htdCurves.k = this.k;
|
|
114
125
|
}
|
|
115
126
|
|
|
127
|
+
if (this.htdParameters) {
|
|
128
|
+
this.htdParameters.k = (this.htdParameters.k != null)
|
|
129
|
+
? this.k
|
|
130
|
+
: undefined;
|
|
131
|
+
}
|
|
132
|
+
|
|
116
133
|
if (this.itcChoice) {
|
|
117
134
|
this.itcChoice.as = this.as;
|
|
118
135
|
this.itcChoice.ds = this.ds;
|
package/src/examples/model.js
CHANGED
|
@@ -10,6 +10,17 @@ import HTDExample from './htd-example';
|
|
|
10
10
|
export default class HTDExampleModel extends HTDExample {
|
|
11
11
|
static get properties() {
|
|
12
12
|
return {
|
|
13
|
+
trials: {
|
|
14
|
+
attribute: 'trials',
|
|
15
|
+
type: Number,
|
|
16
|
+
reflect: true,
|
|
17
|
+
},
|
|
18
|
+
duration: {
|
|
19
|
+
attribute: 'duration',
|
|
20
|
+
type: Number,
|
|
21
|
+
reflect: true,
|
|
22
|
+
},
|
|
23
|
+
|
|
13
24
|
k: {
|
|
14
25
|
attribute: 'k',
|
|
15
26
|
type: Number,
|
|
@@ -21,12 +32,16 @@ export default class HTDExampleModel extends HTDExample {
|
|
|
21
32
|
constructor() {
|
|
22
33
|
super();
|
|
23
34
|
|
|
24
|
-
this.
|
|
35
|
+
this.trials = 10;
|
|
36
|
+
this.duration = 2000;
|
|
37
|
+
|
|
38
|
+
this.k = HTDMath.k.DEFAULT;
|
|
25
39
|
|
|
26
40
|
this.discountableControl = null;
|
|
27
41
|
this.discountableResponse = null;
|
|
28
42
|
this.htdCalculation = null;
|
|
29
43
|
this.htdCurves = null;
|
|
44
|
+
this.htdParameters = null;
|
|
30
45
|
this.itcTask = null;
|
|
31
46
|
}
|
|
32
47
|
|
|
@@ -37,69 +52,51 @@ export default class HTDExampleModel extends HTDExample {
|
|
|
37
52
|
this.discountableResponse = this.querySelector('discountable-response');
|
|
38
53
|
this.htdCalculation = this.querySelector('htd-calculation');
|
|
39
54
|
this.htdCurves = this.querySelector('htd-curves');
|
|
55
|
+
this.htdParameters = this.querySelector('htd-parameters');
|
|
40
56
|
this.itcTask = this.querySelector('itc-task');
|
|
41
57
|
|
|
42
58
|
if (this.discountableControl) {
|
|
43
|
-
|
|
44
|
-
this.
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
this.
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
}
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
if (this.discountableControl.hasAttribute('reset')) {
|
|
89
|
-
this.discountableControl.addEventListener('discountable-control-reset', (/* event */) => {
|
|
90
|
-
if (this.discountableResponse) {
|
|
91
|
-
this.discountableResponse.reset();
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
if (this.htdCurves) {
|
|
95
|
-
this.htdCurves.clearOptions();
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
if (this.itcTask) {
|
|
99
|
-
this.itcTask.reset();
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
}
|
|
59
|
+
this.discountableControl.addEventListener('discountable-control-trials', (event) => {
|
|
60
|
+
this.trials = event.detail.trials;
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
this.discountableControl.addEventListener('discountable-control-duration', (event) => {
|
|
64
|
+
this.duration = event.detail.duration;
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
this.discountableControl.addEventListener('discountable-control-run', (/* event */) => {
|
|
68
|
+
if (this.htdCurves) {
|
|
69
|
+
this.htdCurves.resumeTrial();
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (this.itcTask) {
|
|
73
|
+
this.itcTask.running = true;
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
this.discountableControl.addEventListener('discountable-control-pause', (/* event */) => {
|
|
78
|
+
if (this.htdCurves) {
|
|
79
|
+
this.htdCurves.pauseTrial();
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (this.itcTask) {
|
|
83
|
+
this.itcTask.running = false;
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
this.discountableControl.addEventListener('discountable-control-reset', (/* event */) => {
|
|
88
|
+
if (this.discountableResponse) {
|
|
89
|
+
this.discountableResponse.reset();
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (this.htdCurves) {
|
|
93
|
+
this.htdCurves.clearOptions();
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (this.itcTask) {
|
|
97
|
+
this.itcTask.reset();
|
|
98
|
+
}
|
|
99
|
+
});
|
|
103
100
|
}
|
|
104
101
|
|
|
105
102
|
if (this.htdCurves) {
|
|
@@ -114,11 +111,13 @@ export default class HTDExampleModel extends HTDExample {
|
|
|
114
111
|
});
|
|
115
112
|
}
|
|
116
113
|
|
|
117
|
-
if (this.
|
|
118
|
-
|
|
119
|
-
this.
|
|
120
|
-
}
|
|
114
|
+
if (this.htdParameters) {
|
|
115
|
+
this.htdParameters.addEventListener('htd-parameters-k', (event) => {
|
|
116
|
+
this.k = event.detail.k;
|
|
117
|
+
});
|
|
118
|
+
}
|
|
121
119
|
|
|
120
|
+
if (this.itcTask) {
|
|
122
121
|
this.itcTask.addEventListener('itc-trial-start', (event) => {
|
|
123
122
|
if (this.discountableResponse) {
|
|
124
123
|
this.discountableResponse.start(
|
|
@@ -168,6 +167,25 @@ export default class HTDExampleModel extends HTDExample {
|
|
|
168
167
|
update(changedProperties) {
|
|
169
168
|
super.update(changedProperties);
|
|
170
169
|
|
|
170
|
+
if (this.discountableControl) {
|
|
171
|
+
this.discountableControl.trials = (this.discountableControl.trials != null)
|
|
172
|
+
? this.trials
|
|
173
|
+
: undefined;
|
|
174
|
+
this.discountableControl.duration = (this.discountableControl.duration != null)
|
|
175
|
+
? this.duration
|
|
176
|
+
: undefined;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
if (this.discountableResponse) {
|
|
180
|
+
this.discountableResponse.trialTotal = this.trials;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
if (this.itcTask) {
|
|
184
|
+
this.itcTask.duration = this.duration;
|
|
185
|
+
this.itcTask.iti = this.duration;
|
|
186
|
+
this.itcTask.trials = this.trials;
|
|
187
|
+
}
|
|
188
|
+
|
|
171
189
|
if (this.htdCalculation) {
|
|
172
190
|
this.htdCalculation.k = this.k;
|
|
173
191
|
}
|
|
@@ -175,6 +193,12 @@ export default class HTDExampleModel extends HTDExample {
|
|
|
175
193
|
if (this.htdCurves) {
|
|
176
194
|
this.htdCurves.k = this.k;
|
|
177
195
|
}
|
|
196
|
+
|
|
197
|
+
if (this.htdParameters) {
|
|
198
|
+
this.htdParameters.k = (this.htdParameters.k != null)
|
|
199
|
+
? this.k
|
|
200
|
+
: undefined;
|
|
201
|
+
}
|
|
178
202
|
}
|
|
179
203
|
}
|
|
180
204
|
|