hayun-vite 0.1.2 → 0.2.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/package.json +1 -1
- package/src/Audiogram/Audiogram.js +11 -40
- package/src/Form/Forms.js +1 -17
- package/src/Form/printForm.js +27 -56
package/package.json
CHANGED
@@ -2,14 +2,11 @@ import putLine from "../common/putLine.js";
|
|
2
2
|
import putPoint from "../common/putPoint.js";
|
3
3
|
import putRect from "../common/putRect.js";
|
4
4
|
import getAllSymbolsSVG from "../Symbol/getAllSymbolsSVG.js";
|
5
|
-
|
6
5
|
const svgNS = "http://www.w3.org/2000/svg";
|
7
6
|
|
8
7
|
export default class AudiogramChart {
|
9
8
|
constructor({ container, side, x = 0, y = 0, pname, events = true, dims }) {
|
10
|
-
|
11
9
|
const { width, height, chartPadding, symbolDims, vFrequency, vToFreq, freqToV, intensity, styles } = dims;
|
12
|
-
|
13
10
|
x = dims.margin.left
|
14
11
|
y = dims.margin.top
|
15
12
|
|
@@ -25,34 +22,27 @@ export default class AudiogramChart {
|
|
25
22
|
this.side = side;
|
26
23
|
let style;
|
27
24
|
|
28
|
-
|
29
25
|
const xArea = { min: chartPadding.left, max: width - (chartPadding.right) }
|
30
|
-
|
31
26
|
const yArea = { min: chartPadding.top, max: height - (chartPadding.bottom) }
|
32
27
|
const xAxiosLength = { mm: width - (chartPadding.left + chartPadding.right), hz: 14 }
|
33
28
|
const yAxiosLength = height
|
34
|
-
|
35
29
|
const vFrequencyAxiosLength = {
|
36
30
|
mm: width - (chartPadding.left + chartPadding.right),
|
37
31
|
hz: vFrequency.max - vFrequency.min
|
38
32
|
}
|
39
33
|
this.vFrequencyAxiosLength = vFrequencyAxiosLength;
|
40
|
-
|
41
34
|
const intensityAxiosLength = {
|
42
35
|
mm: height - (chartPadding.top + chartPadding.bottom),
|
43
36
|
db: intensity.max - intensity.min,
|
44
37
|
}
|
45
38
|
this.intensityAxiosLength = intensityAxiosLength;
|
46
|
-
|
47
39
|
const svg = document.createElementNS(svgNS, "svg");
|
48
|
-
this.svg = svg;
|
49
|
-
|
40
|
+
this.svg = svg; // کل نودی که به کانتینر اپند میشه
|
50
41
|
svg.setAttribute("width", width);
|
51
42
|
svg.setAttribute("height", height);
|
52
43
|
svg.setAttribute("x", x);
|
53
44
|
svg.setAttribute("y", y);
|
54
45
|
svg.setAttribute("viewBox", [-chartPadding.left, -chartPadding.top, width, height]);
|
55
|
-
|
56
46
|
// محدوده مختصات خطوط جدول
|
57
47
|
const chartArea = putRect({
|
58
48
|
container: svg,
|
@@ -63,7 +53,6 @@ export default class AudiogramChart {
|
|
63
53
|
|
64
54
|
const currentPointer = putPoint({ container: svg, x: 0, y: 0, r: 4, color: 'black' });
|
65
55
|
this.currentPointer = currentPointer;
|
66
|
-
|
67
56
|
// رسم خطوط افقی از بالا به پایین
|
68
57
|
let x1 = this.getX(vFrequency.min);
|
69
58
|
let x2 = this.getX(vFrequency.max);
|
@@ -72,7 +61,6 @@ export default class AudiogramChart {
|
|
72
61
|
const y2 = y1
|
73
62
|
putLine({ container: svg, x1, y1, x2, y2, style: styles.line })
|
74
63
|
}
|
75
|
-
|
76
64
|
// رسم خطوط عمودی از چپ به راست
|
77
65
|
let y1 = this.getY(intensity.min)
|
78
66
|
let y2 = this.getY(intensity.max)
|
@@ -81,44 +69,25 @@ export default class AudiogramChart {
|
|
81
69
|
const x2 = x1
|
82
70
|
putLine({ container: svg, x1, y1, x2, y2, style: styles.line })
|
83
71
|
}
|
84
|
-
|
85
72
|
// یک بوردر راهنمای توسعه برای اس وی جی به تمام پهنا و ارتفاع رسم میکنیم
|
86
73
|
// این مربع مرزی را آخرین ایجاد میکنیم تا بالاترین لایه باشد و روی ریودادها درست عمل کند
|
87
74
|
const borderRect = putRect({ container: svg, x: -chartPadding.left, y: -chartPadding.top, width, height, name: 'RAudiogram' });
|
88
75
|
this.borderRect = borderRect;
|
89
|
-
|
90
76
|
// ایجاد رویدادها روی فقط چارت جدول
|
91
77
|
borderRect.addEventListener('mousemove', (e) => {
|
92
78
|
const x = e.offsetX
|
93
79
|
const y = e.offsetY
|
94
|
-
|
95
80
|
currentPointer.setAttribute('cx', x - chartPadding.left)
|
96
81
|
currentPointer.setAttribute('cy', y - chartPadding.top)
|
97
82
|
console.log('x:', x, 'f:', getFreq(x));
|
98
|
-
// تبدیل مختصات به مختصات فرکانس و شدت
|
99
|
-
|
100
83
|
})
|
101
84
|
|
85
|
+
container && container.appendChild(svg);
|
86
|
+
|
102
87
|
// تبدیل مقدار ایکس مختصات به فرکانس
|
103
88
|
function getFreq(x) {
|
104
89
|
return vToFreq[Math.round((x - xArea.min) * (xAxiosLength.hz / xAxiosLength.mm))]
|
105
90
|
}
|
106
|
-
|
107
|
-
container && container.appendChild(svg);
|
108
|
-
|
109
|
-
// تست تابع آپدیت
|
110
|
-
// this.update({
|
111
|
-
// data: {
|
112
|
-
// // R_AC_M: { 8000: 25, 2000: 5, 1500: 0, },
|
113
|
-
// R_AC: { 1000: 25, 500: 15, 750: 20, 250: 10, 6000: 35, 2000: 45 },
|
114
|
-
// R_AC_NR: { 1500: 85 },
|
115
|
-
// R_BC_M: { 2000: 25, 6000: 25 },
|
116
|
-
// R_BC_M_NR: { 3000: 85 },
|
117
|
-
// R_BC: { 1000: 20, 500: 10, 750: 15, 250: 5, 4000: 20 },
|
118
|
-
// },
|
119
|
-
// side: this.side,
|
120
|
-
// })
|
121
|
-
|
122
91
|
}
|
123
92
|
|
124
93
|
getX(f) {
|
@@ -132,12 +101,15 @@ export default class AudiogramChart {
|
|
132
101
|
}
|
133
102
|
|
134
103
|
update({ data, side }) {
|
104
|
+
// پاک کردن نودهای سمبل دیتای قبلی در صورت وجود از نود مربوطه
|
105
|
+
this.svg.querySelectorAll('[data-name=symbol]').forEach(symbol => symbol.remove())
|
106
|
+
// پاک کردن خطوط اتصال دیتای قبلی در صورت وجود از نود مربوطه
|
107
|
+
this.svg.querySelectorAll('[data-name=junction]').forEach(symbol => symbol.remove())
|
108
|
+
|
109
|
+
|
135
110
|
const junctions = { AC: {}, BC: {}, side };
|
136
111
|
this.junctions = junctions;
|
137
|
-
// console.log(data);
|
138
|
-
|
139
112
|
for (const symbolName in data) {
|
140
|
-
|
141
113
|
for (const freq in data[symbolName]) {
|
142
114
|
const x = this.getX(this.freqToV[freq]);
|
143
115
|
const y = this.getY(data[symbolName][freq]);
|
@@ -150,10 +122,8 @@ export default class AudiogramChart {
|
|
150
122
|
}
|
151
123
|
}
|
152
124
|
this.drawJunctions();
|
153
|
-
|
154
125
|
// بالا آوردن مستطیل احاطه کننده به بالاترین لایه برای دریافت صحیح رویدادهای موس
|
155
126
|
this.svg.appendChild(this.borderRect)
|
156
|
-
|
157
127
|
}
|
158
128
|
|
159
129
|
drawJunctions() {
|
@@ -173,7 +143,7 @@ export default class AudiogramChart {
|
|
173
143
|
type === "BC"
|
174
144
|
? this.styles.juncDashLine + `stroke: ${color}`
|
175
145
|
: this.styles.juncLine + `stroke: ${color}`;
|
176
|
-
x1 && !NR1 && !NR2 && putLine({ container: this.svg, x1, y1, x2, y2, style });
|
146
|
+
x1 && !NR1 && !NR2 && putLine({ container: this.svg, x1, y1, x2, y2, style, name: 'junction' });
|
177
147
|
}
|
178
148
|
}
|
179
149
|
}
|
@@ -190,6 +160,7 @@ export default class AudiogramChart {
|
|
190
160
|
|
191
161
|
getSymbol(symbolName) {
|
192
162
|
const point = this.symbols[symbolName].cloneNode(true);
|
163
|
+
|
193
164
|
return point
|
194
165
|
}
|
195
166
|
}
|
package/src/Form/Forms.js
CHANGED
@@ -76,13 +76,7 @@ export default class Forms {
|
|
76
76
|
|
77
77
|
// });
|
78
78
|
// for Develop
|
79
|
-
this.event();
|
80
|
-
}
|
81
|
-
|
82
|
-
event() {
|
83
|
-
this.div.addEventListener('click', (e) => {
|
84
|
-
console.log(e.target);
|
85
|
-
})
|
79
|
+
// this.event();
|
86
80
|
}
|
87
81
|
// این تابع یک بار از بیرون کلاس فراخوانی میشه و یک بار وقتی از داخل تمپلت فرم را عوض میکنیم
|
88
82
|
update({ data, officeData, patientData, sessionIndex = 0 }) {
|
@@ -102,21 +96,11 @@ export default class Forms {
|
|
102
96
|
}
|
103
97
|
// توابع داخلی ایجاد دکمه و لینک های بالای فرم
|
104
98
|
putButton({ container, id, text, className }) {
|
105
|
-
|
106
99
|
const button = document.createElement('button');
|
107
100
|
button.setAttribute('id', id);
|
108
101
|
className && button.setAttribute('class', className);
|
109
102
|
button.innerHTML = text;
|
110
|
-
|
111
|
-
// button.addEventListener('mouseenter', () => {
|
112
|
-
// button.style.backgroundColor = 'rgb(54, 115, 115)'; // Change color on hover
|
113
|
-
// });
|
114
|
-
// button.addEventListener('mouseleave', () => {
|
115
|
-
// button.style.backgroundColor = 'rgb(0, 149, 149)'; // Revert color when not hovering
|
116
|
-
// });
|
117
|
-
|
118
103
|
container.appendChild(button);
|
119
104
|
return button;
|
120
|
-
|
121
105
|
}
|
122
106
|
}
|
package/src/Form/printForm.js
CHANGED
@@ -1,25 +1,8 @@
|
|
1
|
-
// import '../style.css'
|
2
|
-
// import '../fonts/Vazirmatn-Regular.woff2'
|
3
|
-
|
4
|
-
|
5
1
|
export default function printForm({ container }) {
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
function print(paperForm) {
|
12
|
-
iframePrint(paperForm);
|
13
|
-
return new Date().toLocaleString("fa-IR");
|
14
|
-
}
|
15
|
-
|
16
|
-
function iframePrint(paperForm) {
|
17
|
-
const hideFrame = document.createElement("iframe");
|
18
|
-
let printDateTime;
|
19
|
-
hideFrame.onload = setPrint;
|
20
|
-
hideFrame.style.display = "block"; // hide iframe
|
21
|
-
|
22
|
-
let style = `
|
2
|
+
const iframe = document.createElement("iframe");
|
3
|
+
iframe.onload = setPrint;
|
4
|
+
iframe.style.display = "block";
|
5
|
+
let style = `
|
23
6
|
@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@100..900&display=swap');
|
24
7
|
|
25
8
|
@page {
|
@@ -88,39 +71,27 @@ export default function printForm({ container }) {
|
|
88
71
|
font-weight: bold;
|
89
72
|
}
|
90
73
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
document.body.appendChild(hideFrame);
|
115
|
-
|
116
|
-
return 1;
|
117
|
-
function setPrint() {
|
118
|
-
const closePrint = () => { document.body.removeChild(this); };
|
119
|
-
this.contentWindow.onbeforeunload = () => closePrint();
|
120
|
-
this.contentWindow.onafterprint = () => {
|
121
|
-
closePrint();
|
122
|
-
}
|
123
|
-
this.contentWindow.print();
|
124
|
-
}
|
125
|
-
}
|
74
|
+
`;
|
75
|
+
iframe.srcdoc = `
|
76
|
+
<!DOCTYPE html>
|
77
|
+
<html lang="en">
|
78
|
+
|
79
|
+
<head>
|
80
|
+
<meta charset="UTF-8">
|
81
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
82
|
+
<style>${style}</style>
|
83
|
+
</head>
|
84
|
+
|
85
|
+
<body>${container.outerHTML}</body>
|
86
|
+
|
87
|
+
</html>
|
88
|
+
`;
|
89
|
+
document.body.appendChild(iframe);
|
90
|
+
}
|
91
|
+
|
92
|
+
function setPrint() {
|
93
|
+
const closePrint = () => { document.body.removeChild(this); };
|
94
|
+
this.contentWindow.onbeforeunload = closePrint;
|
95
|
+
this.contentWindow.onafterprint = closePrint;
|
96
|
+
this.contentWindow.print();
|
126
97
|
}
|