Skip to content

Commit

Permalink
v0.94
Browse files Browse the repository at this point in the history
-1 minute timeout for idle / disconnected websocket (initiates reconnect attempt automatically)
-Night-friendly soft white for text
  • Loading branch information
taoteh1221 committed Jul 16, 2019
1 parent a5754f3 commit ff8540b
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Apps/Ticker-UI/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ p {
height: auto;
width: auto;
background: black;
color: #e3e3e3;
color: #c6c6c6;
padding: 1em;
padding-bottom: 9px;
}
Expand Down
12 changes: 11 additions & 1 deletion Apps/Ticker-UI/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,17 @@

<link rel="stylesheet" href="css/style.css" type="text/css" />

<script src="js/init.js"></script>
<script src="js/functions.js"></script>


<script>

$(document).ready(function() {
connect();
});

</script>

</head>

<body>
Expand Down
48 changes: 36 additions & 12 deletions Apps/Ticker-UI/js/init.js → Apps/Ticker-UI/js/functions.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,35 @@

/////////////////////////////////////////////////////////////////////////////////////////////////////

function numberWithCommas(x) {
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
}

$(document).ready(function() {
var socket = new WebSocket("wss://ws-feed.gdax.com");
/////////////////////////////////////////////////////////////////////////////////////////////////////

function sendText() {
var msg = {
type: "subscribe",
product_id: "BTC-USD"
};
socket.send(JSON.stringify(msg));
}

/////////////////////////////////////////////////////////////////////////////////////////////////////

function connect() {
var socket = new WebSocket('wss://ws-feed.gdax.com');
socket.onopen = function() {
var msg = {
type: "subscribe",
product_id: "BTC-USD"
};
socket.send(JSON.stringify(msg));
console.log(msg);
$("#status").text("Coinbase").css("color", "#2bbf2b");
$("#status").text("Coinbase").css("color", "#2bbf7b");
};

socket.onmessage = function(event) {
socket.onmessage = function(e) {
var msg = JSON.parse(event.data);
if (msg["type"] == "match") {

Expand Down Expand Up @@ -63,12 +78,21 @@ function numberWithCommas(x) {
}
};

function sendText() {
var msg = {
type: "subscribe",
product_id: "BTC-USD"
};
socket.send(JSON.stringify(msg));
}
});
socket.onclose = function(e) {
//console.log('Connecting', e.reason);
setTimeout(function() {
$("#status").text("Connecting").css("color", "red");
connect();
}, 60000); // Reconnect after no data received for 1 minute
};

socket.onerror = function(err) {
$("#status").text("Error").css("color", "red");
//console.error('Socket encountered error: ', err.message, 'Closing socket');
socket.close();
};
}

/////////////////////////////////////////////////////////////////////////////////////////////////////


7 changes: 7 additions & 0 deletions Misc.Docs.Etc/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,10 @@ v0.92.0
v0.93.0
-Documentation for "goodtft LCD-show" LCDs seperated from main documentation
---------------------------------------------------------


---------------------------------------------------------
v0.94.0
-1 minute timeout for idle / disconnected websocket (initiates reconnect attempt automatically)
-Night-friendly soft white for text
---------------------------------------------------------

0 comments on commit ff8540b

Please sign in to comment.