gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r14413 - gauger


From: gnunet
Subject: [GNUnet-SVN] r14413 - gauger
Date: Tue, 15 Feb 2011 16:41:53 +0100

Author: bartpolot
Date: 2011-02-15 16:41:53 +0100 (Tue, 15 Feb 2011)
New Revision: 14413

Added:
   gauger/ajax.php
Modified:
   gauger/params.php
   gauger/plot.php
   gauger/style.css
   gauger/template.php
   gauger/template_graph.php
   gauger/template_host.php
Log:
Added dynamic range selection


Added: gauger/ajax.php
===================================================================
--- gauger/ajax.php                             (rev 0)
+++ gauger/ajax.php     2011-02-15 15:41:53 UTC (rev 14413)
@@ -0,0 +1,13 @@
+<?php
+
+include "params.php";
+
+foreach (Array('x_max', 'x_min', 'y_max', 'y_min') as $param_name) {
+    if (array_key_exists($param_name, $_SESSION)) {
+            echo "$param_name:$_SESSION[$param_name] ";
+    }
+    $$param_name = get_param($param_name, '', get_param('persist') == 'true');
+    if(!is_numeric($$param_name)) $$param_name = '*';
+}
+
+die("OK");

Modified: gauger/params.php
===================================================================
--- gauger/params.php   2011-02-15 15:31:09 UTC (rev 14412)
+++ gauger/params.php   2011-02-15 15:41:53 UTC (rev 14413)
@@ -14,6 +14,14 @@
     return $ret;
 }
 
+function get_session($name, $default = '') {
+    if (array_key_exists($name, $_SESSION)) {
+        return $_SESSION[$name];
+    } else {
+        return $default;
+    }
+}
+
 session_start();
 
 if (get_param('logout')) {

Modified: gauger/plot.php
===================================================================
--- gauger/plot.php     2011-02-15 15:31:09 UTC (rev 14412)
+++ gauger/plot.php     2011-02-15 15:41:53 UTC (rev 14413)
@@ -12,7 +12,7 @@
     if(!empty($g)) $cmd .=  ' set ylabel "' . get_counter_unit($g[0]) . '";';
 
     foreach (Array('x_max', 'x_min', 'y_max', 'y_min') as $param_name) {
-        $$param_name = get_param($param_name, '', TRUE);
+        $$param_name = get_param($param_name, '', get_param('persist') == '1');
         if(!is_numeric($$param_name)) $$param_name = '*';
     }
     $cmd .= " set xrange [$x_min:$x_max];";

Modified: gauger/style.css
===================================================================
--- gauger/style.css    2011-02-15 15:31:09 UTC (rev 14412)
+++ gauger/style.css    2011-02-15 15:41:53 UTC (rev 14413)
@@ -101,8 +101,53 @@
     margin:             5px;
 }
 
+.left-range {
+    float: left;
+}
+
+.right-range {
+    float: right;
+}
+
+.right {
+    float: right;
+}
+
+.slider-range {
+    margin:             5px/* 25px 5px 25px*/;
+    width:              90%;
+}
+
+.slider {
+    margin:             5px;
+    width:              80px;
+}
+
+.ui-slider .ui-slider-handle {
+    width:              8px;
+}
+
+.slider_control {
+    display:            none;
+    padding:            2px 1px 2px 6px;
+    margin-top:         5px;
+    border:             1px black solid;
+}
+
+
+#default_range_control {
+    position:           absolute;
+    margin-left:        -10px;
+    width:              90px;
+}
+
+#change_origin_control {
+    position:           absolute;
+    margin-left:        78px;
+}
+
 .footer-shadow {
     height:             50px;
     background-image:   url("f.png");
     clear:              both;
-}
\ No newline at end of file
+}

Modified: gauger/template.php
===================================================================
--- gauger/template.php 2011-02-15 15:31:09 UTC (rev 14412)
+++ gauger/template.php 2011-02-15 15:41:53 UTC (rev 14413)
@@ -4,14 +4,112 @@
     <head>
         <meta http-equiv="content-type" content="text/html; charset=utf-8">
         <title>Gauger [<?php echo isset($current) ? $current : $currentg 
?>]</title>
+        <link 
href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css";
 rel="stylesheet" type="text/css"/> 
+        <script type="text/javascript" 
src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js";></script>
+        <script type="text/javascript" 
src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.9/jquery-ui.min.js";></script>
+
         <link rel="shortcut icon" href="favicon.png" />
         <link href="style.css" type="text/css" rel="stylesheet">
