Update bookmarklet.js
This commit is contained in:
parent
e0f42bc6dc
commit
0b6a03641a
@ -1,11 +1,7 @@
|
|||||||
(function() {
|
(function() {
|
||||||
var version = "4.2.1";
|
|
||||||
console.log("Version: " + version);
|
|
||||||
|
|
||||||
var global = {};
|
var global = {};
|
||||||
global.isDev = /.*jira.atlassian.com\/secure\/RapidBoard.jspa\?.*projectKey=ANERDS.*/g.test(document.URL) // Jira
|
global.version = "4.2.1";
|
||||||
|| /.*pivotaltracker.com\/n\/projects\/510733.*/g.test(document.URL) // PivotTracker
|
global.isDev = document.scripts[document.scripts.length-1].src == "";
|
||||||
|| (/.*trello.com\/.*/g.test(document.URL) && jQuery("span.js-member-name").text() == 'Bengt Brodersen'); // Trello
|
|
||||||
global.isProd = !global.isDev;
|
global.isProd = !global.isDev;
|
||||||
|
|
||||||
window.addEventListener("error", function(event) {
|
window.addEventListener("error", function(event) {
|
||||||
@ -26,12 +22,15 @@
|
|||||||
|
|
||||||
// wait untill all scripts loaded
|
// wait untill all scripts loaded
|
||||||
appendScript('https://qoomon.github.io/void', function() {
|
appendScript('https://qoomon.github.io/void', function() {
|
||||||
main();
|
init().then(function(){
|
||||||
|
main();
|
||||||
|
}).catch(function(){
|
||||||
|
alert("ERROR on init!");
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
function main() {
|
function main() {
|
||||||
init();
|
console.log("Run...")
|
||||||
|
|
||||||
// determine application
|
// determine application
|
||||||
if (jQuery("meta[name='application-name'][ content='JIRA']").length > 0) {
|
if (jQuery("meta[name='application-name'][ content='JIRA']").length > 0) {
|
||||||
console.log("App: " + "Jira");
|
console.log("App: " + "Jira");
|
||||||
@ -63,6 +62,8 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// open print preview
|
// open print preview
|
||||||
jQuery("body").append(printOverlayHTML());
|
jQuery("body").append(printOverlayHTML());
|
||||||
jQuery("#card-print-overlay").prepend(printOverlayStyle());
|
jQuery("#card-print-overlay").prepend(printOverlayStyle());
|
||||||
@ -85,9 +86,9 @@
|
|||||||
jQuery("#hide-due-date-checkbox").attr('checked', readCookie("card_printer_hide_due_date", 'false') == 'true');
|
jQuery("#hide-due-date-checkbox").attr('checked', readCookie("card_printer_hide_due_date", 'false') == 'true');
|
||||||
jQuery("#hide-status-checkbox").attr('checked', readCookie("card_printer_hide_status", 'true') == 'true');
|
jQuery("#hide-status-checkbox").attr('checked', readCookie("card_printer_hide_status", 'true') == 'true');
|
||||||
|
|
||||||
jQuery("#card-print-dialog-title").text("Card Printer " + version + " - Loading issues...");
|
jQuery("#card-print-dialog-title").text("Card Printer " + global.version + " - Loading issues...");
|
||||||
renderCards(issueKeyList, function() {
|
renderCards(issueKeyList, function() {
|
||||||
jQuery("#card-print-dialog-title").text("Card Printer " + version);
|
jQuery("#card-print-dialog-title").text("Card Printer " + global.version);
|
||||||
//print();
|
//print();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -97,6 +98,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
|
console.log("Init...")
|
||||||
addStringFunctions();
|
addStringFunctions();
|
||||||
addDateFunctions();
|
addDateFunctions();
|
||||||
|
|
||||||
@ -110,6 +112,13 @@
|
|||||||
if (global.isProd) {
|
if (global.isProd) {
|
||||||
initGoogleAnalytics();
|
initGoogleAnalytics();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var promises = [];
|
||||||
|
promises.push(httpGetCors(global.hostOrigin + "card.html", function(data){
|
||||||
|
global.cardHtml = data;
|
||||||
|
console.log("foooooo: " + data);
|
||||||
|
}));
|
||||||
|
return Promise.all(promises);
|
||||||
}
|
}
|
||||||
|
|
||||||
function print() {
|
function print() {
|
||||||
@ -141,19 +150,19 @@
|
|||||||
|
|
||||||
var deferredList = [];
|
var deferredList = [];
|
||||||
jQuery.each(issueKeyList, function(index, issueKey) {
|
jQuery.each(issueKeyList, function(index, issueKey) {
|
||||||
var page = cardHtml(issueKey);
|
var card = cardElement(issueKey);
|
||||||
page.attr("index", index);
|
card.attr("index", index);
|
||||||
page.hide();
|
card.hide();
|
||||||
page.find('.issue-id').text(issueKey);
|
card.find('.issue-id').text(issueKey);
|
||||||
jQuery("body", printDocument).append(page);
|
jQuery("body", printDocument).append(card);
|
||||||
var deferred = addDeferred(deferredList);
|
var deferred = addDeferred(deferredList);
|
||||||
global.appFunctions.getCardData(issueKey, function(cardData) {
|
global.appFunctions.getCardData(issueKey, function(cardData) {
|
||||||
//console.log("cardData: " + cardData);
|
//console.log("cardData: " + cardData);
|
||||||
if (global.isProd) {
|
if (global.isProd) {
|
||||||
ga('send', 'event', 'card', 'generate', cardData.type);
|
ga('send', 'event', 'card', 'generate', cardData.type);
|
||||||
}
|
}
|
||||||
fillCard(page, cardData);
|
fillCard(card, cardData);
|
||||||
page.show();
|
card.show();
|
||||||
redrawCards();
|
redrawCards();
|
||||||
deferred.resolve();
|
deferred.resolve();
|
||||||
});
|
});
|
||||||
@ -664,45 +673,10 @@
|
|||||||
|
|
||||||
// card layout: http://jsfiddle.net/qoomon/ykbLb2pw/76
|
// card layout: http://jsfiddle.net/qoomon/ykbLb2pw/76
|
||||||
|
|
||||||
function cardHtml(issueKey) {
|
function cardElement(issueKey) {
|
||||||
var page = jQuery(document.createElement('div'))
|
var page = jQuery(document.createElement('div'))
|
||||||
.attr("id", issueKey)
|
.attr("id", issueKey)
|
||||||
.html(multilineString(function() {
|
.html(global.cardHtml);
|
||||||
/*!
|
|
||||||
<div class="card">
|
|
||||||
<div class="card-content">
|
|
||||||
<div class="card-body shadow">
|
|
||||||
<div class="issue-summary"></div>
|
|
||||||
<div class="issue-description"></div>
|
|
||||||
</div>
|
|
||||||
<div class="card-header">
|
|
||||||
<div class="issue-id badge"></div>
|
|
||||||
<div class="issue-id-fadeout"></div>
|
|
||||||
<div class="issue-icon badge" type="story"></div>
|
|
||||||
<div class="issue-estimate badge"></div>
|
|
||||||
<div class="issue-due-box">
|
|
||||||
<div class="issue-due-date badge"></div>
|
|
||||||
<div class="issue-due-icon badge"></div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="card-footer">
|
|
||||||
<div class="issue-qr-code badge"></div>
|
|
||||||
<div class="issue-attachment badge"></div>
|
|
||||||
<div class="issue-assignee badge"></div>
|
|
||||||
<div class="issue-epic-box badge">
|
|
||||||
<span class="issue-epic-id"></span>
|
|
||||||
<span class="issue-epic-name"></span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="author">
|
|
||||||
<span>©BengtBrodersen</span><br>
|
|
||||||
qoomon.com
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
*/
|
|
||||||
}));
|
|
||||||
|
|
||||||
return page;
|
return page;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1312,16 +1286,8 @@ body {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function httpGet(url){
|
function httpGetCors(url, callback){
|
||||||
var response;
|
return jQuery.get('https://jsonp.afeld.me/?url=' + url, callback);
|
||||||
jQuery.ajax({
|
|
||||||
url: 'https://jsonp.afeld.me/?url=' + url,
|
|
||||||
success: function (data) {
|
|
||||||
result = data
|
|
||||||
},
|
|
||||||
async: false
|
|
||||||
});
|
|
||||||
return response;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user