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) {
53 var row = document.getElementsByTagName("TR")[aRowIndex];
54 appendCell(row, aRowSpan, aColSpan);
57 function insertCell(aRow, aColIndex, aRowSpan, aColSpan) {
58 var cells = aRow.cells;
59 var refCell = cells.item(aColIndex);
60 var newCell = document.createElement("TD", null);
61 newCell.rowSpan = aRowSpan;
62 newCell.colSpan = aColSpan;
63 var text = document.createTextNode(genName());
64 newCell.appendChild(text);
65 aRow.insertBefore(newCell, refCell);
66 //dump("SCRIPT: inserted CELL as first cell in first row\n");
69 function insertCellAt(aRowIndex, aColIndex, aRowSpan, aColSpan) {
70 var row = document.getElementsByTagName("TR")[aRowIndex];
71 insertCell(row, aColIndex, aRowSpan, aColSpan);
74 function deleteCell(aRow, aColIndex) {
75 aRow.deleteCell(aColIndex);
78 function deleteCellAt(aRowIndex, aColIndex) {
79 var row = document.getElementsByTagName("TR")[aRowIndex];
80 deleteCell(row, aColIndex);
83 //function appendRow(aRowGroup) {
84 // var row = document.createElement("TR", null);
85 // cell = document.createElement("TD", null);
86 // row.appendChild(cell);
87 // aRowGroup.appendChild(row);
90 function appendRow(aRowGroup) {
91 var row = document.createElement("TR", null);
92 cell = document.createElement("TD", null);
93 aRowGroup.appendChild(row);
94 //row.appendChild(cell);
95 //appendCell(row, 1, 1);
98 function appendRowAt(aRowGroupIndex) {
99 var rowGroup = document.getElementsByTagName("TBODY")[aRowGroupIndex];
103 function insertRow(aRowGroup, aRowIndex) {
104 var rows = aRowGroup.rows;
105 var refRow = rows.item(aRowIndex);
106 var row = document.createElement("TR", null);
107 aRowGroup.insertBefore(row, refRow);
108 //appendCell(row, 1, 1);
111 function insertRowAt(aRowGroupIndex, aRowIndex) {
112 var rowGroup = document.getElementsByTagName("TBODY")[aRowGroupIndex];
113 insertRow(rowGroup, aRowIndex);
116 function deleteRow(aRowGroup, aRowIndex) {
117 aRowGroup.deleteRow(aRowIndex);
120 function deleteRowAt(aRowGroupIndex, aRowIndex) {
121 var row = document.getElementsByTagName("TBODY")[aRowGroupIndex];
122 deleteRow(row, aRowIndex);
125 function insertTbody(aTable, aTbodyIndex) {
126 var tbodies = aTable.tBodies;
127 var refTbody = tbodies.item(aTbodyIndex);
128 var tbody = document.createElement("TBODY", null);
129 aTable.insertBefore(tbody, refTbody);
132 function insertTbodyAt(aTableIndex, aTbodyIndex) {
133 var table = document.getElementsByTagName("TABLE")[aTableIndex];
134 insertTbodyAt(table, aTbodyIndex);
137 function deleteTbody(aTable, aTbodyIndex) {
138 var tbodies = aTable.tBodies;
139 var tbody = tbodies.item(aTbodyIndex);
140 aTable.removeChild(tbody);
143 function deleteTbodyAt(aTableIndex, aTbodyIndex) {
144 var table = document.getElementsByTagName("TABLE")[aTableIndex];
145 deleteTbody(table, aTbodyIndex);
148 function buildTable(aNumRows, aNumCols) {
149 var table = document.getElementsByTagName("TABLE")[0];
150 for (rowX = 0; rowX < aNumRows; rowX++) {
151 var row = document.createElement("TR", null);
152 for (colX = 0; colX < aNumCols; colX++) {
153 var cell = document.createElement("TD", null);
154 var text = document.createTextNode(genName());
155 cell.appendChild(text);
156 row.appendChild(cell);
158 table.appendChild(row);