Skip to content

Instantly share code, notes, and snippets.

@danielpunkass
Created May 20, 2013 13:57
Show Gist options
  • Save danielpunkass/5612389 to your computer and use it in GitHub Desktop.
Save danielpunkass/5612389 to your computer and use it in GitHub Desktop.
Quick 5 ... bugmonkey code for adding an easy "Open first 5 tickets in background" button to FogBugz.
name: Quick 5
description: Add "Quick 5" shortcut link to the main UI to open up 5 tickets in separate windows
author: Daniel Jalkut
version: 1.0.0.0
js:
var xpath = function (xpath, context) {
var doc = window.document;
var result = doc.evaluate(xpath, context || doc, null, XPathResult.ANY_TYPE, null);
switch (result.resultType) {
case XPathResult.NUMBER_TYPE:
return result.numberValue;
case XPathResult.STRING_TYPE:
return result.stringValue;
case XPathResult.BOOLEAN_TYPE:
return result.booleanValue;
default:
var nodes = [];
var node;
while (node = result.iterateNext())
nodes.push(node);
return nodes;
}
};
$(document).ready(function() {
var quick5 = document.createElement("A");
quick5.innerText = "Quick 5";
quick5.className = "navlink"; // gives it same style/appearance as others
// Build up the function that will do the work
quick5.onclick = function () {
// we find the case links rather clumsily but this seems to work for now:
var caseLinks = xpath("//tr/td/div/nobr/span/a[@class!='person']")
var theCount = 5;
if (theCount > caseLinks.length) theCount = caseLinks.length;
for (var i=0; i < theCount; i++)
{
var newWindow = window.open(caseLinks[i].href, "_blank");
}
};
// Tack it in!
var mainNavDiv = xpath("//div[@id='mainnav']")[0];
mainNavDiv.appendChild(quick5);
});
@dougn
Copy link

dougn commented May 20, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment