<commit_before>// ==UserScript==
// @name         Pivotal Tracker Enhanced
// @namespace    https://www.pivotaltracker.com/
// @version      0.57
// @description  Pivotal Tracker enhanced for Omnimed
// @author       Omnimed
// @match        https://www.pivotaltracker.com/*
// @grant        unsafeWindow
// ==/UserScript==

var $ = jQuery;
var analyseTemplate;
var bugTemplate;
var choreTemplate;
var featureTemplate;
var countStory = 0;
var countChore = 0;
var countBug = 0;
var releaseName;
var sumStory = 0;
var sumChore = 0;
var sumBug = 0;
var sumTotal = 0;
var inApiCall = false;

function capitalizeFirstLetter(string) {
    return string.charAt(0).toUpperCase() + string.slice(1);
}

$(function() {
    $("head").append("<style id='omnimedStyles' type='text/css'>\n"
        + ".devopsIcon{ background-image:url(https://raw.githubusercontent.com/Omnimed/Omnimed-utilitiesScript/master/TamperMonkey/image/devops.png) !important;}"
        + ".analyseIcon{ background-image:url(https://raw.githubusercontent.com/Omnimed/Omnimed-utilitiesScript/master/TamperMonkey/image/analyse.png) !important;}"
        + ".shadowIcon{ background-image:url(https://raw.githubusercontent.com/Omnimed/Omnimed-utilitiesScript/master/TamperMonkey/image/shadow.png) !important;}"
        + ".onAirIcon{ background-image:url(https://raw.githubusercontent.com/Omnimed/Omnimed-utilitiesScript/master/TamperMonkey/image/onair.png) !important;}"
        + ".invalidStory .preview { background-color: #fb9595 !important;}"
        + ".labelNeed { background-color: #4d5258 !important; color: white !important; border-radius: 5px ; padding: 0px 5px 0px 5px; margin-right: 2px; }"
        + ".labelMustHave { background-color: #cc0000 !important; color: white !important; border-radius: 5px ; padding: 0px 5px 0px 5px; margin-right: 2px; }"
        + ".labelShouldHave { background-color: #f0ab00 !important; color: white !important; border-radius: 5px ; padding: 0px 5px 0px 5px; margin-right: 2px;}"
        + ".labelCouldHave { background-color: #0088ce !important; color: white !important; border-radius: 5px ; padding: 0px 5px 0px 5px; margin-right: 2px; }"
        + ".labelFeatureBranch { background-color: #000000!important; color: white !important; border-radius: 10px ; padding: 0px 5px 0px 5px; margin-right: 2px; }"
        + "\n</style>")
});

function updateIcons() {
    $('.feature .labels:has(a:contains("onair"))').parentsUntil('.story').find('span.StoryPreviewItem__storyType___sBjDnL7T').addClass('onAirIcon')
    $('.feature .labels:has(a:contains("devops"))').parentsUntil('.story').find('span.StoryPreviewItem__storyType___sBjDnL7T').addClass('devopsIcon');
    $('.feature .labels:has(a:contains("analyse"))').parentsUntil('.story').find('span.StoryPreviewItem__storyType___sBjDnL7T').addClass('analyseIcon');
    $('.feature .labels:has(a:contains("shadow"))').parentsUntil('.story').find('span.StoryPreviewItem__storyType___sBjDnL7T').addClass('shadowIcon');
}

function updateFlyoverIcons() {
    $('.flyover.visible').find("a:contains('onair')").parent().parent().children('.meta').addClass( "onAirIcon" );
    $('.flyover.visible').find("a:contains('devops')").parent().parent().children('.meta').addClass( "devopsIcon" );
    $('.flyover.visible').find("a:contains('analyse')").parent().parent().children('.meta').addClass( "analyseIcon" );
    $('.flyover.visible').find("a:contains('shadow')").parent().parent().children('.meta').addClass( "shadowIcon" );
    highlightLabels();
}

