[missions] improved mission details, now including the mission's length (for non-hidden missions)
This commit is contained in:
BIN
images/mission-length.png
Normal file
BIN
images/mission-length.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 109 B |
@ -47,7 +47,9 @@
|
||||
|
||||
.plugin-mission-summary > .nickname {
|
||||
display: inline-block;
|
||||
box-sizing: border-box;
|
||||
min-width: 8em; /* to align with time */
|
||||
padding-right: 0.2em;
|
||||
}
|
||||
|
||||
.plugin-mission-info .portal-distance-bearing {
|
||||
@ -59,6 +61,8 @@
|
||||
.plugin-mission-info {
|
||||
display: inline-block;
|
||||
}
|
||||
.plugin-mission-info.length { min-width: 6em; }
|
||||
.plugin-mission-info.distance { min-width: 6em; }
|
||||
.plugin-mission-info.time { min-width: 8em; }
|
||||
.plugin-mission-info.rating { min-width: 6em; }
|
||||
.plugin-mission-info.players { min-width: 4em; }
|
||||
@ -69,6 +73,9 @@
|
||||
margin-right: 8px;
|
||||
vertical-align: top;
|
||||
}
|
||||
.plugin-mission-info.players img {
|
||||
padding: 0 3px; /* the icon is 12x18 */
|
||||
}
|
||||
|
||||
.plugin-mission-details .plugin-mission-summary > a,
|
||||
.plugin-mission-details .plugin-mission-summary .description {
|
||||
|
@ -321,6 +321,32 @@ window.plugin.missions = {
|
||||
span.className = 'nickname ' + (cachedMission.authorTeam === 'R' ? 'res' : 'enl')
|
||||
span.textContent = cachedMission.authorNickname;
|
||||
|
||||
var len = cachedMission.waypoints.filter(function(waypoint) {
|
||||
return !!waypoint.portal;
|
||||
}).map(function(waypoint) {
|
||||
return L.latLng(waypoint.portal.latE6/1E6, waypoint.portal.lngE6/1E6);
|
||||
}).map(function(latlng1, i, latlngs) {
|
||||
if(i == 0) return 0;
|
||||
var latlng2 = latlngs[i - 1];
|
||||
return latlng1.distanceTo(latlng2);
|
||||
}).reduce(function(a, b) {
|
||||
return a + b;
|
||||
});
|
||||
|
||||
if(len > 0) {
|
||||
if(len > 1000)
|
||||
len = Math.round(len / 100) / 10 + "km";
|
||||
else
|
||||
len = Math.round(len * 10) / 10 + "m";
|
||||
|
||||
var infoLength = container.appendChild(document.createElement('span'));
|
||||
infoLength.className = 'plugin-mission-info length help';
|
||||
infoLength.title = 'Length of this mission.\n\nNOTE: The actual distance required to cover may vary depending on several factors!';
|
||||
infoLength.textContent = len;
|
||||
img = infoLength.insertBefore(document.createElement('img'), infoLength.firstChild);
|
||||
img.src = '@@INCLUDEIMAGE:images/mission-length.png@@';
|
||||
}
|
||||
|
||||
if(window.plugin.distanceToPortal && window.plugin.distanceToPortal.currentLoc) {
|
||||
var infoDistance = container.appendChild(document.createElement('span'));
|
||||
infoDistance.className = 'plugin-mission-info distance help';
|
||||
@ -335,31 +361,34 @@ window.plugin.missions = {
|
||||
container.appendChild(document.createElement('br'));
|
||||
|
||||
var infoTime = container.appendChild(document.createElement('span'));
|
||||
infoTime.className = 'plugin-mission-info time';
|
||||
infoTime.className = 'plugin-mission-info time help';
|
||||
infoTime.title = 'Typical duration';
|
||||
infoTime.textContent = timeToRemaining((mission.medianCompletionTimeMs / 1000) | 0) + ' ';
|
||||
img = infoTime.insertBefore(document.createElement('img'), infoTime.firstChild);
|
||||
img.src = 'https://commondatastorage.googleapis.com/ingress.com/img/tm_icons/time.png';
|
||||
|
||||
var infoRating = container.appendChild(document.createElement('span'));
|
||||
infoRating.className = 'plugin-mission-info rating';
|
||||
infoRating.className = 'plugin-mission-info rating help';
|
||||
infoRating.title = 'Average rating';
|
||||
infoRating.textContent = (((mission.ratingE6 / 100) | 0) / 100) + '%' + ' ';
|
||||
img = infoRating.insertBefore(document.createElement('img'), infoRating.firstChild);
|
||||
img.src = 'https://commondatastorage.googleapis.com/ingress.com/img/tm_icons/like.png';
|
||||
|
||||
if (cachedMission) {
|
||||
var infoPlayers = container.appendChild(document.createElement('span'));
|
||||
infoPlayers.className = 'plugin-mission-info players';
|
||||
infoPlayers.className = 'plugin-mission-info players help';
|
||||
infoPlayers.title = 'Unique players who have completed this mission';
|
||||
infoPlayers.textContent = cachedMission.numUniqueCompletedPlayers + ' ';
|
||||
img = infoPlayers.insertBefore(document.createElement('img'), infoPlayers.firstChild);
|
||||
img.src = 'https://commondatastorage.googleapis.com/ingress.com/img/tm_icons/players.png';
|
||||
|
||||
var infoWaypoints = container.appendChild(document.createElement('span'));
|
||||
infoWaypoints.className = 'plugin-mission-info waypoints';
|
||||
infoWaypoints.className = 'plugin-mission-info waypoints help';
|
||||
infoWaypoints.title = (cachedMission.type ? cachedMission.type + ' mission' : 'Unknown mission type')
|
||||
+ ' with ' + cachedMission.waypoints.length + ' waypoints';
|
||||
infoWaypoints.textContent = cachedMission.waypoints.length + ' ';
|
||||
img = infoWaypoints.insertBefore(document.createElement('img'), infoWaypoints.firstChild);
|
||||
img.src = this.missionTypeImages[cachedMission.typeNum] || this.missionTypeImages[0];
|
||||
img.title = cachedMission.type || 'Unknown mission type';
|
||||
img.className = 'help';
|
||||
}
|
||||
|
||||
return container;
|
||||
|
Reference in New Issue
Block a user