Implement server kicks and updating the server time on the page according to heartbeats
This commit is contained in:
@@ -10,6 +10,10 @@ body {
|
||||
font-family: Verdana,Tahoma,"DejaVu Sans",sans-serif;
|
||||
}
|
||||
|
||||
body.night, body.evening {
|
||||
background-image: url(img/bg_night.png);
|
||||
}
|
||||
|
||||
.stat-box {
|
||||
padding: 1em;
|
||||
color: #fff;
|
||||
|
||||
@@ -4,6 +4,7 @@ function pollMessages(id) {
|
||||
$('#chat-display').html('');
|
||||
$('#balance-display').html(data['user-info']['balance']);
|
||||
$(data['events']).each(function(idx, evt) {
|
||||
console.log(evt['type']);
|
||||
if (evt['type'] == "chat") {
|
||||
$('#chat-display').append("<li>"+evt['payload']['sender']+": "+evt['payload']['message']);
|
||||
} else if (evt['type'] == 'join') {
|
||||
@@ -14,6 +15,18 @@ function pollMessages(id) {
|
||||
$('#chat-display').append("<li><strong>"+evt['payload']['message']+"</strong></li>");
|
||||
} else if (evt['type'] == 'player-death') {
|
||||
$('#chat-display').append("<li><em>"+evt['payload']['player']+" died.</em></li>");
|
||||
} else if (evt['type'] == 'server-heartbeat') {
|
||||
cls = "night";
|
||||
console.log(evt['payload']['time']);
|
||||
t = new Date(evt['payload']['time']*1000);
|
||||
$('body').removeClass("morning night");
|
||||
if (t.getHours() > 8 && t.getHours() < 17) {
|
||||
cls = "morning";
|
||||
$('body').addClass("morning");
|
||||
} else {
|
||||
$('body').addClass("night");
|
||||
}
|
||||
$('#time-display').html(t.toLocaleTimeString());
|
||||
}
|
||||
});
|
||||
window.setTimeout(function() {pollMessages(data['poll-id'])}, 1);
|
||||
|
||||
Reference in New Issue
Block a user