From 9f366147de433b82030ee92c1a9f0dea6f306773 Mon Sep 17 00:00:00 2001 From: Bengt Brodersen Date: Sun, 15 Feb 2015 18:07:50 +0100 Subject: [PATCH] Update and rename DependencyChecker.js to dependencyBookmarklet.js --- DependencyChecker.js | 52 ---------------------------------------- dependencyBookmarklet.js | 52 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 52 deletions(-) delete mode 100644 DependencyChecker.js create mode 100644 dependencyBookmarklet.js diff --git a/DependencyChecker.js b/DependencyChecker.js deleted file mode 100644 index d71450a..0000000 --- a/DependencyChecker.js +++ /dev/null @@ -1,52 +0,0 @@ -jQuery.fn.isAfter = function(sel){ - return this.prevAll().filter(sel).length !== 0; -}; - -jQuery.fn.isBefore= function(sel){ - return this.nextAll().filter(sel).length !== 0; -}; - -function loadDataJSON(issueKey, callback) { - - //https://docs.atlassian.com/jira/REST/latest/ - var url = '/rest/api/2/issue/' + issueKey + '?fields=summary,issuelinks'; - //console.log("IssueUrl: " + window.location.hostname + url); - //console.log("Issue: " + issueKey + " Loading..."); - return jQuery.ajax({ - type: 'GET', - url: url, - dataType: 'json', - success: function(responseData){ - //console.log("Issue: " + issueKey + " Loaded!"); - callback(responseData); - }, - data: {}, - }); -} - -function checkDependencies(){ - jQuery('[data-issue-key]').each(function() { - var issueElement = jQuery(this); - var issueKey = issueElement.attr('data-issue-key'); - loadDataJSON(issueKey, function(responseData){ - var issueLinks = responseData.fields.issuelinks; - jQuery.each(issueLinks,function(position, issue) { - if(issue.type.name == "Blocker" && issue.inwardIssue){ - var dependencyIssueKey = issue.inwardIssue.key; - if (issueElement.isBefore('[data-issue-key='+dependencyIssueKey+']')) { - issueElement.find('.ghx-end.ghx-row').find('.ghx-end') - .before(''+'⚠☟ '+' '+dependencyIssueKey+'') - - } - } - }) - }) - }); -} - -checkDependencies(); - -$( ".js-issue-list" ).change(function() { - console.log("##################################"); - checkDependencies(); -}); diff --git a/dependencyBookmarklet.js b/dependencyBookmarklet.js new file mode 100644 index 0000000..144eb6d --- /dev/null +++ b/dependencyBookmarklet.js @@ -0,0 +1,52 @@ +(function() { + jQuery.fn.isAfter = function(sel){ + return this.prevAll().filter(sel).length !== 0; + }; + + jQuery.fn.isBefore= function(sel){ + return this.nextAll().filter(sel).length !== 0; + }; + + function loadDataJSON(issueKey, callback) { + + //https://docs.atlassian.com/jira/REST/latest/ + var url = '/rest/api/2/issue/' + issueKey + '?fields=summary,issuelinks'; + //console.log("IssueUrl: " + window.location.hostname + url); + //console.log("Issue: " + issueKey + " Loading..."); + return jQuery.ajax({ + type: 'GET', + url: url, + dataType: 'json', + success: function(responseData){ + //console.log("Issue: " + issueKey + " Loaded!"); + callback(responseData); + }, + data: {}, + }); + } + + function checkDependencies(){ + // reomve old warnings first + jQuery('.blocked-warning').remove(); + // check for dependencies + jQuery('[data-issue-key]').each(function() { + var issueElement = jQuery(this); + var issueKey = issueElement.attr('data-issue-key'); + loadDataJSON(issueKey, function(responseData){ + var issueLinks = responseData.fields.issuelinks; + jQuery.each(issueLinks,function(position, issue) { + if(issue.type.name == "Blocker" && issue.inwardIssue){ + var dependencyIssueKey = issue.inwardIssue.key; + if (issueElement.isBefore('[data-issue-key='+dependencyIssueKey+']')) { + issueElement.find('.ghx-end.ghx-row') + .prepend('↯ '+dependencyIssueKey+'') + //issueElement.css('background-color', '#FFD351'); + } + } + }) + }) + }); + } + + checkDependencies(); +})();