Revision 6eab4b83588e () - Diff

Link to this snippet: https://friendpaste.com/7hSPSeZuHpA4AafLgSlD3C
Embed:
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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<style>
#templates .template { display:none; }
.odd { background:#bbb}
</style>
<script type="text/javascript" src="../js/jqueryMin.js" runat='server'></script>
<script type="text/javascript" src="../js/pure.js" runat='server'></script>
<script type="text/javascript" runat='server'>
function transform()
{
Jaxer.Log.info('transforming...');
var html = document.getElementById('template1');
var props = [];
for (prop in Jaxer.Config)
{
props.push([prop,Jaxer.Config[prop]]);
}
var context = { 'list' : props};
var directive = {
"tfoot td.total" : 'list.length'
, "tbody tr": "rows <- list"
, "tbody td.property": "rows[0]"
, "tbody td.value": "rows[1]"
, 'tbody tr[class]' : (function(context, items, pos) { return ( pos % 2 == 0 ) ? 'even' : 'odd'; })
};
html = $p.map(directive, html);
var target = document.getElementById('renderedContent');
$p.render(html, context, target);
}
</script>
</head>
<body onserverload='transform();'>
<div id='templates'>
<table id='template1' class='template'>
<thead>
<tr><th>Property</th><th>Value</th></tr>
</thead>
<tbody>
<tr><td class='property'></td><td class='value'></td></tr>
</tbody>
<tfoot>
<tr><td>Count</td><td class='total'></td></tr>
</tfoot>
</table>
</div>
<div id='renderedContent'>
</div>
</body>
</html>