-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
146 lines (124 loc) · 6.19 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Example site</title>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/css/bootstrap.min.css" integrity="sha384-Zug+QiDoJOrZ5t4lssLdxGhVrurbmBWopoEl+M6BdEfwnCJZtKxi1KgxUyJq13dy" crossorigin="anonymous">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" crossorigin="anonymous">
<link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.css">
</head>
<body>
<!-- navigation bar -->
<nav class="navbar navbar-expand-md navbar-dark bg-dark fixed-top">
<a href="https://www.nova-labs.org"><img src="images/nova-labs_icon_120x120.png" width="40" height="40" id="state_icon_header"></a>
<a class="navbar-brand" href="#" onclick="show_main()">Example Web Site</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbar" aria-controls="navbar" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbar">
<ul class="navbar-nav mr-auto">
<li class="nav-item active dropdown">
<a class="nav-link dropdown-toggle" href="#" id="menu" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Menu</a>
<div class="dropdown-menu" aria-labelledby="menu">
<a class="dropdown-item" href="#" id="item_1">Item 1</a>
<a class="dropdown-item" href="#" id="item_2">Item 2</a>
</div>
</li>
<li>
<button type="button" class="btn" data-toggle="collapse" data-target="#demo" id="state_button_xsm">unknown</button>
</li>
</ul>
</div>
</nav>
<!-- end navigation bar -->
<!-- container -->
<main role="main" class="container">
<div class="starter-template" id="main_content">
<h1>Example Site</h1>
<p class="lead">Example site</p>
<p>
Simple text: <span id="state_text">unknown</span>
</p>
<div>
<button type="button" class="btn" data-toggle="collapse" data-target="#demo" id="state_button_lg">
unknown
</button>
<button type="button" class="btn" data-toggle="collapse" data-target="#demo" id="state_button_sm">
unknown
</button>
</div>
<br/>
<div>
<img src="images/nova-labs_icon_120x120.png" id="state_icon">
<img src="images/nova-labs_icon_120x120.png" width="60" height="60" id="state_icon_sm">
<img src="images/nova-labs_icon_120x120.png" width="30" height="30" id="state_icon_bug">
</div>
<br/>
<div>
<h5>Event JSON</h5>
<pre id="state_json"></pre>
</div>
</div>
</main>
<!-- end container -->
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<!-- developer versions -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.3/js/bootstrap.min.js" integrity="sha384-a5N7Y/aK3qNeh15eJKGWxsqtnX/wWdSZSKp+81YjTmS15nvnvxKHuzaWwXHDli+4" crossorigin="anonymous"></script>
<script src="./js/jquery.formatDateTime.min.js"></script>
<script type="application/javascript">
//var base_url = "http://localhost:8080";
var base_url = "//event.nova-labs.org";
var url = base_url + "/events/novalabs_space/latest";
function eventToStatus(event) {
var status = { "id": 0, "text": "UNKNOWN", "classes": "btn btn-warning", "time": new Date(0), "icon": "images/nova-labs_icon_64x64.png"};
if (event == null || event === undefined) {
} else {
if (event.value == "open") {
status.id = 1;
status.text = "OPEN";
status.classes = "btn btn-success";
status.icon = "images/nova-labs_icon_120x120.png";
} else if (event.value == "closed") {
status.id = 0;
status.text = "CLOSED";
status.classes = "btn btn-danger";
status.icon = "images/nova-labs_icon_off_120x120.png";
}
status.time = new Date(event.epochMillis);
}
return status;
}
function formatDate(date) {
return jQuery.formatDateTime('D yy-mm-dd gg:ii:ss.uu a', date);
}
function formatShortDate(date) {
return jQuery.formatDateTime('M dd hh:ii', date);
}
jQuery( document ).ready(function() {
jQuery.getJSON(url, function( event ) {
var status = eventToStatus(event);
var dateTime = formatDate(status.time);
var shortDateTime = formatShortDate(status.time);
jQuery("#state_text").html(status.text);
jQuery("#state_button_xsm").html(status.text).removeClass().addClass(status.classes);
jQuery("#state_button_sm").html(status.text + "<br/>" + shortDateTime).removeClass().addClass(status.classes);
jQuery("#state_button_lg").html(status.text + "<br/>" + dateTime).removeClass().addClass(status.classes);
jQuery("#state_icon").attr("src", status.icon);
jQuery("#state_icon_sm").attr("src", status.icon);
jQuery("#state_icon_bug").attr("src", status.icon);
jQuery("#state_icon_header").attr("src", status.icon);
jQuery("#state_json").html(JSON.stringify(event, null, 4));
});
});
</script>
</body>
</html>