JSFiddle - React, Tailwind, and code Playground
JavaScript
const movePosition = (x, y) => false;
const createInput = (index, handleClick) => {
const clickHandler = handleClick.bind(null, 0, index);
const input = document.createElement('input');
input.type = 'checkbox';
input.className = 'checkbox';
input.id = `checkbox-pos-${index}`;
input.addEventListener('click', clickHandler);
return input;
};
const createRadioButtons = (index, outerIndex, handleClick) => {
const td = document.createElement('td');
const input = document.createElement('input');
input.type = 'radio';
input.name = `рычаг_ебты${index}`;
input.className = 'position';
input.id = `РЫЧООГ_${index}_${outerIndex}`;
input.addEventListener('click', handleClick);
if (index % 2 === 0) {
const span = document.createElement('span');
span.className = 'text';
span.innerHTML = outerIndex;
td.append(span);
}
td.append(input);
return td;
};
const genTdWithText = text => {
const td = document.createElement('td');
td.innerHTML = ` ${text}`;
td.className = 'text';
return td;
};
const firstTdContent = new Array(7).fill(undefined).map((item, index) => createInput(index, movePosition));
const secondRowTds = new Array(9).fill(undefined).map((item, index) => genTdWithText(index));
const genRows = genTd => {
const rows = [];
for (let outerCounter = 0; outerCounter < 10; outerCounter++) {
const tr = document.createElement('tr');
rows.push(tr);
for (let innerCounter = 8; innerCounter >= 0; innerCounter--) {
const td = genTd(createRadioButtons);
tr.append(td);
}
}
return rows;
};
const table = document.createElement('table');
const firstRow = document.createElement('tr');
const secondRow = document.createElement('tr');
const firstRowTd = document.createElement('td');
const thirdRow =...