function validateStories() {
    /* Validate that all stories have a release tag */
    var firstId;
    var secondId;
    var releaseName;
    var response;
    var xhr = new XMLHttpRequest();

    if (!inApiCall) {
        inApiCall = true;
        $.ajax ( {
            type:       'GET',
            url:        'https://www.pivotaltracker.com/services/v5/projects/605365/releases?limit=1&with_state=accepted&offset=-1',
            dataType:   'JSON',
            success:    function (response) {
                firstId = response[0].id;
                $.ajax ( {
                    type:       'GET',
                    url:        'https://www.pivotaltracker.com/services/v5/projects/605365/releases?with_state=planned',
                    dataType:   'JSON',
                    success:    function (response) {
                        for (var i = 0; i < response.length; i++) {
                            secondId = response[i].id;
                            releaseName = response[i].name.substring(0, response[i].name.lastIndexOf(" ")).toLowerCase();
                            $.ajax ( {
                                type:       'GET',
                                url:        'https://www.pivotaltracker.com/services/v5/projects/605365/stories?after_story_id=' + firstId + '&before_story_id=' + secondId + '&limit=10000',
                                dataType:   'JSON',
                                releaseName: releaseName,
                                success:    function (response) {
                                    applyStoriesValidation(response, this.releaseName);
                                }
                            } );
                            firstId = secondId;
                        }
                        $.ajax ( {
                            type:       'GET',
                            url:        'https://www.pivotaltracker.com/services/v5/projects/605365/releases?with_state=unstarted',
                            dataType:   'JSON',
                            success:    function (response) {
                                for (var i = 0; i < response.length; i++) {
                                    secondId = response[i].id;
                                    releaseName = response[i].name.substring(0, response[i].name.lastIndexOf(" ")).toLowerCase();
                                    $.ajax ( {
                                        type:       'GET',
                                        url:        'https://www.pivotaltracker.com/services/v5/projects/605365/stories?after_story_id=' + firstId + '&before_story_id=' + secondId + '&limit=10000',
                                        dataType:   'JSON',
                                        releaseName: releaseName,
                                        success:    function (response) {
                                            applyStoriesValidation(response, this.releaseName);
                                        }
                                    } );
                                    firstId = secondId;
                                }
                            }
                        } );
                    }
                } );
            }
        } );
        inApiCall = false;
    }
}

function highlightLabels() {
    $("a.label:contains('needs')").addClass('labelNeed');
    $("a.label:contains('besoin')").addClass('labelNeed');
    $("a.label:contains('should have')").addClass('labelShouldHave');
    $("a.label:contains('must have')").addClass('labelMustHave');
    $("a.label:contains('could have')").addClass('labelCouldHave');
    $("a.label:contains('feature-')").addClass('labelFeatureBranch');
}


