Skip to content

Commit 6a1f264

Browse files
committed
Revert "beads.html with palette separated"
This reverts commit 4b8f9de.
1 parent 4b8f9de commit 6a1f264

1 file changed

Lines changed: 9 additions & 72 deletions

File tree

beads.html

Lines changed: 9 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,6 @@
44
<head>
55
<title></title>
66
<style>
7-
body {
8-
display: grid;
9-
grid-template-columns: auto auto;
10-
gap: 1px;
11-
}
12-
137
#grid-container {
148
display: grid;
159
grid-template-columns: repeat(29, 32px);
@@ -60,69 +54,15 @@
6054
.inactive {
6155
opacity: 0.4;
6256
}
63-
64-
.active {
65-
/* margin: 4px; */
66-
/* outline: 4px green */
67-
}
68-
69-
.palette-item {
70-
display: inline-block;
71-
vertical-align: top;
72-
margin: 5px;
73-
}
74-
75-
.palette-item p {
76-
display: inline-block;
77-
vertical-align: top;
78-
margin: 0 0 0 10px;
79-
/* Add some space between the div and the text */
80-
font-size: 12px;
81-
font-weight: bold;
82-
color: black;
83-
}
8457
</style>
8558
</head>
8659

8760
<body>
8861
<div id="grid-container">
8962
<!-- Grid will be generated here -->
9063
</div>
91-
<div id="palette-container"></div>
9264

9365
<script>
94-
function createPalette(colorData) {
95-
const container = document.getElementById('palette-container');
96-
97-
const allColors = colorData.flat()
98-
99-
const allUniqueColors = [...new Set(allColors.map(pixel => pixel.color))];
100-
const allUniquePixels = allUniqueColors.map(color => allColors.find(pixel => pixel.color === color));
101-
102-
allUniquePixels
103-
.sort((a, b) => a.number - b.number)
104-
.forEach(({ name, number, color }) => {
105-
const colorContainer = document.createElement('div');
106-
colorContainer.style.display = 'flex'
107-
const colorDiv = document.createElement('div');
108-
colorDiv.style.backgroundColor = color;
109-
colorDiv.style.width = '32px';
110-
colorDiv.style.height = '32px';
111-
colorDiv.style.border = '1px solid black';
112-
colorDiv.className = 'palette-item';
113-
const colorDivP = document.createElement('p');
114-
colorDiv.append(colorDivP);
115-
colorDivP.textContent = number;
116-
117-
const p = document.createElement('p');
118-
p.textContent = `${number} ${name}`;
119-
120-
colorContainer.appendChild(colorDiv);
121-
colorContainer.appendChild(p);
122-
container.appendChild(colorContainer);
123-
});
124-
}
125-
12666
function createGrid(colorData) {
12767
const container = document.getElementById('grid-container');
12868
container.innerHTML = ''; // Clear existing grid
@@ -131,11 +71,10 @@
13171
for (let col = 0; col < 29; col++) {
13272
const div = document.createElement('div');
13373

134-
const pixel = colorData[row][col];
74+
const pixel = colorData[row][col]
13575
div.style.backgroundColor = pixel.color;
13676

13777
const p = document.createElement('p');
138-
p.style.display = 'none';
13978
p.textContent = pixel?.number;
14079
div.appendChild(p);
14180
container.appendChild(div);
@@ -146,7 +85,6 @@
14685
}
14786
}
14887
}
149-
15088
// Function to move the selected class
15189
function moveSelected(direction) {
15290
const grid = document.getElementById('grid-container');
@@ -193,7 +131,9 @@
193131
}
194132

195133
// Function to read JSON file
196-
async function readJSON(filename) { }
134+
async function readJSON(filename) {
135+
}
136+
197137

198138
let selectedPValue = '';
199139
function handleSpacebarPress() {
@@ -203,25 +143,22 @@
203143
const selectedColor = selectedDiv.style.backgroundColor;
204144

205145
// First make all divs active
206-
Array.from(grid.children).forEach(div => div.classList.remove('inactive', 'active'));
146+
Array.from(grid.children).forEach(div => div.classList.remove('inactive'));
207147

208148
if (newSelectedPValue !== selectedPValue) {
209149
// Add 'inactive' class to divs not matching the color
210150
Array.from(grid.children).forEach(div => {
211151
if (div.style.backgroundColor !== selectedColor) {
212152
div.classList.add('inactive');
213-
} else {
214-
div.classList.add('active');
215-
216153
}
217154
});
218155
selectedPValue = newSelectedPValue;
219156
} else {
220-
221-
selectedPValue = '';
157+
selectedPValue = ''
222158
}
223159
}
224160

161+
225162
// Event listener for arrow keys
226163
document.addEventListener('keydown', function (event) {
227164
if (['ArrowUp', 'ArrowDown', 'ArrowLeft', 'ArrowRight'].includes(event.key)) {
@@ -238,17 +175,17 @@
238175
const load = urlParams.get('t');
239176
url = `https://tinyurl.com/${load.replaceAll("_", "ZZ")}`;
240177
}
241-
178+
242179
const imageData = await (await fetch(url)).json();
243180
createGrid(imageData);
244-
createPalette(imageData);
245181
});
246182

247183
document.addEventListener('keydown', function (event) {
248184
if (event.key === ' ') {
249185
handleSpacebarPress();
250186
}
251187
});
188+
252189
</script>
253190
</body>
254191

0 commit comments

Comments
 (0)