Skip to content

Commit e911316

Browse files
authored
initial
1 parent 4f0edf4 commit e911316

File tree

6 files changed

+113
-0
lines changed

6 files changed

+113
-0
lines changed

bootbox.min.js

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

icons/enzo-48.jpg

2.55 KB
Loading

icons/enzo-96.jpg

6.58 KB
Loading

jquery-3.3.1.slim.min.js

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

manifest.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
3+
"manifest_version": 2,
4+
"name": "Version Ninja",
5+
"version": "1.0",
6+
7+
"description": "Extends VersionOne to generate formatted (commit) message for a task.",
8+
9+
"icons": {
10+
"48": "icons/enzo-48.jpg",
11+
"96": "icons/enzo-96.jpg"
12+
},
13+
14+
"content_scripts": [{
15+
"matches": ["*://www52.v1host.com/*"],
16+
"js": ["jquery-3.3.1.slim.min.js", "version-ninja.js"]
17+
}],
18+
19+
"permissions": [
20+
"clipboardWrite"
21+
]
22+
23+
}

version-ninja.js

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
console.log(".~. begin .~.");
2+
3+
function getTaskCards() {
4+
return $("div.task-card-actions-container");
5+
}
6+
7+
function copy(message) {
8+
var $temp = $("<div>");
9+
$("body").append($temp);
10+
$temp.attr("contenteditable", true)
11+
.html(message).select()
12+
.on("focus", function() {
13+
document.execCommand('selectAll', false, null)
14+
})
15+
.focus();
16+
document.execCommand("copy");
17+
$temp.remove();
18+
}
19+
20+
function generateAndCopyMessage() {
21+
var taskId = $.trim($("div.toolbar>h2").text()).replace("Task ", "");
22+
var taskDesc = $("h1.title textarea").text();
23+
24+
var type;
25+
if ($("div.main-panel-scroller a[rel^='Story']").length > 0) {
26+
type = "Story";
27+
} else if ($("div.main-panel-scroller a[rel^='Defect']").length > 0) {
28+
type = "Defect";
29+
}
30+
var storyInternalId = $("div.main-panel-scroller a[rel^='" + type + "']")[0].rel;
31+
var storyId = $.trim($("tr[rowid='" + storyInternalId + "'] span.number").text());
32+
var storyDesc = $("div.main-panel-scroller a[rel^='" + type + "']>span").text();
33+
34+
var message = storyId + " [" + taskId + "] " + storyDesc + " [" + taskDesc + "] ...";
35+
copy(message);
36+
37+
// add notification here
38+
}
39+
40+
function handleButtonClick(event) {
41+
var button = $(event.target);
42+
var taskCard = button.parents("div.task-card:first");
43+
taskCard.find("a.open-by-name.asset-name-link:first")[0].click();
44+
45+
var nTimer = setInterval(function() {
46+
if ($("div.toolbar").length > 0) {
47+
clearInterval(nTimer);
48+
generateAndCopyMessage();
49+
}
50+
}, 300);
51+
}
52+
53+
function addCopyActionButton() {
54+
$("div.task-card").css("min-height", "5em");
55+
var taskActionsDivs = getTaskCards();
56+
taskActionsDivs.each(function(idx) {
57+
var button = $("<a></a>", {
58+
class: "task-card-actions version-ninja",
59+
text: "C",
60+
title: "Copy to clipboard as commit message"
61+
});
62+
button.click(handleButtonClick);
63+
button.appendTo($(this));
64+
});
65+
}
66+
67+
function main() {
68+
$("a.version-ninja").remove();
69+
addCopyActionButton();
70+
}
71+
72+
73+
$(function() {
74+
var nTimer = setInterval(function() {
75+
if (getTaskCards().length > 1) {
76+
clearInterval(nTimer);
77+
main();
78+
}
79+
}, 500);
80+
});
81+
82+
console.log("+#+ end +#+");

0 commit comments

Comments
 (0)