separate app functions into objects
This commit is contained in:
parent
5c1bc72d2d
commit
77f8f19fae
615
bookmarklet.js
615
bookmarklet.js
@ -1,5 +1,5 @@
|
|||||||
(function() {
|
(function() {
|
||||||
var version = "3.4.0";
|
var version = "3.5.0";
|
||||||
console.log("Version: " + version);
|
console.log("Version: " + version);
|
||||||
|
|
||||||
var isDev = /.*jira.atlassian.com\/secure\/RapidBoard.jspa\?.*projectKey=ANERDS.*/g.test(document.URL) // Jira
|
var isDev = /.*jira.atlassian.com\/secure\/RapidBoard.jspa\?.*projectKey=ANERDS.*/g.test(document.URL) // Jira
|
||||||
@ -14,12 +14,21 @@
|
|||||||
//$("#card").load("https://cors-anywhere.herokuapp.com/"+"https://qoomon.github.io/Jira-Issue-Card-Printer/card.html");
|
//$("#card").load("https://cors-anywhere.herokuapp.com/"+"https://qoomon.github.io/Jira-Issue-Card-Printer/card.html");
|
||||||
|
|
||||||
// <GoogleAnalytics>
|
// <GoogleAnalytics>
|
||||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
(function(i, s, o, g, r, a, m) {
|
||||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
i['GoogleAnalyticsObject'] = r;
|
||||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
i[r] = i[r] || function() {
|
||||||
|
(i[r].q = i[r].q || []).push(arguments)
|
||||||
|
}, i[r].l = 1 * new Date();
|
||||||
|
a = s.createElement(o),
|
||||||
|
m = s.getElementsByTagName(o)[0];
|
||||||
|
a.async = 1;
|
||||||
|
a.src = g;
|
||||||
|
m.parentNode.insertBefore(a, m)
|
||||||
})(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');
|
})(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');
|
||||||
|
|
||||||
ga('create', 'UA-50840116-3', {'alwaysSendReferrer': true});
|
ga('create', 'UA-50840116-3', {
|
||||||
|
'alwaysSendReferrer': true
|
||||||
|
});
|
||||||
ga('set', 'page', '/cardprinter');
|
ga('set', 'page', '/cardprinter');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -56,13 +65,11 @@
|
|||||||
|
|
||||||
resourceOrigin = hostOrigin + "resources/";
|
resourceOrigin = hostOrigin + "resources/";
|
||||||
|
|
||||||
APP_JIRA='APP_JIRA'
|
appFunctions = {};
|
||||||
APP_PIVOTAL_TRACKER='APP_PIVOTAL_TRACKER'
|
|
||||||
issueTracker = 'UNKNOWN'
|
|
||||||
if (jQuery("meta[name='application-name'][ content='JIRA']").length > 0) {
|
if (jQuery("meta[name='application-name'][ content='JIRA']").length > 0) {
|
||||||
issueTracker = APP_JIRA
|
appFunctions = jiraFunctions;
|
||||||
} else if (/.*\pivotaltracker.com\/.*/g.test(document.URL)) {
|
} else if (/.*\pivotaltracker.com\/.*/g.test(document.URL)) {
|
||||||
issueTracker = APP_PIVOTAL_TRACKER
|
appFunctions = pivotalTrackerFunctions
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,7 +80,7 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var issueKeyList = getSelectedIssueKeyList();
|
var issueKeyList = appFunctions.getSelectedIssueKeyList();
|
||||||
|
|
||||||
if (issueKeyList.length <= 0) {
|
if (issueKeyList.length <= 0) {
|
||||||
alert("Please select at least one issue.");
|
alert("Please select at least one issue.");
|
||||||
@ -114,11 +121,7 @@
|
|||||||
jQuery(page).css("height", "calc( 50% - 1cm )");
|
jQuery(page).css("height", "calc( 50% - 1cm )");
|
||||||
jQuery(page).css("float", "left");
|
jQuery(page).css("float", "left");
|
||||||
|
|
||||||
var height = jQuery(page).height()
|
var height = jQuery(page).height() - jQuery(page).find(".card-header").outerHeight() - jQuery(page).find(".card-footer").outerHeight() - jQuery(page).find(".content-header").outerHeight() - 40;
|
||||||
- jQuery(page).find(".card-header").outerHeight()
|
|
||||||
- jQuery(page).find(".card-footer").outerHeight()
|
|
||||||
- jQuery(page).find(".content-header").outerHeight()
|
|
||||||
- 40;
|
|
||||||
jQuery(page).find(".description").css("max-height", height + "px");
|
jQuery(page).find(".description").css("max-height", height + "px");
|
||||||
var lineHeight = jQuery(page).find(".description").css("line-height");
|
var lineHeight = jQuery(page).find(".description").css("line-height");
|
||||||
lineHeight = lineHeight.substring(0, lineHeight.length - 2);
|
lineHeight = lineHeight.substring(0, lineHeight.length - 2);
|
||||||
@ -187,7 +190,7 @@
|
|||||||
page.find('.key').text(issueKey);
|
page.find('.key').text(issueKey);
|
||||||
jQuery("body", printDocument).append(page);
|
jQuery("body", printDocument).append(page);
|
||||||
var deferred = addDeferred(deferredList);
|
var deferred = addDeferred(deferredList);
|
||||||
getCardData(issueKey, function(cardData) {
|
appFunctions.getCardData(issueKey, function(cardData) {
|
||||||
console.logDebug("cardData: " + cardData);
|
console.logDebug("cardData: " + cardData);
|
||||||
if (!isDev) {
|
if (!isDev) {
|
||||||
ga('send', 'event', 'task', 'generate', 'card', cardData.type);
|
ga('send', 'event', 'task', 'generate', 'card', cardData.type);
|
||||||
@ -216,213 +219,6 @@
|
|||||||
jQuery("#card-print-overlay-style").remove();
|
jQuery("#card-print-overlay-style").remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
function getSelectedIssueKeyList() {
|
|
||||||
switch(issueTracker) {
|
|
||||||
case APP_JIRA:
|
|
||||||
return getSelectedIssueKeyListJira();
|
|
||||||
case APP_PIVOTAL_TRACKER:
|
|
||||||
return getSelectedIssueKeyListPivotalTracker();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function getSelectedIssueKeyListJira() {
|
|
||||||
|
|
||||||
//Browse
|
|
||||||
if (/.*\/browse\/.*/g.test(document.URL)) {
|
|
||||||
return jQuery("a[data-issue-key][id='key-val']").map(function() {
|
|
||||||
return jQuery(this).attr('data-issue-key');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// RapidBoard
|
|
||||||
if (/.*\/secure\/RapidBoard.jspa.*/g.test(document.URL)) {
|
|
||||||
return jQuery('div[data-issue-key].ghx-selected').map(function() {
|
|
||||||
return jQuery(this).attr('data-issue-key');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
function getSelectedIssueKeyListPivotalTracker() {
|
|
||||||
//Single Story
|
|
||||||
if (/.*\/stories\/.*/g.test(document.URL)) {
|
|
||||||
return [document.URL.replace(/.*\/stories\/(.*)\??/,'$1')];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Board
|
|
||||||
if (/.*\/projects\/.*/g.test(document.URL)) {
|
|
||||||
return jQuery('.story[data-id]:has(.selected)').map(function() {
|
|
||||||
return jQuery(this).attr('data-id');
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
function getCardData(issueKey, callback){
|
|
||||||
switch(issueTracker) {
|
|
||||||
case APP_JIRA:
|
|
||||||
return getCardDataJira(issueKey, callback);
|
|
||||||
case APP_PIVOTAL_TRACKER:
|
|
||||||
return getCardDataPivotalTracker(issueKey, callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function getCardDataJira(issueKey, callback) {
|
|
||||||
getIssueDataJira(issueKey,function(data){
|
|
||||||
|
|
||||||
var issueData = {};
|
|
||||||
|
|
||||||
issueData.key = data.key;
|
|
||||||
|
|
||||||
issueData.type = data.fields.issuetype.name.toLowerCase();
|
|
||||||
|
|
||||||
issueData.summary = data.fields.summary;
|
|
||||||
|
|
||||||
issueData.description = data.renderedFields.description;
|
|
||||||
|
|
||||||
if ( data.fields.assignee ) {
|
|
||||||
issueData.assignee = data.fields.assignee.displayName;
|
|
||||||
var avatarUrl = data.fields.assignee.avatarUrls['48x48'];
|
|
||||||
if(avatarUrl.indexOf("ownerId=") >= 0){
|
|
||||||
issueData.avatarUrl = avatarUrl;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( data.fields.duedate ) {
|
|
||||||
issueData.dueDate = new Date(data.fields.duedate).format('D d.m.');
|
|
||||||
}
|
|
||||||
|
|
||||||
issueData.hasAttachment = data.fields.attachment.length > 0;
|
|
||||||
if(issueData.description){
|
|
||||||
var printScope = issueData.description.indexOf(printScopeDeviderToken);
|
|
||||||
if (printScope >= 0) {
|
|
||||||
issueData.description = issueData.description.substring(0, printScope);
|
|
||||||
issueData.hasAttachment = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
issueData.storyPoints = data.fields.storyPoints;
|
|
||||||
|
|
||||||
issueData.epicKey = data.fields.epicLink;
|
|
||||||
if ( issueData.epicKey ) {
|
|
||||||
getIssueDataJira(issueData.epicKey , function(data) {
|
|
||||||
issueData.epicName = data.fields.epicName;
|
|
||||||
}, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
issueData.url = window.location.origin + "/browse/" + issueData.key;
|
|
||||||
|
|
||||||
//check for lrs
|
|
||||||
if(true){
|
|
||||||
console.logInfo("Apply LRS Specifics");
|
|
||||||
//Desired-Date
|
|
||||||
if ( data.fields.desiredDate ) {
|
|
||||||
issueData.dueDate = new Date(data.fields.desiredDate).format('D d.m.');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
callback(issueData);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function getCardDataPivotalTracker(issueKey, callback) {
|
|
||||||
getIssueDataPivotalTracker(issueKey,function(data){
|
|
||||||
|
|
||||||
var issueData = {};
|
|
||||||
|
|
||||||
issueData.key = data.id;
|
|
||||||
|
|
||||||
issueData.type = data.kind.toLowerCase();
|
|
||||||
|
|
||||||
issueData.summary = data.name;
|
|
||||||
|
|
||||||
issueData.description = data.description;
|
|
||||||
if(issueData.description){
|
|
||||||
issueData.description = "<p>"+issueData.description
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( data.owned_by && data.owned_by.length > 0 ) {
|
|
||||||
issueData.assignee = data.owner_ids[0].name;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( data.deadline ) {
|
|
||||||
issueData.dueDate = new Date(data.deadline).format('D d.m.');
|
|
||||||
}
|
|
||||||
|
|
||||||
issueData.hasAttachment = false;
|
|
||||||
if(issueData.description){
|
|
||||||
var printScope = issueData.description.indexOf(printScopeDeviderToken);
|
|
||||||
if (printScope >= 0) {
|
|
||||||
issueData.description = issueData.description.substring(0, printScope);
|
|
||||||
issueData.hasAttachment = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
issueData.storyPoints = data.estimate;
|
|
||||||
|
|
||||||
// TODO
|
|
||||||
// issueData.epicKey = data.fields.epicLink;
|
|
||||||
// if ( issueData.epicKey ) {
|
|
||||||
// getIssueDataPivotalTracker(issueData.epicKey , function(data) {
|
|
||||||
// issueData.epicName = data.fields.epicName;
|
|
||||||
// }, false);
|
|
||||||
// }
|
|
||||||
|
|
||||||
issueData.url = data.url;
|
|
||||||
|
|
||||||
callback(issueData);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function getIssueDataJira(issueKey, callback, async) {
|
|
||||||
async = typeof async !== 'undefined' ? async : true;
|
|
||||||
//https://docs.atlassian.com/jira/REST/latest/
|
|
||||||
var url = '/rest/api/2/issue/' + issueKey + '?expand=renderedFields,names';
|
|
||||||
console.logDebug("IssueUrl: " + url);
|
|
||||||
console.logDebug("Issue: " + issueKey + " Loading...");
|
|
||||||
jQuery.ajax({
|
|
||||||
type: 'GET',
|
|
||||||
url: url,
|
|
||||||
data: {},
|
|
||||||
dataType: 'json',
|
|
||||||
async: async,
|
|
||||||
success: function(responseData){
|
|
||||||
console.logDebug("Issue: " + issueKey + " Loaded!");
|
|
||||||
// add custom fields with field names
|
|
||||||
jQuery.each(responseData.names, function(key, value) {
|
|
||||||
if(key.startsWith("customfield_")){
|
|
||||||
var newFieldId = value.toCamelCase();
|
|
||||||
console.logTrace("add new field: " + newFieldId +" with value from "+ key);
|
|
||||||
responseData.fields[value.toCamelCase()] = responseData.fields[key];
|
|
||||||
}
|
|
||||||
});
|
|
||||||
callback(responseData);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function getIssueDataPivotalTracker(issueKey, callback, async) {
|
|
||||||
async = typeof async !== 'undefined' ? async : true;
|
|
||||||
//http://www.pivotaltracker.com/help/api
|
|
||||||
var url = 'https://www.pivotaltracker.com/services/v5/stories/' + issueKey + "?fields=name,kind,description,story_type,owned_by(name),comments(file_attachments(kind)),estimate,deadline";
|
|
||||||
console.logDebug("IssueUrl: " + url);
|
|
||||||
console.logDebug("Issue: " + issueKey + " Loading...");
|
|
||||||
jQuery.ajax({
|
|
||||||
type: 'GET',
|
|
||||||
url: url,
|
|
||||||
data: {},
|
|
||||||
dataType: 'json',
|
|
||||||
async: async,
|
|
||||||
success: function(responseData){
|
|
||||||
console.logDebug("Issue: " + issueKey + " Loaded!");
|
|
||||||
callback(responseData);
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function fillCard(card, data) {
|
function fillCard(card, data) {
|
||||||
//Key
|
//Key
|
||||||
card.find('.key').text(data.key);
|
card.find('.key').text(data.key);
|
||||||
@ -455,8 +251,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Attachment
|
//Attachment
|
||||||
if ( data.hasAttachment ) {
|
if (data.hasAttachment) {} else {
|
||||||
} else{
|
|
||||||
card.find('.attachment').addClass('hidden');
|
card.find('.attachment').addClass('hidden');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1225,10 +1020,11 @@
|
|||||||
Date.prototype.format = function(format) {
|
Date.prototype.format = function(format) {
|
||||||
var returnStr = '';
|
var returnStr = '';
|
||||||
var replace = Date.replaceChars;
|
var replace = Date.replaceChars;
|
||||||
for (var i = 0; i < format.length; i++) { var curChar = format.charAt(i); if (i - 1 >= 0 && format.charAt(i - 1) == "\\") {
|
for (var i = 0; i < format.length; i++) {
|
||||||
|
var curChar = format.charAt(i);
|
||||||
|
if (i - 1 >= 0 && format.charAt(i - 1) == "\\") {
|
||||||
returnStr += curChar;
|
returnStr += curChar;
|
||||||
}
|
} else if (replace[curChar]) {
|
||||||
else if (replace[curChar]) {
|
|
||||||
returnStr += replace[curChar].call(this);
|
returnStr += replace[curChar].call(this);
|
||||||
} else if (curChar != "\\") {
|
} else if (curChar != "\\") {
|
||||||
returnStr += curChar;
|
returnStr += curChar;
|
||||||
@ -1244,59 +1040,144 @@
|
|||||||
longDays: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
|
longDays: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
|
||||||
|
|
||||||
// Day
|
// Day
|
||||||
d: function() { return (this.getDate() < 10 ? '0' : '') + this.getDate(); },
|
d: function() {
|
||||||
D: function() { return Date.replaceChars.shortDays[this.getDay()]; },
|
return (this.getDate() < 10 ? '0' : '') + this.getDate();
|
||||||
j: function() { return this.getDate(); },
|
},
|
||||||
l: function() { return Date.replaceChars.longDays[this.getDay()]; },
|
D: function() {
|
||||||
N: function() { return this.getDay() + 1; },
|
return Date.replaceChars.shortDays[this.getDay()];
|
||||||
S: function() { return (this.getDate() % 10 == 1 && this.getDate() != 11 ? 'st' : (this.getDate() % 10 == 2 && this.getDate() != 12 ? 'nd' : (this.getDate() % 10 == 3 && this.getDate() != 13 ? 'rd' : 'th'))); },
|
},
|
||||||
w: function() { return this.getDay(); },
|
j: function() {
|
||||||
z: function() { var d = new Date(this.getFullYear(),0,1); return Math.ceil((this - d) / 86400000); }, // Fixed now
|
return this.getDate();
|
||||||
|
},
|
||||||
|
l: function() {
|
||||||
|
return Date.replaceChars.longDays[this.getDay()];
|
||||||
|
},
|
||||||
|
N: function() {
|
||||||
|
return this.getDay() + 1;
|
||||||
|
},
|
||||||
|
S: function() {
|
||||||
|
return (this.getDate() % 10 == 1 && this.getDate() != 11 ? 'st' : (this.getDate() % 10 == 2 && this.getDate() != 12 ? 'nd' : (this.getDate() % 10 == 3 && this.getDate() != 13 ? 'rd' : 'th')));
|
||||||
|
},
|
||||||
|
w: function() {
|
||||||
|
return this.getDay();
|
||||||
|
},
|
||||||
|
z: function() {
|
||||||
|
var d = new Date(this.getFullYear(), 0, 1);
|
||||||
|
return Math.ceil((this - d) / 86400000);
|
||||||
|
}, // Fixed now
|
||||||
// Week
|
// Week
|
||||||
W: function() { var d = new Date(this.getFullYear(), 0, 1); return Math.ceil((((this - d) / 86400000) + d.getDay() + 1) / 7); }, // Fixed now
|
W: function() {
|
||||||
|
var d = new Date(this.getFullYear(), 0, 1);
|
||||||
|
return Math.ceil((((this - d) / 86400000) + d.getDay() + 1) / 7);
|
||||||
|
}, // Fixed now
|
||||||
// Month
|
// Month
|
||||||
F: function() { return Date.replaceChars.longMonths[this.getMonth()]; },
|
F: function() {
|
||||||
m: function() { return (this.getMonth() < 9 ? '0' : '') + (this.getMonth() + 1); },
|
return Date.replaceChars.longMonths[this.getMonth()];
|
||||||
M: function() { return Date.replaceChars.shortMonths[this.getMonth()]; },
|
},
|
||||||
n: function() { return this.getMonth() + 1; },
|
m: function() {
|
||||||
t: function() { var d = new Date(); return new Date(d.getFullYear(), d.getMonth(), 0).getDate() }, // Fixed now, gets #days of date
|
return (this.getMonth() < 9 ? '0' : '') + (this.getMonth() + 1);
|
||||||
|
},
|
||||||
|
M: function() {
|
||||||
|
return Date.replaceChars.shortMonths[this.getMonth()];
|
||||||
|
},
|
||||||
|
n: function() {
|
||||||
|
return this.getMonth() + 1;
|
||||||
|
},
|
||||||
|
t: function() {
|
||||||
|
var d = new Date();
|
||||||
|
return new Date(d.getFullYear(), d.getMonth(), 0).getDate()
|
||||||
|
}, // Fixed now, gets #days of date
|
||||||
// Year
|
// Year
|
||||||
L: function() { var year = this.getFullYear(); return (year % 400 == 0 || (year % 100 != 0 && year % 4 == 0)); }, // Fixed now
|
L: function() {
|
||||||
o: function() { var d = new Date(this.valueOf()); d.setDate(d.getDate() - ((this.getDay() + 6) % 7) + 3); return d.getFullYear();}, //Fixed now
|
var year = this.getFullYear();
|
||||||
Y: function() { return this.getFullYear(); },
|
return (year % 400 == 0 || (year % 100 != 0 && year % 4 == 0));
|
||||||
y: function() { return ('' + this.getFullYear()).substr(2); },
|
}, // Fixed now
|
||||||
|
o: function() {
|
||||||
|
var d = new Date(this.valueOf());
|
||||||
|
d.setDate(d.getDate() - ((this.getDay() + 6) % 7) + 3);
|
||||||
|
return d.getFullYear();
|
||||||
|
}, //Fixed now
|
||||||
|
Y: function() {
|
||||||
|
return this.getFullYear();
|
||||||
|
},
|
||||||
|
y: function() {
|
||||||
|
return ('' + this.getFullYear()).substr(2);
|
||||||
|
},
|
||||||
// Time
|
// Time
|
||||||
a: function() { return this.getHours() < 12 ? 'am' : 'pm'; },
|
a: function() {
|
||||||
A: function() { return this.getHours() < 12 ? 'AM' : 'PM'; },
|
return this.getHours() < 12 ? 'am' : 'pm';
|
||||||
B: function() { return Math.floor((((this.getUTCHours() + 1) % 24) + this.getUTreminutes() / 60 + this.getUTCSeconds() / 3600) * 1000 / 24); }, // Fixed now
|
},
|
||||||
g: function() { return this.getHours() % 12 || 12; },
|
A: function() {
|
||||||
G: function() { return this.getHours(); },
|
return this.getHours() < 12 ? 'AM' : 'PM';
|
||||||
h: function() { return ((this.getHours() % 12 || 12) < 10 ? '0' : '') + (this.getHours() % 12 || 12); },
|
},
|
||||||
H: function() { return (this.getHours() < 10 ? '0' : '') + this.getHours(); },
|
B: function() {
|
||||||
i: function() { return (this.getMinutes() < 10 ? '0' : '') + this.getMinutes(); },
|
return Math.floor((((this.getUTCHours() + 1) % 24) + this.getUTreminutes() / 60 + this.getUTCSeconds() / 3600) * 1000 / 24);
|
||||||
s: function() { return (this.getSeconds() < 10 ? '0' : '') + this.getSeconds(); },
|
}, // Fixed now
|
||||||
u: function() { var m = this.getMilliseconds(); return (m < 10 ? '00' : (m < 100 ? '0' : '')) + m; },
|
g: function() {
|
||||||
|
return this.getHours() % 12 || 12;
|
||||||
|
},
|
||||||
|
G: function() {
|
||||||
|
return this.getHours();
|
||||||
|
},
|
||||||
|
h: function() {
|
||||||
|
return ((this.getHours() % 12 || 12) < 10 ? '0' : '') + (this.getHours() % 12 || 12);
|
||||||
|
},
|
||||||
|
H: function() {
|
||||||
|
return (this.getHours() < 10 ? '0' : '') + this.getHours();
|
||||||
|
},
|
||||||
|
i: function() {
|
||||||
|
return (this.getMinutes() < 10 ? '0' : '') + this.getMinutes();
|
||||||
|
},
|
||||||
|
s: function() {
|
||||||
|
return (this.getSeconds() < 10 ? '0' : '') + this.getSeconds();
|
||||||
|
},
|
||||||
|
u: function() {
|
||||||
|
var m = this.getMilliseconds();
|
||||||
|
return (m < 10 ? '00' : (m < 100 ? '0' : '')) + m;
|
||||||
|
},
|
||||||
// Timezone
|
// Timezone
|
||||||
e: function() { return "Not Yet Supported"; },
|
e: function() {
|
||||||
|
return "Not Yet Supported";
|
||||||
|
},
|
||||||
I: function() {
|
I: function() {
|
||||||
var DST = null;
|
var DST = null;
|
||||||
for (var i = 0; i < 12; ++i) {
|
for (var i = 0; i < 12; ++i) {
|
||||||
var d = new Date(this.getFullYear(), i, 1);
|
var d = new Date(this.getFullYear(), i, 1);
|
||||||
var offset = d.getTimezoneOffset();
|
var offset = d.getTimezoneOffset();
|
||||||
if (DST === null) DST = offset;
|
if (DST === null) DST = offset;
|
||||||
else if (offset < DST) { DST = offset; break; }
|
else if (offset < DST) {
|
||||||
else if (offset > DST) break;
|
DST = offset;
|
||||||
|
break;
|
||||||
|
} else if (offset > DST) break;
|
||||||
}
|
}
|
||||||
return (this.getTimezoneOffset() == DST) | 0;
|
return (this.getTimezoneOffset() == DST) | 0;
|
||||||
},
|
},
|
||||||
O: function() { return (-this.getTimezoneOffset() < 0 ? '-' : '+') + (Math.abs(this.getTimezoneOffset() / 60) < 10 ? '0' : '') + (Math.abs(this.getTimezoneOffset() / 60)) + '00'; },
|
O: function() {
|
||||||
P: function() { return (-this.getTimezoneOffset() < 0 ? '-' : '+') + (Math.abs(this.getTimezoneOffset() / 60) < 10 ? '0' : '') + (Math.abs(this.getTimezoneOffset() / 60)) + ':00'; }, // Fixed now
|
return (-this.getTimezoneOffset() < 0 ? '-' : '+') + (Math.abs(this.getTimezoneOffset() / 60) < 10 ? '0' : '') + (Math.abs(this.getTimezoneOffset() / 60)) + '00';
|
||||||
T: function() { var m = this.getMonth(); this.setMonth(0); var result = this.toTimeString().replace(/^.+ \(?([^\)]+)\)?$/, '$1'); this.setMonth(m); return result;},
|
},
|
||||||
Z: function() { return -this.getTimezoneOffset() * 60; },
|
P: function() {
|
||||||
|
return (-this.getTimezoneOffset() < 0 ? '-' : '+') + (Math.abs(this.getTimezoneOffset() / 60) < 10 ? '0' : '') + (Math.abs(this.getTimezoneOffset() / 60)) + ':00';
|
||||||
|
}, // Fixed now
|
||||||
|
T: function() {
|
||||||
|
var m = this.getMonth();
|
||||||
|
this.setMonth(0);
|
||||||
|
var result = this.toTimeString().replace(/^.+ \(?([^\)]+)\)?$/, '$1');
|
||||||
|
this.setMonth(m);
|
||||||
|
return result;
|
||||||
|
},
|
||||||
|
Z: function() {
|
||||||
|
return -this.getTimezoneOffset() * 60;
|
||||||
|
},
|
||||||
// Full Date/Time
|
// Full Date/Time
|
||||||
c: function() { return this.format("Y-m-d\\TH:i:sP"); }, // Fixed now
|
c: function() {
|
||||||
r: function() { return this.toString(); },
|
return this.format("Y-m-d\\TH:i:sP");
|
||||||
U: function() { return this.getTimep() / 1000; }
|
}, // Fixed now
|
||||||
|
r: function() {
|
||||||
|
return this.toString();
|
||||||
|
},
|
||||||
|
U: function() {
|
||||||
|
return this.getTimep() / 1000;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1311,4 +1192,204 @@
|
|||||||
iframe.height(iframe[0].contentWindow.document.body.scrollHeight);
|
iframe.height(iframe[0].contentWindow.document.body.scrollHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// APP Specific Functions
|
||||||
|
//############################################################################################################################
|
||||||
|
//############################################################################################################################
|
||||||
|
//############################################################################################################################
|
||||||
|
|
||||||
|
var jiraFunctions = {
|
||||||
|
|
||||||
|
getSelectedIssueKeyList: function() {
|
||||||
|
//Browse
|
||||||
|
if (/.*\/browse\/.*/g.test(document.URL)) {
|
||||||
|
return jQuery("a[data-issue-key][id='key-val']").map(function() {
|
||||||
|
return jQuery(this).attr('data-issue-key');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// RapidBoard
|
||||||
|
if (/.*\/secure\/RapidBoard.jspa.*/g.test(document.URL)) {
|
||||||
|
return jQuery('div[data-issue-key].ghx-selected').map(function() {
|
||||||
|
return jQuery(this).attr('data-issue-key');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return [];
|
||||||
|
},
|
||||||
|
|
||||||
|
getCardData: function(issueKey, callback) {
|
||||||
|
jiraFunctions.getIssueData(issueKey, function(data) {
|
||||||
|
|
||||||
|
var issueData = {};
|
||||||
|
|
||||||
|
issueData.key = data.key;
|
||||||
|
|
||||||
|
issueData.type = data.fields.issuetype.name.toLowerCase();
|
||||||
|
|
||||||
|
issueData.summary = data.fields.summary;
|
||||||
|
|
||||||
|
issueData.description = data.renderedFields.description;
|
||||||
|
|
||||||
|
if (data.fields.assignee) {
|
||||||
|
issueData.assignee = data.fields.assignee.displayName;
|
||||||
|
var avatarUrl = data.fields.assignee.avatarUrls['48x48'];
|
||||||
|
if (avatarUrl.indexOf("ownerId=") >= 0) {
|
||||||
|
issueData.avatarUrl = avatarUrl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.fields.duedate) {
|
||||||
|
issueData.dueDate = new Date(data.fields.duedate).format('D d.m.');
|
||||||
|
}
|
||||||
|
|
||||||
|
issueData.hasAttachment = data.fields.attachment.length > 0;
|
||||||
|
if (issueData.description) {
|
||||||
|
var printScope = issueData.description.indexOf(printScopeDeviderToken);
|
||||||
|
if (printScope >= 0) {
|
||||||
|
issueData.description = issueData.description.substring(0, printScope);
|
||||||
|
issueData.hasAttachment = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
issueData.storyPoints = data.fields.storyPoints;
|
||||||
|
|
||||||
|
issueData.epicKey = data.fields.epicLink;
|
||||||
|
if (issueData.epicKey) {
|
||||||
|
jiraFunctions.getIssueData(issueData.epicKey, function(data) {
|
||||||
|
issueData.epicName = data.fields.epicName;
|
||||||
|
}, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
issueData.url = window.location.origin + "/browse/" + issueData.key;
|
||||||
|
|
||||||
|
//check for lrs
|
||||||
|
if (true) {
|
||||||
|
console.logInfo("Apply LRS Specifics");
|
||||||
|
//Desired-Date
|
||||||
|
if (data.fields.desiredDate) {
|
||||||
|
issueData.dueDate = new Date(data.fields.desiredDate).format('D d.m.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
callback(issueData);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
getIssueData: function(issueKey, callback, async) {
|
||||||
|
async = typeof async !== 'undefined' ? async : true;
|
||||||
|
//https://docs.atlassian.com/jira/REST/latest/
|
||||||
|
var url = '/rest/api/2/issue/' + issueKey + '?expand=renderedFields,names';
|
||||||
|
console.logDebug("IssueUrl: " + url);
|
||||||
|
console.logDebug("Issue: " + issueKey + " Loading...");
|
||||||
|
jQuery.ajax({
|
||||||
|
type: 'GET',
|
||||||
|
url: url,
|
||||||
|
data: {},
|
||||||
|
dataType: 'json',
|
||||||
|
async: async,
|
||||||
|
success: function(responseData) {
|
||||||
|
console.logDebug("Issue: " + issueKey + " Loaded!");
|
||||||
|
// add custom fields with field names
|
||||||
|
jQuery.each(responseData.names, function(key, value) {
|
||||||
|
if (key.startsWith("customfield_")) {
|
||||||
|
var newFieldId = value.toCamelCase();
|
||||||
|
console.logTrace("add new field: " + newFieldId + " with value from " + key);
|
||||||
|
responseData.fields[value.toCamelCase()] = responseData.fields[key];
|
||||||
|
}
|
||||||
|
});
|
||||||
|
callback(responseData);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var pivotalTrackerFunctions = {
|
||||||
|
|
||||||
|
getSelectedIssueKeyList: function() {
|
||||||
|
//Single Story
|
||||||
|
if (/.*\/stories\/.*/g.test(document.URL)) {
|
||||||
|
return [document.URL.replace(/.*\/stories\/(.*)\??/, '$1')];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Board
|
||||||
|
if (/.*\/projects\/.*/g.test(document.URL)) {
|
||||||
|
return jQuery('.story[data-id]:has(.selected)').map(function() {
|
||||||
|
return jQuery(this).attr('data-id');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return [];
|
||||||
|
},
|
||||||
|
|
||||||
|
getCardData: function(issueKey, callback) {
|
||||||
|
pivotalTrackerFunctions.getIssueData(issueKey, function(data) {
|
||||||
|
|
||||||
|
var issueData = {};
|
||||||
|
|
||||||
|
issueData.key = data.id;
|
||||||
|
|
||||||
|
issueData.type = data.kind.toLowerCase();
|
||||||
|
|
||||||
|
issueData.summary = data.name;
|
||||||
|
|
||||||
|
issueData.description = data.description;
|
||||||
|
if (issueData.description) {
|
||||||
|
issueData.description = "<p>" + issueData.description
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.owned_by && data.owned_by.length > 0) {
|
||||||
|
issueData.assignee = data.owner_ids[0].name;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (data.deadline) {
|
||||||
|
issueData.dueDate = new Date(data.deadline).format('D d.m.');
|
||||||
|
}
|
||||||
|
|
||||||
|
issueData.hasAttachment = false;
|
||||||
|
if (issueData.description) {
|
||||||
|
var printScope = issueData.description.indexOf(printScopeDeviderToken);
|
||||||
|
if (printScope >= 0) {
|
||||||
|
issueData.description = issueData.description.substring(0, printScope);
|
||||||
|
issueData.hasAttachment = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
issueData.storyPoints = data.estimate;
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
// issueData.epicKey = data.fields.epicLink;
|
||||||
|
// if ( issueData.epicKey ) {
|
||||||
|
// getIssueDataPivotalTracker(issueData.epicKey , function(data) {
|
||||||
|
// issueData.epicName = data.fields.epicName;
|
||||||
|
// }, false);
|
||||||
|
// }
|
||||||
|
|
||||||
|
issueData.url = data.url;
|
||||||
|
|
||||||
|
callback(issueData);
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
getIssueData: function(issueKey, callback, async) {
|
||||||
|
async = typeof async !== 'undefined' ? async : true;
|
||||||
|
//http://www.pivotaltracker.com/help/api
|
||||||
|
var url = 'https://www.pivotaltracker.com/services/v5/stories/' + issueKey + "?fields=name,kind,description,story_type,owned_by(name),comments(file_attachments(kind)),estimate,deadline";
|
||||||
|
console.logDebug("IssueUrl: " + url);
|
||||||
|
console.logDebug("Issue: " + issueKey + " Loading...");
|
||||||
|
jQuery.ajax({
|
||||||
|
type: 'GET',
|
||||||
|
url: url,
|
||||||
|
data: {},
|
||||||
|
dataType: 'json',
|
||||||
|
async: async,
|
||||||
|
success: function(responseData) {
|
||||||
|
console.logDebug("Issue: " + issueKey + " Loaded!");
|
||||||
|
callback(responseData);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user