From 2da83079f99952b0491e17c38b3a7bc21633365b Mon Sep 17 00:00:00 2001 From: Jordan Lee Date: Wed, 24 Aug 2011 18:42:10 +0000 Subject: [PATCH] (trunk web) #4438 "Add tooltip for peer status in web interface" -- patch by niol --- web/javascript/formatter.js | 33 ++++++++++++++++++++++++++++++++- web/javascript/transmission.js | 2 +- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/web/javascript/formatter.js b/web/javascript/formatter.js index 4a28e992d..30bd221a6 100644 --- a/web/javascript/formatter.js +++ b/web/javascript/formatter.js @@ -269,6 +269,37 @@ Transmission.fmt = (function() plural: function(i, word) { return [ i, ' ', word, (word==1?'':'s') ].join(''); - } + }, + + peerStatus: function( flagStr ) + { + var formattedFlags = []; + for (var i=0, flag; flag=flagStr[i]; ++i) + { + var explanation = null; + switch (flag) + { + case "O": explanation = "Optimistic unchoke"; break; + case "D": explanation = "Downloading from this peer"; break; + case "d": explanation = "We would download from this peer if they'd let us"; break; + case "U": explanation = "Uploading to peer"; break; + case "u": explanation = "We would upload to this peer if they'd ask"; break; + case "K": explanation = "Peer has unchoked us, but we're not interested"; break; + case "?": explanation = "We unchoked this peer, but they're not interested"; break; + case "E": explanation = "Encrypted Connection"; break; + case "H": explanation = "Peer was discovered through Distributed Hash Table (DHT)"; break; + case "X": explanation = "Peer was discovered through Peer Exchange (PEX)"; break; + case "I": explanation = "Peer is an incoming connection"; break; + case "T": explanation = "Peer is connected via uTP"; break; + } + + if( explanation == null ) { + formattedFlags.push(flag); + } else { + formattedFlags.push("" + flag + ""); + } + } + return formattedFlags.join(''); + }, } })(); diff --git a/web/javascript/transmission.js b/web/javascript/transmission.js index 0edad49f2..c11e82803 100644 --- a/web/javascript/transmission.js +++ b/web/javascript/transmission.js @@ -1361,7 +1361,7 @@ Transmission.prototype = '', (peer.rateToPeer ? fmt.speedBps(peer.rateToPeer) : ''), '', '', (peer.rateToClient ? fmt.speedBps(peer.rateToClient) : ''), '', '', Math.floor(peer.progress*100), '%', '', - '', peer.flagStr, '', + '', fmt.peerStatus(peer.flagStr), '', '', peer.address, '', '', peer.clientName, '', ''); -- 2.40.0