Refresh Button for Dashboard

Adds button that reloads all widgets on a dashboard.

Bu betiği kurabilmeniz için Tampermonkey, Greasemonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu betiği kurabilmeniz için Tampermonkey ya da Violentmonkey gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

Bu betiği kurabilmeniz için Tampermonkey ya da Userscripts gibi bir kullanıcı betiği eklentisini kurmanız gerekmektedir.

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

Bu komut dosyasını yüklemek için bir kullanıcı komut dosyası yöneticisi uzantısı yüklemeniz gerekecek.

(Zaten bir kullanıcı komut dosyası yöneticim var, kurmama izin verin!)

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.

(Zateb bir user-style yöneticim var, yükleyeyim!)

// ==UserScript==
// @name         Refresh Button for Dashboard
// @author       Qteb
// @match        https://*.myjetbrains.com/youtrack/dashboard*
// @description  Adds button that reloads all widgets on a dashboard.
// @version 0.0.1.20170302134951
// @namespace https://greasyfork.org/users/106502
// ==/UserScript==

function refreshWidgets() {
    console.log('Updating...');
    $('div[react-value-glyph="#refresh"]').each( function() {
        $(this).click();
    });
}

(function() {
    'use strict';

    var vis = (function(){
        var stateKey, eventKey, keys = {
            hidden: "visibilitychange",
            webkitHidden: "webkitvisibilitychange",
            mozHidden: "mozvisibilitychange",
            msHidden: "msvisibilitychange"
        };
        for (stateKey in keys) {
            if (stateKey in document) {
                eventKey = keys[stateKey];
                break;
            }
        }
        return function(c) {
            if (c) document.addEventListener(eventKey, c);
            return !document[stateKey];
        };
    })();

    vis(function(){
        if(vis()) {
            refreshWidgets();
        }
    });

    // add refresh button
    setTimeout(function () {
        // while button does not exists
        while ($('.ring-button__content:contains("Reload All")').text().length === 0) {
            $('.dashboard-page__toolbar-buttons')
                .prepend($('<button>').addClass("ring-button ring-button_default reloadAll")
                         .prepend($('<span>').addClass("ring-button__content")
                                  .prepend($('<span>').text('Reload All'))));
        }
        // click refresh button action
        $('.ring-button__content:contains("Reload All")').click(function () {
            refreshWidgets();
        });
    }, 1000);
})();