Re-Added 'Added an overlay to display when the websocket isn't connected.' Don't know what happened there...
This commit is contained in:
parent
fad4f2c707
commit
5c0822b704
@ -9,9 +9,24 @@
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
|
||||
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
|
||||
<script src="https://kit.fontawesome.com/272149490a.js" crossorigin="anonymous"></script>
|
||||
<style>
|
||||
.overlay {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background-color: rgba(0, 0, 0, 0.85);
|
||||
position: absolute;
|
||||
z-index: 1;
|
||||
margin: auto 0px;
|
||||
vertical-align: middle;
|
||||
color: white;
|
||||
font-size: 60px;
|
||||
text-align: center;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="overlay" class="overlay">Not connected...</div>
|
||||
<div class="container bg-dark text-light">
|
||||
<div class="row">
|
||||
<div class="col-sm-1">
|
||||
@ -104,7 +119,7 @@
|
||||
<input type="text" class="form-control" id="input_url" />
|
||||
<div class="input-group-append">
|
||||
<button class="btn btn-primary" id="button_url_open">Go</button>
|
||||
<button class="btn btn-danger" id="button_url_add_mapping" style="display: none;"><i class="fa fa-arrows-alt-h"></i></button>
|
||||
<button class="btn btn-warning" id="button_url_add_mapping" style="display: none;"><i class="fa fa-arrows-alt-h"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -273,10 +288,30 @@ process_ws_message = function(event) {
|
||||
}
|
||||
|
||||
var play_on_click = true;
|
||||
interval = null;
|
||||
ws = null;
|
||||
|
||||
var start_reconnect_timer = function() {
|
||||
console.log("start_reconnect_timer() running...");
|
||||
$('#overlay').show();
|
||||
interval = setInterval(connect_to_ws, 2500);
|
||||
}
|
||||
|
||||
var connect_to_ws = function() {
|
||||
if (!ws || ws.readyState >= ws.CLOSING) {
|
||||
ws = new WebSocket("ws://" + location.host + "/ws");
|
||||
ws.onopen = function() {
|
||||
console.log("on_open() running...");
|
||||
clearInterval(interval);
|
||||
$('#overlay').hide();
|
||||
};
|
||||
ws.onmessage = process_ws_message;
|
||||
ws.onclose = start_reconnect_timer;
|
||||
}
|
||||
}
|
||||
|
||||
$(function() {
|
||||
ws = new WebSocket("ws://" + location.host + "/ws");
|
||||
ws.onmessage = process_ws_message;
|
||||
start_reconnect_timer();
|
||||
|
||||
$('#volume_slider').change(function(e) { ws.send("volume=" + e.target.value); });
|
||||
$('#button_play').click(function(e) { ws.send("play"); });
|
||||
|
Loading…
Reference in New Issue
Block a user