/**
 * @depends {nrs.js}
 */
var NRS = (function(NRS, $, undefined) {
	NRS.pages.peers = function() {
		NRS.sendRequest("getPeers+", function(response) {
			if (response.peers && response.peers.length) {
				var peers = {};
				var nrPeers = 0;

				for (var i = 0; i < response.peers.length; i++) {
					NRS.sendRequest("getPeer+", {
						"peer": response.peers[i]
					}, function(peer, input) {
						if (NRS.currentPage != "peers") {
							peers = {};
							return;
						}

						if (!peer.errorCode) {
							peers[input.peer] = peer;
						}

						nrPeers++;

						if (nrPeers == response.peers.length) {
							var rows = "";
							var uploaded = 0;
							var downloaded = 0;
							var connected = 0;
							var upToDate = 0;
							var activePeers = 0;

							for (var i = 0; i < nrPeers; i++) {
								var peer = peers[response.peers[i]];

								if (!peer) {
									continue;
								}

								if (peer.state != 0) {
									activePeers++;
									downloaded += peer.downloadedVolume;
									uploaded += peer.uploadedVolume;
									if (peer.state == 1) {
										connected++;
									}

									var versionToCompare = (!NRS.isTestNet ? NRS.normalVersion.versionNr : NRS.state.version);

									if (NRS.versionCompare(peer.version, versionToCompare) >= 0) {
										upToDate++;
									}

									rows += "<tr><td>" + (peer.state == 1 ? "<i class='fa fa-check-circle' style='color:#5cb85c' title='Connected'></i>" : "<i class='fa fa-times-circle' style='color:#f0ad4e' title='Disconnected'></i>") + "&nbsp;&nbsp;" + (peer.announcedAddress ? String(peer.announcedAddress).escapeHTML() : "No name") + "</td><td" + (peer.weight > 0 ? " style='font-weight:bold'" : "") + ">" + NRS.formatWeight(peer.weight) + "</td><td>" + NRS.formatVolume(peer.downloadedVolume) + "</td><td>" + NRS.formatVolume(peer.uploadedVolume) + "</td><td><span class='label label-" +
										(NRS.versionCompare(peer.version, versionToCompare) >= 0 ? "success" : "danger") + "'>" + (peer.application && peer.version ? String(peer.application).escapeHTML() + " " + String(peer.version).escapeHTML() : "?") + "</label></td><td>" + (peer.platform ? String(peer.platform).escapeHTML() : "?") + "</td></tr>";
								}
							}

							$("#peers_uploaded_volume").html(NRS.formatVolume(uploaded)).removeClass("loading_dots");
							$("#peers_downloaded_volume").html(NRS.formatVolume(downloaded)).removeClass("loading_dots");
							$("#peers_connected").html(connected).removeClass("loading_dots");
							$("#peers_up_to_date").html(upToDate + '/' + activePeers).removeClass("loading_dots");

							NRS.dataLoaded(rows);
						}
					});
				}
			} else {
				$("#peers_uploaded_volume, #peers_downloaded_volume, #peers_connected, #peers_up_to_date").html("0").removeClass("loading_dots");
				NRS.dataLoaded();
			}
		});
	}

	NRS.incoming.peers = function() {
		NRS.loadPage("peers");
	}

	return NRS;
}(NRS || {}, jQuery));
@@ -125,16 +125,43 @@
 Peers+%22,
+ %7B%0A%09%09%09%22active%22: %22true%22%0A%09%09%7D,
  functio
@@ -935,40 +935,8 @@
 %09%7D%0A%0A
-%09%09%09%09%09%09%09%09if (peer.state != 0) %7B%0A%09
 %09%09%09%09
@@ -950,25 +950,24 @@
 ivePeers++;%0A
-%09
 %09%09%09%09%09%09%09%09down
@@ -991,33 +991,32 @@
 wnloadedVolume;%0A
-%09
 %09%09%09%09%09%09%09%09uploaded
@@ -1044,25 +1044,24 @@
 me;%0A%09%09%09%09%09%09%09%09
-%09
 if (peer.sta
@@ -1080,17 +1080,16 @@
 %09%09%09%09%09%09%09%09
-%09
 connecte
@@ -1089,25 +1089,24 @@
 onnected++;%0A
-%09
 %09%09%09%09%09%09%09%09%7D%0A%0A%09
@@ -1108,25 +1108,24 @@
 %09%7D%0A%0A%09%09%09%09%09%09%09%09
-%09
 var versionT
@@ -1208,25 +1208,24 @@
 );%0A%0A%09%09%09%09%09%09%09%09
-%09
 if (NRS.vers
@@ -1271,25 +1271,24 @@
 re) %3E= 0) %7B%0A
-%09
 %09%09%09%09%09%09%09%09%09upT
@@ -1300,29 +1300,27 @@
 ++;%0A%09%09%09%09%09%09%09%09
-%09
 %7D%0A%0A
-%09
 %09%09%09%09%09%09%09%09rows
@@ -1881,17 +1881,16 @@
 %09%09%09%09%09%09%09%09
-%09
 (NRS.ver
@@ -2193,26 +2193,16 @@
 %3C/tr%3E%22;%0A
-%09%09%09%09%09%09%09%09%7D%0A
 %09%09%09%09%09%09%09%7D

Active peers optimization.