Skip to content

Commit

Permalink
initial jiranator
Browse files Browse the repository at this point in the history
  • Loading branch information
robfe committed Jan 10, 2017
1 parent 42ee1ba commit 0c5c9fb
Show file tree
Hide file tree
Showing 4 changed files with 129 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node_modules
68 changes: 68 additions & 0 deletions docs/jiranator/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<!DOCTYPE html>
<html>

<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<link rel="stylesheet" href="styles.css">

</head>

<body>
<a class="bookmarklet" data-prefix="Drag this bookmarklet to the favourites bar, and then click the bookmarklet from a JIRA ticket page"
href="javascript:document.location = 'https://robfe.github.io/pages/jiranator/#'+encodeURIComponent(document.location.pathname.replace(/^.*\//, '')+' '+document.getElementById('summary-val').innerText)">JIRA Halper</a>
<br />
<h1>Options:</h1>
<label for="ticket">Branch Name:</label>
<input type="text" id="ticket" size="50" />
<h1>Git Scripts:</h1>
<h2>Checkout / Create branch:</h2>
<textarea>
if ! git checkout {ticket};
then
git checkout master;
git pull --rebase
git checkout -b {ticket};
fi
</textarea>

<h2>Checkout / Create branch With Stash:</h2>
<textarea>
git stash;
if ! git checkout {ticket};
then
git checkout master;
git pull --rebase
git checkout -b {ticket};
fi;
git stash pop;
</textarea>

<h1>Create PR</h1>
<a href="https://github.com/pushpay/pushpay/" data-href-placeholder="https://github.com/pushpay/pushpay/compare/{ticket}?expand=1">Once you've pushed the branch, click here to create the PR</a>


<h1>Other bookmarklets:</h1>
<a class="bookmarklet" data-prefix="Create a ticket from selected text on any page" href="javascript:
var text = window.getSelection().toString();
var p = {
pid:10000, /*project: PP*/
issuetype:1, /*1:bug,2:new feature,3:task*/
customfield_11000:'10200', /*production issue: no*/
priority:4,
summary: text,
description:`{code}\n${text}\n{code}\n\nfrom: ${document.location.toString()}`,
reporter:'rob.fonseca-ensor'
};
var ps = Object.keys(p).map(x=>`${x}=${encodeURIComponent(p[x])}`).join('&');
var url = 'https://pushpay.atlassian.net/secure/CreateIssueDetails!init.jspa?'+ps;
window.open(url);
">Create JIRA Bug<a>
<br />
<script src="script.js"></script>
</body>

</html>
38 changes: 38 additions & 0 deletions docs/jiranator/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
function UpdateTemplate() {
var s = decodeURIComponent(document.location.hash) || "???";
s = s.replace(/ /g, "-").replace(/^#/, "").replace(/[^\w-]/g, "");
document.title=s;

for (var i = 0, a = document.querySelectorAll("textarea"); i < a.length; i++) {
let p = a.item(i);
p.value = p.template.replace(/\{ticket\}/g, s);
}

for (var i = 0, a = document.querySelectorAll("[data-href-placeholder]"); i < a.length; i++) {
var p = a.item(i);
p.href = p.getAttribute("data-href-placeholder").replace(/\{ticket\}/g, s);
}
}

var textBox = document.getElementById("ticket");

textBox.value = decodeURIComponent(document.location.hash.replace(/^#/, ""));

textBox.addEventListener("input", function(e) {
document.location.hash = encodeURIComponent(e.target.value);
});

for (var i = 0, a = document.querySelectorAll("textarea"); i < a.length; i++) {
let p = a.item(i);
p.onclick = () => p.select();
p.template = p.value;
if(i == 0){
setTimeout(()=>{
p.focus();
p.select();
}, 50);
}
}

UpdateTemplate();
window.onhashchange = UpdateTemplate;
22 changes: 22 additions & 0 deletions docs/jiranator/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

body, h1,h2,h3{
font-family: "Segoe UI", Helvetica;
}

[data-prefix]:before{
content:attr(data-prefix) ': ';
}


textarea{
width: 100%;
box-sizing: border-box;
border: 2px solid #ccc;
min-height: 150px;
display:block;
background: #ddd;
border-radius: 3px;
padding: 7px;
transition:background 0.2s ease;

}

0 comments on commit 0c5c9fb

Please sign in to comment.