[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 |
|
---|
[250] | 27 | function StartUIUpdatesModule () {
|
---|
| 28 | var updateGameTimeEvent = function() {
|
---|
| 29 | $.getJSON( "../api/getwebuiupdates?latestLine=" + lastLogLine)
|
---|
| 30 | .done(function(data) {
|
---|
| 31 | var time = "Day " + data.gametime.days + ", ";
|
---|
| 32 | if (data.gametime.hours < 10)
|
---|
| 33 | time += "0";
|
---|
| 34 | time += data.gametime.hours;
|
---|
| 35 | time += ":";
|
---|
| 36 | if (data.gametime.minutes < 10)
|
---|
| 37 | time += "0";
|
---|
| 38 | time += data.gametime.minutes;
|
---|
| 39 |
|
---|
| 40 | $("#stats_time").html (time);
|
---|
| 41 | $("#stats_players").html (data.players);
|
---|
| 42 | $("#newlogcount").html (data.newlogs);
|
---|
| 43 | if (data.newlogs > 0) {
|
---|
| 44 | $("#newlogcount").addClass ("visible");
|
---|
| 45 | } else {
|
---|
| 46 | $("#newlogcount").removeClass ("visible");
|
---|
| 47 | }
|
---|
| 48 | })
|
---|
| 49 | .fail(function(jqxhr, textStatus, error) {
|
---|
| 50 | console.log("Error fetching ui updates");
|
---|
| 51 | })
|
---|
| 52 | .always(function() {
|
---|
| 53 | });
|
---|
| 54 | window.setTimeout(updateGameTimeEvent, 2000);
|
---|
| 55 | };
|
---|
| 56 | updateGameTimeEvent();
|
---|
| 57 | }
|
---|
| 58 |
|
---|