hayun-vite 1.2.0 → 1.4.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/index.html +34 -19
- package/index.js +4 -1
- package/package.json +1 -1
- package/src/Audiogram/Audiogram.js +1 -1
- package/src/Audiogram/AudiogramUI.js +66 -0
- package/src/Reflex/Reflex.js +29 -2
- package/src/Reflex/ReflexUI.js +8 -7
- package/src/Speech/Speech.js +0 -3
- package/src/Tympanogram/Tympanogram.js +68 -35
- package/src/Tympanogram/TympanogramUI.js +187 -165
- package/src/allFormUI/AllFormUI.js +5 -0
- package/src/Tympanogram/ui.js +0 -165
package/index.html
CHANGED
|
@@ -21,36 +21,51 @@
|
|
|
21
21
|
import speechUI from "/src/Speech/SpeechUI.js"
|
|
22
22
|
import formsUI from "/src/Forms/FormsUI.js"
|
|
23
23
|
import reflexUI from "/src/Reflex/ReflexUI.js"
|
|
24
|
+
import tympanogramUI from "/src/Tympanogram/TympanogramUI"
|
|
25
|
+
import audiogramUI from "/src/Audiogram/AudiogramUI"
|
|
26
|
+
|
|
24
27
|
|
|
25
28
|
const { appSettingData, officeData, patientData } = currentData
|
|
26
|
-
let data = patientData.sessions[0].speech
|
|
27
|
-
speechUI.draw({ containerId: '#app' })
|
|
28
|
-
speechUI.update({ data })
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
let data
|
|
31
|
+
data = patientData.sessions[0].audiogram
|
|
32
|
+
audiogramUI.draw({ containerId: '#app' })
|
|
33
|
+
audiogramUI.update({ data })
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
// data = patientData.sessions[0].speech
|
|
37
|
+
// speechUI.draw({ containerId: '#app' })
|
|
38
|
+
// speechUI.update({ data })
|
|
39
|
+
// // فراخوانی متد آپدیت بدون پارامتر مقادیر وارد شده کاربر را به دیتاآبجکت جاری میفرستد
|
|
31
40
|
// setInterval(() => { speechUI.update() }, 3000);
|
|
32
41
|
|
|
33
|
-
//
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
42
|
+
// data = patientData.sessions[0].tympanogram
|
|
43
|
+
// tympanogramUI.draw({ containerId: '#app' })
|
|
44
|
+
// tympanogramUI.update({ data })
|
|
45
|
+
// setInterval(() => { tympanogramUI.update() }, 2000);
|
|
37
46
|
|
|
38
|
-
// formsUI Section
|
|
39
|
-
// data = patientData.sessions[0]
|
|
40
|
-
// formsUI.draw({ containerId: '#app' })
|
|
41
|
-
// formsUI.update({ patientData, sessionIndex: 0 })
|
|
42
47
|
|
|
43
|
-
// setInterval(() => {
|
|
44
|
-
// formsUI.update({ patientData, sessionIndex: 0 })
|
|
45
|
-
// console.log('forms update!');
|
|
46
48
|
|
|
47
|
-
// }, 2000)
|
|
48
49
|
|
|
49
50
|
|
|
50
|
-
// document.querySelector('#log').addEventListener('click', () => {
|
|
51
|
-
// console.log(data.R, data.L);
|
|
52
51
|
|
|
53
|
-
//
|
|
52
|
+
// Accoustic Reflexes Section
|
|
53
|
+
// data = patientData.sessions[0].reflex
|
|
54
|
+
// reflexUI.draw({ containerId: '#app' })
|
|
55
|
+
// reflexUI.update({ data })
|
|
56
|
+
// setInterval(() => { reflexUI.update() }, 3000);
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
// formsUI Section
|
|
61
|
+
data = patientData.sessions[0]
|
|
62
|
+
formsUI.draw({ containerId: '#app' })
|
|
63
|
+
formsUI.update({ patientData, sessionIndex: 0 })
|
|
64
|
+
|
|
65
|
+
setInterval(() => {
|
|
66
|
+
formsUI.update({ patientData, sessionIndex: 0 })
|
|
67
|
+
console.log('forms update!');
|
|
68
|
+
}, 2000)
|
|
54
69
|
|
|
55
70
|
|
|
56
71
|
</script>
|
package/index.js
CHANGED
|
@@ -20,6 +20,9 @@ import logo2 from './assets/logos/logo-2.png'
|
|
|
20
20
|
import Speech from './src/Speech/Speech'
|
|
21
21
|
// import { ReflexUI } from './src/components'
|
|
22
22
|
import speechUI from './src/Speech/SpeechUI'
|
|
23
|
+
import reflexUI from './src/Reflex/ReflexUI'
|
|
24
|
+
import tympanogramUI from './src/Tympanogram/TympanogramUI'
|
|
25
|
+
import audiogramUI from './src/Audiogram/AudiogramUI'
|
|
23
26
|
|
|
24
27
|
const logos = [logo0, logo1, logo2]
|
|
25
28
|
|
|
@@ -28,6 +31,6 @@ const logos = [logo0, logo1, logo2]
|
|
|
28
31
|
|
|
29
32
|
export {
|
|
30
33
|
Audiogram, Forms, dims, currentData, combo_template,
|
|
31
|
-
logos, Speech, speechUI, formsUI
|
|
34
|
+
logos, Speech, speechUI, reflexUI, tympanogramUI, formsUI, audiogramUI
|
|
32
35
|
|
|
33
36
|
}
|
package/package.json
CHANGED
|
@@ -444,7 +444,7 @@ export default class Audiogram {
|
|
|
444
444
|
// پاک کردن نودهای سمبل دیتای قبلی در صورت وجود از نود مربوطه
|
|
445
445
|
this.svg.querySelectorAll('[data-name=symbol]').forEach(symbol => symbol.remove())
|
|
446
446
|
// پاک کردن خطوط اتصال دیتای قبلی در صورت وجود از نود مربوطه
|
|
447
|
-
this.svg.querySelectorAll('[data-name=junction]').forEach(
|
|
447
|
+
this.svg.querySelectorAll('[data-name=junction]').forEach(line => line.remove())
|
|
448
448
|
|
|
449
449
|
const junctions = { AC: {}, BC: {}, side };
|
|
450
450
|
this.junctions = junctions;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import Audiogram from "./Audiogram";
|
|
2
|
+
|
|
3
|
+
class AudiogramUI {
|
|
4
|
+
constructor() {
|
|
5
|
+
this.data = { R: '', L: '' }
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
draw({ containerId = '#app' } = {}) {
|
|
9
|
+
|
|
10
|
+
document.querySelector(containerId).insertAdjacentHTML('beforeend', `
|
|
11
|
+
<div class="center border">
|
|
12
|
+
<section id="r-audiogram"></section>
|
|
13
|
+
<section id="l-audiogram"></section>
|
|
14
|
+
</div>
|
|
15
|
+
`);
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
const dims = {
|
|
19
|
+
"blank": false,
|
|
20
|
+
"name": "RAudiogram",
|
|
21
|
+
"w": 100,
|
|
22
|
+
"h": 90,
|
|
23
|
+
"margin": {
|
|
24
|
+
"left": 1,
|
|
25
|
+
"top": 1,
|
|
26
|
+
"right": 1,
|
|
27
|
+
"bottom": 1
|
|
28
|
+
},
|
|
29
|
+
"display": "inline",
|
|
30
|
+
"borderBox": "display",
|
|
31
|
+
"width": 600,
|
|
32
|
+
"height": 600
|
|
33
|
+
}
|
|
34
|
+
this.rcontainer = document.getElementById('r-audiogram')
|
|
35
|
+
this.rchart = new Audiogram({ container: this.rcontainer, side: 'R', dims })
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
this.lcontainer = document.getElementById('l-audiogram')
|
|
39
|
+
this.lchart = new Audiogram({ container: this.lcontainer, side: 'L', dims })
|
|
40
|
+
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
update({ data } = {}) {
|
|
44
|
+
|
|
45
|
+
this.rchart.update({ data: data.R, side: 'R' })
|
|
46
|
+
this.lchart.update({ data: data.L, side: 'L' })
|
|
47
|
+
// if (data) {
|
|
48
|
+
// this.rchart.update(data.R, this.rcontainer)
|
|
49
|
+
// this.lchart.update(data.L, this.lcontainer)
|
|
50
|
+
// this.data = { R: data.R, L: data.L }
|
|
51
|
+
// } else
|
|
52
|
+
// // اگر این تابع بدون پارامتر فراخوانی شود مقادیر اینپوت کاربر گرفته و دیتاآبجکت را آپدیت کند
|
|
53
|
+
// {
|
|
54
|
+
// console.log('without param');
|
|
55
|
+
|
|
56
|
+
// this.rchart.fetchInputUserData()
|
|
57
|
+
// this.lchart.fetchInputUserData()
|
|
58
|
+
// this.data.R = this.rchart.data
|
|
59
|
+
// this.data.L = this.lchart.data
|
|
60
|
+
// }
|
|
61
|
+
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export default new AudiogramUI()
|
|
66
|
+
|
package/src/Reflex/Reflex.js
CHANGED
|
@@ -116,10 +116,20 @@ export default class Reflex {
|
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
// جایگذاری داده های رفلکس
|
|
119
|
-
update(data) {
|
|
119
|
+
update(data, container) {
|
|
120
|
+
|
|
121
|
+
this.data = data
|
|
122
|
+
|
|
123
|
+
// انتخاب اینکه اینپوت های کاربر را آپدیت کنه یا اس وی جی تکست ها رو
|
|
124
|
+
// بر حسب اینکه پارامتر کانتینر باشه یا نباشه
|
|
125
|
+
const prop = container ? 'value' : 'textContent'
|
|
126
|
+
const elem = container ? 'input' : 'text';
|
|
127
|
+
!container && (container = this.chart);
|
|
128
|
+
|
|
120
129
|
for (const key in data) {
|
|
121
130
|
for (const freq in data[key]) {
|
|
122
|
-
|
|
131
|
+
container.querySelector(`${elem}[name=${key}-${freq}]`)[prop] = data?.[key]?.[freq] || "";
|
|
132
|
+
// container.querySelector(`${elem}[name=${label}]`)[prop] = data?.[label] || "";
|
|
123
133
|
}
|
|
124
134
|
}
|
|
125
135
|
}
|
|
@@ -169,4 +179,21 @@ export default class Reflex {
|
|
|
169
179
|
})
|
|
170
180
|
// firstInput.focus()
|
|
171
181
|
}
|
|
182
|
+
|
|
183
|
+
// دریافت دیتای کاربر از اینپوت ها و جایگزین کردن در دیتای آبجکت کلاس
|
|
184
|
+
// تغییر این دیتا باعث تغییر دیتای جاری میشود. چون آبجکت ها اشاره گر هستن
|
|
185
|
+
fetchInputUserData() {
|
|
186
|
+
[500, 1000, 2000, 4000].
|
|
187
|
+
forEach(freq => {
|
|
188
|
+
const value = this.container.querySelector(`input[name=ipsi-${freq}]`).value
|
|
189
|
+
this.data.ipsi[freq] = value // جایگزین کردن پراپرتی آبجکت دیتای جاری و اینجا
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
[500, 1000, 2000, 4000].
|
|
193
|
+
forEach(freq => {
|
|
194
|
+
const value = this.container.querySelector(`input[name=contra-${freq}]`).value
|
|
195
|
+
this.data.contra[freq] = value // جایگزین کردن پراپرتی آبجکت دیتای جاری و اینجا
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
}
|
|
172
199
|
}
|
package/src/Reflex/ReflexUI.js
CHANGED
|
@@ -41,11 +41,11 @@ class ReflexUI {
|
|
|
41
41
|
this.rchart = new Reflex({ container: this.rcontainer, dims, side: 'R' })
|
|
42
42
|
|
|
43
43
|
// فراخوانی متد ایجاد اینپوت روی چارت اسپیچ
|
|
44
|
-
|
|
44
|
+
this.rchart.createUserInput({ container: this.rcontainer })
|
|
45
45
|
|
|
46
46
|
this.lcontainer = document.getElementById('l-reflex')
|
|
47
47
|
this.lchart = new Reflex({ container: this.lcontainer, dims, side: 'L' })
|
|
48
|
-
|
|
48
|
+
this.lchart.createUserInput({ container: this.lcontainer })
|
|
49
49
|
|
|
50
50
|
}
|
|
51
51
|
|
|
@@ -57,12 +57,13 @@ class ReflexUI {
|
|
|
57
57
|
} else
|
|
58
58
|
// اگر این تابع بدون پارامتر فراخوانی شود مقادیر اینپوت کاربر گرفته و دیتاآبجکت را آپدیت کند
|
|
59
59
|
{
|
|
60
|
-
console.log('without param');
|
|
61
60
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
61
|
+
this.rchart.fetchInputUserData()
|
|
62
|
+
this.lchart.fetchInputUserData()
|
|
63
|
+
this.data.R = this.rchart.data
|
|
64
|
+
this.data.L = this.lchart.data
|
|
65
|
+
console.log('without param', this.data.R);
|
|
66
|
+
|
|
66
67
|
}
|
|
67
68
|
|
|
68
69
|
}
|
package/src/Speech/Speech.js
CHANGED
|
@@ -169,9 +169,6 @@ export default class Speech {
|
|
|
169
169
|
font-family: Vazirmatn;
|
|
170
170
|
`
|
|
171
171
|
const color = (this.side === 'R') ? 'crimson' : 'blue';
|
|
172
|
-
// ایجاد یک المنت اینپوت
|
|
173
|
-
// let input
|
|
174
|
-
// آماده سازی اولین نود اینپوت از داکیومنت و سپس ساختن بقیه نودها از روی آن
|
|
175
172
|
// const firstInput = input // نگهداری اولین اینپوت برای برگشت و فوکوس کردن بهش
|
|
176
173
|
let inputDims = this.inputDims
|
|
177
174
|
|
|
@@ -161,12 +161,13 @@ export default class Tympanogram {
|
|
|
161
161
|
{ name: 'MEP', x: getX(-300), y: getY(compliance.min), dy: 10, dx: 11 },
|
|
162
162
|
{ name: 'SC', x: getX(0), y: getY(compliance.min), dy: 10, dx: 8 },
|
|
163
163
|
{ name: 'G', x: getX(300), y: getY(compliance.min), dy: 10, dx: 4 },
|
|
164
|
-
{ name: 'type', x: getX(-
|
|
164
|
+
{ name: 'type', x: getX(-490), y: getY(2.5), dx: 9, dy: 0 },
|
|
165
165
|
]
|
|
166
166
|
.forEach(input => {
|
|
167
167
|
const { name, x, y, dx, dy } = input
|
|
168
168
|
putText({ container: svg, value, style, name, x, y, dx, dy })
|
|
169
|
-
|
|
169
|
+
// نگهداری مختصات اینپوت ها برای استفاده بعدی
|
|
170
|
+
this.inputDims.push({ name, x: (x + dx + padding.left + 4) * kx, y: (y + dy + padding.top) * ky })
|
|
170
171
|
// putPoint({ container: svg, x, y, dx, dy, r: 0.8, fill: 'brown' })
|
|
171
172
|
});
|
|
172
173
|
|
|
@@ -232,8 +233,16 @@ export default class Tympanogram {
|
|
|
232
233
|
}
|
|
233
234
|
}
|
|
234
235
|
|
|
235
|
-
update(data) {
|
|
236
|
+
update(data, container) {
|
|
236
237
|
this.data = data
|
|
238
|
+
// انتخاب اینکه اینپوت های کاربر را آپدیت کنه یا اس وی جی تکست ها رو
|
|
239
|
+
// بر حسب اینکه پارامتر کانتینر باشه یا نباشه
|
|
240
|
+
const prop = container ? 'value' : 'textContent'
|
|
241
|
+
const elem = container ? 'input' : 'text';
|
|
242
|
+
!container && (container = this.chart);
|
|
243
|
+
|
|
244
|
+
// container.querySelector(`${elem}[name=${label}]`)[prop] = data?.[label] || "";
|
|
245
|
+
|
|
237
246
|
|
|
238
247
|
let { ECV, SC, MEP, G } = data
|
|
239
248
|
|
|
@@ -243,21 +252,22 @@ export default class Tympanogram {
|
|
|
243
252
|
G && (G = (+G).toFixed(2));
|
|
244
253
|
|
|
245
254
|
// جایگذاری مقادیر تمپانومتری در تکستباکس ها
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
// پاک کردن منحنی قبلی از کانتینر جاری
|
|
252
|
-
// console.log(this.chart.querySelector(`path[name="curve"]`));
|
|
255
|
+
container.querySelector(`${elem}[name="type"]`)[prop] = data?.type || "-";
|
|
256
|
+
container.querySelector(`${elem}[name="ECV"]`)[prop] = ECV || "";
|
|
257
|
+
container.querySelector(`${elem}[name="MEP"]`)[prop] = data?.MEP || "";
|
|
258
|
+
container.querySelector(`${elem}[name="SC"]`)[prop] = SC || "";
|
|
259
|
+
container.querySelector(`${elem}[name="G"]`)[prop] = G || "";
|
|
253
260
|
|
|
254
|
-
this.chart.querySelector(`path[name="curve"]`)?.remove();
|
|
255
261
|
// رسم منحنی
|
|
256
262
|
this.drawCurve(data);
|
|
257
263
|
}
|
|
258
264
|
|
|
259
265
|
// توابع داخلی
|
|
260
266
|
drawCurve(data) {
|
|
267
|
+
|
|
268
|
+
// پاک کردن منحنی قبلی از کانتینر جاری
|
|
269
|
+
this.chart.querySelector(`path[name="curve"]`)?.remove();
|
|
270
|
+
|
|
261
271
|
let { type, ECV, SC, MEP, G, expanded, cp, cpp } = data
|
|
262
272
|
|
|
263
273
|
// Ensure to Convert to Numbers //
|
|
@@ -377,45 +387,68 @@ export default class Tympanogram {
|
|
|
377
387
|
}
|
|
378
388
|
}
|
|
379
389
|
|
|
380
|
-
// ایجاد اینپوتهای کاربر در کانتینر چارت
|
|
381
390
|
createUserInput({ container }) {
|
|
382
391
|
// استایل دهی نسبی به کانتینر
|
|
383
392
|
container.style.position = 'relative'
|
|
384
|
-
//
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
input.type = 'text'
|
|
388
|
-
input.maxLength = 4
|
|
389
|
-
input.autocomplete = 'off'
|
|
390
|
-
input.placeholder = '---'
|
|
391
|
-
const width = 70 // به دست آوردن پهنای اینپوت برای محاسبه مختصات نقطه مرکزش
|
|
392
|
-
const height = 25 // به دست آوردن پهنای اینپوت برای محاسبه مختصات نقطه مرکزش
|
|
393
|
+
const width = 60 // به دست آوردن پهنای اینپوت برای محاسبه مختصات نقطه مرکزش
|
|
394
|
+
const height = 30 // به دست آوردن پهنای اینپوت برای محاسبه مختصات نقطه مرکزش
|
|
395
|
+
|
|
393
396
|
let style = `
|
|
394
|
-
|
|
395
|
-
padding: 0;
|
|
396
|
-
text-align: center;
|
|
397
|
-
font-size: 24px;
|
|
398
|
-
font-weight: bold;
|
|
399
|
-
color: crimson;
|
|
400
|
-
position: absolute;
|
|
397
|
+
all: revert;
|
|
401
398
|
width: ${width}px;
|
|
402
399
|
height: ${height}px;
|
|
400
|
+
box-sizing: border-box;
|
|
403
401
|
border: none;
|
|
402
|
+
/* Ensures padding doesn't increase height */
|
|
403
|
+
position: absolute;
|
|
404
|
+
padding-top: 4px;
|
|
405
|
+
text-align: center;
|
|
406
|
+
font-size: 24px;
|
|
407
|
+
font-weight: bold;
|
|
408
|
+
font-family: Vazirmatn;
|
|
404
409
|
`
|
|
405
|
-
|
|
406
|
-
//
|
|
407
|
-
const firstInput = input // نگهداری اولین اینپوت برای برگشت و فوکوس کردن بهش
|
|
410
|
+
const color = (this.side === 'R') ? 'crimson' : 'blue';
|
|
411
|
+
// const firstInput = input // نگهداری اولین اینپوت برای برگشت و فوکوس کردن بهش
|
|
408
412
|
let inputDims = this.inputDims
|
|
409
|
-
input.style.color = (this.side === 'R') ? 'crimson' : 'blue';
|
|
410
413
|
|
|
411
414
|
inputDims.forEach(dims => {
|
|
415
|
+
const input = document.createElement('input')
|
|
416
|
+
// input.className = 'user-input'
|
|
417
|
+
input.name = dims.name
|
|
418
|
+
input.type = 'text'
|
|
419
|
+
input.maxLength = 4
|
|
420
|
+
input.autocomplete = 'off'
|
|
421
|
+
input.placeholder = '---'
|
|
422
|
+
input.style = style
|
|
423
|
+
input.style.color = color
|
|
412
424
|
input.style.left = dims.x - width / 2 + 'px'
|
|
413
425
|
input.style.top = dims.y - height / 2 + 'px'
|
|
414
|
-
input.setAttribute('name', dims.name)
|
|
415
426
|
container.appendChild(input)
|
|
416
|
-
input = input.cloneNode() // در آخر یک المنت اضافه ایجاد شده است - باگ بی آزار
|
|
427
|
+
// input = input.cloneNode() // در آخر یک المنت اضافه ایجاد شده است - باگ بی آزار
|
|
417
428
|
})
|
|
418
429
|
|
|
419
|
-
|
|
430
|
+
//افزودن رویداد به اینپوت ها
|
|
431
|
+
this.createUserInputEvent()
|
|
432
|
+
// firstInput.focus()
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
// دریافت دیتای کاربر از اینپوت ها و جایگزین کردن در دیتای آبجکت کلاس
|
|
436
|
+
// تغییر این دیتا باعث تغییر دیتای جاری میشود. چون آبجکت ها اشاره گر هستن
|
|
437
|
+
fetchInputUserData() {
|
|
438
|
+
['type', 'ECV', 'MEP', 'SC', 'G'].forEach(name => {
|
|
439
|
+
const value = this.container.querySelector(`input[name= ${name}]`).value
|
|
440
|
+
this.data[name] = value // جایگزین کردن پراپرتی آبجکت دیتای جاری و اینجا
|
|
441
|
+
})
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
createUserInputEvent() {
|
|
445
|
+
['type', 'ECV', 'MEP', 'SC', 'G'].forEach(name => {
|
|
446
|
+
this.container.querySelector(`input[name= ${name}]`).
|
|
447
|
+
addEventListener('change', (e) => {
|
|
448
|
+
console.log(e.target.value)
|
|
449
|
+
this.fetchInputUserData() // همه مقادیر اینپوت ها میگیره و دیتای کلاس رو به روز میکنه
|
|
450
|
+
this.drawCurve(this.data) // رسم مجدد منحنی با دیتای جدید
|
|
451
|
+
})
|
|
452
|
+
})
|
|
420
453
|
}
|
|
421
454
|
}
|
|
@@ -1,166 +1,188 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
-
|
|
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
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
1
|
+
import Tympanogram from "./Tympanogram";
|
|
2
|
+
|
|
3
|
+
class TympanogramUI {
|
|
4
|
+
constructor() {
|
|
5
|
+
this.data = { R: '', L: '' }
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
draw({ containerId = '#app' } = {}) {
|
|
9
|
+
|
|
10
|
+
document.querySelector(containerId).insertAdjacentHTML('beforeend', `
|
|
11
|
+
<div name="tympanograms">
|
|
12
|
+
<h1 class="center title">Tympanograms</h1>
|
|
13
|
+
<div class="center">
|
|
14
|
+
<div>
|
|
15
|
+
<h2 class="center side red">Right</h2>
|
|
16
|
+
<section id="r-tympanogram"></section>
|
|
17
|
+
<section name="r-tympanogram">
|
|
18
|
+
<p>Curve settings:</p>
|
|
19
|
+
<input type="range" id="cp" name="cp" min="10" max="150" value="70" step="5" />
|
|
20
|
+
<label for="cp">cp</label>
|
|
21
|
+
<input type="range" id="cpp" name="cpp" min="1" max="10" value="5" step="1" />
|
|
22
|
+
<label for="cpp">cpp</label>
|
|
23
|
+
<div>
|
|
24
|
+
<input type="checkbox" name="extra-sc" id="r-extra-sc">
|
|
25
|
+
<label for="r-extra-sc">Extra SC</label>
|
|
26
|
+
</div>
|
|
27
|
+
<div>
|
|
28
|
+
<input type="checkbox" name="compensated" id="r-compensated">
|
|
29
|
+
<label for="r-compensated">Compensated</label>
|
|
30
|
+
</div>
|
|
31
|
+
</section>
|
|
32
|
+
</div>
|
|
33
|
+
|
|
34
|
+
<div>
|
|
35
|
+
<h2 class="center side blue">Left</h2>
|
|
36
|
+
<section id="l-tympanogram"></section>
|
|
37
|
+
<section name="l-tympanogram">
|
|
38
|
+
<p>Curve settings:</p>
|
|
39
|
+
<input type="range" id="cp" name="cp" min="10" max="150" value="70" step="5" />
|
|
40
|
+
<label for="cp">cp</label>
|
|
41
|
+
<input type="range" id="cpp" name="cpp" min="1" max="10" value="5" step="1" />
|
|
42
|
+
<label for="cpp">cpp</label>
|
|
43
|
+
<div>
|
|
44
|
+
<input type="checkbox" name="extra-sc" id="l-extra-sc">
|
|
45
|
+
<label for="l-extra-sc">Extra SC</label>
|
|
46
|
+
</div>
|
|
47
|
+
<div>
|
|
48
|
+
<input type="checkbox" name="compensated" id="l-compensated">
|
|
49
|
+
<label for="l-compensated">Compensated</label>
|
|
50
|
+
</section>
|
|
51
|
+
</div>
|
|
52
|
+
</div>
|
|
53
|
+
</div>
|
|
54
|
+
`);
|
|
55
|
+
|
|
56
|
+
this.dims = {
|
|
57
|
+
"name": "RTympanogram",
|
|
58
|
+
"w": 100,
|
|
59
|
+
"h": 60,
|
|
60
|
+
"margin": {
|
|
61
|
+
"left": 2,
|
|
62
|
+
"top": 0,
|
|
63
|
+
"right": 2,
|
|
64
|
+
"bottom": 0
|
|
65
|
+
},
|
|
66
|
+
"display": "inline",
|
|
67
|
+
"width": 100 * 6,
|
|
68
|
+
"height": 60 * 6,
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// let data = {
|
|
72
|
+
// type: "An",
|
|
73
|
+
// ECV: '1.30',
|
|
74
|
+
// SC: '0.80',
|
|
75
|
+
// MEP: '-130',
|
|
76
|
+
// G: 0.2,
|
|
77
|
+
// expanded: false, // by default is false for expand pressure from -600 to +400
|
|
78
|
+
|
|
79
|
+
// }
|
|
80
|
+
const dims = this.dims
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
const width = 50 // به دست آوردن پهنای اینپوت برای محاسبه مختصات نقطه مرکزش
|
|
84
|
+
const height = 25 // به دست آوردن پهنای اینپوت برای محاسبه مختصات نقطه مرکزش
|
|
85
|
+
|
|
86
|
+
let style = `
|
|
87
|
+
margin: 0;
|
|
88
|
+
padding: 0;
|
|
89
|
+
text-align: center;
|
|
90
|
+
font-size: 22px;
|
|
91
|
+
font-weight: bold;
|
|
92
|
+
color: crimson;
|
|
93
|
+
position: absolute;
|
|
94
|
+
width: ${width}px;
|
|
95
|
+
height: ${height}px;
|
|
96
|
+
border: none;
|
|
97
|
+
`
|
|
98
|
+
this.rcontainer = document.getElementById('r-tympanogram')
|
|
99
|
+
this.rchart = new Tympanogram({ container: this.rcontainer, dims, side: 'R' })
|
|
100
|
+
// فراخوانی متد ایجاد اینپوت روی چارت اسپیچ
|
|
101
|
+
this.rchart.createUserInput({ container: this.rcontainer })
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
this.lcontainer = document.getElementById('l-tympanogram')
|
|
105
|
+
this.lchart = new Tympanogram({ container: this.lcontainer, dims, side: 'L' })
|
|
106
|
+
// فراخوانی متد ایجاد اینپوت روی چارت اسپیچ
|
|
107
|
+
this.lchart.createUserInput({ container: this.lcontainer })
|
|
108
|
+
|
|
109
|
+
// cereateEvents(this.lcontainer, this.lchart, 'l-tympanogram')
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
|
|
113
|
+
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
update({ data } = {}) {
|
|
117
|
+
if (data) {
|
|
118
|
+
this.rchart.update(data.R, this.rcontainer)
|
|
119
|
+
this.lchart.update(data.L, this.lcontainer)
|
|
120
|
+
this.data = { R: data.R, L: data.L }
|
|
121
|
+
// در اولین دیتادهی رویدادها ایجاد شود
|
|
122
|
+
this.cereateEvents(this.rcontainer, this.rchart, 'r-tympanogram', data.R)
|
|
123
|
+
this.cereateEvents(this.lcontainer, this.lchart, 'l-tympanogram', data.L)
|
|
124
|
+
|
|
125
|
+
} else
|
|
126
|
+
// اگر این تابع بدون پارامتر فراخوانی شود مقادیر اینپوت کاربر گرفته و دیتاآبجکت را آپدیت کند
|
|
127
|
+
{
|
|
128
|
+
console.log('without param');
|
|
129
|
+
|
|
130
|
+
this.rchart.fetchInputUserData()
|
|
131
|
+
this.lchart.fetchInputUserData()
|
|
132
|
+
this.data.R = this.rchart.data
|
|
133
|
+
this.data.L = this.lchart.data
|
|
134
|
+
console.log(this.data.L);
|
|
135
|
+
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
cereateEvents(container, tympanogram, containerId, data) {
|
|
140
|
+
// کنترلرهای منحنی
|
|
141
|
+
let cp = 70, cpp = 5, extraCompliance, compensated, dims
|
|
142
|
+
|
|
143
|
+
container = document.querySelector(`[name=${containerId}]`)
|
|
144
|
+
container.querySelector("[name=compensated]").addEventListener("input", e => {
|
|
145
|
+
compensated = e.target.checked
|
|
146
|
+
console.log(e.target.checked);
|
|
147
|
+
dims = { ...this.dims, compensated }
|
|
148
|
+
tympanogram.draw({ dims })
|
|
149
|
+
})
|
|
150
|
+
|
|
151
|
+
container.querySelector("[name=extra-sc]").addEventListener("input", e => {
|
|
152
|
+
extraCompliance = e.target.checked
|
|
153
|
+
console.log(e.target.checked);
|
|
154
|
+
dims = { ...this.dims, extraCompliance }
|
|
155
|
+
tympanogram.draw({ dims })
|
|
156
|
+
})
|
|
157
|
+
|
|
158
|
+
container.querySelector("#cp").addEventListener("input", e => {
|
|
159
|
+
cp = e.target.value
|
|
160
|
+
console.log(cp);
|
|
161
|
+
data = { ...data, cp }
|
|
162
|
+
tympanogram.update(data)
|
|
163
|
+
})
|
|
164
|
+
|
|
165
|
+
container.querySelector("#cpp").addEventListener("input", e => {
|
|
166
|
+
cpp = e.target.value
|
|
167
|
+
console.log(cpp);
|
|
168
|
+
data = { ...data, cpp }
|
|
169
|
+
tympanogram.update(data)
|
|
170
|
+
})
|
|
171
|
+
}
|
|
172
|
+
|
|
166
173
|
}
|
|
174
|
+
|
|
175
|
+
export default new TympanogramUI()
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
|
|
188
|
+
|
package/src/Tympanogram/ui.js
DELETED
|
@@ -1,165 +0,0 @@
|
|
|
1
|
-
import Tympanogram from "./Tympanogram";
|
|
2
|
-
|
|
3
|
-
document.querySelector('#app').insertAdjacentHTML('beforeend', `
|
|
4
|
-
<div name="tympanograms">
|
|
5
|
-
<h1 class="center">Tympanograms</h1>
|
|
6
|
-
<div class="center">
|
|
7
|
-
<div>
|
|
8
|
-
<h2 class="center red">Right</h2>
|
|
9
|
-
<section id="r-tympanogram" style="position: relative;">
|
|
10
|
-
<input type="text" name="type" maxlength="4" placeholder="---" autocomplete="off" />
|
|
11
|
-
</section>
|
|
12
|
-
<section name="r-tympanogram">
|
|
13
|
-
<p>Curve settings:</p>
|
|
14
|
-
<input type="range" id="cp" name="cp" min="10" max="150" value="70" step="5" />
|
|
15
|
-
<label for="cp">cp</label>
|
|
16
|
-
<input type="range" id="cpp" name="cpp" min="1" max="10" value="5" step="1" />
|
|
17
|
-
<label for="cpp">cpp</label>
|
|
18
|
-
<div>
|
|
19
|
-
<input type="checkbox" name="extra-sc" id="r-extra-sc">
|
|
20
|
-
<label for="r-extra-sc">Extra SC</label>
|
|
21
|
-
</div>
|
|
22
|
-
<div>
|
|
23
|
-
<input type="checkbox" name="compensated" id="r-compensated">
|
|
24
|
-
<label for="r-compensated">Compensated</label>
|
|
25
|
-
</div>
|
|
26
|
-
</section>
|
|
27
|
-
</div>
|
|
28
|
-
|
|
29
|
-
<div>
|
|
30
|
-
<h2 class="center blue">Left</h2>
|
|
31
|
-
<section id="l-tympanogram" style="position: relative;">
|
|
32
|
-
<input type="text" name="type" maxlength="4" placeholder="---" autocomplete="off" />
|
|
33
|
-
</section>
|
|
34
|
-
<section name="l-tympanogram">
|
|
35
|
-
<p>Curve settings:</p>
|
|
36
|
-
<input type="range" id="cp" name="cp" min="10" max="150" value="70" step="5" />
|
|
37
|
-
<label for="cp">cp</label>
|
|
38
|
-
<input type="range" id="cpp" name="cpp" min="1" max="10" value="5" step="1" />
|
|
39
|
-
<label for="cpp">cpp</label>
|
|
40
|
-
<div>
|
|
41
|
-
<input type="checkbox" name="extra-sc" id="l-extra-sc">
|
|
42
|
-
<label for="l-extra-sc">Extra SC</label>
|
|
43
|
-
</div>
|
|
44
|
-
<div>
|
|
45
|
-
<input type="checkbox" name="compensated" id="l-compensated">
|
|
46
|
-
<label for="l-compensated">Compensated</label>
|
|
47
|
-
</section>
|
|
48
|
-
</div>
|
|
49
|
-
</div>
|
|
50
|
-
</div>
|
|
51
|
-
`);
|
|
52
|
-
|
|
53
|
-
let dims = {
|
|
54
|
-
"name": "RTympanogram",
|
|
55
|
-
"w": 100,
|
|
56
|
-
"h": 60,
|
|
57
|
-
"margin": {
|
|
58
|
-
"left": 2,
|
|
59
|
-
"top": 0,
|
|
60
|
-
"right": 2,
|
|
61
|
-
"bottom": 0
|
|
62
|
-
},
|
|
63
|
-
"display": "inline",
|
|
64
|
-
"width": 100 * 6,
|
|
65
|
-
"height": 60 * 6,
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
let data = {
|
|
69
|
-
type: "An",
|
|
70
|
-
ECV: '1.30',
|
|
71
|
-
SC: '0.80',
|
|
72
|
-
MEP: '-130',
|
|
73
|
-
G: 0.2,
|
|
74
|
-
expanded: false, // by default is false for expand pressure from -600 to +400
|
|
75
|
-
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
let cp = 70, cpp = 5, extraCompliance, compensated
|
|
79
|
-
|
|
80
|
-
const width = 50 // به دست آوردن پهنای اینپوت برای محاسبه مختصات نقطه مرکزش
|
|
81
|
-
const height = 25 // به دست آوردن پهنای اینپوت برای محاسبه مختصات نقطه مرکزش
|
|
82
|
-
|
|
83
|
-
let style = `
|
|
84
|
-
margin: 0;
|
|
85
|
-
padding: 0;
|
|
86
|
-
text-align: center;
|
|
87
|
-
font-size: 22px;
|
|
88
|
-
font-weight: bold;
|
|
89
|
-
color: crimson;
|
|
90
|
-
position: absolute;
|
|
91
|
-
width: ${width}px;
|
|
92
|
-
height: ${height}px;
|
|
93
|
-
border: none;
|
|
94
|
-
`
|
|
95
|
-
insertInputs({ containerID: 'r-tympanogram', side: 'R', dims, style }).focus()
|
|
96
|
-
|
|
97
|
-
insertInputs({ containerID: 'l-tympanogram', side: 'L', dims, style })
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
function insertInputs({ containerID, side, dims, style }) {
|
|
101
|
-
let container = document.getElementById(containerID)
|
|
102
|
-
const tympanogram = new Tympanogram({ container, dims, side })
|
|
103
|
-
tympanogram.update(data)
|
|
104
|
-
|
|
105
|
-
let input = container.querySelector('[name=type]')
|
|
106
|
-
const firstInput = input // اولین اینپوت
|
|
107
|
-
|
|
108
|
-
let inputDims = tympanogram.inputDims
|
|
109
|
-
input.style = style
|
|
110
|
-
input.style.color = (side === 'R') ? 'crimson' : 'blue';
|
|
111
|
-
input.style.left = inputDims[0].x - width / 2 + 'px'
|
|
112
|
-
input.style.top = inputDims[0].y - height / 2 + 'px'
|
|
113
|
-
inputDims.shift() // حذف اولین عنصر آرایه بخاط اینکه استفاده شد در نود بالایی
|
|
114
|
-
|
|
115
|
-
inputDims.forEach(dims => {
|
|
116
|
-
input = input.cloneNode()
|
|
117
|
-
input.style.left = dims.x - width / 2 + 'px'
|
|
118
|
-
input.style.top = dims.y - height / 2 + 'px'
|
|
119
|
-
input.setAttribute('name', dims.name)
|
|
120
|
-
container.appendChild(input)
|
|
121
|
-
})
|
|
122
|
-
|
|
123
|
-
container = document.querySelector(`[name=${containerID}]`)
|
|
124
|
-
console.log(container);
|
|
125
|
-
|
|
126
|
-
container.querySelector("[name=compensated]").addEventListener("input", e => {
|
|
127
|
-
compensated = e.target.checked
|
|
128
|
-
console.log(e.target.checked);
|
|
129
|
-
dims = { ...dims, compensated }
|
|
130
|
-
tympanogram.draw({ dims })
|
|
131
|
-
})
|
|
132
|
-
|
|
133
|
-
container.querySelector("[name=extra-sc]").addEventListener("input", e => {
|
|
134
|
-
extraCompliance = e.target.checked
|
|
135
|
-
console.log(e.target.checked);
|
|
136
|
-
dims = { ...dims, extraCompliance }
|
|
137
|
-
tympanogram.draw({ dims })
|
|
138
|
-
})
|
|
139
|
-
|
|
140
|
-
container.querySelector("#cp").addEventListener("input", e => {
|
|
141
|
-
cp = e.target.value
|
|
142
|
-
console.log(cp);
|
|
143
|
-
data = { ...data, cp }
|
|
144
|
-
tympanogram.update(data)
|
|
145
|
-
})
|
|
146
|
-
|
|
147
|
-
container.querySelector("#cpp").addEventListener("input", e => {
|
|
148
|
-
cpp = e.target.value
|
|
149
|
-
console.log(cpp);
|
|
150
|
-
data = { ...data, cpp }
|
|
151
|
-
tympanogram.update(data)
|
|
152
|
-
})
|
|
153
|
-
|
|
154
|
-
return firstInput
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|