Navigate Jira Issues on Swimlanes with y & n

Navigate between open issues on the Jira current sprint with y (up) and n (down). Add shift to jump to first or last.

目前為 2018-02-07 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Navigate Jira Issues on Swimlanes with y & n
// @namespace    http://tedmor.in/
// @version      0.1
// @description  Navigate between open issues on the Jira current sprint with y (up) and n (down). Add shift to jump to first or last.
// @require https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js
// @author       Ted Morin
// @match        https://*.atlassian.net/secure/*
// @grant        none
// ==/UserScript==
// jshint asi:true

(function() {
    'use strict';
    let issueNumber = 0
    /* Open issues */
    function openIssues() {
        return $('.ghx-swimlane .ghx-swimlane-header') // Get all headers
            .filter((i, el) => !$(el).hasClass('ghx-done')) // Filter out the closed ones
            .map((i, el) => $(el).parent())
    }
    /* Return the open issue at given index */
    function issueAt(index) {
        return openIssues()[index] // Return the parent, which is the actual swimlane element
    }
    /* Scroll to an issue by index */
    function scrollToIssue(index) {
        console.log('Scrolling to', index)
        $('#ghx-pool').animate({scrollTop: issueAt(index).offset().top - $('.ghx-first').offset().top}, 200)
    }
    $(document).keypress(function(e) {
        switch (e.which) {
            case 110: // n
                if (issueAt(issueNumber + 1)) {
                    issueNumber += 1
                    scrollToIssue(issueNumber)
                }
                break;
            case 78: // N
                issueNumber = openIssues().length - 1
                break;
            case 121: // y
                if (issueAt(issueNumber - 1)) {
                    issueNumber -= 1
                }
                break;
            case 89: // Y
                issueNumber = 0
                break;
        }
        scrollToIssue(issueNumber)
    })
})();