michael@0: /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: var count = 1; michael@0: function genName(prefix) { michael@0: return "X" + count++ + "\n"; michael@0: } michael@0: michael@0: function appendCell(aRow, aRowSpan, aColSpan) { michael@0: var cell = document.createElement("TD", null); michael@0: cell.rowSpan = aRowSpan; michael@0: cell.colSpan = aColSpan; michael@0: var text = document.createTextNode(genName()); michael@0: cell.appendChild(text); michael@0: aRow.appendChild(cell); michael@0: } michael@0: michael@0: function appendCellAt(aRowIndex, aRowSpan, aColSpan) { michael@0: var row = document.getElementsByTagName("TR")[aRowIndex]; michael@0: appendCell(row, aRowSpan, aColSpan); michael@0: } michael@0: michael@0: function insertCell(aRow, aColIndex, aRowSpan, aColSpan) { michael@0: var cells = aRow.cells; michael@0: var refCell = cells.item(aColIndex); michael@0: var newCell = document.createElement("TD", null); michael@0: newCell.rowSpan = aRowSpan; michael@0: newCell.colSpan = aColSpan; michael@0: var text = document.createTextNode(genName()); michael@0: newCell.appendChild(text); michael@0: aRow.insertBefore(newCell, refCell); michael@0: //dump("SCRIPT: inserted CELL as first cell in first row\n"); michael@0: } michael@0: michael@0: function insertCellAt(aRowIndex, aColIndex, aRowSpan, aColSpan) { michael@0: var row = document.getElementsByTagName("TR")[aRowIndex]; michael@0: insertCell(row, aColIndex, aRowSpan, aColSpan); michael@0: } michael@0: michael@0: function deleteCell(aRow, aColIndex) { michael@0: aRow.deleteCell(aColIndex); michael@0: } michael@0: michael@0: function deleteCellAt(aRowIndex, aColIndex) { michael@0: var row = document.getElementsByTagName("TR")[aRowIndex]; michael@0: deleteCell(row, aColIndex); michael@0: } michael@0: michael@0: //function appendRow(aRowGroup) { michael@0: // var row = document.createElement("TR", null); michael@0: // cell = document.createElement("TD", null); michael@0: // row.appendChild(cell); michael@0: // aRowGroup.appendChild(row); michael@0: //} michael@0: michael@0: function appendRow(aRowGroup) { michael@0: var row = document.createElement("TR", null); michael@0: cell = document.createElement("TD", null); michael@0: aRowGroup.appendChild(row); michael@0: //row.appendChild(cell); michael@0: //appendCell(row, 1, 1); michael@0: } michael@0: michael@0: function appendRowAt(aRowGroupIndex) { michael@0: var rowGroup = document.getElementsByTagName("TBODY")[aRowGroupIndex]; michael@0: appendRow(rowGroup); michael@0: } michael@0: michael@0: function insertRow(aRowGroup, aRowIndex) { michael@0: var rows = aRowGroup.rows; michael@0: var refRow = rows.item(aRowIndex); michael@0: var row = document.createElement("TR", null); michael@0: aRowGroup.insertBefore(row, refRow); michael@0: //appendCell(row, 1, 1); michael@0: } michael@0: michael@0: function insertRowAt(aRowGroupIndex, aRowIndex) { michael@0: var rowGroup = document.getElementsByTagName("TBODY")[aRowGroupIndex]; michael@0: insertRow(rowGroup, aRowIndex); michael@0: } michael@0: michael@0: function deleteRow(aRowGroup, aRowIndex) { michael@0: aRowGroup.deleteRow(aRowIndex); michael@0: } michael@0: michael@0: function deleteRowAt(aRowGroupIndex, aRowIndex) { michael@0: var row = document.getElementsByTagName("TBODY")[aRowGroupIndex]; michael@0: deleteRow(row, aRowIndex); michael@0: } michael@0: michael@0: function insertTbody(aTable, aTbodyIndex) { michael@0: var tbodies = aTable.tBodies; michael@0: var refTbody = tbodies.item(aTbodyIndex); michael@0: var tbody = document.createElement("TBODY", null); michael@0: aTable.insertBefore(tbody, refTbody); michael@0: } michael@0: michael@0: function insertTbodyAt(aTableIndex, aTbodyIndex) { michael@0: var table = document.getElementsByTagName("TABLE")[aTableIndex]; michael@0: insertTbodyAt(table, aTbodyIndex); michael@0: } michael@0: michael@0: function deleteTbody(aTable, aTbodyIndex) { michael@0: var tbodies = aTable.tBodies; michael@0: var tbody = tbodies.item(aTbodyIndex); michael@0: aTable.removeChild(tbody); michael@0: } michael@0: michael@0: function deleteTbodyAt(aTableIndex, aTbodyIndex) { michael@0: var table = document.getElementsByTagName("TABLE")[aTableIndex]; michael@0: deleteTbody(table, aTbodyIndex); michael@0: } michael@0: michael@0: function buildTable(aNumRows, aNumCols) { michael@0: var table = document.getElementsByTagName("TABLE")[0]; michael@0: for (rowX = 0; rowX < aNumRows; rowX++) { michael@0: var row = document.createElement("TR", null); michael@0: for (colX = 0; colX < aNumCols; colX++) { michael@0: var cell = document.createElement("TD", null); michael@0: var text = document.createTextNode(genName()); michael@0: cell.appendChild(text); michael@0: row.appendChild(cell); michael@0: } michael@0: table.appendChild(row); michael@0: } michael@0: } michael@0: