This repository has been archived on 2022-03-12. You can view files and clone it, but cannot push or open issues or pull requests.
reValuate/Website/scripts/getCurrentCoins.js
Yamozha 91e0557b20 included "database" and primitive balance checking
let's make it so we have a way to integrate it with sql in later stages.
PLEASE FIX the "fstring" in the js and the id to balance sequence
2021-02-03 18:45:10 +02:00

36 lines
862 B
JavaScript

socketAdress="ws://localhost:8765"
// Lacking protocol for ids lmao
document.cookie = "id=1";
function currencyTicker(){
var ws = new WebSocket(socketAdress);
ws.onopen = function(){
console.log("Connection is Established");
ws.send("STATUSONCOIN");
};
ws.onmessage = function(evt) {
var received_msg = evt.data;
w = document.getElementById("odometer").innerHTML = received_msg;
};
}
function userBalance(){
var ws = new WebSocket(socketAdress);
ws.onopen = function(){
ws.send("STATUSONUSER");
};
ws.onmessage = function(evt){
var balanceStatus = evt.data;
// this doesnt work, fix pls
var websiteReplace = "Your balance is:${balanceStatus}"
w = document.getElementById("balance").innerHTML = websiteReplace
}
}
var t=setInterval(currencyTicker,5000);
var y=setInterval(userBalance,10000);