-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
131 lines (118 loc) · 5.29 KB
/
app.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
var currentpic = 1;
function photochange(num) {
document.querySelector('#mainphoto img').src = `images/image-product-${num}.jpg`;
document.querySelector('#modelmainphoto img').src = `images/image-product-${num}.jpg`;
currentpic = num;
document.querySelector(`#thums img:nth-child(1)`).style.border = 'none';
document.querySelector(`#thums img:nth-child(1)`).style.filter = 'opacity(1)';
document.querySelector(`#modelthums img:nth-child(1)`).style.border = 'none';
document.querySelector(`#modelthums img:nth-child(1)`).style.filter = 'opacity(1)';
document.querySelector(`#thums img:nth-child(2)`).style.border = 'none';
document.querySelector(`#thums img:nth-child(2)`).style.filter = 'opacity(1)';
document.querySelector(`#modelthums img:nth-child(2)`).style.border = 'none';
document.querySelector(`#modelthums img:nth-child(2)`).style.filter = 'opacity(1)';
document.querySelector(`#thums img:nth-child(3)`).style.border = 'none';
document.querySelector(`#thums img:nth-child(3)`).style.filter = 'opacity(1)';
document.querySelector(`#modelthums img:nth-child(3)`).style.border = 'none';
document.querySelector(`#modelthums img:nth-child(3)`).style.filter = 'opacity(1)';
document.querySelector(`#thums img:nth-child(4)`).style.border = 'none';
document.querySelector(`#thums img:nth-child(4)`).style.filter = 'opacity(1)';
document.querySelector(`#modelthums img:nth-child(4)`).style.border = 'none';
document.querySelector(`#modelthums img:nth-child(4)`).style.filter = 'opacity(1)';
document.querySelector(`#thums img:nth-child(${num})`).style.border = '3px solid #ff7d1b';
document.querySelector(`#thums img:nth-child(${num})`).style.filter = 'opacity(0.5)';
document.querySelector(`#modelthums img:nth-child(${num})`).style.border = '3px solid #ff7d1b';
document.querySelector(`#modelthums img:nth-child(${num})`).style.filter = 'opacity(0.5)';
}
var quan = 1;
function quantity(id) {
if (quan == 1 && id == -1) { }
else {
quan = quan + id;
}
document.querySelector('#details div button:nth-child(2)').innerHTML = quan;
}
function addtocart() {
document.querySelector('#nav_right div span').style.display = 'block';
document.querySelector('#mycart aside').style.display = "flex";
document.querySelector('#mycart button').style.display = "block";
document.querySelector('#nav_right div span').innerHTML = quan;
document.getElementById('calci').innerHTML = `$125.00 x ${quan}`;
document.getElementById('total').innerHTML = `$${quan * 125}.00`;
document.getElementById('empty').style.display = "none";
document.getElementById('mycart').style.height = "185px";
}
function whichphoto(temp) {
if (temp == -1) {
if (currentpic != 1) {
photochange(currentpic - 1);
}
else {
photochange(4);
}
}
else if (temp == 1) {
if (currentpic == 4) {
photochange(1);
}
else {
photochange(currentpic + 1);
}
}
}
function modelbox() {
document.getElementById('model').style.display = 'flex';
}
function closemodel() {
document.getElementById('model').style.display = 'none';
}
window.onclick = function (event) {
if (event.target == document.getElementById('model')) {
document.getElementById('model').style.display = "none";
}
}
var mode = 'light';
function switchmode() {
if (mode == "light") {
mode = "dark";
document.querySelector('body').style.backgroundColor = '#252525';
document.querySelector('#nav_left img').style.filter = 'invert(1)';
document.getElementById('name').style.color = 'white';
document.querySelector('#nav_right div img').style.filter = "invert(0)";
document.querySelector('#nav_right div span').style.color = 'black';
document.getElementById('price').style.color = 'white';
}
else {
mode = "light";
document.querySelector('body').style.backgroundColor = 'white';
document.querySelector('#nav_left img').style.filter = 'invert(0)';
document.getElementById('name').style.color = 'black';
document.querySelector('#nav_right div img').style.filter = "invert(1)";
document.querySelector('#nav_right div span').style.color = 'white';
document.getElementById('price').style.color = 'black';
}
}
function mycart() {
if (document.getElementById('mycart').style.display == 'none') {
document.getElementById('mycart').style.display = "block";
}
else {
document.getElementById('mycart').style.display = 'none';
}
}
function emptycart() {
quan = 1;
document.querySelector('#details div button:nth-child(2)').innerHTML = quan;
document.querySelector('#nav_right div span').style.display = 'none';
document.getElementById('calci').innerHTML = ``;
document.getElementById('total').innerHTML = ``;
document.getElementById('empty').style.display = "block";
document.getElementById('mycart').style.height = "105px";
document.querySelector('#mycart aside').style.display = "none";
document.querySelector('#mycart button').style.display = "none";
}
window.onclick = function (event) {
if (event.target == document.getElementById('mycart')) {
document.getElementById('mycart').style.display = "none";
}
}