$( document ).bind("ajaxSuccess",function(event, xhr, settings) {
    if (xhr.responseJSON && xhr.responseJSON.data && (xhr.responseJSON.data.kind === "layout_scheme" || xhr.responseJSON.data.kind === "command_create_response" || (xhr.responseJSON.data.kind === "message" && xhr.responseJSON.data.text === "Subscribed to push changes")) ) {
        $('.selector').unbind("click");
        $('.selector').bind("click", function(){
            setTimeout(function() {
                update_bug();
                update_chore();
                update_feature();
                update_output();
                highlightLabels();
            }, 100);
        });setTimeout(function() {
            updateFlyoverIcons();
        }, 1100);
        $('.expander.undraggable').unbind("click");
        $('.expander.undraggable').bind("click", function(){
            setTimeout(function() {
                $('.autosaves.collapser').unbind("click");
                $('.autosaves.collapser').bind("click", function(){
                    setTimeout(function() {
                        updateIcons();
                        $('.autosaves.collapser').unbind("click");
                    }, 100);
                });
            }, 100);
        });<commit_msg>Ajout NiceToHave au TM PivotalTracker.js<commit_after>// ==UserScript==
// @name         Pivotal Tracker Enhanced
// @namespace    https://www.pivotaltracker.com/
// @version      0.58
// @description  Pivotal Tracker enhanced for Omnimed
// @author       Omnimed
// @match        https://www.pivotaltracker.com/*
// @grant        unsafeWindow
// ==/UserScript==

var $ = jQuery;
var analyseTemplate;
var bugTemplate;
var choreTemplate;
var featureTemplate;
var countStory = 0;
var countChore = 0;
var countBug = 0;
var releaseName;
var sumStory = 0;
var sumChore = 0;
var sumBug = 0;
var sumTotal = 0;
var inApiCall = false;

function capitalizeFirstLetter(string) {
    return string.charAt(0).toUpperCase() + string.slice(1);
}

$(function() {
    $("head").append("<style id='omnimedStyles' type='text/css'>\n"
        + ".devopsIcon{ background-image:url(https://raw.githubusercontent.com/Omnimed/Omnimed-utilitiesScript/master/TamperMonkey/image/devops.png) !important;}"
        + ".analyseIcon{ background-image:url(https://raw.githubusercontent.com/Omnimed/Omnimed-utilitiesScript/master/TamperMonkey/image/analyse.png) !important;}"
        + ".shadowIcon{ background-image:url(https://raw.githubusercontent.com/Omnimed/Omnimed-utilitiesScript/master/TamperMonkey/image/shadow.png) !important;}"
        + ".onAirIcon{ background-image:url(https://raw.githubusercontent.com/Omnimed/Omnimed-utilitiesScript/master/TamperMonkey/image/onair.png) !important;}"
        + ".invalidStory .preview { background-color: #fb9595 !important;}"
        + ".labelNeed { background-color: #4d5258 !important; color: white !important; border-radius: 5px ; padding: 0px 5px 0px 5px; margin-right: 2px; }"
        + ".labelMustHave { background-color: #cc0000 !important; color: white !important; border-radius: 5px ; padding: 0px 5px 0px 5px; margin-right: 2px; }"
        + ".labelShouldHave { background-color: #f0ab00 !important; color: white !important; border-radius: 5px ; padding: 0px 5px 0px 5px; margin-right: 2px;}"
        + ".labelNiceToHave { background-color: #e1d414 !important; color: white !important; border-radius: 5px ; padding: 0px 5px 0px 5px; margin-right: 2px; }"
        + ".labelCouldHave { background-color: #0088ce !important; color: white !important; border-radius: 5px ; padding: 0px 5px 0px 5px; margin-right: 2px; }"
        + ".labelFeatureBranch { background-color: #000000!important; color: white !important; border-radius: 10px ; padding: 0px 5px 0px 5px; margin-right: 2px; }"
        + "\n</style>")
});

function updateIcons() {
    $('.feature .labels:has(a:contains("onair"))').parentsUntil('.story').find('span.StoryPreviewItem__storyType___sBjDnL7T').addClass('onAirIcon')
    $('.feature .labels:has(a:contains("devops"))').parentsUntil('.story').find('span.StoryPreviewItem__storyType___sBjDnL7T').addClass('devopsIcon');
    $('.feature .labels:has(a:contains("analyse"))').parentsUntil('.story').find('span.StoryPreviewItem__storyType___sBjDnL7T').addClass('analyseIcon');
    $('.feature .labels:has(a:contains("shadow"))').parentsUntil('.story').find('span.StoryPreviewItem__storyType___sBjDnL7T').addClass('shadowIcon');
}

function updateFlyoverIcons() {
    $('.flyover.visible').find("a:contains('onair')").parent().parent().children('.meta').addClass( "onAirIcon" );
    $('.flyover.visible').find("a:contains('devops')").parent().parent().children('.meta').addClass( "devopsIcon" );
    $('.flyover.visible').find("a:contains('analyse')").parent().parent().children('.meta').addClass( "analyseIcon" );
    $('.flyover.visible').find("a:contains('shadow')").parent().parent().children('.meta').addClass( "shadowIcon" );
    highlightLabels();
}

function validateStories() {
    /* Validate that all stories have a release tag */
    var firstId;
    var secondId;
    var releaseName;
    var response;
    var xhr = new XMLHttpRequest();

    if (!inApiCall) {
        inApiCall = true;
        $.ajax ( {
            type:       'GET',
            url:        'https://www.pivotaltracker.com/services/v5/projects/605365/releases?limit=1&with_state=accepted&offset=-1',
            dataType:   'JSON',
            success:    function (response) {
                firstId = response[0].id;
                $.ajax ( {
                    type:       'GET',
                    url:        'https://www.pivotaltracker.com/services/v5/projects/605365/releases?with_state=planned',
                    dataType:   'JSON',
                    success:    function (response) {
                        for (var i = 0; i < response.length; i++) {
                            secondId = response[i].id;
                            releaseName = response[i].name.substring(0, response[i].name.lastIndexOf(" ")).toLowerCase();
                            $.ajax ( {
                                type:       'GET',
                                url:        'https://www.pivotaltracker.com/services/v5/projects/605365/stories?after_story_id=' + firstId + '&before_story_id=' + secondId + '&limit=10000',
                                dataType:   'JSON',
                                releaseName: releaseName,
                                success:    function (response) {
                                    applyStoriesValidation(response, this.releaseName);
                                }
                            } );
                            firstId = secondId;
                        }
                        $.ajax ( {
                            type:       'GET',
                            url:        'https://www.pivotaltracker.com/services/v5/projects/605365/releases?with_state=unstarted',
                            dataType:   'JSON',
                            success:    function (response) {
                                for (var i = 0; i < response.length; i++) {
                                    secondId = response[i].id;
                                    releaseName = response[i].name.substring(0, response[i].name.lastIndexOf(" ")).toLowerCase();
                                    $.ajax ( {
                                        type:       'GET',
                                        url:        'https://www.pivotaltracker.com/services/v5/projects/605365/stories?after_story_id=' + firstId + '&before_story_id=' + secondId + '&limit=10000',
                                        dataType:   'JSON',
                                        releaseName: releaseName,
                                        success:    function (response) {
                                            applyStoriesValidation(response, this.releaseName);
                                        }
                                    } );
                                    firstId = secondId;
                                }
                            }
                        } );
                    }
                } );
            }
        } );
        inApiCall = false;
    }
}

function highlightLabels() {
    $("a.label:contains('needs')").addClass('labelNeed');
    $("a.label:contains('besoin')").addClass('labelNeed');
    $("a.label:contains('should have')").addClass('labelShouldHave');
    $("a.label:contains('must have')").addClass('labelMustHave');
    $("a.label:contains('nice to have')").addClass('labelNiceToHave');
    $("a.label:contains('could have')").addClass('labelCouldHave');
    $("a.label:contains('feature-')").addClass('labelFeatureBranch');
}


$( document ).bind("ajaxSuccess",function(event, xhr, settings) {
    if (xhr.responseJSON && xhr.responseJSON.data && (xhr.responseJSON.data.kind === "layout_scheme" || xhr.responseJSON.data.kind === "command_create_response" || (xhr.responseJSON.data.kind === "message" && xhr.responseJSON.data.text === "Subscribed to push changes")) ) {
        $('.selector').unbind("click");
        $('.selector').bind("click", function(){
            setTimeout(function() {
                update_bug();
                update_chore();
                update_feature();
                update_output();
                highlightLabels();
            }, 100);
        });setTimeout(function() {
            updateFlyoverIcons();
        }, 1100);
        $('.expander.undraggable').unbind("click");
        $('.expander.undraggable').bind("click", function(){
            setTimeout(function() {
                $('.autosaves.collapser').unbind("click");
                $('.autosaves.collapser').bind("click", function(){
                    setTimeout(function() {
                        updateIcons();
                        $('.autosaves.collapser').unbind("click");
                    }, 100);
                });
            }, 100);
        });
{'fraction_non_alphanumeric': 0.15210054695682532, 'fraction_numerical': 0.01664145234493192, 'mean_word_length': 2.0041950707918197, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 7, 'https://': 22, 'lorem ipsum': 0, 'www.': 14, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 36, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1776729', 'n_tokens_mistral': 5025, 'n_tokens_neox': 4731, 'n_words': 755}