-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
251 lines (246 loc) · 11.2 KB
/
index.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
<!doctype html>
<html>
<head>
<meta charset="utf-8" />
<title>home - ElectrOsu!web</title>
<link rel="stylesheet" href="style/picnic.min.css">
<link rel="stylesheet" type="text/css" href="style/main.css">
<!-- <link href="//fonts.googleapis.com/css?family=Exo+2:400,600italic" rel="stylesheet" type="text/css"> -->
<link rel="stylesheet" type="text/css" href="style/font.css">
<link rel="icon" href="favicon.png">
<script src="scripts/launchgame.js"></script>
<script src="scripts/downloader.js"></script>
<script src="scripts/addbeatmaplist.js"></script>
<script src="scripts/settings.js"></script>
<script src="scripts/jsloader.js"></script>
<script src="scripts/lib/localforage.min.js"></script>
</head>
<body>
<div class="game-area" id="game-area" hidden>
</div>
<div class="pause-menu" id="pause-menu" hidden>
<div class="paused-title">paused</div>
<div class="button-list">
<div class="pausebutton continue" id="pausebtn-continue">
<div class="inner">Continue</div>
</div>
<div class="pausebutton retry" id="pausebtn-retry">
<div class="inner">Retry</div>
</div>
<div class="pausebutton quit" id="pausebtn-quit">
<div class="inner">Quit</div>
</div>
</div>
</div>
<nav id="main-nav">
<div class="nav-link">
<a href="index.html" class="brand">ElectrOsu!web</a>
<a href="new.html" class="pseudo button">New</a>
<a href="hot.html" class="pseudo button">Hot</a>
<a href="genre.html" class="pseudo button">Genre</a>
</div>
<div class="nav-search">
<form action="search.html">
<input type="text" name="q" placeholder="beatmap id (bancho)"/>
<input type="image" class="search-button" src="research.svg">
</form>
</div>
<div class="nav-tool">
<a href="local.html" class="pseudo button">Saved</a>
<a href="faq.html" class="pseudo button">FAQ</a>
<a href="settings.html" class="pseudo button">Settings</a>
<a onclick="document.documentElement.requestFullscreen();" class="pseudo button">Fullscreen Mode</a>
</div>
</nav>
<div class="main-page" id="main-page">
<div class="main-content">
<div class="announcement">
This website is still under development. Please keep an eye out for announcements in ElectrOsu!'s <a href="https://discord.gg/K5bwkk2cc5">official server</a>
</div>
<br>
<div class="index-area">
<h2>top plays</h2>
<hr/>
<table>
<thead>
<tr>
<td>player</td>
<td>song</td>
<td>combo</td>
<td>score</td>
<td>Accuracy</td>
<td>Mods<td>
<td>time</td>
</tr>
</thead>
<tbody id="activity-list">
<!-- will be filled in script -->
</tbody>
</table>
</div>
<div class="index-area">
<h2>Recent Plays</h2>
<a href="history.html" class="more">View your play History</a>
<hr/>
<div class="beatmap-list" id="beatmap-list-history">
<!-- to be filled in script -->
</div>
</div>
<div class="index-area">
<h2>latest beatmaps</h2>
<a href="new.html" class="more">see more beatmaps</a>
<hr/>
<div class="beatmap-list" id="beatmap-list-new">
<!-- to be filled in script -->
</div>
</div>
<div class="index-area">
<h2>saved beatmaps</h2>
<a href="local.html" class="more">View more beatmaps</a>
<hr/>
<div class="beatmap-list" id="beatmap-list-liked">
<!-- to be filled in script -->
</div>
</div>
<div class="index-area">
<h2>Popular beatmaps</h2>
<a href="hot.html" class="more">See More Popular beatmaps</a>
<hr/>
<div class="beatmap-list" id="beatmap-list-hot">
<!-- to be filled in script -->
</div>
</div>
<div class="text">latest versions of Firefox and Chrome are recommended.</div>
<div class="text">Alpha v1.0.0 <a href="https://github.com/electrosu/electrosu-web">on github (private repo)</a></div>
<div class="text">Beatmaps are provided by <a href="https://osu.sayobot.cn/">Sayobot</a></div>
</div>
<div class="statuslines" id="statuslines">
<div class="progress" id="script-progress">
Scripts
<div class="lds-dual-ring"></div>
</div>
<div class="progress" id="skin-progress">
Skin
<div class="lds-dual-ring"></div>
</div>
<div class="progress" id="sound-progress">
Hitsounds
<div class="lds-dual-ring"></div>
</div>
</div>
</div>
<script>
// what's happening
let tbody = document.getElementById("activity-list");
function formattime(date) {
let m;
return date.getHours() + ":" + ((m=date.getMinutes())<10?('0'+m):m);
}
function showActivity(records) {
records = records.reverse();
while (tbody.firstChild)
tbody.removeChild(tbody.firstChild);
for (let i=0; i<records.length && i<10; ++i) {
let tr = document.createElement("tr");
tbody.appendChild(tr);
function nexttd(content) {
let td = document.createElement("td");
tr.appendChild(td);
if (!content) return;
if (content.tagName)
td.appendChild(content);
else
td.innerText = content;
}
let b = records[i].ip.split(".");
b[0]="**";
if (b.length>3) b[3]="**";
nexttd(b.join("."));
let title = document.createElement("a");
title.innerText = records[i].title + " [" + records[i].version + "]";
title.title = records[i].title + " [" + records[i].version + "]";
title.href = "search.html?q=" + (records[i].sid || records[i].title);
nexttd(title);
nexttd(records[i].combo + "x");
nexttd(parseInt(records[i].score).toLocaleString());
let acc = document.createElement("span");
acc.innerText = records[i].acc;
acc.className = records[i].grade;
nexttd(acc);
nexttd(records[i].mods);
nexttd(formattime(new Date(parseInt(records[i].time))));
}
}
let b={ip:"",title:"",version:"loading",score:0,combo:0,acc:0};
showActivity([b,b,b,b,b,b,b,b,b,b])
function refreshLivescore(){
let xhr = new XMLHttpRequest();
xhr.responseType = 'text';
xhr.open("GET", "http://api.osugame.online/fetch/");
xhr.onload = function() {
showActivity(JSON.parse(xhr.response));
}
xhr.onerror = function() {
console.error("failed fetching activities");
}
xhr.send();
}
refreshLivescore();
window.setInterval(refreshLivescore, 5000);
// recently played
if (window.localforage) {
let listhistory = document.getElementById("beatmap-list-history");
localforage.getItem("playhistory1000", function(err, item) {
if (err) {
listhistory.innerText = "Failed to load records.";
return;
}
if (item && item.length) {
item = item.reverse();
sid = [];
for (let i=0; i<item.length; ++i) {
if (item[i].sid)
sid.push(item[i].sid);
}
sid = [...new Set(sid)]; // uniq
for (let i=0; i<4 && i<sid.length; ++i)
addBeatmapSid(sid[i], listhistory)
}
else {
listhistory.innerText = "You didn't play a beatmap yet! choose a beatmap and start playing.";
}
})
}
// new
addBeatmapList("https://api.sayobot.cn/beatmaplist?0=20&1=0&2=2&5=1",
document.getElementById("beatmap-list-new"),
function(t){return (t.modes&1)!=0;}, 4);
// hot
addBeatmapList("https://api.sayobot.cn/beatmaplist?0=4&1=0&2=1&5=1", document.getElementById("beatmap-list-hot"));
// liked
if (window.localforage) {
window.localforage.getItem("likedsidset", function(err, val){
if (err) {
document.getElementById("beatmap-list-liked").innerText = "收藏夹加载失败。";
return;
}
if (val && val.size) {
let listlike = document.getElementById("beatmap-list-liked");
list = Array.from(val);
for (let i=0; i<list.length && i<4; ++i)
addBeatmapSid(list[i], listlike);
}
else {
document.getElementById("beatmap-list-liked").innerText = "you don't have any beatmaps saved! bookmark a beatmap to save it.";
}
});
}
else {
alert("localforage not supported")
}
</script>
</body>
</html>
<!-- attribution -->
<!-- play icon made by https://www.flaticon.com/authors/those-icons -->
<!-- search icon made by https://www.flaticon.com/authors/good-ware -->