Redmine Ticket Link

Add link to current ticket.

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

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

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

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.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==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');
})();