/[Frey]/trunk/static/Frey/jQuery/flot/dataset_checkboxes.js
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /trunk/static/Frey/jQuery/flot/dataset_checkboxes.js

Parent Directory Parent Directory | Revision Log Revision Log


Revision 907 - (show annotations)
Fri Dec 26 01:32:09 2008 UTC (15 years, 4 months ago) by dpavlin
File MIME type: application/javascript
File size: 2187 byte(s)
make iframe to role and plug it into flot
1 /* from example at http://people.iola.dk/olau/flot/examples/turning-series.html */
2
3 // hard-code color indices to prevent them from shifting as
4 // countries are turned on/off
5 var i = 0;
6 $.each(datasets, function(key, val) {
7 val.color = i;
8 ++i;
9 });
10
11 // insert checkboxes
12 var choiceContainer = $("#choices");
13 $.each(datasets, function(key, val) {
14 choiceContainer.append('<br/><input type="checkbox" name="' + key +
15 '" checked="checked" >' + val.label + '</input>');
16 });
17 choiceContainer.find("input").click(plotAccordingToChoices);
18
19
20 function plotAccordingToChoices() {
21 var data = [];
22
23 choiceContainer.find("input:checked").each(function () {
24 var key = $(this).attr("name");
25 if (key && datasets[key])
26 data.push(datasets[key]);
27 });
28
29 var placeholder = $('#placeholder');
30 if ( ! placeholder ) alert("can't find #placeholder");
31
32 if (data.length > 0)
33 $.plot( placeholder, data, options);
34
35 placeholder.bind("plotselected", function (event,ranges) {
36
37 function DateTimeStr(t) {
38 var d = new Date( parseInt(t) );
39
40 function pad2(n) {
41 var s = new String(n);
42 if ( s.length == 1 ) {
43 return '0' + s;
44 } else {
45 return s;
46 }
47 }
48
49 var str =
50 pad2( d.getUTCFullYear() ) + '-' +
51 pad2( d.getUTCMonth() + 1 ) + '-' +
52 pad2( d.getUTCDate() ) + ' ' +
53 pad2( d.getUTCHours() ) + ':' +
54 pad2( d.getUTCMinutes() ) + ':' +
55 pad2( d.getUTCSeconds() ) ;
56
57 return str;
58 }
59
60 var from = DateTimeStr( ranges.xaxis.from.toFixed(1) );
61 var to = DateTimeStr( ranges.xaxis.to.toFixed(1) );
62
63 var url = '/Frey::Shell::Log/as_sponge'
64 + '?from_datetime=' + from
65 + '&to_datetime=' + to
66 // + '&log_command=cat /var/log/{syslog,messages} /var/log/{kern,auth,daemon,mail,user}.log'
67 ;
68
69 $('#selection').html(
70 from + ' &rarr; ' + to
71 + ' <a target="Frey::Shell::Log" href="' + url + '">log</a>'
72 + ' <a target="transport_iframe" href="' + url + '" onclick="ifr_show(); return true;">inline</a>'
73 );
74 });
75
76 }
77
78 plotAccordingToChoices();
79

  ViewVC Help
Powered by ViewVC 1.1.26