forked from Ratnasambhav/VGFanstasy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
hero_select.js
58 lines (53 loc) · 2.01 KB
/
hero_select.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
$(document).ready(function () {
$('.button-collapse').sideNav();
$('.tooltipped').tooltip({
delay: 50
});
});
function heroCheck(name) {
const captainName = document.querySelector('body > div.selected_hero > div > div:nth-child(1) > div.col.s12.captain-name > h5').innerHTML.toLowerCase();
const carryName = document.querySelector('body > div.selected_hero > div > div:nth-child(2) > div.col.s12.carry-name > h5').innerHTML.toLowerCase();
const junglerName = document.querySelector('body > div.selected_hero > div > div:nth-child(3) > div.col.s12.jungler-name > h5').innerHTML.toLowerCase();
if (name === captainName || name === carryName || name === junglerName) {
Materialize.toast('Hero already selected', 4000);
return false;
} else {
return true;
}
}
function toTitleCase(str) {
return str.replace(/\w\S*/g, function (txt) {
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
});
}
function captain(hero) {
if (heroCheck(hero)) {
const img = document.querySelector('.captain-img');
const name = document.querySelector('.captain-name');
const phpCaptain = document.querySelector('#cap-n');
phpCaptain.value= hero;
img.src = `Images/VGPics/VG Hero Portraits/${hero}.png`;
name.innerHTML = `<h5>${toTitleCase(hero)}</h5>`;
}
}
function carry(hero) {
if (heroCheck(hero)) {
const img = document.querySelector('.carry-img');
const name = document.querySelector('.carry-name');
//asdasdasd
const phpCarry = document.querySelector('#car-n');
phpCarry.value= hero;
img.src = `Images/VGPics/VG Hero Portraits/${hero}.png`;
name.innerHTML = `<h5>${toTitleCase(hero)}</h5>`;
}
}
function jungler(hero) {
if (heroCheck(hero)) {
const img = document.querySelector('.jungler-img');
const name = document.querySelector('.jungler-name');
const phpJungler = document.querySelector('#jung-n');
phpJungler.value= hero;
img.src = `Images/VGPics/VG Hero Portraits/${hero}.png`;
name.innerHTML = `<h5>${toTitleCase(hero)}</h5>`;
}
}