Created
May 20, 2013 13:57
-
-
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
}); | |
Fixed version that deals with read and unread cases:
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Working on an updated version that will load all cases that are selected. FogBugz uses jquery which simplifies the xpath stuff greatly. Here is the 1 liner to get all links for cases that are selected, assuming the 'id' column is in the filter:
$('td[style="background-color: rgb(253, 253, 212);"] div nobr span a.uvb:not(.title)')
Will ignore person, estimate, and other links, including title links, and will only list those that are selected. If you remove the '[style=...]' then is will list them all.