rotateInterface = {
let div = html`<div>
<style>
table.interface tr { margin:2px; border:0px;}
table.interface td.button {
cursor:pointer;
background:white;
border-radius:5px;
border:1px solid gray;
text-align:center;
}
button.interface {
cursor:pointer;
width:14em;
}
table.interface {
border-collapse:separate;
width:14em;
}
</style>
</div>`;
let reset = html`<button class=interface> Reset`;
reset.onclick = () => {
if (mutable rotInfo) return;
mutable rotInfo = { type: "reset" };
};
div.append(reset);
let table = html`<table class=interface>`;
div.append(table);
let buttonClick = rot => {
return () => {
if (mutable rotInfo) return;
mutable rotInfo = rot;
};
};
for (let i = -1; i <= 6; i++) {
let tr = html`<tr>`;
table.append(tr);
if (i == -1) {
tr.append(html`<td>`);
tr.append(html`<td>`);
let td = html`<td colspan=4 class=button>↓</td>`;
td.onclick = buttonClick({ type: "allcol", angle: 90 });
tr.append(td);
tr.append(html`<td>`);
tr.append(html`<td>`);
continue;
}
if (i == 6) {
tr.append(html`<td>`);
tr.append(html`<td>`);
let td = html`<td colspan=4 class=button>↑</td>`;
td.onclick = buttonClick({ type: "allcol", angle: -90 });
tr.append(td);
tr.append(html`<td>`);
tr.append(html`<td>`);
continue;
}
if (i == 1) {
let td = html`<td rowspan=4 class=button>→</td>`;
td.onclick = buttonClick({ type: "allrow", angle: 90 });
tr.append(td);
} else if (i == 0 || i == 5) {
tr.append(html`<td>`);
}
for (let j = 0; j <= 5; j++) {
if (i == j || i + j == 5) {
tr.append(html`<td>`);
continue;
}
let rot, sym;
if (i == 0)
[rot, sym] = [{ type: "col", row: 0, col: j - 1, angle: 90 }, "↓"];
else if (i == 5)
[rot, sym] = [{ type: "col", row: 0, col: j - 1, angle: -90 }, "↑"];
else if (j == 0)
[rot, sym] = [{ type: "row", row: 4 - i, col: 0, angle: 90 }, "→"];
else if (j == 5)
[rot, sym] = [{ type: "row", row: 4 - i, col: 0, angle: -90 }, "←"];
if (rot) {
let td = html`<td class=button>`;
tr.append(td);
td.onclick = buttonClick(rot);
td.append(sym);
} else tr.append(html`<td>`);
}
if (i == 1) {
let td = html`<td rowspan=4 class=button>←</td>`;
td.onclick = buttonClick({ type: "allrow", row: 0, col: 0, angle: -90 });
tr.append(td);
} else if (i == 0 || i == 5) {
tr.append(html`<td>`);
}
}
return div;
}