-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
204 lines (163 loc) · 5.89 KB
/
index.html
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no, target-densitydpi=device-dpi" />
<script type="text/javascript" src="js/vue.min.js"></script>
<script src="http://libs.baidu.com/jquery/1.10.2/jquery.min.js"></script>
<link rel="stylesheet" href="css/buttons.css">
<link rel="stylesheet" href="css/index.css">
</head>
<body>
<div id="app">
<div id="cards" v-show="cards_status">
<div class="card" v-if="seatbelt">
Getting permission of SeatBelt is {{ seatbelt }}
</div>
<div class="card" v-if="inhibited">
Getting permission of inhibited is {{ inhibited }}
</div>
<div class="card" v-if="loc">
Getting permission of location is {{ loc }}
</div>
<div class="card" v-if="speed">
Getting permission of speed is {{ speed }}
</div>
<div class="card" v-if="crash">
Getting permission of crash is {{ crash }}
</div>
<button class="button button-highlight button-large" style="margin-top: 50%" onclick="showIm(2)">Edit Filter</button>
</div>
<div id="filters" v-show="filter_status">
<div class="line">
<button class="filter-option button button-royal button-jumbo" onclick="permission(1)">SeatBelt</button>
</div>
<div class="line">
<button class="filter-option button button-royal button-jumbo" onclick="permission(2)">Airbags</button>
</div>
<div class="line">
<button class="filter-option button button-royal button-jumbo" onclick="permission(3)">Location</button>
</div>
<div class="line">
<button class="filter-option button button-royal button-jumbo" onclick="permission(4)">Speed</button>
</div>
<div class="line">
<button class="filter-option button button-royal button-jumbo" onclick="permission(5)">Crash</button>
</div>
<div class="line">
<button class="filter-option button button-caution button-jumbo" onclick="showIm(1);send_event();">Apply</button>
</div>
</div>
<div id="notification" v-show="notification_status">
<div class="line large">
{{msg}}
</div>
<div class="line">
<button class="filter-option button button-royal button-jumbo" onclick="showIm(1)">Back</button>
</div>
</div>
</div>
<script>
var vue = new Vue({
el: '#app',
data: {
msg: '',
filter_status:false,
notification_status: false,
cards_status: true,
seatbelt: false,
inhibited: false,
loc: false,
speed: false,
crash: false,
todos: [
{ text: 'Getting permission of SeatBelt is' + this.seatbelt },
{ text: 'Getting permission of inhibited is' + this.inhibited},
{ text: 'Getting permission of location is' + this.loc},
{ text: 'Getting permission of speed is' + this.speed},
{ text: 'Getting permission of crash is' + this.crash}
]
}
});
function showIm(Get_part){
vue.filter_status = false;
vue.notification_status = false;
vue.cards_status = false;
switch(Get_part){
case 1:
vue.cards_status = true;
break;
case 2:
vue.filter_status = true;
break;
case 3:
vue.notification_status = true;
break;
}
}
function permission(getP){
switch(getP){
case 1:
vue.seatbelt=!vue.seatbelt;
break;
case 2:
vue.inhibited=!vue.inhibited;
break;
case 3:
vue.loc=!vue.loc;
break;
case 4:
vue.speed=!vue.speed;
break;
case 5:
vue.crash=!vue.crash;
break;
}
}
function send_event(){
if (websocket !== undefined )websocket.close();
var base_URL = '192.168.128.245:4567';
var wsServer = 'ws://' + base_URL + '/event';
var websocket = new WebSocket(wsServer);
function onOpen(evt) {
var result = {
driver_id: "string",
secret_id: "string",
filters: [
]};
if (vue.seatbelt == true){
result.filters.push({name: "seatbelt", range: [0, 1, 2, 3]});
}
if (vue.inhibited == true){
result.filters.push({name: "inhibited", range: ["airbag", "ESC"]});
}
if (vue.loc == true){
result.filters.push({name: "location", range: [51.503262, -0.127701]});
}
if (vue.speed == true){
result.filters.push({name: "speed", limit: 120});
}
if (vue.crash == true){
result.filters.push({name: "crash"});
}
websocket.send(JSON.stringify(result));
}
websocket.onopen = function (evt) { onOpen(evt) };
websocket.onclose = function (evt) { onClose(evt) };
websocket.onmessage = function (evt) { onMessage(evt) };
websocket.onerror = function (evt) { onError(evt) };
function onClose(evt) {
//console.log("Disconnected");
}
function onMessage(evt) {
//console.log('Retrieved data from server: ' + evt.data);
vue.msg = JSON.parse(evt.data).message;
showIm(3);
}
function onError(evt) {
console.log('Error occurred: ' + evt.data);
}
}
</script>
</body>
</html>