hayun-vite 0.3.1 → 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.
@@ -1,85 +1,125 @@
1
- // for
2
1
  const dims = {
3
2
  name: 'Audiogram',
4
- // پس از اضافه کردن هر آیتم در زیر این تمپلت رو هم آپدیت کنید
5
- template: {
6
- margin: { left: 0, top: 0, }, // در کانتینر دیو این عمل نمیکنه. مگر در کانتینر اس وی جی بذاریم
7
-
8
- width: 700,
9
- height: 700,
10
-
11
- chartPadding: { left: 30, top: 45, right: 30, bottom: 10 },
12
- symbolDims: { width: 55, height: 55 },
13
- // virtual frequency
14
- vFrequency: { min: 0, max: 14, step: 1 },
15
- vToFreq: { 0: 125, 2: 250, 4: 500, 5: 750, 6: 1000, 7: 1500, 8: 2000, 9: 3000, 10: 4000, 11: 6000, 12: 8000, 13: 12000, 14: 16000 },
16
- freqToV: { 125: 0, 250: 2, 500: 4, 750: 5, 1000: 6, 1500: 7, 2000: 8, 3000: 9, 4000: 10, 6000: 11, 8000: 12, 12000: 13, 16000: 14 },
17
- intensity: { min: -20, max: 120, step: 10 },
18
-
19
- styles: {
20
- line: ``,
21
- juncDashLine: ``,
22
- juncLine: ``,
23
- }
24
- },
3
+ margin: { left: 0, top: 0, }, // در کانتینر دیو این عمل نمیکنه. مگر در کانتینر اس وی جی بذاریم
4
+
5
+ // واحد ویوباکس - بدون واحد
6
+ vbWidth: 700, // برای اینکه ضخامت خطوط تغییری ناهنجار نکند این ثابت میماند
7
+ vbHeight: 750, // این به نسبت تغییر می‌کند
25
8
 
26
- display: {
27
- margin: { left: 0, top: 0, }, // در کانتینر دیو این عمل نمیکنه. مگر در کانتینر اس وی جی بذاریم
28
-
29
- width: 700,
30
- height: 700,
31
-
32
- chartPadding: { left: 30, top: 45, right: 30, bottom: 10 }, // این فاصله خطوط جدول از لبه ها هست
33
- symbolDims: { width: 55, height: 55 },
34
- // virtual frequency
35
- vFrequency: { min: 0, max: 14, step: 1 },
36
- vToFreq: { 0: 125, 2: 250, 4: 500, 5: 750, 6: 1000, 7: 1500, 8: 2000, 9: 3000, 10: 4000, 11: 6000, 12: 8000, 13: 12000, 14: 16000 },
37
- freqToV: { 125: 0, 250: 2, 500: 4, 750: 5, 1000: 6, 1500: 7, 2000: 8, 3000: 9, 4000: 10, 6000: 11, 8000: 12, 12000: 13, 16000: 14 },
38
- intensity: { min: -20, max: 130, step: 10 },
39
-
40
- styles: {
41
- line: `stroke: black; stroke-width: 1;`,
42
- juncDashLine: `stroke-width: 1 ; stroke-opacity: 0.8; stroke-dasharray: 4;`,
43
- juncLine: `stroke-width: 1; stroke-opacity: 0.8;`,
44
- }
9
+ // واحد پیکسل، میلیمتر، ...
10
+ // اگر واحد پایینی توسط بیرون تغییر کرد واحدهای بالایی باید با نسبت پایینی تغییر کنند
11
+ width: 700,
12
+ height: 700 ,
13
+
14
+ // این فاصله خطوط محورهای بالا و چپ ادیوگرام از لبه ها هست
15
+ chartPadding: { left: 40, top: 40, right: 30, bottom: 20 },
16
+ symbolDims: { width: 55, height: 55 },
17
+ symbolsChart: {
18
+ width: 240, height: 60
45
19
  },
46
- rasa_audiometry: {
47
- blank: true, // define Blank Chart for PrePrinted Chart, Lines do not draw
48
- // width: 70.6,
49
- // height: 70,
50
- // margin: { left: 17, top: 18.5, },
51
- chartPadding: { left: 0, top: 0, right: 0, bottom: 0 },
52
- symbolDims: { width: 8, height: 8 },
53
- // virtual frequency
54
- vFrequency: { min: 0, max: 14, step: 1 },
55
- vToFreq: { 0: 125, 2: 250, 4: 500, 5: 750, 6: 1000, 7: 1500, 8: 2000, 9: 3000, 10: 4000, 11: 6000, 12: 8000, 13: 12000, 14: 16000 },
56
- freqToV: { 125: 0, 250: 2, 500: 4, 750: 5, 1000: 6, 1500: 7, 2000: 8, 3000: 9, 4000: 10, 6000: 11, 8000: 12, 12000: 13, 16000: 14 },
57
- intensity: { min: -20, max: 120, step: 10 },
58
-
59
- styles: {
60
- line: `stroke: black; stroke-width: 0.1;`,
61
- juncDashLine: `stroke-width: 0.1 ; stroke-opacity: 0.8; stroke-dasharray: 0.5;`,
62
- juncLine: `stroke-width: 0.2; stroke-opacity: 0.8;`,
63
- }
20
+ // virtual frequency
21
+ mainFrequencies: [125, 250, 500, 1000, 2000, 4000, 8000],
22
+ frequencies: [
23
+ { f: 125, vf: 0, label: false }, { f: 250, vf: 2 },
24
+ { f: 500, vf: 4 }, { f: 750, vf: 5.2, semiOctav: true },
25
+ { f: 1000, vf: 6 }, { f: 1500, vf: 7.2, semiOctav: true },
26
+ { f: 2000, vf: 8 }, { f: 3000, vf: 9.2, semiOctav: true },
27
+ { f: 4000, vf: 10 }, { f: 6000, vf: 11.2, semiOctav: true },
28
+ { f: 8000, vf: 12 }, { f: 16000, vf: 14 },
29
+ ],
30
+
31
+ vf: { min: 0, max: 14, step: 1 }, // virtual frequency
32
+ vfArray: [0, 2, 4, 5.2, 6, 7.2, 8, 9.2, 10, 11.2, 12],
33
+ vfToF: { 0: 125, 2: 250, 4: 500, 5.2: 750, 6: 1000, 7.2: 1500, 8: 2000, 9.2: 3000, 10: 4000, 11.2: 6000, 12: 8000, 13: 12000, 14: 16000 },
34
+ fToVf: { 125: 0, 250: 2, 500: 4, 750: 5.2, 1000: 6, 1500: 7.2, 2000: 8, 3000: 9.2, 4000: 10, 6000: 11.2, 8000: 12, 12000: 13.2, 16000: 14 },
35
+ intensity: { min: -20, max: 130, step: 10 },
36
+ styles: {
37
+ frequency: `text-anchor: middle; dominant-baseline: hanging;
38
+ font: 1.3em Verdana, Helvetica, Arial, sans-serif; user-select: none;font-weight:bold;`,
39
+ intensity: `text-anchor: end; dominant-baseline: middle;
40
+ font: 1.3em Verdana, Helvetica, Arial, sans-serif; user-select: none;font-weight:bold;`,
41
+ mainFreqline: `stroke: black; stroke-width: 1;`,
42
+ semiOctavFreqline: `stroke: black; stroke-width: 1; stroke-dasharray: 4;`,
43
+ boldLine: 'stroke: black; stroke-width: 3;',
44
+
45
+ juncDashLine: `stroke-width: 1 ; stroke-opacity: 0.8; stroke-dasharray: 4;`,
46
+ juncLine: `stroke-width: 1; stroke-opacity: 0.8;`,
64
47
  },
65
- combo: {
66
- // width: 50,
67
- // height: 40,
68
- // margin: { left: 5, top: 5, right: 5, bottom: 5 },
69
- chartPadding: { left: 8, top: 8, right: 5, bottom: 3 },
70
- symbolDims: { width: 8, height: 8 },
71
- // virtual frequency
72
- vFrequency: { min: 0, max: 14, step: 1 },
73
- vToFreq: { 0: 125, 2: 250, 4: 500, 5: 750, 6: 1000, 7: 1500, 8: 2000, 9: 3000, 10: 4000, 11: 6000, 12: 8000, 13: 12000, 14: 16000 },
74
- freqToV: { 125: 0, 250: 2, 500: 4, 750: 5, 1000: 6, 1500: 7, 2000: 8, 3000: 9, 4000: 10, 6000: 11, 8000: 12, 12000: 13, 16000: 14 },
75
- intensity: { min: -20, max: 120, step: 10 },
76
-
77
- styles: {
78
- line: `stroke: black; stroke-width: 0.1;`,
79
- juncDashLine: `stroke-width: 0.1 ; stroke-opacity: 0.8; stroke-dasharray: 0.5;`,
80
- juncLine: `stroke-width: 0.2; stroke-opacity: 0.8;`,
81
- }
82
- }
48
+
49
+ // پس از اضافه کردن هر آیتم در زیر این تمپلت رو هم آپدیت کنید
50
+ // template: {
51
+ // margin: { left: 0, top: 0, }, // در کانتینر دیو این عمل نمیکنه. مگر در کانتینر اس وی جی بذاریم
52
+
53
+ // width: 700,
54
+ // height: 700,
55
+
56
+ // chartPadding: { left: 40, top: 50, right: 30, bottom: 10 },
57
+ // symbolDims: { width: 55, height: 55 },
58
+ // // virtual frequency
59
+ // frequencies: [{ value: 125, x: 0 }, { value: 250, x: 2 }, { value: 500, x: 4 }, { value: 750, x: 5 }],
60
+
61
+ // iFrequency: { min: 0, max: 14, step: 1 },
62
+ // iToFreq: { 0: 125, 2: 250, 4: 500, 5: 750, 6: 1000, 7: 1500, 8: 2000, 9: 3000, 10: 4000, 11: 6000, 12: 8000, 13: 12000, 14: 16000 },
63
+ // fToVf: { 125: 0, 250: 2, 500: 4, 750: 5, 1000: 6, 1500: 7, 2000: 8, 3000: 9, 4000: 10, 6000: 11, 8000: 12, 12000: 13, 16000: 14 },
64
+ // intensity: { min: -20, max: 120, step: 10 },
65
+
66
+ // styles: {
67
+ // freq: ``,
68
+ // line: ``,
69
+ // juncDashLine: ``,
70
+ // juncLine: ``,
71
+ // }
72
+ // },
73
+
74
+ // display: {
75
+ // width: 800,
76
+ // height: 600,
77
+
78
+
79
+ // },
80
+ // rasa_audiometry: {
81
+ // blank: true, // define Blank Chart for PrePrinted Chart, Lines do not draw
82
+ // // width: 70.6,
83
+ // // height: 70,
84
+ // // margin: { left: 17, top: 18.5, },
85
+ // chartPadding: { left: 0, top: 0, right: 0, bottom: 0 },
86
+ // symbolDims: { width: 8, height: 8 },
87
+ // // virtual frequency
88
+ // frequencies: [{ value: 125, x: 0 }, { value: 250, x: 2 }, { value: 500, x: 4 }, { value: 750, x: 5 }],
89
+
90
+ // iFrequency: { min: 0, max: 14, step: 1 },
91
+ // iToFreq: { 0: 125, 2: 250, 4: 500, 5: 750, 6: 1000, 7: 1500, 8: 2000, 9: 3000, 10: 4000, 11: 6000, 12: 8000, 13: 12000, 14: 16000 },
92
+ // fTovf: { 125: 0, 250: 2, 500: 4, 750: 5.2, 1000: 6, 1500: 7.2, 2000: 8, 3000: 9.2, 4000: 10, 6000: 11.2, 8000: 12, 12000: 13.2, 16000: 14 },
93
+ // intensity: { min: -20, max: 120, step: 10 },
94
+
95
+ // styles: {
96
+ // freq: ``,
97
+ // line: `stroke: black; stroke-width: 0.1;`,
98
+ // juncDashLine: `stroke-width: 0.1 ; stroke-opacity: 0.8; stroke-dasharray: 0.5;`,
99
+ // juncLine: `stroke-width: 0.2; stroke-opacity: 0.8;`,
100
+ // }
101
+ // },
102
+ // combo: {
103
+ // // width: 50,
104
+ // // height: 40,
105
+ // // margin: { left: 5, top: 5, right: 5, bottom: 5 },
106
+ // chartPadding: { left: 8, top: 8, right: 5, bottom: 3 },
107
+ // symbolDims: { width: 8, height: 8 },
108
+ // // virtual frequency
109
+ // frequencies: [{ value: 125, x: 0 }, { value: 250, x: 2 }, { value: 500, x: 4 }, { value: 750, x: 5 }],
110
+
111
+ // iFrequency: { min: 0, max: 14, step: 1 },
112
+ // iToFreq: { 0: 125, 2: 250, 4: 500, 5: 750, 6: 1000, 7: 1500, 8: 2000, 9: 3000, 10: 4000, 11: 6000, 12: 8000, 13: 12000, 14: 16000 },
113
+ // freqToi: { 125: 0, 250: 2, 500: 4, 750: 5, 1000: 6, 1500: 7, 2000: 8, 3000: 9, 4000: 10, 6000: 11, 8000: 12, 12000: 13, 16000: 14 },
114
+ // intensity: { min: -20, max: 120, step: 10 },
115
+
116
+ // styles: {
117
+ // freq: ``,
118
+ // line: `stroke: black; stroke-width: 0.1;`,
119
+ // juncDashLine: `stroke-width: 0.1 ; stroke-opacity: 0.8; stroke-dasharray: 0.5;`,
120
+ // juncLine: `stroke-width: 0.2; stroke-opacity: 0.8;`,
121
+ // }
122
+ // }
83
123
  }
84
124
 
85
125
  export default dims;
package/src/Form/Form.js CHANGED
@@ -1,4 +1,4 @@
1
- import Symbols from "../Symbol/Symbols.js";
1
+ // import Symbols from "../Symbol/Symbols.js";
2
2
  import TextBox from "./TextBox.js";
3
3
  import Header from "./Header.js";
4
4
  import Reflex from "./Reflex.js";
@@ -11,9 +11,7 @@ const svgNS = "http://www.w3.org/2000/svg";
11
11
 
12
12
 
13
13
  export default class Form {
14
- constructor({ container, template, image } = {}) {
15
- this.image = image;
16
- // const dims = template;
14
+ constructor({ container, template } = {}) {
17
15
  this.template = template;
18
16
  this.container = container;
19
17
  this.data = {};
@@ -36,26 +34,26 @@ export default class Form {
36
34
  this.patient.draw({ dims: template.patient });
37
35
  }
38
36
 
39
-
40
37
  if (sections.history) {
41
38
  this.history = new TextBox({ container: sections.history })
42
39
  this.history.draw({ dims: template.history });
43
40
  }
44
41
 
45
- this.symbols = new Symbols();
46
-
47
42
  if (sections.RAudiogram) {
48
43
  this.RAudiogram = new AudiogramChart({
49
44
  container: sections.RAudiogram,
50
45
  dims: template.RAudiogram,
51
46
  side: 'R',
47
+ events: false
52
48
  });
53
49
  }
50
+
54
51
  if (sections.LAudiogram) {
55
52
  this.LAudiogram = new AudiogramChart({
56
53
  container: sections.LAudiogram,
57
54
  dims: template.LAudiogram,
58
55
  side: 'L',
56
+ events: false
59
57
  });
60
58
  }
61
59
  if (sections.RSpeech) {
@@ -67,19 +65,19 @@ export default class Form {
67
65
  this.LSpeech.draw({ dims: template.LSpeech, });
68
66
  }
69
67
  if (sections.RTympanogram) {
70
- this.RTympanogram = new Tympanogram({ container: sections.RTympanogram, dims: template.RTympanogram })
68
+ this.RTympanogram = new Tympanogram({ container: sections.RTympanogram, side: 'R' })
71
69
  this.RTympanogram.draw({ dims: template.RTympanogram });
72
70
  }
73
71
  if (sections.LTympanogram) {
74
- this.LTympanogram = new Tympanogram({ container: sections.LTympanogram, dims: template.LTympanogram })
72
+ this.LTympanogram = new Tympanogram({ container: sections.LTympanogram, side: 'L' })
75
73
  this.LTympanogram.draw({ dims: template.LTympanogram });
76
74
  }
77
75
  if (sections.RReflex) {
78
- this.RReflex = new Reflex({ container: sections.RReflex, dims: template.RReflex })
76
+ this.RReflex = new Reflex({ container: sections.RReflex })
79
77
  this.RReflex.draw({ dims: template.RReflex });
80
78
  }
81
79
  if (sections.LReflex) {
82
- this.LReflex = new Reflex({ container: sections.LReflex, dims: template.LReflex })
80
+ this.LReflex = new Reflex({ container: sections.LReflex })
83
81
  this.LReflex.draw({ dims: template.LReflex });
84
82
  }
85
83
  if (sections.report) {
@@ -87,70 +85,37 @@ export default class Form {
87
85
  this.report.draw({ dims: template.report });
88
86
  }
89
87
  if (sections.footer) {
90
-
91
88
  this.footer = new TextBox({ container: sections.footer })
92
89
  this.footer.draw({ dims: template.footer });
93
90
  }
94
91
 
95
92
  this.container.appendChild(this.form);
96
-
97
93
  }
98
94
 
99
- draw() {
100
-
101
- let pad;
102
- let style = `
103
- user-select: none;
104
- direction: ltr !important;
105
- /* text-align: center; */
106
- font-family: Arial, Helvetica, sans-serif !important;
107
- font-size: 1.3mm;
108
- font-weight: bold;
109
- color: red;
110
- text-anchor: middle; /*تراز افقی*/
111
- dominant-baseline: middle; /* تراز عمودی*/
112
- `;
113
- // Draw Titles first
114
- // putText({ container: this.sections.audiograms, value: "Right Ear", x: 42.5, y: 4, style: style })
115
- // putText({ container: this.sections.speechs, value: "Speech Tests", x: this.sectionWidth / 2, y: 4, style: style })
116
- // putText({ container: this.sections.tympanograms, value: "Tympanometry", x: this.sectionWidth / 2, y: 4, style: style })
117
- // putText({ container: this.sections.reflexes, value: "Acoustic Reflexes", x: this.sectionWidth / 2, y: 4, style: style })
118
-
119
-
120
- // برای مخفی کردن بوردرها تابع تاگل بوردر همین جا فراخوانی شود
121
- // this.toggleBorders({ container: 'form' })
122
- // this.toggleBorders({ container: 'section' })
123
- // this.toggleBorders({ container: 'element' })
124
-
125
-
126
- // بعد از رسم همه المنت ها یک المنت مستطیل تاپ لایر
127
- // drawTopLayer({ container: this.form, dims: this.sections.dims });
128
- }
129
95
 
130
96
  create({ paper, margin }) {
131
97
  const { width, height } = paper;
132
98
  const { left, top } = margin;
133
99
 
134
100
  const backgroundImage = this.template.backgroundImage;
101
+
135
102
  let svg = document.createElementNS(svgNS, "svg");
136
103
  svg.setAttribute("viewBox", [-left, -top, width, height])
137
104
  svg.setAttribute("style", "background-color: BlanchedAlmond");
138
- if (this.image) {
139
- let image = document.createElementNS(svgNS, "image");
140
- image.setAttribute('class', 'non-print')
141
- image.setAttribute('width', width);
142
- image.setAttribute('height', height);
105
+ if (backgroundImage) {
106
+ let image = document.createElementNS(svgNS, "image")
107
+ image.setAttribute('class', 'no-print')
108
+ image.setAttribute('width', width)
109
+ // image.setAttribute('height', height)
143
110
 
144
111
  image.setAttribute('x', 0)
145
- image.setAttribute('y', -0.6)
112
+ image.setAttribute('y', 0)
146
113
  // image.setAttribute('height', height);
147
- image.setAttribute('href', this.image);
148
-
149
- svg.appendChild(image);
150
- }
114
+ image.setAttribute('href', backgroundImage)
151
115
 
152
- // div.appendChild(svg);
153
- return svg;
116
+ svg.appendChild(image)
117
+ }
118
+ return svg
154
119
  }
155
120
 
156
121
  update({ data, officeData, patientData, sessionIndex = 0 }) {
@@ -243,29 +208,6 @@ export default class Form {
243
208
  stroke-dasharray: 0.5;
244
209
  fill: transparent;
245
210
  `;
246
- putRect({ container, x: 0, y: 0, width, height, style })
247
- // Horizontal Lines
248
- // putLine({
249
- // container: container, x1: 0, y1: margin.top,
250
- // x2: width, y2: margin.top, style: style, name: 'form-border'
251
- // })
252
- // putLine({
253
- // container: container, x1: 0, y1: height - margin.bottom,
254
- // x2: width, y2: height - margin.bottom, style: style, name: 'form-border'
255
- // })
256
- // // Vertical Lines
257
- // putLine({
258
- // container: container, x1: margin.left, y1: 0,
259
- // x2: margin.left, y2: height, style: style, name: 'form-border'
260
- // })
261
- // putLine({
262
- // container: container, x1: width - margin.right, y1: 0,
263
- // x2: width - margin.right, y2: height, style: style, name: 'form-border'
264
- // })
265
- // // Middle Line
266
- // putLine({
267
- // container: container, x1: width / 2, y1: 0,
268
- // x2: width / 2, y2: height, style: style, name: 'form-border'
269
- // })
211
+ putRect({ container, x: 0, y: 0, width, height, style, className: 'no-print' })
270
212
  }
271
213
  }
package/src/Form/Forms.js CHANGED
@@ -4,97 +4,83 @@ import printForm from "./printForm.js";
4
4
  import Form from "./Form.js";
5
5
  import combo from "./templates/combo.js"; // این در حقیقیت یک تمپلت هست
6
6
  import rasaAud from "./templates/rasa_audiometry.js";
7
- // import rasaAudImage from './templates/rasaAud.png'
8
- import rasaAudImage from './templates/rasa_audiometry.jpg'
7
+ import rasaTymp from './templates/rasa_tymp_reflex.js'
9
8
 
10
9
  // خط کد زیر لازم هست
11
- import '../fonts/Vazirmatn-Regular.woff2'
10
+ import './fonts/Vazirmatn-Regular.woff2'
12
11
  import '../style.css'
13
12
 
14
13
  // کلاس جدید که فرم‌های مختلف را نمایش میدهد
15
14
  export default class Forms {
16
15
  constructor({ assets, container } = {}) {
16
+ this.container = container
17
+ this.addForms({ templates: [rasaAud, rasaTymp, combo] })
18
+ }
19
+
20
+ // افزودن فرم
21
+ addForms({ templates }) {
22
+ const container = this.container
17
23
  // ایجاد یک دیو برای قرار دادن دکمه ها و لینک های فرم
18
24
  const div = document.createElement('div');
25
+ container.addEventListener('click', e => {
26
+ console.log(e.target);
27
+ })
28
+
19
29
  div.style = 'border: 1px solid brown; margin: 0; padding: 0;'
20
30
  container.appendChild(div);
31
+
21
32
  // اضافه کردن دکمه به دیو فرم
22
33
  let className = 'button-form persian';
23
- const btn = [];
24
- btn[0] = this.putButton({ container: div, text: rasaAud.label, className });
25
- btn[1] = this.putButton({ container: div, text: combo.label, className });
26
- const printBtn = this.putButton({ container: div, text: 'چاپ', className });
34
+ const btns = [];
27
35
 
28
- // یک دیو تعریف میکنیم که سمت ادیولاگ برای تعریف لیستنر استفاده می‌شود
29
- this.div = document.createElement('div'); // این بخش فقط شامل بخش اس‌وی‌جی هست
30
- container.appendChild(this.div)
36
+ const forms = []; // آرایه آبجکت های فرم های مختلف
37
+ this.forms = forms;
31
38
 
32
- this.forms = []; // آرایه آبجکت های فرم های مختلف
33
- this.forms.push(new Form({ container: this.div, template: rasaAud, image: rasaAudImage }));
34
- this.forms.push(new Form({ container: this.div, template: combo }));
35
-
36
- // انتخاب فرم پیش‌فرض
37
- this.forms[0].form.style.display = 'block';
38
- this.selectedForm = this.forms[0]
39
- btn[0].style.backgroundColor = ' #1c15e1'
39
+ templates.forEach((template, index) => {
40
+ btns[index] = this.putButton({ container: div, text: template.label, className });
41
+ this.forms.push(new Form({ container, template }));
42
+ });
40
43
 
44
+ const printBtn = this.putButton({ container: div, text: 'چاپ', className });
41
45
  // تعریف رویداد دکمه چاپ فرم نمایشی
42
- printBtn.addEventListener('click', () => { printForm({ container: this.selectedForm.form }) })
43
-
44
- btn[0].addEventListener('click', () => {
45
- this.forms[1].form.style.display = 'none'
46
- btn[1].style.backgroundColor = ' #7472e2'
46
+ printBtn.addEventListener('click', () => { printForm({ container: this.selectedForm.form }) });
47
47
 
48
- // this.forms[2].form.style.display = 'none'
49
- this.forms[0].form.style.display = 'block';
50
- btn[0].style.backgroundColor = ' #1c15e1'
48
+ // انتخاب فرم پیش‌فرض
49
+ let selectedIndex = 0
50
+ forms[selectedIndex].form.style.display = 'block';
51
+ this.selectedForm = this.forms[selectedIndex]
52
+ btns[selectedIndex].style.backgroundColor = ' #1c15e1'
51
53
 
52
- this.selectedForm = this.forms[0];
53
- this.update(this.allData);
54
54
 
55
- });
55
+ btns.forEach((btn, index) => {
56
+ btn.addEventListener('click', () => {
57
+ // Hide All forms
58
+ forms.forEach((form, i) => {
59
+ form.form.style.display = 'none'
60
+ btns[i].style.backgroundColor = ' #7472e2'
56
61
 
57
- btn[1].addEventListener('click', () => {
58
- this.forms[0].form.style.display = 'none'
59
- btn[0].style.backgroundColor = ' #7472e2'
62
+ });
60
63
 
61
- // this.forms[2].form.style.display = 'none'
62
- this.forms[1].form.style.display = 'block';
63
- btn[1].style.backgroundColor = ' #1c15e1'
64
+ forms[index].form.style.display = 'block';
65
+ btns[index].style.backgroundColor = ' #1c15e1'
64
66
 
65
- this.selectedForm = this.forms[1];
66
- // آپدیت فرم انتخاب شده
67
- this.update(this.allData);
68
- });
67
+ this.selectedForm = forms[index];
68
+ selectedIndex = index
69
+ this.update(this.allData);
70
+ })
71
+ })
69
72
 
70
- // btn3.addEventListener('click', () => {
71
- // this.forms[0].form.style.display = 'none'
72
- // this.forms[1].form.style.display = 'none'
73
- // this.forms[2].form.style.display = 'block';
74
- // this.selectedForm = this.forms[2]
75
- // // آپدیت فرم انتخاب شده
76
- // this.update(this.allData);
77
-
78
- // });
79
- // for Develop
80
- // this.event();
73
+ this.putButton({ container: div, text: 'Show/Hide', className })
74
+ .addEventListener('click', () => { this.toggleDisplay({ container: forms[selectedIndex].form }) });
81
75
  }
76
+
82
77
  // این تابع یک بار از بیرون کلاس فراخوانی میشه و یک بار وقتی از داخل تمپلت فرم را عوض میکنیم
83
78
  update({ data, officeData, patientData, sessionIndex = 0 }) {
84
79
  // ذخیره کل دیتا برای استفاده داخلی آپدیت فرم انتخاب شده
85
80
  this.allData = { data, officeData, patientData, sessionIndex }
86
81
  this.selectedForm.update({ data, officeData, patientData, sessionIndex })
87
82
  }
88
- // ایجاد دکمه تاگل خطوط مرزی فرم و سکشن و المان
89
- toggleBorders({ activeForm, container = 'form' }) {
90
- const borders = activeForm.querySelectorAll(`[data-name="${container}-border"]`);
91
- // آبجکت نگهداری رنگ بوردرها
92
- const color = { form: 'black', section: 'blue', element: 'green' }
93
- borders.forEach(border => {
94
- // console.log(border.style.stroke);
95
- border.style.stroke = (border.style.stroke === 'transparent') ? color[container] : 'transparent';
96
- })
97
- }
83
+
98
84
  // توابع داخلی ایجاد دکمه و لینک های بالای فرم
99
85
  putButton({ container, id, text, className }) {
100
86
  const button = document.createElement('button');
@@ -104,4 +90,13 @@ export default class Forms {
104
90
  container.appendChild(button);
105
91
  return button;
106
92
  }
93
+
94
+ // تابع تاگل نمایش و مخفی کردن خطوط راهنمای طراحی
95
+ toggleDisplay({ container }) {
96
+ container.querySelectorAll(`[data-name='guide-border']`)
97
+ .forEach(element => {
98
+ element.style.display = (element.style.display === '') ? 'none' : '';
99
+ });
100
+
101
+ }
107
102
  }
@@ -6,8 +6,6 @@ const svgNS = "http://www.w3.org/2000/svg";
6
6
  export default class Reflex {
7
7
  constructor({ container }) {
8
8
  this.container = container;
9
- // this.left = dims.pad.left;
10
- // this.top = dims.pad.top;
11
9
  }
12
10
 
13
11
  draw({ dims }) {
@@ -16,14 +14,8 @@ export default class Reflex {
16
14
  let x = dims.margin.left;
17
15
  let y = dims.margin.top;
18
16
  let style;
19
- // جدولی با ۳ سطر و ۵ ستون
20
-
21
- // تقسیم بر ۶ کردم تا با عرض باکس‌های گفتار یکی باشه. وگرنه اینجا ۵ تا ستون داریم. یک ستون میدیم کپشن عمودی ستون اول
22
- const cw = width / 6; // پهنای هر خانه
23
- const ch = height / 3; // ارتفاع هر خانه
24
17
 
25
18
  const svg = document.createElementNS(svgNS, "svg");
26
- // svg.setAttribute("id", id);
27
19
  svg.setAttribute("x", x);
28
20
  svg.setAttribute("y", y);
29
21
  svg.setAttribute("width", width);
@@ -31,7 +23,8 @@ export default class Reflex {
31
23
  svg.setAttribute("class", "reflex");
32
24
 
33
25
  let lable = ["", "500", "1000", "2000", "4000"]; // مقادیر برچسب‌های سطر اول
34
- let cw1 = width / 6; // پهنای خانه‌های سطر اول
26
+ // جدولی با ۳ سطر و ۵ ستون
27
+ let cw1 = width / 5; // پهنای خانه‌های سطر اول
35
28
  let ch1 = height / 3; // ارتفاع خانه‌های سطر اول
36
29
  let ch2 = height / 3; // ارتفاع خانه‌های سطر دوم
37
30
 
@@ -48,7 +41,7 @@ export default class Reflex {
48
41
  `;
49
42
  lable.forEach((value, i) => {
50
43
  if (value != "") {
51
- let x = cw1 / 2 + cw1 * (i + 1);
44
+ let x = cw1 / 2 + cw1 * i;
52
45
  let y = ch1 / 2;
53
46
  // putText(value, x, y, "", "middle", "middle"); // با استایل تراز عمودی پایین نسبت به خط پایه
54
47
  putText({ container: svg, value, x, y, style })
@@ -68,13 +61,13 @@ export default class Reflex {
68
61
  `;
69
62
  lable = ["Freq", "IPSI", "CONTRA"];
70
63
  // چاپ برچسب‌های ستون اول
71
- putText({ container: svg, value: "Freq", x: cw1 * 2, y: ch1 / 2, style: style })
72
- putText({ container: svg, value: "IPSI", x: cw1 * 2, y: ch1 * 3 / 2, style: style })
73
- putText({ container: svg, value: "CONTRA", x: cw1 * 2, y: ch1 * 5 / 2, style: style })
64
+ putText({ container: svg, value: "Freq", x: cw1, y: ch1 / 2, style: style })
65
+ putText({ container: svg, value: "IPSI", x: cw1, y: ch1 * 3 / 2, style: style })
66
+ putText({ container: svg, value: "CONTRA", x: cw1, y: ch1 * 5 / 2, style: style })
74
67
 
75
68
  //چاپ ده باکس سطر دوم و سوم
76
69
  for (let j = 1; j <= 2; j++) {
77
- for (let i = 2; i <= 5; i++) {
70
+ for (let i = 1; i <= 4; i++) {
78
71
  let x = cw1 / 2 + cw1 * i;
79
72
  let y = ch1 * j + ch2 / 2;
80
73
  let bw = cw1 * 0.80; // پهنای هر باکس
@@ -95,7 +88,7 @@ export default class Reflex {
95
88
  `;
96
89
  let names = ["IPSI_500", "IPSI_1000", "IPSI_2000", "IPSI_4000"];
97
90
  for (let index = 0; index < 4; index++) {
98
- x = cw1 / 2 + cw1 * (index + 2);
91
+ x = cw1 / 2 + cw1 * (index + 1);
99
92
  y = ch1 + ch2 / 2;
100
93
  putText({ container: svg, value: "", x: x, y: y, style: style, name: names[index] })
101
94
  }
@@ -106,11 +99,11 @@ export default class Reflex {
106
99
 
107
100
  for (let index = 0; index < 4; index++) {
108
101
  // const idValue = idValues[index];
109
- x = cw1 / 2 + cw1 * (index + 2);
102
+ x = cw1 / 2 + cw1 * (index + 1);
110
103
  y = ch1 * 2 + ch2 / 2;
111
104
  putText({ container: svg, value: "", x: x, y: y, style: style, name: names[index] })
112
105
  }
113
- // مربع احاطه‌کننده کل جدول برای راهنمای توسعه
106
+ // مربع احاطه‌کننده کل جدول برای راهنمای توسعه و دریافت رویداد کلیک روی فرم
114
107
  style = 'fill: transparent; stroke: green; stroke-width: 0.5;';
115
108
  putRect({ container: svg, x: 0, y: 0, width, height, style, name: dims.name })
116
109
  this.container.appendChild(svg);
@@ -130,13 +123,10 @@ export default class Reflex {
130
123
  }
131
124
 
132
125
  update(data) {
133
- this.chart.querySelector(`text[data-name="IPSI_500"]`).innerHTML = data?.IPSI?.["500"] || "";
134
- this.chart.querySelector(`text[data-name="IPSI_1000"]`).innerHTML = data?.IPSI?.["1000"] || "";
135
- this.chart.querySelector(`text[data-name="IPSI_2000"]`).innerHTML = data?.IPSI?.["2000"] || "";
136
- this.chart.querySelector(`text[data-name="IPSI_4000"]`).innerHTML = data?.IPSI?.["4000"] || "";
137
- this.chart.querySelector(`text[data-name="CONTRA_500"]`).innerHTML = data?.CONTRA?.["500"] || "";
138
- this.chart.querySelector(`text[data-name="CONTRA_1000"]`).innerHTML = data?.CONTRA?.["1000"] || "";
139
- this.chart.querySelector(`text[data-name="CONTRA_2000"]`).innerHTML = data?.CONTRA?.["2000"] || "";
140
- this.chart.querySelector(`text[data-name="CONTRA_4000"]`).innerHTML = data?.CONTRA?.["4000"] || "";
126
+ for (const key in data) {
127
+ for (const freq in data[key]) {
128
+ this.chart.querySelector(`text[data-name=${key}_${freq}]`).innerHTML = data?.[key]?.[freq] || "";
129
+ }
130
+ }
141
131
  }
142
132
  }