-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
67 lines (54 loc) · 1.94 KB
/
script.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
$(document).ready(function() {
$('#osuLink').on('click', function() {
setGameMode(0)
});
$('#taikoLink').on('click', function() {
setGameMode(1)
});
$('#catchLink').on('click', function() {
setGameMode(2)
});
$('#maniaLink').on('click', function() {
setGameMode(3)
});
});
function setGameMode(mode) {
var expirationDate = new Date();
expirationDate.setFullYear(expirationDate.getFullYear() + 1);
var cookieValue = "mode=" + mode + "; expires=" + expirationDate.toUTCString() + ";path=/;";
document.cookie = cookieValue;
location.reload();
}
let debounceTimer;
function showResult(str) {
if (str.length == 0) {
document.getElementById("topBarSearchResults").innerHTML = "";
document.getElementById("topBarSearchResults").style.display = "none";
return;
}
clearTimeout(debounceTimer);
debounceTimer = setTimeout(function () {
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function () {
if (this.readyState == 4 && this.status == 200) {
document.getElementById("topBarSearchResults").innerHTML = this.responseText;
document.getElementById("topBarSearchResults").style.display = "block";
}
};
xmlhttp.open("GET", "/beatmapSearch.php?q=" + str, true);
xmlhttp.send();
}, 300);
}
function searchFocus() {
document.getElementById("topBarSearchResults").style.display="block";
}
function openTab(name) {
let x = document.getElementsByClassName("tab");
for (let i = 0; i < x.length; i++)
x[i].style.display = "none";
let buttons = document.getElementsByClassName("tabbed-container-nav")[0].getElementsByTagName("button");
for (let i = 0; i < buttons.length; i++)
buttons[i].classList.remove("active");
document.getElementById(name).style.display = "block";
event.target.classList.add("active");
}