-        <script type="text/javascript" 
src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.0/jquery.min.js";></script>
+
+
+        <script type="text/javascript">
+        $(function() {
+                $( ".slider-range" ).slider({
+                        range: true,
+                        min: <?php echo get_session('xrange_min', '0') ?>,
+                        max: <?php echo get_session('xrange_max', '100') ?>,
+                        values: [ <?php echo get_session('x_min', '0') ?> , 
<?php echo get_session('x_max', '100') ?> ],
+                        slide: function( event, ui ) {
+                                if(this.id == "default_range_slider") {
+                                    $(".left-range").html(ui.values[0]);
+                                    $(".right-range").html(ui.values[1]);
+                                    $( ".slider-range" ).slider('option', 
'values', ui.values);
+                                } else {
+                                    
$(this).parent().find(".left-range").html(ui.values[0]);
+                                    
$(this).parent().find(".right-range").html(ui.values[1]);
+                                }
+                        },
+                        stop: function( event, ui ) {
+                                if(this.id == "default_range_slider") {
+                                    $.get("ajax.php", {
+                                        x_min: ui.values[0],
+                                        x_max: ui.values[1],
+                                        persist: "true"
+                                    }, function(data) {
+                                            $( ".plot" ).each(function(){
+                                                this.src = 
this.src.replace(/&x_m(ax|in)=[^&]+/g, '')+"&reload=1";
+                                            });
+                                        }
+                                    );
+                                } else {
+                                    
$(this).parents("tr").find("img").each(function(){
+                                        this.src = 
this.src+"&x_min="+ui.values[0]+"&x_max="+ui.values[1];
+                                    });
+                                }
+                              }
+                });
+                $( ".slider" ).slider({
+                        min: <?php echo get_session('yrange_min', '0') ?>,
+                        max: <?php echo get_session('yrange_max', '100') ?>,
+                        value: <?php echo get_session('y_min', '0') ?>,
+                        slide: function( event, ui ) {
+                                $(this).parent().find(".right").html(ui.value);
+                        },
+                        stop: function( event, ui ) {
+                                $.get("ajax.php", {
+                                    y_min: ui.value,
+                                    persist: "true"
+                                }, function(data) {
+                                        $( ".plot" ).each(function(){
+                                            this.src = 
this.src.replace(/&y_m(ax|in)=[^&]+/g, '')+"&reload=1";
+                                        });
+                                    }
+                                );
+                        }
+                });
+                $( "#default_range" ).click(function() {
+                    var was = $( "#default_range_control" ).css("display");
+                    $( ".slider_control" ).hide();
+                    if(was == "none")
+                        $( "#default_range_control" ).show();
+                });
+                $( "#change_origin" ).click(function() {
+                    var was = $( "#change_origin_control" ).css("display");
+                    $( ".slider_control" ).hide();
+                    if(was == "none")
+                        $( "#change_origin_control" ).show();
+                });
+        });
+
+        function ajax_handler() {
+
+        }
+
+        function debug() {
+            s = "a.php?a=1&b=2&x_max=100&x_min=0&bo=que";
+            s = s.replace(/&x_m(ax|in)=[^&]+/g, '')+"&reload=1"
+            alert(s);
+        }
+        </script>
+
     </head>
     <body>
         <div class="header">
-            <div class="advanced_menu"> TODO: Default Range | Change Origin | 
<a href="?logout=1">Log out</a></div>
-            <img src="l.png" /><p>Gauger, performance recording tool<p>
+            <div class="advanced_menu">
+                <a href="#" id="default_range" >Default Range</a>
+                <div class="slider_control" id="default_range_control">
+                    <div class="slider-range" id="default_range_slider"></div>
+                    <div class="left-range"><?php echo get_session('x_min', 
'0') ?></div>
+                    <div class="right-range"><?php echo get_session('x_max', 
'100') ?></div>
+                </div> | 
+                <a href="#" id="change_origin" >Change Origin</a>
+                <div class="slider_control" id="change_origin_control">
+                    <div class="slider" id="change_origin_slider"></div>
+                    <div class="right"><?php echo get_session('y_min', '0') 
?></div>
+                </div> | 
+                <a href="?logout=1">Log out</a>
+            </div>
+            <img src="l.png" /><p>Gauger, performance recording tool</p>
         </div>
         <div class="header-shadow"></div>
         <div class="container">
@@ -43,5 +141,6 @@
         </div>
         <div class="footer-shadow"></div>
         Copyright notice and so on
+
     </body>
 </html>

Modified: gauger/template_graph.php
===================================================================
--- gauger/template_graph.php   2011-02-15 15:31:09 UTC (rev 14412)
+++ gauger/template_graph.php   2011-02-15 15:41:53 UTC (rev 14413)
@@ -1,3 +1,3 @@
 <h1>SHOWING GRAPH: <?php echo get_counter_name($currentg) ?></h1>
-<img src="plot.php?g=<?php echo $currentg ?>" alt="PNG not found :("/>
+<img class="plot" src="plot.php?g=<?php echo $currentg ?>" alt="PNG not found 
:("/>
 <p>TODO: Select hosts | Range | Normalize </p>

Modified: gauger/template_host.php
===================================================================
--- gauger/template_host.php    2011-02-15 15:31:09 UTC (rev 14412)
+++ gauger/template_host.php    2011-02-15 15:41:53 UTC (rev 14413)
@@ -10,10 +10,21 @@
         <tr>
             <th>
                 <?php echo get_counter_name($counter) ?><br/><br/>
-                <a href="?graph=<?php echo $counter ?>">Compare</a><br/>
-                <br/>TODO:<br/>Range<br/>Add counter<br/>Colors
+                <a href="?graph=<?php echo $counter ?>">Compare</a>
+                <br/>
+                <br/>Range
+                <br/>
+                <div>
+                    <div class="slider-range"></div>
+                    <div class="left-range"><?php echo get_session('x_min', 
'0') ?></div>
+                    <div class="right-range"><?php echo get_session('x_max', 
'100') ?></div>
+                </div>
+                <br/>
+                <br/>TODO:
+                <br>Add counter
+                <br/>Colors
             </th>
-            <td><img src="plot.php?h=<?php echo "$current&g=$counter" ?>" 
alt="PNG not found :("/></td>
+            <td><img class="plot" src="plot.php?h=<?php echo 
"$current&g=$counter" ?>" alt="PNG not found :("/></td>
         </tr>
         <?php endforeach; ?>
     </table>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]