-
Notifications
You must be signed in to change notification settings - Fork 1
/
cotmes.html
255 lines (231 loc) · 10.4 KB
/
cotmes.html
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
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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
<!doctype html>
<html>
<head>
<!-- Project ChulaDirect: Chulalongkorn University Direct Entrance Score Calculator -->
<!-- Copyright (C) 2019-2022 Siwat Techavoranant -->
<!-- github.com/keenthekeen/ChulaDirect -->
<meta charset="UTF-8"/>
<title>คะแนนกสพท. 2558 - 2565</title>
<meta property="og:title" content="คะแนนกสพท. 2558 - 2565"/>
<meta property="og:type" content="website"/>
<meta property="og:locale" content="th_TH"/>
<meta property="og:image" content="https://chuladirect.keendev.net/screen-cotmes.png"/>
<meta name="twitter:card" content="summary"/>
<meta name="twitter:title" content="คะแนนกสพท. 2558 - 2565"/>
<meta name="twitter:image" content="https://chuladirect.keendev.net/screen-cotmes.png"/>
<meta name="google" content="notranslate"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<meta name="theme-color" content="#3f51b5"/>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css" integrity="sha256-OweaP/Ic6rsV+lysfyS4h+LM6sRwuO3euTYfr6M124g="
crossorigin="anonymous"/>
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"/>
<link href="app.css" rel="stylesheet"/>
<style>
body {
background-color: #3f51b5;
animation: fadein 2s;
}
@keyframes fadein {
from {
background-color: #333;
}
to {
background-color: #3f51b5;
}
}
footer {
background-color: transparent !important;
}
#mainBox {
max-width: 60rem;
min-width: 600px;
}
</style>
</head>
<body>
<main class="container">
<a href="index.html" class="white-text" style="margin-top:2rem"><i class="small material-icons">arrow_back</i> กลับ</a>
<div class="white-text center-align" style="padding-bottom:4vh;line-height:1.5rem;">
<h4>เปรียบเทียบคะแนนรับตรงกสพท.</h4>
<h6>คะแนนต่ำสุด คณะแพทย์/ทันตแพทย์ ปี 2558 - 2565</h6>
<div class="center-align minibox sector red darken-1 white-text" id="mini-al" style="display:none;font-size:1.3rem;line-height: 2rem;">
<h4>ระบบไม่สามารถทำงานได้</h4>
คุณกำลังใช้งานบนอุปกรณ์ที่ไม่เหมาะสม
<br/> ใช้งานได้ดีที่สุดบน
<a href="https://firefox.com">Mozilla Firefox</a> หรือ Google Chrome หรือ Safari รุ่นล่าสุด
</div>
<div class="z-depth-2 fullwidth grey lighten-5" id="mainBox">
<form>
<table>
<tr style="border-bottom: none">
<td>คะแนนรวมกสพท.</td>
<td>
<input class="validate" name="cotmes" id="iCotmes" min="0" max="100" type="number" step="0.000000001"/>
</td>
</tr>
</table>
<br/>
<button type="submit" class="waves-effect waves-light btn-large orange fullwidth" id="calculateBtn" disabled>
แสดงผล
</button>
</form>
<br/>
<br/>
<div class="divider"></div>
<br/>
<div id="chart_cotmes" style="width: 100%; height: 500px;">(กด แสดงผล)</div>
<table id="compareTable"></table>
<p class="grey-text" style="font-size:0.85rem">หมายเหตุ: มีข้อมูลเฉพาะคณะแพทยศาสตร์และคณะทันตแพทยศาสตร์บางสถาบันเท่านั้น โปรดศึกษารายละเอียดจาก<a href="http://www9.si.mahidol.ac.th/"
target="_blank">กสพท</a></p>
</div>
</div>
</main>
<footer class="page-footer">
<div class="footer-copyright">
<div class="container">
<a href="index.html">กลับไปยังหน้าแรก</a>
</div>
</div>
</footer>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js" integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js" integrity="sha256-U/cHDMTIHCeMcvehBv1xQ052bPSbJtbuiw4QA9cTKz0=" crossorigin="anonymous"></script>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
google.charts.load('current', {packages: ['corechart']});
const timeLoaded = (new Date()).getTime();
let list;
$(function () {
fetch('medicine.json').then(function (response) {
return response.json();
}).then(function (data) {
list = data.list;
google.charts.setOnLoadCallback(showGraph);
});
$("form").submit(function (e) {
e.preventDefault();
showGraph();
if ((new Date()).getTime() - timeLoaded > 1800000) {
// If page has been loaded more than 30 minutes ago, reload.
setTimeout(function () {
window.location.reload();
}, 5000);
}
});
if (localStorage.getItem('cotmes-all')) {
$("#iCotmes").val(localStorage.getItem('cotmes-all'));
}
$("button").attr('disabled', false);
});
if (!self.fetch) {
// Check for old browser by checking Fetch API support, which is not present in old browsers.
// Visit http://caniuse.com for more information
$('#mini-al').show();
if (!(typeof Promise !== "undefined" && Promise.toString().indexOf("[native code]") !== -1)) {
// If Promise API not supported
setTimeout(function () {
$('body').css('background-color', '#f44336');
}, 2000);
$('.btn-large').removeClass('orange').addClass('grey');
}
}
function showGraph() {
const scoreRaw = $("#iCotmes").val();
if (!scoreRaw) {
$("#chart_cotmes").html("<h5>โปรดระบุคะแนนรวม</h5>");
return;
}
const score = parseFloat(scoreRaw);
if (score < 54) {
$("#chart_cotmes").html("<h5>ขออภัย ไม่สามารถแสดงผลสำหรับคะแนนที่ต่ำกว่า 54</h5>");
return;
}
localStorage.setItem("cotmes-all", scoreRaw);
let facultyList = [];
const yearData = {};
const facultyOrder = [];
list.forEach(function (faculty) {
const diff = score - faculty['2562'];
if (diff < 7 && diff > -7) {
facultyList.push(faculty);
if (Object.keys(yearData).length === 0) {
Object.keys(faculty).filter(key => key.startsWith('25')).forEach(year => yearData[year] = []);
}
}
});
facultyList.forEach(faculty => {
Object.keys(faculty).forEach(key => {
if (key.startsWith('25')) {
yearData[key].push(faculty[key]);
} else if (key === 'University') {
facultyOrder.push(faculty['University']);
}
});
});
facultyOrder.push('ที่ได้');
const dataArray = [
['คณะ/ปี', ...facultyOrder],
];
Object.keys(yearData).forEach(year => dataArray.push([year, ...yearData[year], score]));
const data = google.visualization.arrayToDataTable(dataArray);
const colorArray = [];
const colorAvailable = ['#ff8282', '#ffbc82', '#eaaa62', '#e6ff82', '#baff82', '#8aff82', '#82ffc2', '#82ddff', '#829bff'];
let colorNo = 0;
while (colorNo < facultyList.length) {
colorArray.push(colorAvailable[colorNo % colorAvailable.length]);
colorNo++;
}
colorArray.push('black');
const options = {
vAxis: {title: 'คะแนน'},
isStacked: false,
colors: colorArray
};
const chart = new google.visualization.AreaChart(document.getElementById('chart_cotmes'));
chart.draw(data, options);
gtag('event', 'show-cotmes', {
'value': score
});
const tableArray = [];
dataArray[0].forEach(() => tableArray.push([]));
let col = 0;
dataArray.forEach(function (elem) {
let row = 0;
elem.forEach(function (ele) {
tableArray[row][col] = ele;
row++;
});
col++;
});
let tableCode = '';
tableArray.forEach((inRow, rowNo) => {
if (rowNo === 0) {
tableCode += '<tead><tr>';
inRow.forEach(v => tableCode += '<th>' + v + '</th>');
tableCode += '</tr></thead>';
} else if (rowNo <= facultyList.length) {
tableCode += '<tr>';
inRow.forEach((v, i) => {
if (i === 0) {
tableCode += '<th>' + v + '</th>';
} else {
const diff = (score - v).toFixed(2);
tableCode += '<td>' + v + ((diff >= 0) ? " (<span class='green-text'>" : " (<span class='red-text'>") + diff + "</span>)</td>";
}
});
tableCode += '</tr>';
}
});
$("#compareTable").html(tableCode);
}
</script>
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-40738950-5"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments);
}
gtag('js', new Date());
gtag('config', 'UA-40738950-5');
</script>
</body>
</html>