version = "3.1.9";
console.log("Version: " + version);
var isDev = typeof isDev === 'undefined' || isDev ;
hostOrigin = "https://qoomon.github.io/Jira-Issue-Card-Printer/";
if(isDev){
console.log("DEVELOPMENT");
hostOrigin = "https://rawgit.com/qoomon/Jira-Issue-Card-Printer/develop/";
isDev = false;
}
cors = "https://cors-anywhere.herokuapp.com/";
//$("#card").load("https://cors-anywhere.herokuapp.com/"+"https://qoomon.github.io/Jira-Issue-Card-Printer/card.html");
//
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;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');
ga('create', 'UA-50840116-3', 'auto');
ga('set', 'location', window.location.protocol + '//' + window.location.host + window.location.pathname);
ga('set', 'hostname', window.location.hostname);
ga('set', 'page', '/cardprinter');
ga('set', 'title', document.title);
ga('set', 'referrer', window.location.hostname);
//ga('set', 'campaignSource', '(direct)');
//ga('set', 'campaignMedium', '(none)');
//
try {
// load jQuery
if (window.jQuery === undefined) {
appendScript('//ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js');
}
// wait untill all scripts loaded
appendScript('https://qoomon.github.io/void', function(){
init();
main();
});
function init(){
addJQueryFunctions();
addConsoleFunctions();
addStringFunctions();
addDateFunctions();
printScopeDeviderToken = "Attachment";
console.logLevel = console.INFO;
resourceOrigin = hostOrigin+ "resources/";
}
function main(){
//preconditions
if(jQuery("#card-print-overlay").length > 0){
alert("Print Card already opened!");
return;
}
var issueKeyList = getSelectedIssueKeyList();
if(issueKeyList.length <= 0){
alert("Please select at least one issue.");
return;
}
// open print preview
jQuery("body").append(printOverlayHTML);
jQuery("#card-print-overlay").prepend(printOverlayStyle);
ga('send', 'pageview');
jQuery("#card-print-dialog-title").text("Card Print - Loading " + issueKeyList.length + " issues...");
renderCards(issueKeyList, function(){
jQuery("#card-print-dialog-title").text("Card Print");
print();
});
}
function print(){
var printFrame = jQuery("#card-print-dialog-content-iframe");
var printWindow = printFrame[0].contentWindow;
var printDocument = printWindow.document;
ga('send', 'event', 'button', 'click', 'print', jQuery(".card", printDocument).length );
printWindow.print();
}
function renderCards(issueKeyList, callback) {
var printFrame = jQuery("#card-print-dialog-content-iframe");
var printWindow = printFrame[0].contentWindow;
var printDocument = printWindow.document;
printDocument.open();
printDocument.write("