reduce polling load by condensing the json poll api into one method instead of several

This commit is contained in:
Trever Fischer
2012-04-19 14:47:44 -04:00
parent b37b7895bf
commit 4ae3407fb0
7 changed files with 47 additions and 38 deletions

View File

@@ -1,14 +0,0 @@
function updateBalance() {
$.get("/api/balance", function(data) {
$("#balance-display").html(data['balance']);
});
}
function pollBalance() {
updateBalance();
window.setTimeout(pollBalance, 3000);
}
$(document).ready(function () {
pollBalance();
});

14
static/js/poll.js Normal file
View File

@@ -0,0 +1,14 @@
function pollMessages() {
$.get('/api/poll/0', function(data) {
$('#balance-display').html(data['user-info']['balance']);
});
}
function poll() {
pollMessages();
window.setTimeout(pollMessages, 3000);
}
$(document).ready(function () {
poll();
});

View File

@@ -1,20 +0,0 @@
function updateServer() {
$.get("/api/server/info/s.camin.us", function(data) {
hours = parseInt((data['time']/1000)+8)%24;
minutes = parseInt(((data['time']/1000)%1)*60);
var day = hours < 12;
minutes = ""+minutes;
while(minutes.length<2)
minutes = "0"+minutes;
$("#time-display").html(hours+":"+minutes+" "+(day ? "am":"pm"));
});
}
function pollServer() {
updateServer();
window.setTimeout(pollServer, 1000);
}
$(document).ready(function () {
pollServer();
});