Skip to content

Instantly share code, notes, and snippets.

@timaschew
Last active November 26, 2015 09:09
Show Gist options
  • Save timaschew/cea38c85fabe8f23bfa0 to your computer and use it in GitHub Desktop.
Save timaschew/cea38c85fabe8f23bfa0 to your computer and use it in GitHub Desktop.
JIRA JavaScript bookmarks
<a href="javascript:(function() {try {var parenttId = jQuery('#key-val').attr('rel');var answer1 = window.prompt('Choose number of subtask to move');if (answer1 == null) return;var sourcePosition = parseInt(answer1) - 1;var selectedSubTask = jQuery('#issuetable tr').eq(sourcePosition).find('td:nth-child(2)').text();var answer2 = window.prompt('To which position you want to move \'' + selectedSubTask + '\'?');if (answer2 == null) return;var targetPosition = parseInt(answer2) - 1;var url = window.location.origin + '/secure/MoveIssueLink.jspa?id=' + parenttId + '&currentSubTaskSequence=' + sourcePosition + '&subTaskSequence=' + targetPosition;jQuery.get(url).done(function() { console.log('moving subtask via bookmark was successfull'); window.location.reload(); }).fail(function() { alert('Operation failed, see browser console for more informations'); });} catch (err) {console.error(err);alert(err);}})();">Move subtasks</a>
<br>
<span>Just drag and drop this link to your bookmark bar</span>

open the page above as rendered HTML and drag and drop the link to save the bookmark

(function() {
	try {
		var parenttId = jQuery('#key-val').attr('rel');
		var answer1 = window.prompt('Choose number of subtask to move');
		if (answer1 == null) return;
		var sourcePosition = parseInt(answer1) - 1;
		var selectedSubTask = jQuery('#issuetable tr')
			.eq(sourcePosition)
			.find('td:nth-child(2)')
			.text();

		var answer2 = window.prompt('To which position you want to move \'' + selectedSubTask + '\'?');
		if (answer2 == null) return;
		var targetPosition = parseInt(answer2) - 1;
		var url = window.location.origin + '/secure/MoveIssueLink.jspa?id=' + parenttId + '&currentSubTaskSequence=' + sourcePosition + '&subTaskSequence=' + targetPosition;
		jQuery.get(url).done(function() {
	    	console.log('moving subtask via bookmark was successfull');
	    	window.location.reload();
	  	}).fail(function() {
	    	alert('Operation failed, see browser console for more informations');
	  	});
	} catch (err) {
		console.error(err);
		alert(err);
	}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment