-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
261 lines (243 loc) · 9.38 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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
<!DOCTYPE html>
<html lang="en">
<head>
<title>Arcom Control Panel</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="https:/arcom.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/bootbox.js/4.4.0/bootbox.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.min.js"></script>
<script src="https:/jquery.xmlrpc.js"></script>
<script>
var call = $.cookie("arcom.call");
var place = $.cookie("arcom.location");
var disable_secs = 0;
function updateBoth(response, status, jqXHR){
updateResponse(response, status, jqXHR);
getStatus();
}
function getStatus(){
callRPC("status", [call], setStatus);
}
function setStatus(response, status, jqXHR){
var html = '';
var obj = response[0]
if (call == null || call == "" || place == null || place == "") {
setResponse('Invalid: Call=' + $.cookie("arcom.call") +
' Location=' + $.cookie("arcom.location"));
$("#fullMenu").hide()
return;
}
$("#fullMenu").show()
$("#statusTitle").html("Operator: " + $.cookie("arcom.call") +
" @ " + $.cookie("arcom.location"));
html = '<table class=\"table table-condensed\"><tbody>'
for (var item in obj) {
if (item == "identity") {
$("#title").html('Repeater Control - ' + obj[item]);
} else if (item == "auto-enable") {
date = new Date(obj[item].toFixed(0)*1000)
html += "<tr><td>" + item + "</td><td>" + date + "</td></tr>";
} else
html += "<tr><td>" + item + "</td><td>" + obj[item] + "</td></tr>";
}
html += "</tbody></table>";
$("#status-content").html(html);
}
function callRPC(func, params, callback){
var rpcURL = "https:/RPC2";
if (call == null || call == "" || place == null || place == "") {
setCallLoc();
return;
}
if (!callback) callback = updateResponse;
$.xmlrpc({
url: rpcURL,
methodName: func,
params: params,
success: callback,
error: function(jqXHR, status, error) { alert("RPC FAIL: " + func + ": " + status + ": " + error) }
});
};
function updateResponse(response, status, jqXHR) {
var tuple = response[0];
setResponse("RPC " + status + ": Command " + tuple[0] + ": " + tuple[1]);
}
function setResponse(text) {
$("#response").html('<div class="well well-sm">' + text + '</div>');
}
function listLog(response, status, jqXHR){
var html = '';
var obj = response[0]
html = '<table class=\"table table-condensed\"><tbody>';
for (var item in obj) {
var entry = obj[item];
date = new Date(entry[0]*1000);
html += "<tr><td>" + date + "</td><td>" +
entry[1] + "</td><td>" + entry[2] + "</td></tr>";
}
$("#response").html(html + "</tbody></table>");
}
function logInterference(response, status, jqXHR){
var tuple = response[0];
if (status == "success" && tuple[0] == true) {
callRPC("logInterference", [call, place, disable_secs], updateBoth);
} else updateResponse(response, status, jqXHR);
}
function disableAndLog(call, seconds){
disable_secs = seconds;
callRPC("port1Disable", [call, seconds], logInterference);
}
function checkCookies(){
if (call == null || call == "" || place == null || place == "") {
setCallLoc();
return false
} else {
getStatus();
return true;
}
}
function setCallLoc(){
bootbox.prompt({
size: "small",
title: "What is your call?",
callback: function(result){
if (result != null) {
$.cookie("arcom.call", result.toUpperCase(), { expires: 365 });
call = result.toUpperCase();
}
bootbox.prompt({
title: "What is your location? (e.g. grid square)",
callback: function(result){
if (result != null) {
$.cookie("arcom.location", result, { expires: 365 });
place = result;
}
checkCookies();
}
});
}
});
}
$(document).ready(function(){
$("#port1Disable5").bind('click', function (){
bootbox.confirm("Confirm disable?", function(result){
if (result) disableAndLog(call, 300);
})
});
$("#port1Disable10").bind('click', function (){
bootbox.confirm("Confirm disable?", function(result){
if (result) disableAndLog(call, 600);
})
});
$("#port1Disable15").bind('click', function (){
bootbox.confirm("Confirm disable?", function(result){
if (result) disableAndLog(call, 900);
})
});
$("#port1Disable").bind('click', function (){
bootbox.confirm("Confirm disable?", function(result){
if (result) callRPC("port1Disable", [call, 0], updateBoth);
})
});
$("#port1Enable").bind('click', function (){
callRPC("port1Enable", [call], updateBoth);
});
$("#port3Unbridge").bind('click', function (){
bootbox.confirm("Confirm unbridging 1 & 3?", function(result){
if (result) callRPC("port3Unbridge", [call], updateBoth);
})
});
$("#port3Bridge").bind('click', function (){
callRPC("port3Bridge", [call], updateBoth);
});
$("#setDateTime").bind('click', function (){
bootbox.confirm("Confirm setting date/time?", function(result){
if (result) callRPC("setDateTime", [call]);
})
});
$("#restart").bind('click', function (){
bootbox.confirm("Confirm restart?", function(result){
if (result) callRPC("restart", [call]);
})
});
$("#getStatus").bind('click', function (){ getStatus();});
$("#getLog").bind('click', function (){callRPC("getLog", [call, 10], listLog)});
$("#setViolator").bind('click', function (){
bootbox.prompt({
title: "Select violator",
inputType: 'select',
inputOptions: [
{ text: 'Violator Alpha (falsetto)',
value: 'Violator Alfa (High pitched, falsetto, singing, swearing)', },
{ text: 'Violator Beta (Doubler)',
value: 'Violator Bravo ("Doubler", doubles with net checkins, occasional other comments)', },
{ text: 'Violator Charlie',
value: 'Violator Charlie (some third person)', },
{ text: 'Someone else', value: 'other', }
],
callback: function (result) {
if (result != null) callRPC("setViolator", [call, result]);
else setResponse("No change.");
}
});
});
$("#setCallLoc").bind('click', function (){ setCallLoc(); });
if (checkCookies()) {
$("#setCookieMenu").hide()
callRPC("status", [call], setStatus);
} else $("#fullMenu").hide()
})
</script>
</head>
<body>
<div class="container">
<div id="header" class="row">
<h3><div id="title">Repeater Control</div></h3>
<h4><div id="statusTitle">Operator: (not set)</div></h4>
<div class="col-sm-4">
<div id="status-content"></div>
</div>
</div>
<div id="fullMenu" class="row">
<h4>Commands</h4>
<div id="menu1" class="btn-group-vertical" class="btn-group-xs" class="col-sm-4">
<button type="button" class="btn btn-danger"
id="port1Disable5">Port 1 Disable for 5 min.</button><br>
<button type="button" class="btn btn-danger"
id="port1Disable10">Port 1 Disable for 10 min.</button><br>
<button type="button" class="btn btn-danger"
id="port1Disable15">Port 1 Disable for 15 min.</button><br>
<button type="button" class="btn btn-danger"
id="port1Disable">Port 1 Disable</button><br>
<button type="button" class="btn btn-danger"
id="port3Unbridge">Unbridge Port 1-to-3</button><br>
<button type="button" class="btn btn-danger"
id="restart">Restart</button><br>
<button type="button" class="btn btn-warning"
id="setDateTime">Set Date & Time</button><br>
</div>
<div id="menu2" class="btn-group-vertical" class="btn-group-xs" class="col-sm-4">
<button type="button" class="btn btn-info"
id="getStatus">Status</button><br>
<button type="button" class="btn btn-info"
id="getLog">Recent Activity</button><br>
<button type="button" class="btn btn-info"
id="setCallLoc">Set Call/Loc</button><br>
<button type="button" class="btn btn-success"
id="port1Enable">Port 1 Enable</button><br>
<button type="button" class="btn btn-success"
id="port3Bridge">Bridge Port 1-to-3</button><br>
<button type="button" class="btn btn-warning"
id="setViolator">Set Violator</button><br>
<button type="button" class="btn btn-info"
id="unused1">(unused)</button><br>
</div>
</div>
<div id="response" class="row"></div>
</div>
</body>
</html>