Ticket #152: testing.html

File testing.html, 1.9 kB (added by Jorge Godoy <jgodoy@gmail.com>, 2 years ago)
Line 
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml">
4   <head>
5     <title>Testing Events and Tables</title>
6
7     <script type="text/javascript" src="/home/godoy/desenvolvimento/python/TurboGears/1.0/thirdparty/mochikit/packed/MochiKit/MochiKit.js"></script>
8     <script type="text/javascript">
9     function row_display(row) {
10       return TR(null, map(partial(TD, null), row));
11     };
12  
13     function header_display(row) {
14       return TR(null, map(partial(TH, null), row));
15     };
16
17     function calculate(evt) {
18        var value_read = this.value;
19        var sample = this.id.split(':')[0];
20        var result = value_read * 3;
21        $(sample+':result').innerHTML = result;
22     }
23
24     function create_table() {
25       var lines = [];
26      
27       for (var sample = 1; sample < 400; sample++) {
28         log ('Sample:', sample);
29         var row = [sample,
30         INPUT({'name':sample+':sample',
31                'id':sample+':sample'}, null),
32         LABEL({'name':sample+':result',
33                'id':sample+':result'}),
34         [INPUT({'name':sample+':ignore_sample',
35                 'id':sample+':ignore_sample',
36                 'value': true,
37                 'type': 'checkbox'}, null),
38          LABEL(null, 'Ignore Reading'),],
39          ];
40         extend(lines, [row]);
41       }
42       var t = TABLE(null,
43                     THEAD(null, header_display(['Sample', 'Value', 'Result', null])),
44                     TFOOT(null, TR(null, TD(null))),
45                     TBODY(null, map(row_display, lines)));
46       swapDOM('insert_table_here', t);
47
48       for (var sample = 1; sample < 400; sample++) {
49           connect(sample+':sample', 'onchange', calculate);
50       }
51     }
52     </script>
53   </head>
54
55   <body>
56     <div id="insert_table_here"></div>
57   <script type="text/javascript">
58       create_table();
59   </script>
60   </body>
61 </html>