MarkTheArtist commited on
Commit
4be9eeb
·
verified ·
1 Parent(s): e42c5b9

Upload interactive_3x3_tile_tool_js_test.html

Browse files
interactive_3x3_tile_tool_js_test.html ADDED
@@ -0,0 +1,365 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!doctype html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1">
6
+ <title>Interactive 3x3 Tile Tool</title>
7
+ <style>
8
+ body {
9
+ margin: 0;
10
+ padding: 22px;
11
+ background: #eee4cf;
12
+ font-family: Arial, Helvetica, sans-serif;
13
+ color: #222;
14
+ }
15
+
16
+ h1 { margin: 0 0 8px 0; }
17
+
18
+ .notice {
19
+ padding: 12px;
20
+ margin: 12px 0 18px 0;
21
+ border-radius: 10px;
22
+ border: 3px solid #9b2f2f;
23
+ background: #ffe7e7;
24
+ font-weight: bold;
25
+ }
26
+
27
+ .notice.ok {
28
+ border-color: #276c35;
29
+ background: #e5f6e8;
30
+ }
31
+
32
+ .layout {
33
+ display: flex;
34
+ flex-wrap: wrap;
35
+ gap: 22px;
36
+ align-items: flex-start;
37
+ }
38
+
39
+ .panel {
40
+ background: white;
41
+ border: 3px solid #aa9568;
42
+ border-radius: 14px;
43
+ padding: 18px;
44
+ box-shadow: 0 8px 18px rgba(0,0,0,.08);
45
+ }
46
+
47
+ #grid {
48
+ display: grid;
49
+ grid-template-columns: repeat(3, 150px);
50
+ grid-template-rows: repeat(3, 150px);
51
+ gap: 12px;
52
+ background: #b69d6a;
53
+ border: 6px solid #302614;
54
+ padding: 12px;
55
+ max-width: 100%;
56
+ overflow: auto;
57
+ }
58
+
59
+ .cell {
60
+ position: relative;
61
+ width: 150px;
62
+ height: 150px;
63
+ background: #fff8e8;
64
+ border: 4px solid #453720;
65
+ box-sizing: border-box;
66
+ cursor: pointer;
67
+ }
68
+
69
+ .cell.selected {
70
+ outline: 8px solid #ffcc33;
71
+ outline-offset: -10px;
72
+ }
73
+
74
+ .num {
75
+ position: absolute;
76
+ top: 6px;
77
+ left: 8px;
78
+ font-weight: bold;
79
+ color: #7e6c49;
80
+ z-index: 5;
81
+ }
82
+
83
+ .tile {
84
+ position: absolute;
85
+ left: 18px;
86
+ top: 18px;
87
+ width: 114px;
88
+ height: 114px;
89
+ transform-origin: 57px 57px;
90
+ }
91
+
92
+ .square-outline {
93
+ position: absolute;
94
+ left: 0;
95
+ top: 0;
96
+ width: 102px;
97
+ height: 102px;
98
+ border: 6px solid black;
99
+ }
100
+
101
+ .bar {
102
+ position: absolute;
103
+ left: 6px;
104
+ top: 50px;
105
+ width: 102px;
106
+ height: 14px;
107
+ background: black;
108
+ }
109
+
110
+ .elbow-v {
111
+ position: absolute;
112
+ left: 50px;
113
+ top: 0;
114
+ width: 14px;
115
+ height: 57px;
116
+ background: black;
117
+ }
118
+
119
+ .elbow-h {
120
+ position: absolute;
121
+ left: 57px;
122
+ top: 50px;
123
+ width: 57px;
124
+ height: 14px;
125
+ background: black;
126
+ }
127
+
128
+ .controls {
129
+ width: 330px;
130
+ max-width: 100%;
131
+ }
132
+
133
+ .group {
134
+ border-bottom: 1px solid #dccba5;
135
+ padding-bottom: 16px;
136
+ margin-bottom: 18px;
137
+ }
138
+
139
+ .group:last-child { border-bottom: none; }
140
+
141
+ button {
142
+ margin: 5px;
143
+ padding: 11px 13px;
144
+ border: 2px solid #6f5b35;
145
+ border-radius: 8px;
146
+ background: #fff8e8;
147
+ font-weight: bold;
148
+ cursor: pointer;
149
+ font-size: 15px;
150
+ }
151
+
152
+ button:hover { background: #ead6aa; }
153
+
154
+ button.active { background: #ffcc33; }
155
+
156
+ #status {
157
+ background: #fff8e8;
158
+ border: 2px solid #d2bd8d;
159
+ border-radius: 8px;
160
+ padding: 10px;
161
+ line-height: 1.45;
162
+ }
163
+
164
+ textarea {
165
+ width: 100%;
166
+ height: 135px;
167
+ font-family: monospace;
168
+ font-size: 12px;
169
+ box-sizing: border-box;
170
+ }
171
+
172
+ @media (max-width: 650px) {
173
+ #grid {
174
+ grid-template-columns: repeat(3, 90px);
175
+ grid-template-rows: repeat(3, 90px);
176
+ gap: 8px;
177
+ padding: 8px;
178
+ }
179
+
180
+ .cell {
181
+ width: 90px;
182
+ height: 90px;
183
+ }
184
+
185
+ .tile {
186
+ left: 10px;
187
+ top: 10px;
188
+ width: 70px;
189
+ height: 70px;
190
+ transform-origin: 35px 35px;
191
+ }
192
+
193
+ .square-outline {
194
+ width: 62px;
195
+ height: 62px;
196
+ border-width: 4px;
197
+ }
198
+
199
+ .bar {
200
+ left: 4px;
201
+ top: 33px;
202
+ width: 62px;
203
+ height: 7px;
204
+ }
205
+
206
+ .elbow-v {
207
+ left: 33px;
208
+ top: 0;
209
+ width: 7px;
210
+ height: 35px;
211
+ }
212
+
213
+ .elbow-h {
214
+ left: 35px;
215
+ top: 33px;
216
+ width: 35px;
217
+ height: 7px;
218
+ }
219
+ }
220
+ </style>
221
+ </head>
222
+ <body>
223
+
224
+ <h1>Interactive 3×3 Tile Tool</h1>
225
+
226
+ <div id="jsCheck" class="notice">
227
+ JavaScript is NOT running yet. If this message stays here, the file is being opened in a preview mode that blocks interaction.
228
+ </div>
229
+
230
+ <div class="layout">
231
+ <div class="panel">
232
+ <div id="grid"></div>
233
+ </div>
234
+
235
+ <div class="panel controls">
236
+ <div class="group">
237
+ <h2>Selected tile</h2>
238
+ <div id="status">Waiting for JavaScript...</div>
239
+ </div>
240
+
241
+ <div class="group">
242
+ <h2>Design</h2>
243
+ <button id="designA" type="button">Design A</button>
244
+ <button id="designB" type="button">Design B</button>
245
+ </div>
246
+
247
+ <div class="group">
248
+ <h2>Orientation</h2>
249
+ <button class="rot" data-rot="0" type="button">0°</button>
250
+ <button class="rot" data-rot="90" type="button">90°</button>
251
+ <button class="rot" data-rot="180" type="button">180°</button>
252
+ <button class="rot" data-rot="270" type="button">270°</button>
253
+ <br>
254
+ <button id="turn" type="button">Rotate selected 90°</button>
255
+ </div>
256
+
257
+ <div class="group">
258
+ <h2>Layout data</h2>
259
+ <textarea id="dataBox"></textarea>
260
+ <button id="selectData" type="button">Select data</button>
261
+ <button id="reset" type="button">Reset</button>
262
+ </div>
263
+ </div>
264
+ </div>
265
+
266
+ <script>
267
+ (function () {
268
+ var selected = 0;
269
+ var cells = [
270
+ {design:"A", rot:0}, {design:"B", rot:90}, {design:"A", rot:90},
271
+ {design:"B", rot:0}, {design:"A", rot:0}, {design:"B", rot:180},
272
+ {design:"A", rot:90}, {design:"B", rot:270}, {design:"A", rot:0}
273
+ ];
274
+
275
+ var jsCheck = document.getElementById("jsCheck");
276
+ jsCheck.className = "notice ok";
277
+ jsCheck.textContent = "JavaScript is working. You can click cells and change the design or rotation.";
278
+
279
+ function makeTile(cell) {
280
+ var design = '<div class="square-outline"></div>';
281
+ if (cell.design === "A") {
282
+ design += '<div class="bar"></div>';
283
+ } else {
284
+ design += '<div class="elbow-v"></div><div class="elbow-h"></div>';
285
+ }
286
+ return '<div class="tile" style="transform: rotate(' + cell.rot + 'deg)">' + design + '</div>';
287
+ }
288
+
289
+ function render() {
290
+ var grid = document.getElementById("grid");
291
+ grid.innerHTML = "";
292
+
293
+ for (var i = 0; i < 9; i++) {
294
+ var div = document.createElement("div");
295
+ div.className = "cell" + (i === selected ? " selected" : "");
296
+ div.setAttribute("data-index", i);
297
+ div.innerHTML = '<div class="num">' + (i + 1) + '</div>' + makeTile(cells[i]);
298
+ div.addEventListener("click", function () {
299
+ selected = Number(this.getAttribute("data-index"));
300
+ render();
301
+ });
302
+ grid.appendChild(div);
303
+ }
304
+
305
+ var current = cells[selected];
306
+ document.getElementById("status").innerHTML =
307
+ "Cell " + (selected + 1) + "<br>Design " + current.design + "<br>Rotation " + current.rot + "°";
308
+
309
+ document.getElementById("designA").className = current.design === "A" ? "active" : "";
310
+ document.getElementById("designB").className = current.design === "B" ? "active" : "";
311
+
312
+ var rotButtons = document.querySelectorAll(".rot");
313
+ for (var r = 0; r < rotButtons.length; r++) {
314
+ var val = Number(rotButtons[r].getAttribute("data-rot"));
315
+ rotButtons[r].className = "rot" + (val === current.rot ? " active" : "");
316
+ }
317
+
318
+ document.getElementById("dataBox").value = JSON.stringify(cells, null, 2);
319
+ }
320
+
321
+ document.getElementById("designA").addEventListener("click", function () {
322
+ cells[selected].design = "A";
323
+ render();
324
+ });
325
+
326
+ document.getElementById("designB").addEventListener("click", function () {
327
+ cells[selected].design = "B";
328
+ render();
329
+ });
330
+
331
+ var rotButtons = document.querySelectorAll(".rot");
332
+ for (var r = 0; r < rotButtons.length; r++) {
333
+ rotButtons[r].addEventListener("click", function () {
334
+ cells[selected].rot = Number(this.getAttribute("data-rot"));
335
+ render();
336
+ });
337
+ }
338
+
339
+ document.getElementById("turn").addEventListener("click", function () {
340
+ cells[selected].rot = (cells[selected].rot + 90) % 360;
341
+ render();
342
+ });
343
+
344
+ document.getElementById("selectData").addEventListener("click", function () {
345
+ var box = document.getElementById("dataBox");
346
+ box.focus();
347
+ box.select();
348
+ });
349
+
350
+ document.getElementById("reset").addEventListener("click", function () {
351
+ cells = [
352
+ {design:"A", rot:0}, {design:"B", rot:90}, {design:"A", rot:90},
353
+ {design:"B", rot:0}, {design:"A", rot:0}, {design:"B", rot:180},
354
+ {design:"A", rot:90}, {design:"B", rot:270}, {design:"A", rot:0}
355
+ ];
356
+ selected = 0;
357
+ render();
358
+ });
359
+
360
+ render();
361
+ })();
362
+ </script>
363
+
364
+ </body>
365
+ </html>