reworking the project on django
This commit is contained in:
37
old/Website/scripts/getCurrentCoins.js
Normal file
37
old/Website/scripts/getCurrentCoins.js
Normal file
@ -0,0 +1,37 @@
|
||||
socketAdress="ws://localhost:8765"
|
||||
// Lacking protocol for ids lmao
|
||||
document.cookie = "id=2";
|
||||
|
||||
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
|
||||
w = document.getElementById("balance").innerHTML = balanceStatus;
|
||||
ws.onmessage = function(evt){
|
||||
w = document.getElementById("username").innerHTML = evt.data;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
var t=setInterval(currencyTicker,5000);
|
||||
var y=setInterval(userBalance,5000);
|
Reference in New Issue
Block a user