1 /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
15 * The Original Code is mozilla.org code.
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998
20 * the Initial Developer. All Rights Reserved.
24 * Alternatively, the contents of this file may be used under the terms of
25 * either of the GNU General Public License Version 2 or later (the "GPL"),
26 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
36 * ***** END LICENSE BLOCK ***** */
39 function genName(prefix) {
40 return "X" + count++ + "\n";
43 function appendCell(aRow, aRowSpan, aColSpan) {
44 var cell = document.createElement("TD", null);
45 cell.rowSpan = aRowSpan;
46 cell.colSpan = aColSpan;
47 var text = document.createTextNode(genName());
48 cell.appendChild(text);
49 aRow.appendChild(cell);
52 function appendCellAt(aRowIndex, aRowSpan, aColSpan) {
54 var row = document.getElementsByTagName("TR")[aRowIndex];
55 appendCell(row, aRowSpan, aColSpan);
58 function insertCell(aRow, aColIndex, aRowSpan, aColSpan) {
59 var cells = aRow.cells;
60 var refCell = cells.item(aColIndex);
61 var newCell = document.createElement("TD", null);
62 newCell.rowSpan = aRowSpan;
63 newCell.colSpan = aColSpan;
64 var text = document.createTextNode(genName());
65 newCell.appendChild(text);
66 aRow.insertBefore(newCell, refCell);
67 //dump("SCRIPT: inserted CELL as first cell in first row\n");
70 function insertCellAt(aRowIndex, aColIndex, aRowSpan, aColSpan) {
71 var row = document.getElementsByTagName("TR")[aRowIndex];
72 insertCell(row, aColIndex, aRowSpan, aColSpan);
75 function deleteCell(aRow, aColIndex) {
76 aRow.deleteCell(aColIndex);
79 function deleteCellAt(aRowIndex, aColIndex) {
80 var row = document.getElementsByTagName("TR")[aRowIndex];
81 deleteCell(row, aColIndex);
84 //function appendRow(aRowGroup) {
85 // var row = document.createElement("TR", null);
86 // cell = document.createElement("TD", null);
87 // row.appendChild(cell);
88 // aRowGroup.appendChild(row);
91 function appendRow(aRowGroup) {
92 var row = document.createElement("TR", null);
93 cell = document.createElement("TD", null);
94 aRowGroup.appendChild(row);
95 //row.appendChild(cell);
96 //appendCell(row, 1, 1);
99 function appendRowAt(aRowGroupIndex) {
100 var rowGroup = document.getElementsByTagName("TBODY")[aRowGroupIndex];
104 function insertRow(aRowGroup, aRowIndex) {
105 var rows = aRowGroup.rows;
106 var refRow = rows.item(aRowIndex);
107 var row = document.createElement("TR", null);
108 aRowGroup.insertBefore(row, refRow);
109 //appendCell(row, 1, 1);
112 function insertRowAt(aRowGroupIndex, aRowIndex) {
113 var rowGroup = document.getElementsByTagName("TBODY")[aRowGroupIndex];
114 insertRow(rowGroup, aRowIndex);
117 function deleteRow(aRowGroup, aRowIndex) {
118 aRowGroup.deleteRow(aRowIndex);
121 function deleteRowAt(aRowGroupIndex, aRowIndex) {
122 var row = document.getElementsByTagName("TBODY")[aRowGroupIndex];
123 deleteRow(row, aRowIndex);
126 function insertTbody(aTable, aTbodyIndex) {
127 var tbodies = aTable.tBodies;
128 var refTbody = tbodies.item(aTbodyIndex);
129 var tbody = document.createElement("TBODY", null);
130 aTable.insertBefore(tbody, refTbody);
133 function insertTbodyAt(aTableIndex, aTbodyIndex) {
134 var table = document.getElementsByTagName("TABLE")[aTableIndex];
135 insertTbodyAt(table, aTbodyIndex);
138 function deleteTbody(aTable, aTbodyIndex) {
139 var tbodies = aTable.tBodies;
140 var tbody = tbodies.item(aTbodyIndex);
141 aTable.removeChild(tbody);
144 function deleteTbodyAt(aTableIndex, aTbodyIndex) {
145 var table = document.getElementsByTagName("TABLE")[aTableIndex];
146 deleteTbody(table, aTbodyIndex);
149 function buildTable(aNumRows, aNumCols) {
150 var table = document.getElementsByTagName("TABLE")[0];
151 for (rowX = 0; rowX < aNumRows; rowX++) {
152 var row = document.createElement("TR", null);
153 for (colX = 0; colX < aNumCols; colX++) {
154 var cell = document.createElement("TD", null);
155 var text = document.createTextNode(genName());
156 cell.appendChild(text);
157 row.appendChild(cell);
159 table.appendChild(row);