Skip to content

Commit

Permalink
non-working attempt at adding bug status to <a> title [issue #4]
Browse files Browse the repository at this point in the history
  • Loading branch information
LeoMcA committed Dec 20, 2014
1 parent d0a5b11 commit 8d34b05
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions assets/js/bugzilla-linker.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,25 @@ Discourse.Dialect.inlineRegexp({
return ['a', {href: Discourse.SiteSettings.bugzilla_url + '/show_bug.cgi?id=' + number}, bug];
}
});

var regex = /^bug (\d+)$/;

Discourse.Dialect.on("parseNode", function(event) {
var node = event.node;
var path = event.path;

// We only care about links
if (node[0] !== 'a') return;

match = regex.exec(node[2]);

if (match == null) return;

node[1].title = "not what I want"

Discourse.ajax({
url: Discourse.SiteSettings.bugzilla_url + '/rest/bug/' + match[1] + '?include_fields=assigned_to,status,summary'
}).then(function(data) {
node[1].title = data.bugs[0].status + ', ' + data.bugs[0].assigned_to + ' - ' + data.bugs[0].summary;
});
});

0 comments on commit 8d34b05

Please sign in to comment.