Skip to content

Instantly share code, notes, and snippets.

@fernandotakai
Created September 29, 2008 20:41
Show Gist options
  • Save fernandotakai/13668 to your computer and use it in GitHub Desktop.
Save fernandotakai/13668 to your computer and use it in GitHub Desktop.
var noun_type_trac_type = new CmdUtils.NounType( "Trac Type", ['defect', 'enhancement', 'task'])
CmdUtils.CreateCommand({
name:"tickets",
author: {name:"Fernando 'fern' Takai",email:"[email protected]"},
license:"MPL",
icon:"http://labs.toolness.com/trac/chrome/common/trac.ico",
takes: {'summary':noun_arb_text},
modifiers: {'keywords':noun_arb_text, 'type':noun_type_trac_type},
description: 'Queries Ubiquity Trac for tickets - w/o parameters, get the last 8 open tickets.',
preview: function(pblock ,summary, mods){
pblock.innerHTML = "<p>Getting the tickets...</p>"
var url = "http://ubiquity.mozilla.com/trac/query?status=%21closed&format=csv&desc=1&order=id&col=id&col=summary";
if(summary && summary.text.length > 0) url += "&summary=~" + summary.text
if(mods.type && mods.type.text && mods.type.text.length > 0) url += "&type=" + mods.type.text
jQuery.get(url, null, function(data){
pblock.innerHTML = "";
var template = "<span style='text-decoration:underline'><a href='http://ubiquity.mozilla.com/trac/ticket/${number}'>#${number}</a></span> ${title} <br />"
data = data.split("\n");
data = data.slice(1, data.length + 2);
var size = 0;
for each(var line in data){
var splitted = line.split(",");
if(size < 8 && splitted[1].length > 0 ){
if(splitted[1].length > 59){
splitted[1] = splitted[1].slice(0, 55) + "..."
}
pblock.innerHTML += CmdUtils.renderTemplate(template, {number:splitted[0], title:splitted[1]});
size++;
}
}
});
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment