浏览代码

Added back tab. Using Glyphicons. Don't show sensor tabs if there is only one.

Thomas Buck 8 年前
父节点
当前提交
e8e4a2f103
共有 4 个文件被更改,包括 31 次插入17 次删除
  1. 27
    13
      client-script.js
  2. 2
    2
      static.h
  3. 1
    1
      template.html
  4. 1
    1
      test.html

+ 27
- 13
client-script.js 查看文件

@@ -13,7 +13,8 @@
13 13
 // Text Strings. Change these to translate.
14 14
 textAvailableSensors = "Available Sensors";
15 15
 textButtonNext = "Continue";
16
-homeTabName = "Home";
16
+backTabName = '<span class="glyphicon glyphicon-step-backward" aria-hidden="true"></span>';
17
+homeTabName = '<span class="glyphicon glyphicon-home" aria-hidden="true"></span>';
17 18
 sensorTabName = "Sensor";
18 19
 errorMessage = "Couldn't read sensor with IP: ";
19 20
 errorTitle = "Error: ";
@@ -86,6 +87,8 @@ function initialView() {
86 87
     $('#listSensorsHeading').html(textAvailableSensors + " (0/" + clients.length + ")");
87 88
 
88 89
     // Iterate all given client IPs and get their data using Websocket
90
+    $('#listSensors').empty();
91
+    arrSensor = Array();
89 92
     var count = [0];
90 93
     jQuery.each(clients, function(index, client) {
91 94
         webSocket(client, "2391", count, clients.length);
@@ -144,17 +147,26 @@ function generateView(arrSensor, animation) {
144 147
     $('#dataDiv').show();
145 148
 
146 149
     // Add home tab
147
-    $('.nav-pills').empty();
148
-    $('.nav-pills').append('<li class="active"><a id="homebut" class="navtab" data-toggle="tab" href="#home">' + homeTabName + '</a></li>');
149
-
150
-    // Add tabs for all sensors
151
-    jQuery.each(arrSensor, function(index, sensor) {
152
-        $('.nav-pills').append('<li><a id="sensbut" class="navtab" data-toggle="tab" href="#' + sensor.id + '">' + sensorTabName + ' ' + sensor.id + '</a></li>');
153
-    });
150
+    $('#navbar').empty();
151
+    $('#navbar').append('<li><a id="backbut" class="navtab" data-toggle="tab" href="#start" aria-label="start page">' + backTabName + '</a></li>');
152
+    $('#navbar').append('<li class="active"><a id="homebut" class="navtab" data-toggle="tab" href="#home">' + homeTabName + '</a></li>');
153
+
154
+    if (arrSensor.length > 1) {
155
+        // Add tabs for all sensors
156
+        jQuery.each(arrSensor, function(index, sensor) {
157
+            $('#navbar').append('<li><a id="sensbut" class="navtab" data-toggle="tab" href="#' + sensor.id + '">' + sensorTabName + ' ' + sensor.id + '</a></li>');
158
+        });
159
+    }
154 160
 
155 161
     // flag for combined plot -> true
156 162
     generateGraph(true, arrSensor, animation);
157 163
 
164
+    // Handler for "back" button, returning to first page
165
+    $("#backbut").click(function(event) {
166
+        currentState = "initial";
167
+        redraw();
168
+    });
169
+
158 170
     // Handler for "Home" button, drawing combined graph
159 171
     $("#homebut").click(function(event) {
160 172
         // flag for combined plot -> true
@@ -162,11 +174,13 @@ function generateView(arrSensor, animation) {
162 174
         currentState = "main";
163 175
     });
164 176
 
165
-    // Handler for single sensor buttons
166
-    $("#sensbut").click(function(event) {
167
-        generateGraph(false, arrSensor[(event.target.text.split(" ")[1] - 1)], true);
168
-        currentState = event.target.text.split(" ")[1];
169
-    });
177
+    if (arrSensor.length > 1) {
178
+        // Handler for single sensor buttons
179
+        $("#sensbut").click(function(event) {
180
+            generateGraph(false, arrSensor[(event.target.text.split(" ")[1] - 1)], true);
181
+            currentState = event.target.text.split(" ")[1];
182
+        });
183
+    }
170 184
 }
171 185
 
172 186
 function generateGraph(flag, sensor, anim) {

+ 2
- 2
static.h
文件差异内容过多而无法显示
查看文件


+ 1
- 1
template.html 查看文件

@@ -52,7 +52,7 @@
52 52
                 </div>
53 53
                 <div id="dataDiv" class="col-sm-12 col-md-12 col-lg-12" style="display: none;">
54 54
                     <div class="panel panel-primary">
55
-                        <ul class="nav nav-pills">
55
+                        <ul id="navbar" class="nav nav-pills">
56 56
                         </ul>
57 57
                         <div class="panel-body">
58 58
                             <div id="contentPanel">

+ 1
- 1
test.html 查看文件

@@ -52,7 +52,7 @@
52 52
                 </div>
53 53
                 <div id="dataDiv" class="col-sm-12 col-md-12 col-lg-12" style="display: none;">
54 54
                     <div class="panel panel-primary">
55
-                        <ul class="nav nav-pills">
55
+                        <ul id="navbar" class="nav nav-pills">
56 56
                         </ul>
57 57
                         <div class="panel-body">
58 58
                             <div id="contentPanel">

正在加载...
取消
保存