Change the title, so that navigation can be done happily
authorBenjamin Smedberg <benjamin@smedbergs.us>
Tue, 25 Mar 2008 13:44:30 -0400
changeset 4 c2b8096ba5a270a1dc713c0f9263b385af4d77b4
parent 3 cfa5f1e9caaeadff4c9762f3fb0acc6859ab610b
child 5 1e12e9eb263f1d2278e08f4d9a3bc9a641d7c85e
push id1
push userbsmedberg@mozilla.com
push dateMon, 14 Apr 2008 15:21:26 +0000
Change the title, so that navigation can be done happily
www/navigate.js
--- a/www/navigate.js
+++ b/www/navigate.js
@@ -20,16 +20,28 @@ var rootContext;
 
 var revs = {};
 
 function short(node)
 {
     return node.slice(0, 12);
 }
 
+/**
+ * Limit a string to len characters... if it is too long, add an ellipsis.
+ */
+function limit(str, len)
+{
+    if (str.length < len) {
+        return str;
+    }
+
+    return str.slice(0, len) + "…";
+}
+
 function measure(r, prop)
 {
     return Number(r.css(prop).replace('px', ''));
 }
 
 /**
  * given an object that represents a revision, return
  * a <div> element cloned from revision-template.
@@ -157,16 +169,20 @@ function drawContext(data)
             revs[nodeid].parentArrows = {};
         }
     }
 
     var center = makeRev(data.context);
     center.css('left', (measure($('#inside-scrolling'), 'width') - REVWIDTH) / 2);
     center.css('top', 200 - measure(center, 'height') / 2);
 
+    document.title = $('#select-repo')[0].value + " revision " +
+        revs[data.context].rev + ": " +
+        limit(revs[data.context].description, 60);
+
     rootContext = data.context;
 
     drawRelations(data.context, 'parents', 2);
     drawRelations(data.context, 'children', 2);
 }
 
 function startContext(hash)
 {