My favorites | Sign in
Project Logo
                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<html>
<head>
<title>Domplate Test</title>

<script type="text/javascript">
// This is just so domplate works

function FBL() {};
function FBTrace() {};

if (!top.console || !top.console.firebug)
{
top.console = {
log: function() {},
time: function() {},
timeEnd: function() {}
}
}

function ddd()
{
console.log.apply(console, arguments);
}

function dir()
{
console.dir.apply(console, arguments);
}

function $(id)
{
return document.getElementById(id);
}
</script>
<!-- include domplate -->
<script src="/libraries/domplate/domplate-debug.js" type="text/javascript"></script>
<script type="text/javascript">

with (FBL) {

function Formatter() {};

Formatter.prototype = domplate({

table:
TABLE({border:1},
TBODY(
TR(
TH('Col 1'),
TH('Col 2')
),
FOR('row','$value,$styles|getRowData',
TR(
FOR('row','$row.value,$row.style|getRowData',
TD({'style':'background-color: $row.style.color'},'$row.value|wrap|wrap')
)
)
)
)
),


getRowData: function(value,styles){

var parts = [];
for (var i=0; i < value.length; i++) {
part = {name: i+1, value: value[i], style: styles[i] };
parts.push(part);
}
return parts;

},

wrap: function(value) {
return '[' + value + ']';
}

});

formatter = new Formatter();

};

function runTest(){

with (FBL){

DomplateDebug.enabled = true;

var rows = [
["row data 1","r1c2"],
["row data 2","r2c2"],
["row data 3","r3c2"]
];
var styles = [
[{color:"red"},{color:"cyan"}],
[{color:"blue"},{color:"gray"}],
[{color:"yellow"},{color:"green"}]
];

formatter.table.append({value:rows, styles:styles}, $("test"));
}

};

window.addEventListener("load", runTest, false);

</script>

</head>
<body>

<div id="test"></div>

</body>
</html>
Show details Hide details

Change log

r14 by christoph.dorn on Sep 10, 2008   Diff
Added support for multiple function
arguments
Go to: 
Project members, sign in to write a code review

Older revisions

r13 by christoph.dorn on Sep 10, 2008   Diff
[No log message]
All revisions of this file

File info

Size: 2278 bytes, 116 lines
Hosted by Google Code