hayun-vite 0.11.1 → 0.12.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.
@@ -16,6 +16,7 @@ const mainTemplate = {
16
16
  },
17
17
 
18
18
  defSections: function () {
19
+
19
20
  this['Header'] = {
20
21
  name: 'header', container: '',
21
22
  width: this.width, height: 20,
@@ -4,6 +4,7 @@ const template_combo = {
4
4
  // backgroundImage: 'backgroundImage',
5
5
  // تعیین نمایش بوردرهای سکشن ها
6
6
  sectionBorders: 'display', // display || none
7
+ boxBorders: 'none', // display || none
7
8
  margin: { left: 5, top: 5, right: 5, bottom: 5 },
8
9
  paper: { type: 'A4', case: 'portrait', width: 210, height: 297 },
9
10
 
@@ -36,6 +37,7 @@ const template_combo = {
36
37
  w: width, h: 8,
37
38
  margin: { left: 1, top: 0, right: 1, bottom: 0 },
38
39
  display: 'block',
40
+ boxBorder: 'none' // display || none default: none
39
41
  }
40
42
 
41
43
  this.history = {
@@ -43,6 +45,7 @@ const template_combo = {
43
45
  w: width, h: 14,
44
46
  margin: { left: 1, top: 0, right: 1, bottom: 0 },
45
47
  display: 'block',
48
+ boxBorder: 'none' // display || none
46
49
  }
47
50
 
48
51
  // Titles Common Object
@@ -92,7 +95,7 @@ const template_combo = {
92
95
  this.RSpeech = {
93
96
  name: 'RSpeech',
94
97
  w: width / 2, h: 15,
95
- margin: { left: 1, top: 0, right: 2, bottom: 0 },
98
+ margin: { left: 1, top: 0, right: 10, bottom: 0 },
96
99
  display: 'inline',
97
100
  stroke: true,
98
101
  }
@@ -100,7 +103,7 @@ const template_combo = {
100
103
  this.LSpeech = {
101
104
  name: 'LSpeech',
102
105
  w: width / 2, h: 15,
103
- margin: { left: 2, top: 0, right: 1, bottom: 0 },
106
+ margin: { left: 10, top: 0, right: 1, bottom: 0 },
104
107
  display: 'block',
105
108
  stroke: true
106
109
  }
@@ -116,14 +119,14 @@ const template_combo = {
116
119
  this.RTympanogram = {
117
120
  name: 'RTympanogram',
118
121
  w: width / 2, h: 60,
119
- margin: { left: 1, top: 0, right: 2, bottom: 0 },
122
+ margin: { left: 1, top: 0, right: 10, bottom: 0 },
120
123
  display: 'inline',
121
124
  }
122
125
 
123
126
  this.LTympanogram = {
124
127
  name: 'LTympanogram',
125
128
  w: width / 2, h: 60,
126
- margin: { left: 2, top: 0, right: 1, bottom: 0 },
129
+ margin: { left: 10, top: 0, right: 1, bottom: 0 },
127
130
  display: 'block',
128
131
  }
129
132
 
@@ -138,14 +141,14 @@ const template_combo = {
138
141
  this.RReflex = {
139
142
  name: 'RReflex',
140
143
  w: width / 2, h: 26,
141
- margin: { left: 1, top: 0, right: 2, bottom: 1 },
144
+ margin: { left: 1, top: 0, right: 10, bottom: 1 },
142
145
  display: 'inline'
143
146
  }
144
147
 
145
148
  this.LReflex = {
146
149
  name: 'LReflex',
147
150
  w: width / 2, h: 26,
148
- margin: { left: 2, top: 0, right: 1, bottom: 1 },
151
+ margin: { left: 10, top: 0, right: 1, bottom: 1 },
149
152
  display: 'block'
150
153
  }
151
154
 
package/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import Audiogram from './src/Audiogram/Audiogram'
2
2
  import dims from './src/Audiogram/dims'
3
3
  import { officeData, patientData } from './assets/data/sampleData'
4
- import Forms from './src/Form/Forms'
4
+ import Forms from './src/Forms/Forms'
5
5
  import combo_template from './assets/templates/template_combo'
6
6
  // import rasa_aud_template from './assets/templates/rasa_audiometry'
7
7
  // import rasa_tymp_reflex_template from './assets/templates/rasa_tymp_reflex'
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "hayun-vite",
3
3
  "private": false,
4
- "version": "0.11.1",
4
+ "version": "0.12.0",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "dev": "vite",
@@ -1,43 +1,42 @@
1
+ import putG from "../common/putG.js";
1
2
  import putLine from "../common/putLine.js";
2
3
  import putPoint from "../common/putPoint.js";
3
4
  import putRect from "../common/putRect.js";
4
5
  import putSVG from "../common/putSVG.js";
5
6
  import putText from "../common/putText.js";
6
7
  import getAllSymbolsSVG from "../Symbol/getAllSymbolsSVG.js";
7
- import mainDims from './dims_N.js';
8
+ import mainDims from './dims.js';
8
9
 
9
10
  export default class Audiogram {
10
- constructor({ box, side, events = true }) {
11
+ constructor({ box, container, side, dims, events = true }) {
12
+ console.log(box);
13
+
14
+ this.container = container;
15
+ this.dims = {}
16
+ Object.assign(this.dims, mainDims)
17
+ // dims = { blank: false }
18
+ // اضافه کردن ابعاد جایگزین و یا اختصاصی دیگر به آبجکت ابعاد
19
+ dims && Object.assign(this.dims, dims);
20
+ // console.log(dims);
11
21
 
12
- // this.container = container;
13
22
 
14
23
  this.events = events;
15
24
  this.side = side;
16
25
  this.data = {};
17
26
  const symbols = getAllSymbolsSVG();
18
27
  this.symbols = symbols;
19
- this.draw({ box });
28
+ this.draw();
20
29
  events && this.addEvents();
21
30
  }
22
31
 
23
- draw({ box }) {
24
-
25
- const { container, width, height, margin, elements, name } = box
26
-
27
- // this.dims = {}
28
- // Object.assign(this.dims, mainDims)
29
-
30
- // اضافه کردن ابعاد جایگزین و یا اختصاصی دیگر به آبجکت ابعاد
31
- // dims && Object.assign(this.dims, dims);
32
-
33
-
34
- // const [container, dims] = [this.container, this.dims]
32
+ draw() {
33
+ const [container, dims] = [this.container, this.dims]
35
34
  let
36
35
  {
37
- vbWidth, vbHeight, chartPadding, symbolDims, vf, vfArray,
36
+ vbWidth, vbHeight, width, height, chartPadding, symbolDims, vf, vfArray,
38
37
  vfToF, fToVf, intensity, styles, frequencies
39
38
  }
40
- = mainDims;
39
+ = dims;
41
40
  // متناسب سازی مقدار ارتفاع ویوباکس بر حسب نسبت طول و عرض پیکسلی
42
41
  const
43
42
  kpx = height / width,
@@ -45,8 +44,8 @@ export default class Audiogram {
45
44
 
46
45
  vbHeight = vbHeight * kpx * kvb;
47
46
 
48
- let x = margin.left
49
- let y = margin.top
47
+ let x = dims.margin.left
48
+ let y = dims.margin.top
50
49
 
51
50
  this.symbolDims = symbolDims;
52
51
  this.vf = vf;
@@ -75,64 +74,88 @@ export default class Audiogram {
75
74
  this.yAxisLength = yAxisLength
76
75
 
77
76
  // Main SVG for Audiogram
77
+ style = styles.svg;
78
78
  const viewBox = [-chartPadding.left, -chartPadding.top, vbWidth, vbHeight]
79
- const svg = putSVG({ container, x, y, width, height, viewBox })
79
+ const svg = putSVG({ container, x, y, width, height, viewBox, style })
80
80
  this.svg = svg; // کل نودی که به کانتینر اپند میشه
81
81
 
82
82
  // برای فرم‌های پیش چاپ نشده
83
- // if (!dims.blank) {
84
- // محدوده مختصات خطوط جدول
85
- const chartArea = putRect({
86
- container: svg,
87
- x: this.getX(vf.min), y: this.getY(intensity.min),
88
- width: xAxisLength.vb, height: yAxisLength.vb,
89
- style: 'stroke-width: 0.4; stroke: gray; fill: transparent'
90
- })
91
- // رسم خطوط افقی از بالا به پایین
92
- let x1 = this.getX(vf.min);
93
- let x2 = this.getX(vf.max);
94
- for (let i = intensity.min; i <= intensity.max; i += intensity.step) {
95
- const y1 = this.getY(i)
96
- const y2 = y1;
97
- style = (i === 0) ? styles.boldLine : styles.line;
98
- putLine({ container: svg, x1, y1, x2, y2, style })
99
- }
83
+ if (!dims.blank) {
84
+ // محدوده مختصات خطوط جدول
85
+ putRect({
86
+ container: svg,
87
+ x: this.getX(vf.min), y: this.getY(intensity.min),
88
+ width: xAxisLength.vb, height: yAxisLength.vb,
89
+ style: 'stroke-width: 0.4; stroke: gray; fill: transparent'
90
+ })
91
+
92
+ // رسم خطوط افقی از بالا به پایین
93
+ let g = putG({ container: svg });
94
+
95
+ let x1 = this.getX(vf.min);
96
+ let x2 = this.getX(vf.max);
97
+
98
+ for (let i = intensity.min; i <= intensity.max; i += intensity.step) {
99
+ const y1 = this.getY(i)
100
+ const y2 = y1;
101
+ style = (i === 0) ? styles.boldLine : styles.line;
102
+ putLine({ container: g, x1, y1, x2, y2, style })
103
+ }
100
104
 
101
- // رسم خطوط عمودی از چپ به راست
102
- let y1 = this.getY(intensity.min)
103
- let y2 = this.getY(intensity.max)
104
- frequencies.forEach(item => {
105
- const x1 = this.getX(item.vf)
106
- const x2 = x1
107
- style = (item.semiOctav) ? styles.semiOctavFreqline : styles.mainFreqline;
108
- (item.f === 1000) && (style = styles.boldLine);
109
- putLine({ container: svg, x1, y1, x2, y2, style })
110
- })
111
- // برچسب های اعداد فرکانس
112
- style = styles.frequency
113
- const y = this.getY(-25)
114
- frequencies.forEach(item => {
115
- const value = item.f
116
- const x = this.getX(item.vf)
117
- !item.semiOctav && item.f != 125 && item.f != 16000 &&
118
- putText({ container: svg, value, x, y, style });
119
- })
105
+ svg.appendChild(g);
106
+
107
+ // رسم خطوط عمودی از چپ به راست
108
+ g = putG({ container: svg });
109
+
110
+ let y1 = this.getY(intensity.min)
111
+ let y2 = this.getY(intensity.max)
112
+
113
+ frequencies.
114
+ forEach(item => {
115
+ const x1 = this.getX(item.vf)
116
+ const x2 = x1
117
+ style = (item.semiOctav) ? styles.semiOctavFreqline : styles.mainFreqline;
118
+ (item.f === 1000) && (style = styles.boldLine);
119
+ putLine({ container: g, x1, y1, x2, y2, style })
120
+ });
121
+
122
+ svg.appendChild(g);
123
+
124
+ // برچسب های اعداد فرکانس
125
+ style = styles.frequency
126
+ g = putG({ container: svg, style });
127
+ const y = this.getY(-25)
128
+
129
+ frequencies.
130
+ forEach(item => {
131
+ const value = item.f
132
+ const x = this.getX(item.vf)
133
+ !item.semiOctav && item.f != 125 && item.f != 16000 &&
134
+ putText({ container: g, value, x, y, });
135
+ });
136
+
137
+ svg.appendChild(g);
138
+
139
+ // رسم اعداد شدت محور عمودی
140
+ style = styles.intensity
141
+ g = putG({ container: svg, style });
142
+ const x = this.getX(-0.1)
143
+
144
+ for (let i = -10; i <= 120; i += 10) {
145
+ const y = this.getY(i)
146
+ const value = i
147
+ putText({ container: g, x, y, value })
148
+ }
149
+
150
+ svg.appendChild(g);
120
151
 
121
- // رسم اعداد شدت محور عمودی
122
- style = styles.intensity
123
- const x = this.getX(-0.1)
124
- for (let i = -10; i <= 120; i += 10) {
125
- const y = this.getY(i)
126
- const value = i
127
- putText({ container: svg, x, y, value, style })
128
152
  }
129
- // }
130
153
  // یک بوردر راهنمای توسعه برای اس‌ وی جی به تمام پهنا و ارتفاع رسم می‌کنیم
131
154
  // این مربع مرزی را آخرین ایجاد میکنیم تا بالاترین لایه باشد و روی ریودادها درست عمل کند
132
155
  const borderRect = putRect({
133
156
  container: svg, x: -chartPadding.left, y: -chartPadding.top,
134
157
  width: vbWidth, height: vbHeight, name: '',
135
- style: 'fill: transparent; stroke: transparent;',
158
+ style: 'fill: transparent; stroke: green;',
136
159
  });
137
160
  this.borderRect = borderRect;
138
161
 
package/src/Form/Form.js CHANGED
@@ -14,13 +14,13 @@ export default class Form {
14
14
  this.container = container;
15
15
  this.data = {};
16
16
  let { width, height, margin, paper } = template;
17
- this.form = this.create({ paper, margin });
18
- this.form.style.display = 'none';
17
+ this.page = this.create({ paper, margin });
18
+ this.page.style.display = 'none';
19
19
  let dims;
20
20
  // رسم مارجین های فرم
21
- this.drawMarginLines({ container: this.form, width, height });
21
+ this.drawMarginLines({ container: this.page, width, height });
22
22
 
23
- const sections = new Sections({ container: this.form, dims: template });
23
+ const sections = new Sections({ container: this.page, dims: template });
24
24
  this.sections = sections;
25
25
 
26
26
  if (sections.header) {
@@ -101,7 +101,7 @@ export default class Form {
101
101
  this.footer = new MultiText({ container: sections.footer, dims})
102
102
  }
103
103
 
104
- this.container.appendChild(this.form);
104
+ this.container.appendChild(this.page);
105
105
  }
106
106
 
107
107
 
@@ -1,14 +1,10 @@
1
- import Box from "./Box.js";
2
- import Header from "../Header/Header_N.js";
3
- import Reflex from "../Reflex/Reflex.js";
4
- import Sections from "./Sections_N.js";
5
- import Speech from "../Speech/Speech_N.js";
6
- import Tympanogram from "../Tympanogram/Tympanogram.js";
1
+ import Header from "../Header/Header_box.js";
2
+ import Speech from "../Speech/Speech_box.js";
7
3
  import putRect from "../common/putRect.js";
8
- import Audiogram from "../Audiogram/Audiogram_N.js";
4
+ import Audiogram from "../Audiogram/Audiogram_box.js";
9
5
  import mainTemplate from "../../assets/templates/mainTemplate.js";
10
6
  import putSVG from "../common/putSVG.js";
11
- import MultiText from "../MultiText/MultiText.js";
7
+ import MultiText from "../MultiText/MultiText_box.js";
12
8
  const svgNS = "http://www.w3.org/2000/svg";
13
9
 
14
10
  export default class Form {
@@ -40,7 +36,7 @@ export default class Form {
40
36
  case 'history':
41
37
  break;
42
38
  case 'RAudiogram':
43
- const RAudiogram = new Audiogram({ box, side: 'R', events: false })
39
+ const RAudiogram = new Audiogram({ box, container: box.container, side: 'R', events: false })
44
40
  break;
45
41
  case 'LAudiogram':
46
42
  // const LAudiogram = new Audiogram({ container: box.container, side: 'L', dims: box, events: false })
@@ -46,7 +46,7 @@ export default class Sections {
46
46
  putRect({
47
47
  container: svg, x: 0, y: 0, width, height,
48
48
  style: 'fill: transparent; stroke: blue; stroke-width: 0.2',
49
- className: 'no-print', name: 'guide-border'
49
+ className: 'no-print', name: 'section-border'
50
50
  });
51
51
 
52
52
  this[name] = svg;
@@ -46,7 +46,7 @@ export default class Sections {
46
46
  putRect({
47
47
  container: svg, x: 0, y: 0, width, height,
48
48
  style: 'fill: transparent; stroke: blue; stroke-width: 0.2',
49
- className: 'no-print', name: 'guide-border'
49
+ className: 'no-print', name: 'section-border'
50
50
  });
51
51
 
52
52
  this[name] = svg;
@@ -1,7 +1,7 @@
1
1
  const svgNS = "http://www.w3.org/2000/svg";
2
2
 
3
3
  import printForm from "./printForm.js";
4
- import Form from "./Form.js";
4
+ import Form from "../Form/Form.js";
5
5
  // import combo from "./templates/combo.js"; // این در حقیقیت یک تمپلت هست
6
6
  // import rasaAud from "./templates/rasa_audiometry.js";
7
7
  // import rasaTymp from './templates/rasa_tymp_reflex.js'
@@ -9,6 +9,7 @@ import Form from "./Form.js";
9
9
  // خط کد زیر لازم هست
10
10
  // import '/fonts/webfonts/Vazirmatn-Regular.woff2'
11
11
  import '../styles.css'
12
+ import putLine from "../common/putLine.js";
12
13
 
13
14
  // کلاس جدید که فرم‌های مختلف را نمایش میدهد
14
15
  export default class Forms {
@@ -34,16 +35,17 @@ export default class Forms {
34
35
 
35
36
  const forms = []; // آرایه آبجکت های فرم های مختلف
36
37
  this.forms = forms;
37
- this.pages = forms
38
38
 
39
- templates.forEach((template, index) => {
40
- (this.mode == 'develop') && (btns[index] = this.putButton({ container: div, text: template.label, className }));
41
- this.forms.push(new Form({ container, template }));
42
- });
39
+ templates.
40
+ forEach((template, index) => {
41
+ this.mode == 'develop' &&
42
+ (btns[index] = this.putButton({ container: div, text: template.label, className }));
43
+ this.forms.push(new Form({ container, template }));
44
+ });
43
45
 
44
46
  // انتخاب فرم پیش‌فرض
45
47
  let selectedIndex = defaultTemplateIndex;
46
- forms[selectedIndex].form.style.display = 'block';
48
+ forms[selectedIndex].page.style.display = 'block';
47
49
  this.selectedForm = this.forms[selectedIndex];
48
50
  (this.mode == 'develop') && (btns[selectedIndex].style.backgroundColor = ' #1c15e1');
49
51
 
@@ -51,18 +53,18 @@ export default class Forms {
51
53
 
52
54
  const printBtn = this.putButton({ container: div, text: 'چاپ', className });
53
55
  // تعریف رویداد دکمه چاپ فرم نمایشی
54
- printBtn.addEventListener('click', () => { printForm({ container: this.selectedForm.form }) });
56
+ printBtn.addEventListener('click', () => { printForm({ container: this.selectedForm.page }) });
55
57
 
56
58
  btns.forEach((btn, index) => {
57
59
  btn.addEventListener('click', () => {
58
60
  // Hide All forms
59
61
  forms.forEach((form, i) => {
60
- form.form.style.display = 'none'
62
+ form.page.style.display = 'none'
61
63
  btns[i].style.backgroundColor = ' #7472e2'
62
64
 
63
65
  });
64
66
 
65
- forms[index].form.style.display = 'block';
67
+ forms[index].page.style.display = 'block';
66
68
  btns[index].style.backgroundColor = ' #1c15e1'
67
69
 
68
70
  this.selectedForm = forms[index];
@@ -71,11 +73,56 @@ export default class Forms {
71
73
  })
72
74
  })
73
75
 
74
- this.putButton({ container: div, text: 'Show/Hide', className })
75
- .addEventListener('click', () => { this.toggleDisplay({ container: forms[selectedIndex].form }) });
76
+ // دکمه نمایش و پنهان خطوط سکشن
77
+ this.putButton({ container: div, text: 'Show/Hide Section Borders', className })
78
+ .addEventListener('click', () => {
79
+ this.toggleDisplay({ container: forms[selectedIndex].page, borderName: 'section-border' })
80
+ });
81
+
82
+ // دکمه نمایش و پنهان خطوط بوردر
83
+ this.putButton({ container: div, text: 'Show/Hide Box Borders', className })
84
+ .addEventListener('click', () => {
85
+ this.toggleDisplay({ container: forms[selectedIndex].page, borderName: 'box-border' })
86
+ });
87
+
88
+ // دکمه نمایش و پنهان شطرنجی
89
+ this.putButton({ container: div, text: 'Show/Hide Grid', className })
90
+ .addEventListener('mouseenter', () => {
91
+ this.grid({ container: forms[selectedIndex].page })
92
+ });
93
+ // فراخوانی تابع شطرنجی در اولین اجرا
94
+ this.grid({ container: forms[selectedIndex].page })
76
95
  }
77
96
  }
78
97
 
98
+ grid({ container }) {
99
+ console.log(container);
100
+ const cord = { xStart: -5, yStart: -5, xEnd: 210 - 5, yEnd: 297 - 5, xStep: 1, yStep: 1 }
101
+ let { xStart, yStart, xEnd, yEnd, xStep, yStep } = cord
102
+
103
+ // رسم خطوط افقی
104
+ let style = 'stroke: blue; stroke-width: 0.05 ; stroke-opacity: 0.8; stroke-dasharray: 0.2;'
105
+ let x1 = xStart
106
+ let y1
107
+
108
+ let x2 = xEnd
109
+ let y2
110
+
111
+ for (let y1 = yStart; y1 <= yEnd; y1 += yStep) {
112
+ y2 = y1
113
+ putLine({ container, x1, y1, x2, y2, style, name: 'grid' })
114
+ }
115
+
116
+ // رسم خطوط عمودی
117
+ y1 = yStart
118
+ for (x1 = xStart; x1 <= xEnd; x1 += xStep) {
119
+ const x2 = x1
120
+ putLine({ container, x1, y1, x2, y2, style, name: 'grid' })
121
+ }
122
+
123
+
124
+ }
125
+
79
126
  // این تابع یک بار از بیرون کلاس فراخوانی میشه و یک بار وقتی از داخل تمپلت فرم را عوض میکنیم
80
127
  update({ data, officeData, patientData, sessionIndex = 0 }) {
81
128
  // ذخیره کل دیتا برای استفاده داخلی آپدیت فرم انتخاب شده
@@ -94,8 +141,8 @@ export default class Forms {
94
141
  }
95
142
 
96
143
  // تابع تاگل نمایش و مخفی کردن خطوط راهنمای طراحی
97
- toggleDisplay({ container }) {
98
- container.querySelectorAll(`[data-name='guide-border']`)
144
+ toggleDisplay({ container, borderName }) {
145
+ container.querySelectorAll(`[data-name=${borderName}]`)
99
146
  .forEach(element => {
100
147
  element.style.display = (element.style.display === '') ? 'none' : '';
101
148
  });
@@ -62,11 +62,23 @@ export default class MultiText {
62
62
  const borderRect = putRect({
63
63
  container: svg, x: 0, y: 0, width, height,
64
64
  name: dims.name, className: 'no-print',
65
- style: 'stroke: green; fill: transparent; stroke-width: 0.3;'
65
+ style: 'stroke: transparent; fill: transparent; stroke-width: 0.3;'
66
66
  });
67
-
68
67
  this.borderRect = borderRect;
69
68
  this.container.appendChild(svg)
69
+
70
+ // Box Border for Design guid with Brown Color
71
+ dims.boxBorder === 'display' && putRect({
72
+ container: svg, x: 0, y: 0, width, height,
73
+ style: 'fill: transparent; stroke-width: 0.3; stroke: brown;',
74
+ name: 'box-border',
75
+ className: 'no-print',
76
+ })
77
+
78
+ this.container.appendChild(svg)
79
+
80
+
81
+
70
82
  }
71
83
 
72
84
  update(data) {
@@ -1,14 +1,13 @@
1
1
  import putRect from "../common/putRect.js";
2
2
  import putSVG from "../common/putSVG.js";
3
3
  import putText from "../common/putText.js";
4
- import putCell from "../common/putCell.js";
5
4
  import units from "./units.js";
6
5
 
7
6
  export default class Reflex {
8
7
  constructor({ container, side, dims }) {
9
8
  this.container = container;
10
9
  this.side = side; // این برای تعیین رنگ راست و چپ استفاده می‌شود
11
- this.draw({dims})
10
+ this.draw({ dims })
12
11
  }
13
12
 
14
13
  draw({ dims }) {
@@ -22,54 +21,35 @@ export default class Reflex {
22
21
  // کل چارت
23
22
  // const svg = putSVG({ x, y, width, height, className: 'reflex' })
24
23
  let { styles, vbWidth, vbHeight } = units;
25
-
24
+
26
25
  // کل چارت
26
+ style = styles.svg
27
27
  vbHeight = (vbWidth * height) / width // متناسب سازی ارتفاع ویباکس با پهنا و ارتفاع ورودی
28
28
  const viewBox = [0, 0, vbWidth, vbHeight].join(' ');
29
- const svg = putSVG({ x, y, width, height, viewBox })
29
+ const svg = putSVG({ x, y, width, height, viewBox, style })
30
30
  // این خط شد دو خط کد طلایی که مشکل سایز فونت در دیسپلی و کاغذ رو حل کرد
31
31
  width = vbWidth; // ثابت می‌ماند همیشه
32
32
  height = vbHeight // با نسبت پهنا و ارتفاع ورودی تغییر میکند
33
33
 
34
34
 
35
-
35
+ // چاپ برچسب‌های سطر اول
36
+ style = styles.numberlabel;
36
37
  let lable = ["", "500", "1000", "2000", "4000"]; // مقادیر برچسب‌های سطر اول
37
38
  // جدولی با ۳ سطر و ۵ ستون
38
39
  let cw1 = width / 5; // پهنای خانه‌های سطر اول
39
40
  let ch1 = height / 3; // ارتفاع خانه‌های سطر اول
40
41
  let ch2 = height / 3; // ارتفاع خانه‌های سطر دوم
41
42
 
42
- // چاپ برچسب‌های سطر اول
43
- style = `
44
- user-select: none;
45
- direction: ltr !important;
46
- /* text-align: center; */
47
- font-family: Arial, Helvetica, sans-serif !important;
48
- font-size: 1mm;
49
- font-weight: bold;
50
- text-anchor: middle; /*تراز افقی*/
51
- dominant-baseline: middle; /* تراز عمودی*/
52
- `;
53
43
  lable.forEach((value, i) => {
54
44
  if (value != "") {
55
45
  let x = cw1 / 2 + cw1 * i;
56
46
  let y = ch1 / 2;
57
- // putText(value, x, y, "", "middle", "middle"); // با استایل تراز عمودی پایین نسبت به خط پایه
58
47
  putText({ container: svg, value, x, y, style })
59
48
  }
60
49
  });
61
50
 
62
51
  // مقادیر برچسب‌های ستون اول
63
- style = `
64
- user-select: none;
65
- direction: ltr !important;
66
- /* text-align: center; */
67
- font-family: Arial, Helvetica, sans-serif !important;
68
- font-size: 1mm;
69
- font-weight: bold;
70
- text-anchor: end; /*تراز افقی*/
71
- dominant-baseline: middle; /* تراز عمودی*/
72
- `;
52
+ style = styles.textLable
73
53
  lable = ["Freq", "IPSI", "CONTRA"];
74
54
  // چاپ برچسب‌های ستون اول
75
55
  putText({ container: svg, value: "Freq", x: cw1, y: ch1 / 2, style: style })
@@ -77,24 +57,27 @@ export default class Reflex {
77
57
  putText({ container: svg, value: "CONTRA", x: cw1, y: ch1 * 5 / 2, style: style })
78
58
 
79
59
  //چاپ ده باکس سطر دوم و سوم
60
+ const inputBox = {
61
+ width: width / 5 * 0.80, height: height / 3 * 0.8,
62
+ rx: width / 100
63
+ }
64
+ // محاسبه کمان گردی بر اساس مقدار پهنا
65
+ inputBox.rx = inputBox.width / 10
66
+
80
67
  for (let j = 1; j <= 2; j++) {
81
68
  for (let i = 1; i <= 4; i++) {
82
- let x = cw1 / 2 + cw1 * i;
83
- let y = ch1 * j + ch2 / 2;
69
+ let cx = cw1 / 2 + cw1 * i;
70
+ let cy = ch1 * j + ch2 / 2;
84
71
  //رسم باکس با مختصات مرکز باکس
85
- putCell({ container: svg, x, y, dx: 0, dy: -1, width: 13, height: 7, rx: 1 });
72
+ putRect({
73
+ container: svg, cx, cy,
74
+ width: inputBox.width, height: inputBox.height, rx: inputBox.rx
75
+ });
86
76
  }
87
77
  }
88
78
 
89
- style = `
90
- user-select: none;
91
- direction: ltr !important;
92
- /* text-align: center; */
93
- font-family: Arial, Helvetica, sans-serif !important;
94
- font-size: 1mm;
95
- text-anchor: middle; /*تراز افقی*/
96
- dominant-baseline: middle; /* تراز عمودی*/
97
- `;
79
+ // مقادیر ورودی عددی
80
+ style = styles.inputNumber
98
81
  // اضافه کردن رنگ قرمز یا آبی به استایل بر اساس جهت
99
82
  style += (this.side === 'R') ? 'fill: red;' : 'fill: blue;';
100
83
 
@@ -102,7 +85,7 @@ export default class Reflex {
102
85
  for (let index = 0; index < 4; index++) {
103
86
  x = cw1 / 2 + cw1 * (index + 1);
104
87
  y = ch1 + ch2 / 2;
105
- putText({ container: svg, value: "", x, y, dx: 0, dy: -1, style, name: names[index] })
88
+ putText({ container: svg, value: "", x, y, style, name: names[index] })
106
89
  }
107
90
 
108
91
  // المنت‌های تکست خالی با آیدی یکتا در سطر سوم
@@ -113,7 +96,7 @@ export default class Reflex {
113
96
  // const idValue = idValues[index];
114
97
  x = cw1 / 2 + cw1 * (index + 1);
115
98
  y = ch1 * 2 + ch2 / 2;
116
- putText({ container: svg, value: "", x, y, dx: 0, dy: -1, style, name: names[index] })
99
+ putText({ container: svg, value: "", x, y, style, name: names[index] })
117
100
  }
118
101
  // مربع احاطه‌کننده کل جدول برای راهنمای توسعه و دریافت رویداد کلیک روی فرم
119
102
  style = 'fill: transparent; stroke: green; stroke-width: 0.5;';
@@ -12,53 +12,25 @@ const units = {
12
12
  height: 30,
13
13
 
14
14
  styles: {
15
- pressure: `
16
- user-select: none;
17
- direction: ltr !important;
18
- font-family: Vazir;
19
- font-size: 3;
20
- text-anchor: middle;
21
- dominant-baseline: hanging;
22
- `,
23
- caption: `
24
- user-select: none;
25
- direction: ltr !important;
26
- font-family: Vazir;
27
- font-size: 3;
28
- text-anchor: middle;
15
+ svg: 'user-select: none; direction: ltr !important; font-family: Vazir;',
16
+ textLable: `
17
+ font-size: 4.2;
18
+ font-weight: bold;
19
+ text-anchor: end;
29
20
  dominant-baseline: middle;
30
21
  `,
31
- label: `
32
- user-select: none;
33
- direction: ltr !important;
34
- font-family: Vazir;
35
- font-size: 1mm;
36
- text-anchor: start;
37
- dominant-baseline: middle;
38
- `,
39
- type: `
40
- user-select: none;
41
- direction: ltr !important;
42
- font-family: Vazir;
43
- font-size: 1mm;
44
- font-weight: bold;
45
- text-anchor: start;
22
+ numberlabel: `
23
+ font-size: 4.2;
24
+ font-weight: 700;
25
+ text-anchor: middle;
46
26
  dominant-baseline: middle;
47
27
  `,
48
- compliance: `
49
- user-select: none;
50
- direction: ltr !important;
51
- font-family: Vazir;
52
- font-size: 0.7mm;
53
- text-anchor: end;
54
- dominant-baseline: middle;
28
+ inputNumber: `
29
+ font-size: 4.2;
30
+ font-weight: 700;
31
+ text-anchor: middle;
32
+ dominant-baseline: middle;
55
33
  `,
56
- mainFreqline: `stroke: black; stroke-width: 1;`,
57
- semiOctavFreqline: `stroke: black; stroke-width: 1; stroke-dasharray: 4;`,
58
- boldLine: 'stroke: black; stroke-width: 3;',
59
-
60
- juncDashLine: `stroke-width: 1 ; stroke-opacity: 0.8; stroke-dasharray: 4;`,
61
- juncLine: `stroke-width: 1; stroke-opacity: 0.8;`,
62
34
  },
63
35
  }
64
36
 
@@ -1,4 +1,4 @@
1
- import putCell from "../common/putCell.js";
1
+ // https://docs.google.com/document/d/19Pgsi0eHRDgsxjkbxweHLRKVB60jrH4fzV52I83-6CM/edit?tab=t.977lyzmcu5uu#heading=h.sd8yc08kbsfo
2
2
  import putRect from "../common/putRect.js";
3
3
  import putText from "../common/putText.js";
4
4
  import putSVG from "../common/putSVG.js";
@@ -9,11 +9,10 @@ export default class Speech {
9
9
  constructor({ container, side = 'R', dims }) {
10
10
  this.container = container;
11
11
  this.side = side;
12
- this.draw({dims})
12
+ this.draw({ dims })
13
13
  }
14
14
 
15
15
  draw({ dims }) {
16
- // console.log(dims);
17
16
 
18
17
  // دریافت اطلاعات مختصات چاپ ورودی ها به جز عادی محاسبه شده
19
18
  this.inputs = (dims.forceInsert) ? dims.forceInputs : dims.inputs
@@ -23,6 +22,7 @@ export default class Speech {
23
22
  let x = dims.margin.left;
24
23
  let y = dims.margin.top;
25
24
  let { styles, vbWidth, vbHeight } = units;
25
+ let cx, cy;
26
26
 
27
27
  // کل چارت
28
28
  vbHeight = (vbWidth * height) / width // متناسب سازی ارتفاع ویباکس با پهنا و ارتفاع ورودی
@@ -32,7 +32,6 @@ export default class Speech {
32
32
  width = vbWidth; // ثابت می‌ماند همیشه
33
33
  height = vbHeight // با نسبت پهنا و ارتفاع ورودی تغییر میکند
34
34
 
35
-
36
35
  const labels = dims.labels;
37
36
  this.labels = labels;
38
37
  // یک جدول 6*2 - ۲ سطر و ۶ ستون
@@ -57,11 +56,11 @@ export default class Speech {
57
56
  ];
58
57
 
59
58
  for (let i = 0; i < rows; i++) {
60
- x = cw / 2;
61
- y = ch / 2 + ch * i;
59
+ cx = cw / 2;
60
+ cy = ch / 2 + ch * i;
62
61
  for (let j = 0; j < columns; j++) {
63
- matrix[i][j] = { i, j, x, y };
64
- x += cw;
62
+ matrix[i][j] = { i, j, cx, cy };
63
+ cx += cw;
65
64
  }
66
65
  }
67
66
 
@@ -70,12 +69,15 @@ export default class Speech {
70
69
  // برای فرم های پیش چاپ شده انجام نمیشود
71
70
  !dims.hideContext &&
72
71
  matrix[0].forEach((cell, index) =>
73
- putText({ container: svg, value: labels[index], x: cell.x, y: cell.y, dx: 0, dy: 1, style }));
72
+ putText({
73
+ container: svg, value: labels[index],
74
+ x: cell.cx, y: cell.cy, dx: 0, dy: 1, style
75
+ }));
74
76
 
75
77
  style += (this.side === 'R') ? 'fill: red;' : 'fill: blue;';
76
78
 
77
79
  const inputBox = {
78
- width: width / 5 * 0.70, height: height / 2 * 0.85,
80
+ width: width / 5 * 0.80, height: height / 2 * 0.95,
79
81
  rx: width / 100
80
82
  }
81
83
  // محاسبه کمان گردی بر اساس مقدار پهنا
@@ -85,14 +87,14 @@ export default class Speech {
85
87
  matrix[1].forEach((cell, index) => {
86
88
  // برای فرم های پیش چاپ شده باکس رسم نمیشود
87
89
  !dims.hideContext &&
88
- putCell({
89
- container: svg, x: cell.x, y: cell.y, dy: -1,
90
+ putRect({
91
+ container: svg, cx: cell.cx, cy: cell.cy, dy: -1,
90
92
  width: inputBox.width, height: inputBox.height,
91
93
  rx: inputBox.rx,
92
94
  });
93
95
  // مقدار نگه دارها
94
96
  if (!dims.forceInsert) {
95
- putText({ container: svg, value: "", x: cell.x, y: cell.y, style, name: labels[index] });
97
+ putText({ container: svg, value: "", x: cell.cx, y: cell.cy, style, name: labels[index] });
96
98
  } else {
97
99
  // برای فرم های مثل رسا استفاده میشود
98
100
  let name;
@@ -1,4 +1,3 @@
1
- import putCell from "../common/putCell.js";
2
1
  import putRect from "../common/putRect.js";
3
2
  import putText from "../common/putText.js";
4
3
  import putSVG from "../common/putSVG.js";
@@ -7,13 +6,10 @@ const svgNS = "http://www.w3.org/2000/svg";
7
6
 
8
7
  export default class Speech {
9
8
  constructor({ box, side = 'R' }) {
10
- console.log(box);
11
-
12
9
  // const { container, width, height, elements } = box
13
10
  // this.container = container;
14
11
  this.side = side;
15
12
  this.draw({ box })
16
-
17
13
  }
18
14
 
19
15
  draw({ box }) {
@@ -52,7 +48,6 @@ export default class Speech {
52
48
  }
53
49
  }
54
50
 
55
-
56
51
  // ایجاد ماتریکس سلول های چارت که آدرس و مختصات مرکز هر سلول را نگهداری میکند
57
52
  const matrix = [
58
53
  [],
@@ -69,7 +64,6 @@ export default class Speech {
69
64
  }
70
65
 
71
66
  style = styles.label;
72
-
73
67
  // برچسب های سطر اول
74
68
  // برای فرم های پیش چاپ شده انجام نمیشود
75
69
  // !dims.hideContext &&
@@ -89,8 +83,8 @@ export default class Speech {
89
83
  matrix[1].forEach((cell, index) => {
90
84
  // برای فرم های پیش چاپ شده باکس رسم نمیشود
91
85
  // !dims.hideContext &&
92
- putCell({
93
- container, x: cell.x, y: cell.y, dy: -1,
86
+ putRect({
87
+ container, cx: cell.x, cy: cell.y, dy: -1,
94
88
  width: inputBox.width, height: inputBox.height,
95
89
  rx: inputBox.rx,
96
90
  });
@@ -2,7 +2,7 @@
2
2
  const svgNS = "http://www.w3.org/2000/svg";
3
3
 
4
4
  export default function putLine({ container, x1, y1, x2, y2, style = 'stroke: black; stroke-width: 0.3;', name }) {
5
-
5
+
6
6
  let line = document.createElementNS(svgNS, "line");
7
7
  line.setAttribute("x1", x1);
8
8
  line.setAttribute("y1", y1);
@@ -10,8 +10,7 @@ export default function putLine({ container, x1, y1, x2, y2, style = 'stroke: bl
10
10
  line.setAttribute("y2", y2);
11
11
  line.setAttribute("style", style)
12
12
  line.setAttribute("data-name", name)
13
- // line.setAttribute("stroke", "black");
14
- // line.setAttribute("stroke-width", 0.5);
13
+
15
14
  container.appendChild(line);
16
15
 
17
16
  }
@@ -1,15 +1,25 @@
1
+ // https://docs.google.com/document/d/19Pgsi0eHRDgsxjkbxweHLRKVB60jrH4fzV52I83-6CM/edit?tab=t.0#heading=h.5zc9gsazq7wu
1
2
  const svgNS = "http://www.w3.org/2000/svg";
2
3
 
3
- export default function putRect({ container, x, y, width, height, style = 'fill: transparent; stroke: green; stroke-width: 0.5;', name, className }) {
4
+
5
+ export default function putRect({
6
+ container, x, y, cx, cy, dx = 0, dy = 0, rx, width, height,
7
+ style = 'fill: transparent; stroke: black; stroke-width: 0.2;', name, className
8
+ }
9
+ ) {
4
10
  let rect = document.createElementNS(svgNS, "rect");
5
- rect.setAttribute("x", x);
6
- rect.setAttribute("y", y);
11
+ cx && rect.setAttribute("x", cx - width / 2 + dx);
12
+ cy && rect.setAttribute("y", cy - height / 2 + dy);
13
+ rx && rect.setAttribute("rx", rx);
14
+ x && rect.setAttribute("x", x + dx);
15
+ y && rect.setAttribute("y", y + dy);
7
16
  rect.setAttribute("width", width);
8
17
  rect.setAttribute("height", height);
9
18
  rect.setAttribute("style", style);
10
19
  className && rect.setAttribute("class", className);
11
- rect.setAttribute("data-name", name);
12
- container.appendChild(rect);
20
+ name && rect.setAttribute("data-name", name);
21
+ container && container.appendChild(rect);
22
+
13
23
  return rect;
14
24
 
15
25
  }
package/src/main.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // import './style.css'
2
2
  import Audiogram from "./Audiogram/Audiogram.js"
3
- import Forms from "./Form/Forms.js";
3
+ import Forms from "./Forms/Forms.js";
4
4
  import { officeData, patientData } from "../assets/data/sampleData.js"
5
5
  import template from "../assets/templates/template_combo.js";
6
6
  import Tympanogram from "./Tympanogram/Tympanogram.js";
@@ -163,7 +163,7 @@ dims = {
163
163
  ]
164
164
  }
165
165
 
166
- const patient = new MultiText({ container, dims })
166
+ // const patient = new MultiText({ container, dims })
167
167
 
168
168
  dims = {
169
169
  "blank": false,
@@ -1,84 +0,0 @@
1
- // import { svgNS } from "../../globalinfo.js";
2
- const svgNS = "http://www.w3.org/2000/svg";
3
-
4
- // پهنا و ارتفاع ظرف را پیدا کن و آنرا شطرنجی کن
5
- export default function drawGrid(container) {
6
- const viewBox = container.getAttribute("viewBox");
7
- const w = container.getAttribute("width");
8
- const h = container.getAttribute("height");
9
- const svg = document.createElementNS(svgNS, "svg");
10
- svg.setAttribute("viewBox", viewBox);
11
- // svg.setAttribute("width", 210);
12
- // svg.setAttribute("height", 297);
13
-
14
- // مربع احاطه‌کننده کل جدول برای راهنمای توسعه
15
- let rect = document.createElementNS(svgNS, "rect");
16
- rect.setAttribute("x", 0);
17
- rect.setAttribute("y", 0);
18
- rect.setAttribute("width", 210);
19
- rect.setAttribute("height", 297);
20
- rect.setAttribute("style", "fill: transparent; stroke-width: 1;");
21
- svg.appendChild(rect);
22
-
23
- let line,
24
- x,
25
- y = 0;
26
- // رسم خطوط افقی با فاصله واحد ویوباکس
27
- for (y = 1; y <= 296; y++) {
28
- line = document.createElementNS(svgNS, "line");
29
- line.setAttribute("x1", 1);
30
- line.setAttribute("y1", y);
31
- line.setAttribute("x2", 209);
32
- line.setAttribute("y2", y);
33
- line.setAttribute(
34
- "style",
35
- "stroke: black; stroke-width: 0.1; stroke-opacity: 0.5; stroke-dasharray: 0.1;"
36
- );
37
- line.setAttribute("class", "gridLines");
38
- svg.appendChild(line);
39
- }
40
-
41
- // رسم خطوط عمودی با فاصله واحد ویوباکس
42
- for (x = 1; x <= 209; x++) {
43
- line = document.createElementNS(svgNS, "line");
44
- line.setAttribute("x1", x);
45
- line.setAttribute("y1", 1);
46
- line.setAttribute("x2", x);
47
- line.setAttribute("y2", 296);
48
- line.setAttribute(
49
- "style",
50
- "stroke: black; stroke-width: 0.1; stroke-opacity: 0.5; stroke-dasharray: 0.1;"
51
- );
52
- line.setAttribute("class", "gridLines");
53
-
54
- svg.appendChild(line);
55
- }
56
- // رسم خط میانی افقی
57
- line = document.createElementNS(svgNS, "line");
58
- line.setAttribute("x1", 1);
59
- line.setAttribute("y1", 297/2);
60
- line.setAttribute("x2", 209);
61
- line.setAttribute("y2", 297/2);
62
- line.setAttribute(
63
- "style",
64
- "stroke: black; stroke-width: 0.2; stroke-opacity: 0.8;"
65
- );
66
- line.setAttribute("class", "gridLines");
67
-
68
- svg.appendChild(line);
69
-
70
- // رسم خط میانی عمودی
71
- line = document.createElementNS(svgNS, "line");
72
- line.setAttribute("x1", 105);
73
- line.setAttribute("y1", 1);
74
- line.setAttribute("x2", 105);
75
- line.setAttribute("y2", 296);
76
- line.setAttribute(
77
- "style",
78
- "stroke: black; stroke-width: 0.2; stroke-opacity: 0.8;"
79
- );
80
- line.setAttribute("class", "gridLines");
81
-
82
- svg.appendChild(line);
83
- container.appendChild(svg);
84
- }
@@ -1,9 +0,0 @@
1
- export default function hideGrid() {
2
-
3
- let gridLines = document.getElementsByClassName("gridLines");
4
-
5
- for (const line of gridLines) {
6
- line.style = "stroke: transparent; fill: transparent;"
7
- }
8
-
9
- }
@@ -1,18 +0,0 @@
1
- const svgNS = "http://www.w3.org/2000/svg";
2
-
3
- export default function putCell(
4
- {
5
- container, x, y, dx = 0, dy= 0 , width, height, rx,
6
- style = "fill: transparent; stroke: black; stroke-width: 0.2;",
7
- }) {
8
- let rect = document.createElementNS(svgNS, "rect");
9
- rect.setAttribute("x", x - width / 2 + dx);
10
- rect.setAttribute("y", y - height / 2 + dy);
11
- rect.setAttribute("rx", rx);
12
-
13
- rect.setAttribute("width", width);
14
- rect.setAttribute("height", height);
15
- rect.setAttribute("style", style);
16
- container.appendChild(rect);
17
-
18
- }
File without changes
File without changes