/
match-predictor.html
149 lines (126 loc) · 5.7 KB
/
match-predictor.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<link rel="stylesheet" href="./css/style.css">
<link rel="stylesheet" href="./css/fonts.css">
<!-- EXTERNAL LIBRARY FIXER -->
<script>
if (typeof module === 'object') {
window.module = module;
module = undefined;
}
</script>
<script src="https://code.jquery.com/jquery-3.3.1.min.js"
integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
<script src="./js/jquery.smoothState.min.js"></script>
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.6.3/css/all.css"
integrity="sha384-UHRtZLI+pbxtHCWp1t77Bi1L4ZtiqrqD80Kn4Z8NTSRyMA2Fd33n5dQ8lWUE00s/" crossorigin="anonymous">
<script>
if (window.module) module = window.module;
</script>
</head>
<body>
<div class="navigation">
<a href="index.html">
<div class="home"><i class="fas fa-home home-icon"></i></div>
</a>
<nav id="nav">
<ul>
<li class="current"><a href="match-predictor.html">Match Predictor</a></li>
<li><a href="tournament-matches.html">Tournament Matches</a></li>
<li><a href="team-analyzer.html">Team Analysis</a></li>
<li><a href="accuracytest.html">Accuracy Test</a></li>
<li><a href="awardscheck.html">Awards Check</a></li>
<li><a href="thedata.html">The Data</a></li>
</ul>
</nav>
</div>
<section class="match-predictor">
<h1 id="title">Match Predictor</h1>
<div class="container">
<div class="red">
<h1 class="title">Red Alliance <span class="redChance"></span>
</h1>
<span class="input input--haruki">
<input class="input__field input__field--haruki" type="text" id="red1" />
<label class="input__label input__label--haruki" for="red1">
<span class="input__label-content
input__label-content--haruki">Red
1</span>
</label>
</span>
<span class="input input--haruki">
<input class="input__field input__field--haruki" type="text" id="red2" />
<label class="input__label input__label--haruki" for="red2">
<span class="input__label-content
input__label-content--haruki">Red
2</span>
</label>
</span>
</div>
<div class="blue">
<h1 class="title">Blue Alliance <span class="blueChance"></span>
</h1>
<span class="input input--haruki">
<input class="input__field input__field--haruki" type="text" id="blue1" />
<label class="input__label input__label--haruki" for="blue1">
<span class="input__label-content
input__label-content--haruki">Blue
1</span>
</label>
</span>
<span class="input input--haruki">
<input class="input__field input__field--haruki" type="text" id="blue2" />
<label class="input__label input__label--haruki" for="blue2">
<span class="input__label-content
input__label-content--haruki">Blue
2</span>
</label>
</span>
</div>
<button class="btn btn-fixed">Predict</button>
</div>
</section>
<div class="credits"><a id="creditLink">Coded by Anish Kachinthaya</a></div>
<script src="./network/matches.js"></script>
<script src="./js/predictBtn.js"></script>
<script src="./js/inputField.js"></script>
<script>
let main = async (red1, red2, blue1, blue2) => {
let net = loadModel();
let prediction = await processMatch(net, red1, red2, blue1, blue2);
let redPercent = ((prediction.red / (prediction.red + prediction.blue)) * 100).toFixed(2);
let bluePercent = ((prediction.blue / (prediction.red + prediction.blue)) * 100).toFixed(2);
document.querySelector(".redChance").innerText = redPercent + "%";
document.querySelector(".blueChance").innerText = bluePercent + "%";
if (redPercent > bluePercent) {
document.querySelector(".red").style.flexGrow = "2";
} else if (bluePercent > redPercent) {
document.querySelector(".blue").style.flexGrow = "2";
}
}
let mainEventListenerFunction = () => {
document.querySelector(".red").style.flexGrow = "1";
document.querySelector(".blue").style.flexGrow = "1";
let red1 = document.getElementById("red1").value;
let red2 = document.getElementById("red2").value;
let blue1 = document.getElementById("blue1").value;
let blue2 = document.getElementById("blue2").value;
main(red1, red2, blue1, blue2);
}
btn.addEventListener('click', (e) => {
mainEventListenerFunction();
})
document.addEventListener('keypress', function (e) {
var key = e.which || e.keyCode;
if (key === 13) { // 13 is enter
mainEventListenerFunction();
}
});
</script>
</body>
</html>