-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathui.js
62 lines (58 loc) · 1.85 KB
/
ui.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
let $mainAvatar = $("#changeMain")
let $realAvatar = $(".theRealAvatar > img")
let $realAvatarLeftArm = $("#userLeftArm")
let $realAvatarUserTorso = $("#userTorso")
let $realAvatarRightArm = $("#userRightArm")
let $realAvatarUserHead = $("#userHead")
let $realAvatarLegs = $("#userLegs")
$(document).on("click", ".body-icon > img", function(e){
let bodyPart = $(this).attr("src")
whichPart(bodyPart)
});
// $(document).on("click", "")
// function hideElements() {
// const elementsArr = [
// ];
// elementsArr.forEach($elem => $elem.hide());
// }
//checks which part of the body it is by checking if includes folder for body part
function whichPart(bodyPart){
/**
* checks if has folder body / arm-left / arm-right
*/
if(bodyPart.includes('/body/')){
changeTorso(bodyPart)
}
if(bodyPart.includes('/arm-left/')){
changeLeftArm(bodyPart)
}
if(bodyPart.includes('/arm-right/')){
changeRightArm(bodyPart)
}
if(bodyPart.includes('/head/')){
changeHead(bodyPart)
}
if(bodyPart.includes('/legs/')){
changeLegs(bodyPart)
}
}
function changeTorso(bodyPart){
newBody = bodyPart.split("/body/");
$realAvatarUserTorso.attr("src", `images/avatar/torso/${newBody[1]}`)
}
function changeLeftArm(bodyPart){
newBody = bodyPart.split("/arm-left/");
$realAvatarLeftArm.attr("src", `images/avatar/arm-left/${newBody[1]}`)
}
function changeRightArm(bodyPart){
newBody = bodyPart.split("/arm-right/");
$realAvatarRightArm.attr("src", `images/avatar/arm-right/${newBody[1]}`)
}
function changeHead(bodyPart){
newBody = bodyPart.split("/head/");
$realAvatarUserHead.attr("src", `images/avatar/head/${newBody[1]}`)
}
function changeLegs(bodyPart){
newBody = bodyPart.split("/legs/");
$realAvatarLegs.attr("src", `images/avatar/legs/${newBody[1]}`)
}