Redmine Ticket Link

Add link to current ticket.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name           Redmine Ticket Link
// @description:en Add link to current ticket.
// @version        0.2
// @namespace      http://twitter.com/foldrr/
// @require        https://code.jquery.com/jquery-1.11.3.min.js
// @require        https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/1.5.3/clipboard.min.js
// @match          http://*/redmine/issues/*
// @description Add link to current ticket.
// ==/UserScript==

(function(){
    var issue_id = (location.href.match(/issues\/(\d+)/) || [])[1];
    if(! issue_id) return;
    
    var issue_title = $('.subject h3').text();
    
    create_link = function(css_class, text, link){
        $('<button/>', {
            'text': text,
            'style': 'margin-left: 20px',
            'class': css_class,
            'data-clipboard-text': link
        }).appendTo("h2");
    };
    
    create_link('copy-button', 'URL', location.href);
    create_link('copy-button', 'Markdown', '[#' + issue_id + " " + issue_title + "](" + location.href + ")");
    new Clipboard('.copy-button');
})();