-
Notifications
You must be signed in to change notification settings - Fork 31
/
compatibility.html
295 lines (278 loc) · 15.8 KB
/
compatibility.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
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
---
layout: compatibility
texts: compatibility
nav: compat
---
<script>
function get(name) {
if (name = (new RegExp('[?&]' + encodeURIComponent(name) + '=([^&]*)')).exec(location.search))
return decodeURIComponent(name[1]);
}
function timeAgo(date) {
const now = new Date();
const seconds = Math.floor((now - date) / 1000);
let interval = Math.floor(seconds / 31536000);
if (interval >= 1) return interval + " years ago";
interval = Math.floor(seconds / 2592000);
if (interval >= 1) return interval + " months ago";
interval = Math.floor(seconds / 86400);
if (interval >= 1) return interval + " days ago";
interval = Math.floor(seconds / 3600);
if (interval >= 1) return interval + " hours ago";
interval = Math.floor(seconds / 60);
if (interval >= 1) return interval + " minutes ago";
return "just now";
}
angular.module('Vita3K', []).controller("angularController", async function ($scope, $filter, $http) {
{% include languagescript.js %}
$scope.views = []
$scope.views['Unknown'] = []
$scope.views['Crashes'] = []
$scope.views['Buggy'] = []
$scope.views['Slow'] = []
$scope.views['Playable'] = []
$scope.views['Nothing'] = []
$scope.views['Bootable'] = []
$scope.views['Intro'] = []
$scope.views['Menu'] = []
$scope.views['Ingame -'] = []
$scope.views['Ingame +'] = []
$scope.changeView = function (field) {
$scope.data = $scope.views[field];
$scope.data = $filter('orderBy')($scope.data, 'name', false);
}
// Angular filter
$scope.filterEntries = function (val) {
return function (entry) {
if (val == undefined) return true;
return entry.name.toLowerCase().includes(val.toLowerCase()) ||
entry.titleId.toLowerCase().includes(val.toLowerCase());
}
}
$scope.orderBy = function(v){
const statusOrder = [
"Nothing",
"Bootable",
"Intro",
"Menu",
"Ingame -",
"Ingame +",
"Playable",
"Unknown",
];
const reversedStatusOrder = [
"Playable",
"Ingame +",
"Ingame -",
"Menu",
"Intro",
"Bootable",
"Nothing",
"Unknown",
];
switch(v){
case 'titleId': {
if($scope.currentOrder !== v){
document.getElementById('titleIdHead').textContent = 'Title ID ↓'
$scope.data = $scope.data.sort((a, b) => a.titleId.localeCompare(b.titleId));
}
else {
$scope.data = $scope.data.sort((b, a) => a.titleId.localeCompare(b.titleId));
document.getElementById('titleIdHead').textContent = 'Title ID ↑'
v = 'titleId2'; // mark as different to titleId so that when we click again it uses the unreversed sort
}
document.getElementById('nameHead').textContent = $scope.texts[19];
document.getElementById('statusHead').textContent = $scope.texts[20];
break;
}
case 'name': {
if($scope.currentOrder !== v){
document.getElementById('nameHead').textContent = `${$scope.texts[19]} ↓`
$scope.data = $scope.data.sort((a, b) => a.name.localeCompare(b.name));
}
else {
document.getElementById('nameHead').textContent = `${$scope.texts[19]} ↑`
$scope.data = $scope.data.sort((b, a) => a.name.localeCompare(b.name));
v = 'name2'; // mark as different to name so that when we click again it uses the unreversed sort
}
document.getElementById('titleIdHead').textContent = 'Title ID';
document.getElementById('statusHead').textContent = $scope.texts[20];
break;
}
case 'status':{
if($scope.currentOrder !== v){
document.getElementById('statusHead').textContent = `${$scope.texts[20]} ↓`
$scope.data = $scope.data.sort((a, b) => statusOrder.indexOf(a.status) - statusOrder.indexOf(b.status));
}
else {
document.getElementById('statusHead').textContent = `${$scope.texts[20]} ↑`
$scope.data = $scope.data.sort((a, b) => reversedStatusOrder.indexOf(a.status) - reversedStatusOrder.indexOf(b.status));
v = 'status2'; // mark as different to status so that when we click again it uses the unreversed sort
}
document.getElementById('titleIdHead').textContent = 'Title ID';
document.getElementById('nameHead').textContent = $scope.texts[19];
break;
}
}
$scope.currentOrder = v;
}
await $http.get('https://vita3k-api.pedro.moe/list/commercial')
.success((res) => {
const updatedAt = new Date(res.date * 1000);
const updatedAtStr = updatedAt.toLocaleString();
const timeAgoStr = timeAgo(updatedAt);
document.getElementById('lastUpdatedAt').textContent = updatedAtStr;
document.getElementById('timeAgo').textContent = timeAgoStr;
$scope.views['Unknown'] = res.list;
$scope.data = $scope.views['Unknown'];
$scope.orderBy('name');
res.list.forEach((e) => {
// Unknown already has all games, no need to add it twice
if (e.status != 'Unknown') {
switch (e.status) {
case 'Nothing': e.translatedStatus = $scope.texts[5]; break;
case 'Bootable': e.translatedStatus = $scope.texts[6]; break;
case 'Intro': e.translatedStatus = $scope.texts[7]; break;
case 'Menu': e.translatedStatus = $scope.texts[8]; break;
case 'Ingame -': e.translatedStatus = $scope.texts[9]; break;
case 'Ingame +': e.translatedStatus = $scope.texts[10]; break;
case 'Playable': e.translatedStatus = $scope.texts[4]; break;
}
$scope.views[e.status].push(e);
}
});
});
var game = get("g");
if (game) {
$scope.field = game;
$scope.$apply();
}
})
</script>
{% raw %}
<section class="text-white" id="compatibility">
<div class="container">
<div class="row">
<div class="col-lg-12 mx-auto text-center">
<h2 class="section-heading">{{texts[26]}}</h2>
<hr class="my-4">
{{texts[34]}}
<br><br>
<p class="mb-5">
<input style="display:inline-block;vertical-align:middle;" type="text" ng-model="field" class="form-control" placeholder="{{texts[24]}}..." required="true" />
<br>
<br>{{texts[14]}}:
<a href="#" class="plate" ng-click="changeView('Nothing')" style="background-color: #e02020">{{texts[5]}} ({{views['Nothing'].length}})</a>
<a href="#" class="plate" ng-click="changeView('Bootable')" style="background-color: #7030b0">{{texts[6]}} ({{views['Bootable'].length}})</a>
<a href="#" class="plate" ng-click="changeView('Intro')" style="background-color: #c71585">{{texts[7]}} ({{views['Intro'].length}})</a>
<a href="#" class="plate" ng-click="changeView('Menu')" style="background-color: #1e64dc">{{texts[8]}} ({{views['Menu'].length}})</a>
<a href="#" class="plate" ng-click="changeView('Ingame -')" style="background-color: #e08a1e">{{texts[9]}} ({{views['Ingame -'].length}})</a>
<a href="#" class="plate" ng-click="changeView('Ingame +')" style="background-color: #fbca04">{{texts[10]}} ({{views['Ingame +'].length}})</a>
<a href="#" class="plate" ng-click="changeView('Playable')" style="background-color: #0e8a16">{{texts[4]}} ({{views['Playable'].length}})</a>
<a href="#" class="plate" ng-click="changeView('Unknown')" style="background-color: #3030ff">{{texts[11]}} ({{views['Unknown'].length}})</a>
<center>
<table>
<tr>
<td>
<small><font color=#ff2020>{{texts[5]}} ({{((views['Nothing'].length/views['Unknown'].length)*100).toFixed(2)}}%):</font> <font color=#ffffff>{{texts[27]}}</font></small>
</td>
<td width="25%">
<div class="progress">
<div class="progress-bar progress-bar-striped progress-bar-animated bg-nothing" style="width:{{(views['Nothing'].length/views['Unknown'].length)*100}}%">
</div>
</div>
</td>
</tr>
<tr>
<td>
<small><font color=#a060ff>{{texts[6]}} ({{((views['Bootable'].length/views['Unknown'].length)*100).toFixed(2)}}%):</font> <font color=#ffffff>{{texts[28]}}</font></small>
</td>
<td width="25%">
<div class="progress">
<div class="progress-bar progress-bar-striped progress-bar-animated bg-bootable" style="width:{{(views['Bootable'].length/views['Unknown'].length)*100}}%">
</div>
</div>
</td>
</tr>
<tr>
<td>
<small><font color=#e632aa>{{texts[7]}} ({{((views['Intro'].length/views['Unknown'].length)*100).toFixed(2)}}%):</font> <font color=#ffffff>{{texts[29]}}</font></small>
</td>
<td width="25%">
<div class="progress">
<div class="progress-bar progress-bar-striped progress-bar-animated bg-intro" style="width:{{(views['Intro'].length/views['Unknown'].length)*100}}%">
</div>
</div>
</td>
</tr>
<tr>
<td>
<small><font color=#50a0fa>{{texts[8]}} ({{((views['Menu'].length/views['Unknown'].length)*100).toFixed(2)}}%):</font> <font color=#ffffff>{{texts[30]}}</font></small>
</td>
<td width="25%">
<div class="progress">
<div class="progress-bar progress-bar-striped progress-bar-animated bg-menu" style="width:{{(views['Menu'].length/views['Unknown'].length)*100}}%">
</div>
</div>
</td>
</tr>
<tr>
<td>
<small><font color=#f0a000>{{texts[9]}} ({{((views['Ingame -'].length/views['Unknown'].length)*100).toFixed(2)}}%):</font> <font color=#ffffff>{{texts[31]}}</font></small>
</td>
<td width="25%">
<div class="progress">
<div class="progress-bar progress-bar-striped progress-bar-animated bg-ingame-" style="width:{{(views['Ingame -'].length/views['Unknown'].length)*100}}%">
</div>
</div>
</td>
</tr>
<tr>
<td>
<small><font color=#ffd250>{{texts[10]}} ({{((views['Ingame +'].length/views['Unknown'].length)*100).toFixed(2)}}%):</font> <font color=#ffffff>{{texts[32]}}</font></small>
</td>
<td width="25%">
<div class="progress">
<div class="progress-bar progress-bar-striped progress-bar-animated bg-ingame" style="width:{{(views['Ingame +'].length/views['Unknown'].length)*100}}%">
</div>
</div>
</td>
</tr>
<tr>
<td>
<small><font color=#28AA28>{{texts[4]}} ({{((views['Playable'].length/views['Unknown'].length)*100).toFixed(2)}}%):</font> <font color=#ffffff>{{texts[33]}}</font></small>
</td>
<td width="25%">
<div class="progress">
<div class="progress-bar progress-bar-striped progress-bar-animated bg-playable" style="width:{{(views['Playable'].length/views['Unknown'].length)*100}}%">
</div>
</div>
</td>
</tr>
</table>
<br>
<p>Last Updated at: <span id="lastUpdatedAt"></span> (<span id="timeAgo"></span>)</p>
<br>
<table class="table-hover table-bordered table-striped">
<thead>
<tr>
<td><a href="#" ng-click="orderBy('titleId')" style="color:yellow"><small id="titleIdHead">Title ID </small></a></td>
<td><a href="#" ng-click="orderBy('name')" style="color:yellow"><small id="nameHead">{{texts[19]}}</small></a></td>
<td><a href="#" ng-click="orderBy('status')" style="color:yellow"><small id="statusHead">{{texts[20]}}</small></a></td>
</tr>
</thead>
<tbody>
<tr ng-repeat="entry in data | filter: filterEntries(field) track by $index">
<td align="left"><b><small>{{entry.titleId}}</small></b></td>
<td align="left"><a href="https://github.com/Vita3K/compatibility/issues/{{entry.issueId}}"><small>{{entry.name}}</small></a></td>
<td bgcolor="{{entry.color}}"><font color="white"><small>{{entry.translatedStatus}}</small></font></td>
</tr>
</tbody>
</table>
</center>
</p>
</div>
</div>
</div>
</section>
{% endraw %}