Added game last played, and total play time stats
* Added game last played, and total play time stats
This commit is contained in:
BIN
gaseous-server/wwwroot/.DS_Store
vendored
BIN
gaseous-server/wwwroot/.DS_Store
vendored
Binary file not shown.
@@ -70,4 +70,30 @@
|
||||
bg.setAttribute('style', 'background-image: url("/api/v1.1/Games/' + gameId + '/artwork/' + artworks[artworksPosition] + '/image/original/' + artworks[artworksPosition] + '.jpg"); background-position: center; background-repeat: no-repeat; background-size: cover; filter: blur(10px); -webkit-filter: blur(10px);');
|
||||
}
|
||||
}
|
||||
|
||||
// statistics
|
||||
var SessionId = undefined;
|
||||
|
||||
function SaveStatistics() {
|
||||
var model;
|
||||
if (SessionId == undefined) {
|
||||
ajaxCall(
|
||||
'/api/v1.1/Statistics/Games/' + gameId,
|
||||
'POST',
|
||||
function (success) {
|
||||
SessionId = success.sessionId;
|
||||
}
|
||||
);
|
||||
} else {
|
||||
ajaxCall(
|
||||
'/api/v1.1/Statistics/Games/' + gameId + '/' + SessionId,
|
||||
'PUT',
|
||||
function (success) {
|
||||
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
setInterval(SaveStatistics, 60000);
|
||||
</script>
|
||||
|
||||
@@ -63,6 +63,16 @@
|
||||
<div id="gamescreenshots_gallery_panel"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="gamestatistics">
|
||||
<div id="gamestatistics_lastplayed" class="gamestatistics_box">
|
||||
<span class="gamestatistics_label">Last Played</span>
|
||||
<span id="gamestatistics_lastplayed_value" class="gamestatistics_value">-</span>
|
||||
</div>
|
||||
<div id="gamestatistics_timeplayed" class="gamestatistics_box">
|
||||
<span class="gamestatistics_label">Total Play Time</span>
|
||||
<span id="gamestatistics_timeplayed_value" class="gamestatistics_value">-</span>
|
||||
</div>
|
||||
</div>
|
||||
<div id="gamesummarytext">
|
||||
<span id="gamesummarytext_label" class="line-clamp-4"></span>
|
||||
<p id="gamesummarytext_label_button_expand" class="text_link" style="display: none;" onclick="document.querySelector('#gamesummarytext_label').classList.remove('line-clamp-4'); document.querySelector('#gamesummarytext_label_button_expand').setAttribute('style', 'display: none;'); document.querySelector('#gamesummarytext_label_button_contract').setAttribute('style', '');">Read more...</p>
|
||||
@@ -256,6 +266,30 @@
|
||||
gamePublisherLabel.setAttribute('style', 'display: none;');
|
||||
}
|
||||
|
||||
// load statistics
|
||||
ajaxCall('/api/v1.1/Statistics/Games/' + gameId, 'GET', function (result) {
|
||||
var gameStat_lastPlayed = document.getElementById('gamestatistics_lastplayed_value');
|
||||
var gameStat_timePlayed = document.getElementById('gamestatistics_timeplayed_value');
|
||||
if (result) {
|
||||
// gameStat_lastPlayed.innerHTML = moment(result.sessionEnd).format("YYYY-MM-DD h:mm:ss a");
|
||||
const dateOptions = {
|
||||
//weekday: 'long',
|
||||
year: 'numeric',
|
||||
month: 'long',
|
||||
day: 'numeric'
|
||||
};
|
||||
gameStat_lastPlayed.innerHTML = new Date(result.sessionEnd).toLocaleDateString(undefined, dateOptions);
|
||||
if (result.sessionLength >= 60) {
|
||||
gameStat_timePlayed.innerHTML = Number(result.sessionLength / 60) + " hours";
|
||||
} else {
|
||||
gameStat_timePlayed.innerHTML = Number(result.sessionLength) + " minutes";
|
||||
}
|
||||
} else {
|
||||
gameStat_lastPlayed.innerHTML = '-';
|
||||
gameStat_timePlayed.innerHTML = '-';
|
||||
}
|
||||
});
|
||||
|
||||
// load release date
|
||||
var gameSummaryRelease = document.getElementById('gamesummary_firstrelease');
|
||||
if (result.firstReleaseDate) {
|
||||
|
||||
@@ -905,6 +905,31 @@ iframe {
|
||||
border-color: white;
|
||||
}
|
||||
|
||||
#gamestatistics {
|
||||
display: block;
|
||||
width: 100%;
|
||||
margin-bottom: 10px;
|
||||
background-color: rgba(56, 56, 56, 0.3);
|
||||
}
|
||||
|
||||
.gamestatistics_box {
|
||||
display: inline-block;
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.gamestatistics_label {
|
||||
display: block;
|
||||
font-weight: bold;
|
||||
font-size: 14px;
|
||||
text-transform: uppercase;
|
||||
padding: 3px;
|
||||
}
|
||||
|
||||
.gamestatistics_value {
|
||||
display: block;
|
||||
padding: 3px;
|
||||
}
|
||||
|
||||
#gamesummarytext_label {
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user