-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
155 lines (140 loc) · 3.43 KB
/
index.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
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
var managers = [
"Abdullah Avcı",
"Aykut Kocaman",
"Ünal Karaman",
"Ersun Yanal",
"Tayfun Korkut",
"Rıza Çalımbay",
"Erol Bulut",
"Okan Buruk",
"Sergen Yalçın",
"Ertuğrul Sağlam",
"Tamer Tuna",
"Kemal Özdeş",
"Hamza Hamzaoğlu",
"Hikmet Karaman",
"Samet Aybaba",
"Mustafa Reşit Akçay",
"İsmail Kartal",
"Mustafa Denizli",
"Bülent Korkmaz",
"Mehmet Özdilek",
"Hüseyin Eroğlu",
"Fuat Çapa",
"Yalçın Koşukavak",
"Yücel İldiz",
"Ümit Özat",
"Mehmet Altıparmak",
"Bülent Uygun",
"İlhan Palut",
"Mesut Bakkal",
"İrfan Buz",
"Tolunay Kafkas",
"Adnan Gülek",
"Orhan Çıkırıkçı",
"İbrahim Üzülmez",
"Muhsin Ertuğral",
"Erkan Utanır",
"Mustafa Kaplan",
"Yılmaz Vural",
"Uğur Tütüneker",
"Osman Özköylü",
"Metin Diyadin",
"Kemalettin Şentürk",
"Erkan Sözeri",
"Engin İpekoğlu",
"Levent Eriş",
"Ziya Doğan",
"Robert Prosinecki",
"Stjepan Thomas",
"Marius Șumudică",
"Cristoph Daum",
"Ahmet Suat Özyazıcı",
"Cihat Arslan",
"Şota Arveladze",
"Mircea Lucescu"
];
var clubs = [
"Galatasaray",
"Fenerbahçe",
"Beşiktaş",
"İstanbul Başakşehir",
"Trabzonspor",
"Sivasspor",
"Yeni Malatyaspor",
"Fatih Karagümrük",
"Alanyaspor",
"Antalyaspor",
"Denizlispor",
"Çaykur Rizespor",
"Gazişehir Gaziantep",
"Konyaspor",
"Kayserispor",
"Göztepe",
"Gençlerbirliği",
"Kasımpaşa",
"Ankaragücü",
"Hatayspor",
"B.B. Erzurumspor",
];
managers.sort();
clubs.sort();
function getRandomItem(array){
var index = Math.floor(Math.random() * array.length);
return array[index];
}
var selectedManager = "Rastgele";
var selectedClub = "Rastgele";
var htmlManagers = document.querySelector("#managers");
var m = htmlManagers.addEventListener("click", function (e) {
selectedManager = e.target.innerText;
if (selectedManager == "Rastgele") {
document.getElementById("manager").style.color = "white";
document.getElementById("manager").innerHTML = "~";
}
else{
document.getElementById("manager").style.color = "#960012";
document.getElementById("manager").innerHTML = selectedManager;
}
});
var htmlClubs = document.querySelector("#clubs");
var c= htmlClubs.addEventListener("click", function (e) {
selectedClub = e.target.innerText;
if (selectedClub == "Rastgele") {
document.getElementById("club").style.color = "white";
document.getElementById("club").innerHTML = "~";
}
else{
document.getElementById("club").style.color = "#960012";
document.getElementById("club").innerHTML = selectedClub;
}
});
async function generate() {
for (let i = 0; i < 20; i++) {
if (selectedManager == "Rastgele") {
document.getElementById("manager").innerHTML = getRandomItem(managers);
}
if (selectedClub == "Rastgele") {
document.getElementById("club").innerHTML = getRandomItem(clubs);
}
let delayres = await delay(40);
}
}
function delay(delayInms) {
return new Promise(resolve => {
setTimeout(() => {
resolve(2);
}, delayInms);
});
}
function setListFromArray(array, listId) {
for (let i = 0; i < array.length; i++) {
document.getElementById(listId).innerHTML =
document.getElementById(listId).innerHTML +
'<li><a class="dropdown-item" style="color: #b8b8b8;" href="#">' +
array[i] +
"</a></li>";
}
}
setListFromArray(clubs,"clubs");
setListFromArray(managers,"managers");