Skip to content

Instantly share code, notes, and snippets.

@anthonyec
Last active September 4, 2018 08:30
Show Gist options
  • Save anthonyec/18f64e45e8be39f5459be4e16ebf1753 to your computer and use it in GitHub Desktop.
Save anthonyec/18f64e45e8be39f5459be4e16ebf1753 to your computer and use it in GitHub Desktop.
GWT Template Bookmarklet for JIRA
(function(){
console.log('Bookmarklet loaded');
var template = '*Outcome*\nGiven \nWhen \nThen \n\n*Todo*\n* \n\n*Dev notes*\n* ';
var $tab = document.querySelector('.menu-item[data-mode="source"]');
var $text = document.querySelector('#description-wiki-edit .textarea');
// There are 2 tabs, "Visual" and "Text". Click "Text" if it exists.
if ($tab && !$tab.classList.contains('active-tab')) {
$tab.querySelector('a').click();
}
if ($text && ($text.value.trim() === '' || $text.value === template)) {
$text.value = template;
$text.focus();
$text.setSelectionRange(16, 16);
$text.style.height = '232px';
setTimeout(function () {
$text.scrollTop = 0;
}, 10);
}
})();
{
"name": "MAKE A JIRA",
"description": "Insert a \"Given, When, Then\" template into the Jira ticket that is currently being created"
}
javascript:(function()%7Bjavascript%3A !function()%7Bvar e%3D"*Outcome*%5CnGiven %5CnWhen %5CnThen %5Cn%5Cn*Todo*%5Cn* %5Cn%5Cn*Dev notes*%5Cn* "%2Ct%3Ddocument.querySelector('.menu-item%5Bdata-mode%3D"source"%5D')%2Cn%3Ddocument.querySelector("%23description-wiki-edit .textarea")%3Bt%26%26!t.classList.contains("active-tab")%26%26t.querySelector("a").click()%2C!n%7C%7C""!%3D%3Dn.value.trim()%26%26n.value!%3D%3De%7C%7C(n.value%3De%2Cn.focus()%2Cn.setSelectionRange(16%2C16)%2Cn.style.height%3D"232px"%2CsetTimeout(function()%7Bn.scrollTop%3D0%7D%2C10))%7D()%7D)()
javascript: !function(){var e="*Outcome*\nGiven \nWhen \nThen \n\n*Todo*\n* \n\n*Dev notes*\n* ",t=document.querySelector('.menu-item[data-mode="source"]'),n=document.querySelector("#description-wiki-edit .textarea");t&&!t.classList.contains("active-tab")&&t.querySelector("a").click(),!n||""!==n.value.trim()&&n.value!==e||(n.value=e,n.focus(),n.setSelectionRange(16,16),n.style.height="232px",setTimeout(function(){n.scrollTop=0},10))}();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment