From 13668170b6880e9afa60bca62059497fe185448a Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Sat, 20 Jul 2019 15:21:07 +0300 Subject: [PATCH] Made player overview dynamic --- .../assets/plan/web/js/player-values.js | 96 ++ .../resources/assets/plan/web/player.html | 990 ++++++------------ 2 files changed, 388 insertions(+), 698 deletions(-) create mode 100644 Plan/common/src/main/resources/assets/plan/web/js/player-values.js diff --git a/Plan/common/src/main/resources/assets/plan/web/js/player-values.js b/Plan/common/src/main/resources/assets/plan/web/js/player-values.js new file mode 100644 index 000000000..65e34c913 --- /dev/null +++ b/Plan/common/src/main/resources/assets/plan/web/js/player-values.js @@ -0,0 +1,96 @@ +function loadPlayerOverviewValues(json, error) { + if (error) { + $("#player-overview").addClass("forbidden"); // TODO Figure out 403 + return; + } + + tab = $("#player-overview"); + + // Player information card + data = json.info; + element = $(tab).find("#data_player_info"); + + $(element).find("#data_online").replaceWith(data.online ? ' Online' : ' Offline'); + $(element).find("#data_titles").replaceWith((data.operator ? ' Operator' : '') + (data.banned ? ' Banned' : '')); + $(element).find("#data_kick_count").text(data.kick_count); + $(element).find("#data_player_kills").text(data.player_kill_count); + $(element).find("#data_mob_kills").text(data.mob_kill_count); + $(element).find("#data_deaths").text(data.death_count); + + $(element).find("#data_playtime").text(data.playtime); + $(element).find("#data_active_playtime").text(data.active_playtime); + $(element).find("#data_afk_time").text(data.afk_time); + $(element).find("#data_session_count").text(data.session_count); + $(element).find("#data_longest_session_lenght").text(data.longest_session_lenght); + $(element).find("#data_session_median").text(data.session_median); + + $(element).find("#data_activity_index").text(data.activity_index); + $(element).find("#data_activity_index_group").text(data.activity_index_group); + $(element).find("#data_favorite_server").text(data.favorite_server); + $(element).find("#data_average_ping").text(data.average_ping); + $(element).find("#data_best_ping").text(data.best_ping); + $(element).find("#data_worst_ping").text(data.worst_ping); + + $(element).find("#data_registered").text(data.registered); + $(element).find("#data_last_seen").text(data.last_seen); + + $('#data_nicknames').replaceWith(createNicknameTableBody(json.nicknames)); + + $('#data_connections').replaceWith(createConnectionsTableBody(json.connections)); + + // Online activity + data = json.online_activity; + element = $(tab).find("#data_online_activity"); + + $(element).find("#data_playtime_30d").text(data.playtime_30d); + $(element).find("#data_playtime_7d").text(data.playtime_7d); + $(element).find("#data_active_playtime_30d").text(data.active_playtime_30d); + $(element).find("#data_active_playtime_7d").text(data.active_playtime_7d); + $(element).find("#data_afk_time_30d").text(data.afk_time_30d); + $(element).find("#data_afk_time_7d").text(data.afk_time_7d); + $(element).find("#data_average_session_length_30d").text(data.average_session_length_30d); + $(element).find("#data_average_session_length_7d").text(data.average_session_length_7d); + $(element).find("#data_session_count_30d").text(data.session_count_30d); + $(element).find("#data_session_count_7d").text(data.session_count_7d); + $(element).find("#data_player_kills_30d").text(data.player_kill_count_30d); + $(element).find("#data_player_kills_7d").text(data.player_kill_count_7d); + $(element).find("#data_mob_kills_30d").text(data.mob_kill_count_30d); + $(element).find("#data_mob_kills_7d").text(data.mob_kill_count_7d); + $(element).find("#data_deaths_30d").text(data.death_count_30d); + $(element).find("#data_deaths_7d").text(data.death_count_7d) +} + +function createNicknameTableBody(nicknames) { + var table = ''; + + if (nicknames.length === 0) { + table += 'No Nicknames--' + } + + for (var i = 0; i < nicknames.length; i++) { + var nickname = nicknames[i]; + table += '' + nickname.nickname + '' + + '' + nickname.server + '' + + '' + nickname.date + '' + } + + table += ''; + return table; +} + +function createConnectionsTableBody(connections) { + var table = ''; + + if (connections.length === 0) { + table += 'No Connection Data-' + } + + for (var i = 0; i < connections.length; i++) { + var connection = connections[i]; + table += '' + connection.geolocation + '' + + '' + connection.date + '' + } + + table += ''; + return table; +} \ No newline at end of file diff --git a/Plan/common/src/main/resources/assets/plan/web/player.html b/Plan/common/src/main/resources/assets/plan/web/player.html index 6942d2941..970ba577c 100644 --- a/Plan/common/src/main/resources/assets/plan/web/player.html +++ b/Plan/common/src/main/resources/assets/plan/web/player.html @@ -9,7 +9,7 @@ - Plan | Player name + Plan | ${playerName}