Rev | Line | |
---|
[245] | 1 | function StartStatsModule () {
|
---|
| 2 | var updateGameTimeEvent = function() {
|
---|
| 3 | $.getJSON( "../api/getstats")
|
---|
| 4 | .done(function(data) {
|
---|
| 5 | var time = "Day " + data.gametime.days + ", ";
|
---|
| 6 | if (data.gametime.hours < 10)
|
---|
| 7 | time += "0";
|
---|
| 8 | time += data.gametime.hours;
|
---|
| 9 | time += ":";
|
---|
| 10 | if (data.gametime.minutes < 10)
|
---|
| 11 | time += "0";
|
---|
| 12 | time += data.gametime.minutes;
|
---|
| 13 |
|
---|
| 14 | $("#stats_time").html (time);
|
---|
| 15 | $("#stats_players").html (data.players);
|
---|
| 16 | })
|
---|
| 17 | .fail(function(jqxhr, textStatus, error) {
|
---|
| 18 | console.log("Error fetching game stats");
|
---|
| 19 | })
|
---|
| 20 | .always(function() {
|
---|
| 21 | });
|
---|
| 22 | window.setTimeout(updateGameTimeEvent, 2000);
|
---|
| 23 | };
|
---|
| 24 | updateGameTimeEvent();
|
---|
| 25 | }
|
---|
| 26 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.