WIP
This commit is contained in:
parent
5565124bd5
commit
6faf3293ad
@ -9,10 +9,6 @@
|
||||
}));
|
||||
}
|
||||
|
||||
// $.inidb.get('streamInfo', 'lastSub', subscriber);
|
||||
// $.inidb.get('streamInfo', 'lastFollow', follower);
|
||||
// $.inidb.get('streamInfo', 'lastDonator', donationUsername);
|
||||
|
||||
$.bind('command', function(event) {
|
||||
|
||||
const sender = "" + event.getSender().toLowerCase(),
|
||||
|
@ -14,6 +14,13 @@
|
||||
<!-- Main body -->
|
||||
<body>
|
||||
<div class="main">
|
||||
<div id="all" class="col-12 row m-auto ">
|
||||
<div class="col-1"></div>
|
||||
<div class="col-3 m-2 card"><div class="position-absolute">Last Follow:</div><div id="follow" class="text-center fs-1 fw-bolder">-</div></div>
|
||||
<div class="col-3 m-2 card"><div class="position-absolute">Last Sub:</div><div id="subscribe" class="text-center fs-1 fw-bolder">-</div></div>
|
||||
<div class="col-3 m-2 card"><div class="position-absolute">Last Dono:</div><div id="dono" class="text-center fs-1 fw-bolder">-</div></div>
|
||||
</div>
|
||||
<div id="single"></div>
|
||||
</div>
|
||||
<!-- jQuery -->
|
||||
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
|
||||
|
@ -1,4 +1,9 @@
|
||||
$(function () {
|
||||
const webSocket = window.socket;
|
||||
var lastFollow = '-',
|
||||
lastSub = '-',
|
||||
lastDonator = '-',
|
||||
timer = '-';
|
||||
|
||||
const getQueryMap = () => {
|
||||
let queryString = window.location.search,
|
||||
@ -12,37 +17,43 @@ $(function () {
|
||||
}
|
||||
return queryMap;
|
||||
}
|
||||
|
||||
const queryMap = getQueryMap();
|
||||
const getOrElse = (option, def) => queryMap.has(option) ? queryMap.get(option): def;
|
||||
|
||||
const refreshUI = () => {
|
||||
if(queryMap.single){ $("all").hide(); $("single").show(); }
|
||||
else{ $("all").show(); $("single").hide(); }
|
||||
|
||||
$('follow').text(lastFollow);
|
||||
$('subscribe').text(lastSub);
|
||||
$('donate').text(lastDonator);
|
||||
}
|
||||
|
||||
const handleSocketMessage = (e)=>{
|
||||
try {
|
||||
console.log(e.data)
|
||||
let rawMessage = e.data,
|
||||
message = JSON.parse(rawMessage);
|
||||
|
||||
if(!message.hasOwnProperty('eventFamily') || message['eventFamily'] != 'overlay' ||
|
||||
!message.hasOwnProperty('eventType') || !message.hasOwnProperty['data'])
|
||||
if(!message.hasOwnProperty('eventFamily') || message.eventFamily != 'overlay' ||
|
||||
!message.hasOwnProperty('eventType') || !message.hasOwnProperty('data'))
|
||||
return;
|
||||
|
||||
if(message['eventType'] == 'follow') {
|
||||
console.log("New Follow !! ", message['data'])
|
||||
} else if(message['eventType'] == 'subscribe') {
|
||||
console.log("New Sub !! ", message['data'])
|
||||
} else if(message['eventType'] == 'donation') {
|
||||
console.log("New dono !! ", message['data'])
|
||||
} else if(message['eventType'] == 'timer') {
|
||||
console.log("New timer !! ", message['data'])
|
||||
console.log(message.eventType, message.data)
|
||||
if(message.eventType == 'follow') {
|
||||
lastFollow = message.data || lastFollow;
|
||||
} else if(message.eventType == 'subscribe') {
|
||||
lastSub = message.data || lastSub;
|
||||
} else if(message.eventType == 'donation') {
|
||||
lastDonator = message.data || lastDonator;
|
||||
} else if(message.eventType == 'timer') {
|
||||
console.log("New timer !! ", message.data)
|
||||
}
|
||||
|
||||
refreshUI();
|
||||
} catch (ex) {
|
||||
console.log(ex)
|
||||
}
|
||||
};
|
||||
|
||||
const webSocket = window.socket,
|
||||
queryMap = getQueryMap();
|
||||
|
||||
socket.addFamilyHandler("overlay", handleSocketMessage);
|
||||
|
||||
$(document).ready(async ()=>{
|
||||
@ -50,13 +61,17 @@ $(function () {
|
||||
while(socket.getReadyState() === 0){
|
||||
await new Promise(r => setTimeout(r, 500));
|
||||
}
|
||||
// $.inidb.get('streamInfo', 'lastSub', subscriber);
|
||||
// $.inidb.get('streamInfo', 'lastFollow', follower);
|
||||
// $.inidb.get('streamInfo', 'lastDonator', donationUsername);
|
||||
socket.getDBValue("get_current_stream_info", 'streamInfo', 'lastFollow', function(response) {
|
||||
console.log(response);
|
||||
|
||||
if(response.request_data) console.log(response.request_data)
|
||||
socket.getDBValue("get_current_stream_info", 'streamInfo', 'lastFollow', (response)=>{
|
||||
if(response.streamInfo) lastFollow = response.streamInfo || lastFollow;
|
||||
refreshUI();
|
||||
})
|
||||
socket.getDBValue("get_current_stream_info", 'streamInfo', 'lastSub', (response)=>{
|
||||
if(response.streamInfo) lastSub = response.streamInfo || lastSub;
|
||||
refreshUI();
|
||||
})
|
||||
socket.getDBValue("get_current_stream_info", 'streamInfo', 'lastDonator', (response)=>{
|
||||
if(response.streamInfo) lastDonator = response.streamInfo || lastDonator;
|
||||
refreshUI();
|
||||
})
|
||||
}
|
||||
})
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user