function textFieldChanged(row, textField) { var newValue = textField.value; google.colab.kernel.invokeFunction("text_callback", [row, newValue], {}); } function toggleCellContent(cell, row, col) { if (row === col) { var textCell = document.getElementById(`cell_${row}`); var diagMap = { 'H': ['E', 'yellow', 5], 'E': ['C', 'lime', 3], 'C': ['?', 'lightgray', 0], '?': ['H', 'red', 19], }; [cell.textContent, cell.style.backgroundColor, textCell.value] = diagMap[cell.textContent] || ['', '']; if (cell.textContent === "?" || cell.textContent === "H" || cell.textContent === "C"){ var gridContainer = document.querySelector('.grid-container'); var currentSize = (Math.sqrt(1 + 4 * gridContainer.childElementCount) - 1) / 2 - 1; for (var k = 0; k < currentSize; k++){ if (k !== row){ var a = document.getElementById(`cell_${k}_${row}`); var b = document.getElementById(`cell_${row}_${k}`); var diagCell = document.getElementById(`cell_${k}_${k}`); if (cell.textContent === "?" || diagCell.textContent === "?" ){ a.textContent = b.textContent = '?'; a.style.backgroundColor = b.style.backgroundColor = 'lightgray'; a.style.opacity = b.style.opacity = 0.1; } else { a.textContent = b.textContent = '0'; a.style.backgroundColor = b.style.backgroundColor = 'white'; if (cell.textContent === "C" || diagCell.textContent === "C" ){ a.style.opacity = b.style.opacity = 0.1; } else { a.style.opacity = b.style.opacity = 1.0; } } } } } } else { var diagRow = document.getElementById(`cell_${row}_${row}`); var diagCol = document.getElementById(`cell_${col}_${col}`); if (diagRow.textContent !== "?" && diagCol.textContent !== "?" && diagRow.textContent !== "C" && diagCol.textContent !== "C"){ var symcell = document.getElementById(`cell_${col}_${row}`); var offdiagMap = { '0': ['1', 'lightblue'], '1': ['?', 'lightgray'], '?': ['0', 'white'] }; [cell.textContent, cell.style.backgroundColor] = [symcell.textContent, symcell.style.backgroundColor] = offdiagMap[cell.textContent] || ['', '']; } } google.colab.kernel.invokeFunction("toggle_callback", [row, col], {}); } function updateGridClickEvents() { var cells = document.querySelectorAll('.grid-item'); cells.forEach(cell => { cell.addEventListener('click', () => { var [row, col] = cell.id.split('_').slice(1).map(Number); toggleCellContent(cell, row, col); }); }); } function createGridItem(row, col, bgColor, content, opacity) { return `