mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-06 15:44:49 +08:00
Session accordion parsing javascript
This commit is contained in:
parent
4a14f2024f
commit
05a8668fbf
@ -0,0 +1,73 @@
|
||||
function loadSessionAccordion(json, error) {
|
||||
if (error) {
|
||||
$('#sessions-overview').addClass('forbidden'); // TODO Figure out 403
|
||||
return;
|
||||
}
|
||||
|
||||
sessionTable = $("#sessions-overview").find("#tableAccordion").find("tbody");
|
||||
|
||||
if (!sessionTable) throw new Error("Session table not found with ids #session-overview #tableAccordion");
|
||||
|
||||
var sessions = json.sessions;
|
||||
for (var i = 0; i < sessions.length; i++) {
|
||||
var session = sessions[i];
|
||||
var title = createAccordionTitle(i, session);
|
||||
var body = createAccordionBody(i, session);
|
||||
|
||||
var worldSeries = {name: 'World Playtime', colorByPoint: true, data: session.world_series};
|
||||
var gmSeries = session.gm_series;
|
||||
|
||||
sessionTable.append(title);
|
||||
sessionTable.append(body);
|
||||
|
||||
worldPie("worldpie_" + i, worldSeries, gmSeries);
|
||||
}
|
||||
}
|
||||
|
||||
function createAccordionTitle(i, session) {
|
||||
return '<tr aria-controls="session_t_' + i + '" aria-expanded="false" class="clickable collapsed bg-teal" data-target="#session_t_' + i + '" data-toggle="collapse"><td>'
|
||||
+ session.name + '</td>'
|
||||
+ '<td>' + session.start + '</td>'
|
||||
+ '<td>' + session.length + '</td>'
|
||||
+ '<td>' + session.most_used_world + '</td></tr>'
|
||||
}
|
||||
|
||||
function createAccordionBody(i, session) {
|
||||
|
||||
|
||||
return '<tr class="collapse" data-parent="#tableAccordion" id="session_t_' + i + '">' +
|
||||
'<td colspan="4">' +
|
||||
'<div class="collapse row" data-parent="#tableAccordion" id="session_t_' + i + '">' +
|
||||
'<div class="col-xs-12 col-sm-12 col-md-6 col-lg-6">' +
|
||||
'<p><i class="col-teal far fa-fw fa-clock"></i> Session Ended<span class="float-right"><b>' + session.end + '</b></span></p>' +
|
||||
'<p><i class="col-green far fa-fw fa-clock"></i> Session Length<span class="float-right"><b>' + session.length + '</b></span></p>' +
|
||||
'<p><i class="col-grey far fa-fw fa-clock"></i> AFK<span class="float-right"><b>' + session.afk_time + '</b></span></p>' +
|
||||
'<p><i class="col-green fa fa-fw fa-server"></i> Server<span class="float-right"><b>' + session.server_name + '</b></span></p><br>' +
|
||||
'<p><i class="col-red fa fa-fw fa-crosshairs"></i> Player Kills<span class="float-right"><b>' + session.player_kills.length + '</b></span></p>' +
|
||||
'<p><i class="col-green fa fa-fw fa-crosshairs"></i> Mob Kills<span class="float-right"><b>' + session.mob_kills + '</b></span></p>' +
|
||||
'<p><i class=" fa fa-fw fa-skull"></i> Deaths<span class="float-right"><b>' + session.deaths + '</b></span></p><hr>' +
|
||||
createKillsTable(session.player_kills) +
|
||||
'</div><div class="col-xs-12 col-sm-12 col-md-6 col-lg-6">' +
|
||||
'<div id="worldpie_' + i + '" class="chart-pie"></div>' +
|
||||
'<a target="_blank" href="/player/' + session.player_name + '"><button type="button" class="float-right btn bg-blue waves-effect\"><i class="fa fa-user"></i><span> Player Page</span></button></a>' +
|
||||
'</div>' +
|
||||
'</div></td></tr>'
|
||||
}
|
||||
|
||||
function createKillsTable(player_kills) {
|
||||
var table = '<table class="table table-striped scrollbar"><tbody>';
|
||||
|
||||
if (player_kills.length === 0) {
|
||||
table += '<td>No Kills</td><td>-</td><td>-</td>'
|
||||
}
|
||||
|
||||
for (var i = 0; i < player_kills.length; i++) {
|
||||
var kill = player_kills[i];
|
||||
table += '<td>' + kill.date + '</td>' +
|
||||
'<td>' + kill.killer + '<i class="fa fa-fw fa-angle-right col-red"></i>' + kill.victim + '</td>' +
|
||||
'<td>' + kill.weapon + '</td>'
|
||||
}
|
||||
|
||||
table += '</tbody></table>';
|
||||
return table;
|
||||
}
|
@ -526,110 +526,6 @@
|
||||
<th><i class="far fa-fw fa-map"></i> Most played World</th>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr aria-controls="session_t_1" aria-expanded="true"
|
||||
class="clickable collapsed bg-teal" data-target="#session_t_1"
|
||||
data-toggle="collapse">
|
||||
<td>Rsl1122</td>
|
||||
<td>Oct 28 2018, 10:05</td>
|
||||
<td>3s</td>
|
||||
<td>World (100%)</td>
|
||||
</tr>
|
||||
<tr class="collapse" data-parent="#tableAccordion" id="session_t_1">
|
||||
<td colspan="4">
|
||||
<div class="collapse row" data-parent="#tableAccordion"
|
||||
id="session_t_1">
|
||||
<div class="col-xs-12 col-sm-12 col-md-6 col-lg-6">
|
||||
<p><i class="col-teal far fa-fw fa-clock"></i> Session
|
||||
Ended<span class="float-right"><b>Oct 28 2018,
|
||||
10:05</b></span>
|
||||
</p>
|
||||
<p><i class="col-green far fa-fw fa-clock"></i> Session
|
||||
Length<span class="float-right"><b>3s</b></span></p>
|
||||
<p><i class="col-grey far fa-fw fa-clock"></i> AFK<span
|
||||
class="float-right"><b>-</b></span></p>
|
||||
<p><i class="col-green fa fa-fw fa-server"></i> Server<span
|
||||
class="float-right"><b>______T</b></span></p><br>
|
||||
<p><i class="col-red fa fa-fw fa-crosshairs"></i> Player
|
||||
Kills<span class="float-right"><b>0</b></span></p>
|
||||
<p><i class="col-green fa fa-fw fa-crosshairs"></i> Mob
|
||||
Kills<span class="float-right"><b>0</b></span></p>
|
||||
<p><i class=" fa fa-fw fa-skull"></i> Deaths<span
|
||||
class="float-right"><b>0</b></span></p>
|
||||
<table class="table table-striped scrollbar">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><i class=" far fa-fw fa-clock"></i> Time
|
||||
</th>
|
||||
<th>Killed</th>
|
||||
<th>With</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>No Kills</td>
|
||||
<td>-</td>
|
||||
<td>-</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="col-xs-12 col-sm-12 col-md-6 col-lg-6">
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr aria-controls="session_t_2" aria-expanded="true"
|
||||
class="clickable collapsed bg-teal" data-target="#session_t_2"
|
||||
data-toggle="collapse">
|
||||
<td>Rsl1122 <i class="far fa-fw fa-calendar-plus" title="Registered"></i></td>
|
||||
<td>Oct 28 2018, 9:05</td>
|
||||
<td>45s</td>
|
||||
<td>World (100%)</td>
|
||||
</tr>
|
||||
<tr class="collapse" data-parent="#tableAccordion" id="session_t_2">
|
||||
<td colspan="4">
|
||||
<div class="row collapse" data-parent="#tableAccordion"
|
||||
id="session_t_2">
|
||||
<div class="col-xs-12 col-sm-12 col-md-6 col-lg-6">
|
||||
<p><i class="col-teal far fa-fw fa-clock"></i> Session
|
||||
Ended<span class="float-right"><b>Oct 28 2018,
|
||||
10:05</b></span>
|
||||
</p>
|
||||
<p><i class="col-green far fa-fw fa-clock"></i> Session
|
||||
Length<span class="float-right"><b>3s</b></span></p>
|
||||
<p><i class="col-grey far fa-fw fa-clock"></i> AFK<span
|
||||
class="float-right"><b>-</b></span></p>
|
||||
<p><i class="col-green fa fa-fw fa-server"></i> Server<span
|
||||
class="float-right"><b>______T</b></span></p><br>
|
||||
<p><i class="col-red fa fa-fw fa-crosshairs"></i> Player
|
||||
Kills<span class="float-right"><b>0</b></span></p>
|
||||
<p><i class="col-green fa fa-fw fa-crosshairs"></i> Mob
|
||||
Kills<span class="float-right"><b>0</b></span></p>
|
||||
<p><i class=" fa fa-fw fa-skull"></i> Deaths<span
|
||||
class="float-right"><b>0</b></span></p>
|
||||
<table class="table table-striped scrollbar">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><i class=" far fa-fw fa-clock"></i> Time
|
||||
</th>
|
||||
<th>Killed</th>
|
||||
<th>With</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>No Kills</td>
|
||||
<td>-</td>
|
||||
<td>-</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="col-xs-12 col-sm-12 col-md-6 col-lg-6">
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@ -1525,6 +1421,7 @@
|
||||
<script src="js/charts/worldMap.js"></script>
|
||||
<script src="js/charts/onlineActivityCalendar.js"></script>
|
||||
<script src="js/charts/horizontalBarGraph.js"></script>
|
||||
<script src="js/charts/sessionAccordion.js"></script>
|
||||
|
||||
<script>
|
||||
setLoadingText('Calculating values..');
|
||||
@ -1943,6 +1840,34 @@
|
||||
}
|
||||
x.style.opacity = "1";
|
||||
openFunc(slideIndex)();
|
||||
|
||||
loadSessionAccordion({
|
||||
sessions: [
|
||||
{
|
||||
name: 'Rsl1122',
|
||||
player_name: 'Rsl1122',
|
||||
server_name: "Test server",
|
||||
start: "Oct 23, 4:32",
|
||||
end: "Oct 23, 5:34",
|
||||
most_used_world: "World (100%)",
|
||||
length: "1h 2m",
|
||||
afk_time: "5m",
|
||||
mob_kills: 4,
|
||||
deaths: 0,
|
||||
player_kills: [
|
||||
{
|
||||
date: "Oct 23 4:50",
|
||||
victim: "Bill",
|
||||
killer: "Rsl1122",
|
||||
weapon: "Diamond Sword"
|
||||
}
|
||||
],
|
||||
world_series: [{name: 'World', y: 4320}],
|
||||
gm_series: []
|
||||
}
|
||||
]
|
||||
}, null);
|
||||
|
||||
setLoadingText('Done.');
|
||||
setTimeout(function () {
|
||||
$('.page-loader').fadeOut();
|
||||
|
Loading…
Reference in New Issue
Block a user