1 <!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 4.0//EN">
6 <style type=
"text/css">
9 font-family: verdana
, sans-serif
;
29 text-decoration:underline
;
34 text-decoration: none
;
47 border-bottom-width:1px;
48 border-bottom-style:dotted
;
64 <table width=
"90%" border=
"0" cellspacing=
"1" cellpadding=
"5">
67 <big><tt>Global.helma.Markup.TableWriter.prototype.write
(text,
attr)
</tt></big><br>
73 Write a table cell.
<br><br>
76 <li><b>Parameter
</b> <code>String
</code>:
<br/>
77 the table cell content as text
<li><b>Parameter
</b> <code>attr
</code>:
<br/>
78 an optional attributes holder for the td tag
89 <table width=
"90%" border=
"0" cellspacing=
"1" cellpadding=
"5">
91 <td>Sourcecode in helmaTools.zip/Global/helma.Markup.js:
92 <pre><font color=
"#aaaaaa">455:
</font> this.write = function(text, attr) {
93 <font color=
"#aaaaaa">456:
</font> <font color=
"#33aa00"> // set up some variables
94 <font color=
"#aaaaaa">457:
</font> </font> var isHeaderRow = (this.writeHeader
&& this.written
< this.ncols);
95 <font color=
"#aaaaaa">458:
</font> var isNewRow = (this.written % this.ncols ==
0);
96 <font color=
"#aaaaaa">459:
</font> var isEvenRow = ((this.written / this.ncols) %
2 ==
0);
97 <font color=
"#aaaaaa">460:
</font> var isEvenCol = ((this.written % this.ncols) %
2 ==
0);
98 <font color=
"#aaaaaa">461:
</font> <font color=
"#33aa00"> // write out table and table row tags
99 <font color=
"#aaaaaa">462:
</font> </font> if (this.written ==
0) {
100 <font color=
"#aaaaaa">463:
</font> if (this.writeString)
101 <font color=
"#aaaaaa">464:
</font> res.push();
102 <font color=
"#aaaaaa">465:
</font> helma.Markup.openTag(
<font color=
"#9999aa">"table
"</font>, this.attr.table);
103 <font color=
"#aaaaaa">466:
</font> helma.Markup.openTag(
<font color=
"#9999aa">"tr
"</font>, this.attr.trHead);
104 <font color=
"#aaaaaa">467:
</font> } else if (isNewRow) {
105 <font color=
"#aaaaaa">468:
</font> helma.Markup.closeTag(
<font color=
"#9999aa">"tr
"</font>);
106 <font color=
"#aaaaaa">469:
</font> if (isEvenRow)
107 <font color=
"#aaaaaa">470:
</font> helma.Markup.openTag(
<font color=
"#9999aa">"tr
"</font>, this.attr.trEven);
108 <font color=
"#aaaaaa">471:
</font> else
109 <font color=
"#aaaaaa">472:
</font> helma.Markup.openTag(
<font color=
"#9999aa">"tr
"</font>, this.attr.trOdd);
110 <font color=
"#aaaaaa">473:
</font> }
111 <font color=
"#aaaaaa">474:
</font> <font color=
"#33aa00"> // get the attribute object for the table cell
112 <font color=
"#aaaaaa">475:
</font> </font> if (!attr) {
113 <font color=
"#aaaaaa">476:
</font> <font color=
"#33aa00"> // no explicit attribute given
114 <font color=
"#aaaaaa">477:
</font> </font> if (isEvenCol)
115 <font color=
"#aaaaaa">478:
</font> attr = isHeaderRow ? this.attr.thEven : this.attr.tdEven;
116 <font color=
"#aaaaaa">479:
</font> else
117 <font color=
"#aaaaaa">480:
</font> attr = isHeaderRow ? this.attr.thOdd : this.attr.tdOdd;
118 <font color=
"#aaaaaa">481:
</font> }
119 <font color=
"#aaaaaa">482:
</font> <font color=
"#33aa00"> // write out table cell tag
120 <font color=
"#aaaaaa">483:
</font> </font> helma.Markup.openTag(isHeaderRow ?
<font color=
"#9999aa">"th
"</font> :
<font color=
"#9999aa">"td
"</font>, attr);
121 <font color=
"#aaaaaa">484:
</font> <font color=
"#33aa00"> // write out table cell contents
122 <font color=
"#aaaaaa">485:
</font> </font> if (text)
123 <font color=
"#aaaaaa">486:
</font> res.write(text);
124 <font color=
"#aaaaaa">487:
</font> <font color=
"#33aa00"> // close table cell
125 <font color=
"#aaaaaa">488:
</font> </font> helma.Markup.closeTag(isHeaderRow ?
<font color=
"#9999aa">"th
"</font> :
<font color=
"#9999aa">"td
"</font>);
126 <font color=
"#aaaaaa">489:
</font> if (attr
&& !isNaN(attr.colspan))
127 <font color=
"#aaaaaa">490:
</font> this.written += attr.colspan;
128 <font color=
"#aaaaaa">491:
</font> else
129 <font color=
"#aaaaaa">492:
</font> this.written +=
1;
130 <font color=
"#aaaaaa">493:
</font> return;
131 <font color=
"#aaaaaa">494:
</font> }