]> granicus.if.org Git - transmission/commitdiff
(trunk web) #4438 "Add tooltip for peer status in web interface" -- patch by niol
authorJordan Lee <jordan@transmissionbt.com>
Wed, 24 Aug 2011 18:42:10 +0000 (18:42 +0000)
committerJordan Lee <jordan@transmissionbt.com>
Wed, 24 Aug 2011 18:42:10 +0000 (18:42 +0000)
web/javascript/formatter.js
web/javascript/transmission.js

index 4a28e992d3da2b1a51010f61ab5ffcb73b281dea..30bd221a6d4a574192b17372e5d579d0e630ab25 100644 (file)
@@ -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("<span title=\"" + flag + ': ' + explanation + "\">" + flag + "</span>"); 
+                               } 
+                       } 
+                       return formattedFlags.join(''); 
+               },
        }
 })();
index 0edad49f21a4e782828539847ccff5c7227a1838..c11e82803752df4a894f6cec69fab8e5761023fa 100644 (file)
@@ -1361,7 +1361,7 @@ Transmission.prototype =
                                                   '<td>', (peer.rateToPeer ? fmt.speedBps(peer.rateToPeer) : ''), '</td>',
                                                   '<td>', (peer.rateToClient ? fmt.speedBps(peer.rateToClient) : ''), '</td>',
                                                   '<td class="percentCol">', Math.floor(peer.progress*100), '%', '</td>',
-                                                  '<td>', peer.flagStr, '</td>',
+                                                  '<td>', fmt.peerStatus(peer.flagStr), '</td>',
                                                   '<td>', peer.address, '</td>',
                                                   '<td class="clientCol">', peer.clientName, '</td>',
                                                   '</tr>');