-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
248 lines (218 loc) · 9.13 KB
/
index.html
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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Product Representation</title>
<style>
body {
font-family: Arial, sans-serif;
background: #f4f4f4;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
}
.form-container {
background: #fff;
padding: 20px;
border-radius: 8px;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}
.color-select {
margin-bottom: 10px;
}
.color-select select {
width: 100%;
padding: 8px;
border-radius: 4px;
border: 1px solid #ddd;
font-size: 16px;
margin-top: 5px;
}
.product-container-r {
position: relative;
width: 400px;
height: 200px;
border-radius: 5px;
border-width: 5px;
border-color: #5a5a5a;
background-color: #000000;
border-style: solid;
margin: 20%;
display: inline-block;
}
.product-flap {
position: absolute;
left: 49%;
top: 0;
width: 2%;
height: 100%;
background-color: #1C1C1C;
transform-origin: left;
transform: rotateY(-30deg);
}
.color-block {
position: absolute;
left: 0;
top: 50px;
width: 00px;
height: 100px;
background: linear-gradient(to right, #00D2FF 0%, #9B00FF 50%, #000000 50%);
}
.product-tag {
position: absolute;
right: 10px;
bottom: 10px;
width: 50px;
height: 25px;
background-color: #FFD700;
}
</style>
</head>
<body>
<div class="form-container">
<form id="colorForm">
<div class="color-select">
Design Selection:
<select name="mainColor" onchange="updateImage(this.value)" >
<option value="Asset 2.svg">Trifecta</option>
<option value="Asset 3.svg">Angles</option>
<option value="Asset 4.svg">Rays</option>
<option value="Asset 5.svg">Racer</option>
<option value="Asset 6.svg">Blank</option>
</select>
</div>
<div class="color-select">
Background Color:
<select name="mainColor" onchange="updateColor('Color_0', this.value)" class="color-list">
<option value="" selected disabled hidden>Choose here</option>
</select>
</div>
<div class="color-select">
Accent Color 1:
<select name="color1" onchange="updateColor('Color_1', this.value)" class="color-list">
<option value="" selected disabled hidden>Choose here</option>
</select>
</div>
<div class="color-select">
Accent Color 2:
<select name="color2" onchange="updateColor('Color_2', this.value)" class="color-list">
<option value="" selected disabled hidden>Choose here</option>
</select>
</div>
<div class="color-select">
Logo Selection:
<select name="mainColor" onchange="updateLogo(this.value)">
<option value="Classic Yellow.jpg">Classic Yellow</option>
<option value="Classic Blaze.jpg">Classic Blaze</option>
<option value="Classic Charcoal.jpg">Classic Charcoal</option>
<option value="Classic Purple.jpg">Classic Purple</option>
<option value="Classic Salmon.jpg">Classic Salmon</option>
<option value="Classic Teal.jpg">Classic Teal</option>
<option value="Block Neon.jpg">Block Neon</option>
<option value="Block Primary.jpg">Block Primary</option>
</select>
</div>
</form>
<object data="/Images/SVG/Asset 2.svg" width="300" height="300" id="mainSVG"> </object>
</body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/PapaParse/5.3.0/papaparse.min.js"></script>
<script>
document.addEventListener('DOMContentLoaded', function () {
Papa.parse('/ColorSheet.csv', {
download: true,
header: true,
complete: function (results) {
var colorDropdowns = document.getElementsByClassName("color-list");
var logoDropdown = document.getElementsByClassName("logo-list");
var styleDropdown = document.getElementsByClassName("style-list");
for (var i = 0; i < colorDropdowns.length; i++) {
results.data.forEach(function (row) {
var option = document.createElement('option');
option.textContent = row['Color Name'];
option.value = row['Hexdecimal Code'];
colorDropdowns.item(i).appendChild(option);
});
}
results.data.forEach(function (row) {
var option = document.createElement('option');
option.textContent = row['Style Name'];
option.value = row['SVG File Name'];
logoDropdown.item(i).appendChild(option);
});
results.data.forEach(function (row) {
var option = document.createElement('option');
option.textContent = row['Logo Name'];
option.value = row['Logo File Name'];
logoDropdown.item(i).appendChild(option);
});
}
});
});
</script>
<script>
var a = document.getElementById("mainSVG");
var logo = "Classic Yellow.jpg"
var colors = {
"Color_0": "#6d6e71",
"Color_1": "#e6e7e8",
"Color_2": "#231f20"
}
function updateLogo(newLogo) {
var svgDoc = a.contentDocument;
var logoElement = svgDoc.getElementById("Logo").children[0].children[0];
logoElement.setAttribute("xlink:href", "/Images/Logos/" + newLogo)
logo = newLogo;
}
function updateColor(elementId, newColor) {
var svgDoc = a.contentDocument;
// get the inner element by id
var delta = svgDoc.getElementById(elementId);
for (const child of delta.children) {
if (newColor.includes(".avif") || newColor.includes(".webp") || newColor.includes(".jpg") || newColor.includes(".png")){
child.setAttribute("style", "fill: url(#"+ elementId + "-Camo"+")")
console.log("fill: url(#" + elementId + "-Camo" + ")")
var camo = svgDoc.getElementById(elementId + "-Camo").children[0];
camo.setAttribute("xlink:href", "/Images/Camo/" + newColor)
console.log("SET CAMO")
}else{
child.setAttribute("style", "fill:" + "#" + newColor)
}
}
colors[elementId] = newColor;
console.log(colors)
}
function updateImage(img) {
a.setAttribute("data", "/Images/SVG/" + img)
}
a.addEventListener("load", function () {
// get the inner DOM of alpha.svg
var svgDoc = a.contentDocument;
// get the inner element by id
var logoElement = svgDoc.getElementById("Logo").children[0].children[0];
console.log(svgDoc.getElementById("Logo").children[0].children[0])
logoElement.setAttribute("xlink:href", "/Downloads/" + logo)
for (const key in colors) {
if (Object.hasOwnProperty.call(colors, key)) {
const element = colors[key];
console.log(key)
var delta = svgDoc.getElementById(key);
for (const child of delta.children) {
if (element.includes(".avif") || element.includes(".webp") || element.includes(".jpg") || element.includes(".png")) {
child.setAttribute("style", "fill: url(#" + key + "-Camo" + ")")
console.log("fill: url(#" + key + "-Camo" + ")")
console.log(key+"-Camo")
var camo = svgDoc.getElementById(key + "-Camo").children[0];
camo.setAttribute("xlink:href", "/Images/Camo/" + element)
console.log("SET CAMO")
} else {
child.setAttribute("style", "fill:" + "#" + element)
}
}
}
}
}, false);
</script>
</html>