Three Monkeys, Three Typewriters, Two Days

January 26, 2009

Making tinderbox nicer

I've finally gotten fed up with Tinderbox not doing what I want, and wrote a couple of bookmarklets to make it happier. I must say that the lack of an ID on the waterfall table is mightily annoying!

First, a bookmarklet to allow me to scroll the waterfall without scrolling the headers out of view:

javascript:var%20t%20=%20document.getElementsByTagName("table")[2];%20var%20b1%20=%20document.createElement("tbody");%20/*%20Header%20is%202%20rows%20*/%20b1.appendChild(t.rows[0]);%20b1.appendChild(t.rows[0]);%20var%20b2%20=%20t.tBodies[0];%20t.insertBefore(b1,%20b2);%20b1.id%20=%20"mytable";%20b2.style.height%20=%20(window.innerHeight%20-%20b1.getBoundingClientRect().height-%2025)%20+%20"px";%20b2.style.overflowY%20=%20"scroll";%20b2.style.overflowX%20=%20"hidden";%20location.hash="mytable";%20for%20(var%20node%20=%20b1.parentNode,%20parent%20=%20node.parentNode;%20parent;%20node%20=%20parent,%20parent%20=%20node.parentNode)%20{%20while%20(parent.firstChild%20&&%20parent.firstChild%20!=%20node)%20{%20parent.removeChild(parent.firstChild);%20}%20while%20(parent.lastChild%20&&%20parent.lastChild%20!=%20node)%20{%20parent.removeChild(parent.lastChild);%20}%20}%20document.body.style.margin%20=%20"0";%20document.body.style.padding%20=%20"0";%20void(0)

Second, a bookmarklet to restore the "C" links to the checkins between this build and the previous one for the hg tinderboxen:

javascript:var%20cellMap%20=%20{%20mMap:%20[],getRow:%20function(r)%20{%20if%20(!this.mMap[r])%20{%20this.mMap[r]%20=%20[];%20}%20return%20this.mMap[r];%20}%20};%20function%20buildCellMap()%20{%20var%20tbl%20=%20document.getElementsByTagName("table")[2];%20var%20rows%20=%20tbl.rows;%20for%20(var%20i%20=%200;%20i%20<%20rows.length;%20++i)%20{%20var%20row%20=%20rows[i];%20var%20cells%20=%20row.cells;%20for%20(var%20j%20=%200;%20j%20<%20cells.length;%20++j)%20{%20for%20(var%20k%20=%200;%20cellMap.getRow(i)[k];%20++k)%20/*%20just%20incrementing%20k%20*/;%20var%20cell%20=%20cells[j];%20var%20rowSpan%20=%20cell.rowSpan;%20for%20(var%20m%20=%200;%20m%20<%20rowSpan;%20++m)%20{%20cellMap.getRow(i%20+%20m)[k]%20=%20cell;%20}%20cell.colIndex%20=%20k;%20}%20}%20}%20function%20findNextCell(c)%20{%20if%20(!c)%20{%20return%20null;%20}%20var%20row%20=%20c.parentNode.rowIndex%20+%201;%20var%20col%20=%20c.colIndex;%20do%20{%20row++;%20}%20while%20(cellMap.getRow(row)[col]%20==%20c);%20return%20cellMap.getRow(row)[col];%20}%20function%20findRevFromCell(c)%20{%20if%20(!c)%20return%20"";%20var%20t%20=%20c.textContent;%20var%20r%20=%20t.match(/rev:([a-f0-9]*)/);%20if%20(r)%20{%20r%20=%20r[1];%20return%20r;%20}%20return%20"";%20}%20function%20findNextCellWithRev(c)%20{%20var%20next%20=%20findNextCell(c);%20if%20(!next)%20{%20return%20null;%20}%20if%20(findRevFromCell(next))%20{%20return%20next;%20}%20return%20findNextCellWithRev(next);%20}%20function%20setupTbox()%20{%20buildCellMap();%20var%20cells%20=%20document.getElementsByTagName("table")[2].getElementsByTagName("td");%20for%20(var%20i%20=%200;%20i%20<%20cells.length;%20++i)%20{%20var%20c%20=%20cells[i];%20var%20thisRev%20=%20findRevFromCell(c);%20if%20(!thisRev)%20{%20continue;%20}%20var%20prevRev%20=%20findRevFromCell(findNextCellWithRev(c));%20if%20(!prevRev)%20{%20continue;%20}%20var%20link%20=%20"http://hg.mozilla.org/mozilla-central/pushloghtml?fromchange="%20+%20prevRev%20+%20"&tochange="%20+%20thisRev;%20var%20a%20=%20document.createElement("a");%20a.textContent%20=%20"C";%20a.href%20=%20link;%20var%20prevSibling%20=%20c.getElementsByTagName("a")[0];%20prevSibling.parentNode.insertBefore(a,%20prevSibling.nextSibling);%20var%20space%20=%20document.createTextNode("%20");%20a.parentNode.insertBefore(space,%20a);%20}%20}%20setupTbox();%20void(0)

The source of the second bookmarklet is also available in "pretty" form if desired.

Posted by bzbarsky at 11:32 AM