Created
February 17, 2017 21:22
-
-
Save findepi/3954f82d72b9c95285be9af43bc93f35 to your computer and use it in GitHub Desktop.
JIRA 'w' keyboard shortcut for watch/unwatch issue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Jira | |
// @namespace http://students.mimuw.edu.pl/~findepi | |
// @version 1 | |
// @include http://match-nothing.example.com | |
// @grant none | |
// ==/UserScript== | |
jQuery(function($) { | |
var log = ((window.console && typeof window.console.log == "function") | |
? window.console.log : function() {}) | |
// disable log | |
log = function() {} | |
log("Jira improvements are being installed") | |
// Bind 'w' as 'watch' | |
$(document).keydown(function(e) { | |
if (e.which != 'W'.charCodeAt(0)) { | |
// Not 'w', ignore | |
//log(["not 'w'", e.which]) | |
return | |
} | |
// log("it's w") | |
if (e.altKey || e.shiftKey || e.ctrlKey || e.metaKey) { | |
// 'w' pressed with modifier, ignore | |
//log("'w' with modifier") | |
return | |
} | |
if ($(e.target).is("input, textarea, select")) { | |
// pressed inside input, textarea, select; ignore | |
return | |
} | |
log(["'w' pressed", e]) | |
var wButt = $('#watching-toggle') | |
, nowWatching = wButt.is('.watch-state-off') | |
wButt.click() | |
.parent().parent() | |
.css({outline: '5px solid orange'}) | |
.animate({outlineWidth: 0}, 'fast') | |
$('.watching-notif').remove() | |
$('<span/>').text(nowWatching ? 'Watching' : 'Not watching') | |
.addClass('watching-notif') | |
.prependTo(document.body) | |
.css({ | |
position: 'fixed', 'top': 5, 'right': 5, zIndex: 100000 | |
, background: (nowWatching ? '#CDEB8B' : '#faa') | |
, border: '2px solid black' | |
, borderRadius: '5px' | |
, boxShadow: '0 0 15px 0px #ccc' | |
, padding: '10px' | |
, fontSize: '15px' | |
, fontWeight: 'bold' | |
, display: 'none' | |
}).fadeIn('fast') | |
.delay(2000) | |
.fadeOut('slow') | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment