-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
140 lines (134 loc) · 3.52 KB
/
main.js
1
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
/**
* 明度を切り替えます。
* @param {object} e - event object
*/
const toggleBrightness = (e) => {
const me = e.target;
const parent = me.closest("div[id^='teeth_wrap']");
const children = parent.children; //[teeth_wrap, pod_wrap, margin_wrap]
const style = window.getComputedStyle(me).getPropertyValue("filter");
if (style == null || style == "none") {
me.style.filter = "brightness(0)";
children[1].style.color = "#FFFFFF";
children[2].style.color = "#FFFFFF";
} else {
me.style.filter = null;
// 入力値のフォントカラーを白にして不可視っぽくします。
children[1].style.color = "#000000";
children[2].style.color = "#000000";
}
};
window.addEventListener("load", function () {
document.querySelectorAll(".teeth_svg > img").forEach((element) => {
element.addEventListener("click", toggleBrightness, false);
});
});
const inputs = document.querySelectorAll("input");
const inputElements = [].slice.call(inputs); // Nodelistを配列に変換
/**
* キーボードの一番うえの列で検査値を入力できるようにします。
* @param {object} input - input要素
*/
const keyBind = (input) => {
const key = {
0: 10,
1: 1,
2: 2,
3: 3,
4: 4,
5: 5,
6: 6,
7: 7,
8: 8,
9: 9,
"-": 11,
"^": 12,
"\\": 13,
};
let str = input.value;
// 文頭から文末まで全て0-9かチェック
const result = str.match(/[\d-^\\]/);
if (result) {
str = key[str.slice(-1)];
input.value = str;
} else {
input.value = "";
}
// 入力後次のフォームへ移動
const me = document.activeElement;
const parent = me.parentNode.parentNode.parentNode;
const parentID = parent.getAttribute("id");
const i = inputElements.indexOf(document.activeElement);
const editElm = inputs[i];
const elmClass = editElm.getAttribute("class");
if (["pod_d", "pod_c", "margin_d", "margin_c"].indexOf(elmClass) + 1) {
(inputs[i + 1] || input[i]).focus();
return;
}
if (["mgj", "mobility"].indexOf(elmClass) + 1) {
(inputs[i + 8] || input[i]).focus();
return;
}
if (["maxilla_b", "mandibular_b"].indexOf(parentID) + 1) {
(inputs[i + 6] || input[i]).focus();
return;
} else {
(inputs[i + 4] || input[i]).focus();
return;
}
};
// chart.js
document.getElementById("canvas_maxilla_b").style.width = "575px";
document.getElementById("canvas_maxilla_b").style.height = "86px";
const data = [
4, 3, 4, 3, 2, 3, 4, 3, 2, 3, 4, 3, 3, 5, 4, 4, 5, 2, 6, 3, 4, 6, 3, 4, 2, 3,
4, 3, 2, 3, 4, 2, 3, 4, 4, 5, 4, 5, 5, 6, 4, 3, 4, 5, 4, 3, 4, 5, 4,
];
const ctx = document.getElementById("canvas_maxilla_b").getContext("2d");
const myChart = new Chart(ctx, {
type: "line",
data: {
labels: data.map((value, index) => ""),
datasets: [
{
data: data,
tension: 0.5,
fill: "end",
backgroundColor: "rgba(255, 0, 0, 0.3)",
},
],
},
options: {
plugins: {
legend: {
display: false,
},
},
scales: {
y: {
max: 13,
min: 0,
ticks: {
stepSize: 1,
callback: function (value) {
return " ";
},
},
},
x: {
grid: {
display: false,
},
},
},
elements: {
point: {
radius: 0,
},
},
},
});
let canvas = document.getElementById('canvas_maxilla_b');
let ctx2 = canvas.getContext('2d');
ctx2.fillStyle = 'rgba(128, 128, 128, 0.5)';
ctx2.fillRect(0, 0, canvas.width, canvas.height);