[missions] improved mission details, now including the mission's length (for non-hidden missions)

This commit is contained in:
fkloft
2015-04-14 15:48:58 +02:00
parent d881a5a6a9
commit 933843bd68
3 changed files with 46 additions and 10 deletions

View File

@ -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;