cleanup
This commit is contained in:
parent
c0600c5cd4
commit
362fc8a9b8
408
bookmarklet.js
408
bookmarklet.js
@ -1,20 +1,39 @@
|
|||||||
loadScripts(function(){
|
// <GoogleAnalytics>
|
||||||
|
(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', {'alwaysSendReferrer': true});
|
||||||
|
ga('send', {
|
||||||
|
'hitType': 'pageview',
|
||||||
|
'page': '/jiracardprinter/Bookmarklet.js'
|
||||||
|
});
|
||||||
|
// </GoogleAnalytics>
|
||||||
|
|
||||||
|
// load jQuery
|
||||||
if (window.jQuery === undefined) {
|
if (window.jQuery === undefined) {
|
||||||
appendScript("//ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js", false);
|
appendScript('//ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js');
|
||||||
}
|
}
|
||||||
},function(){
|
|
||||||
addGoogleAnalytics();
|
// wait untill all other scripts loaded
|
||||||
|
appendScript('https://qoomon.github.io/void', function(){
|
||||||
init();
|
init();
|
||||||
main();
|
main();
|
||||||
});
|
});
|
||||||
|
|
||||||
function main(){
|
function init(){
|
||||||
|
addJQueryFunctions();
|
||||||
|
addConsoleFunctions();
|
||||||
|
addStringFunctions();
|
||||||
|
addDateFunctions();
|
||||||
|
|
||||||
|
printScopeDeviderToken = "<b>Attachment</b>"
|
||||||
|
|
||||||
console.logLevel = console.INFO;
|
console.logLevel = console.INFO;
|
||||||
|
}
|
||||||
|
|
||||||
printScopeDeviderToken1 = "~~~~~";
|
function main(){
|
||||||
printScopeDeviderToken2 = "<b>Attachment</b>"
|
|
||||||
|
|
||||||
if(jQuery("#card-print-overlay").length > 0){
|
if(jQuery("#card-print-overlay").length > 0){
|
||||||
alert("Print Card already opened!");
|
alert("Print Card already opened!");
|
||||||
return;
|
return;
|
||||||
@ -26,24 +45,10 @@ function main(){
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Google Analytics
|
openPrintPreview(issueKeyList);
|
||||||
ga('create', 'UA-50840116-3', 'auto', {'alwaysSendReferrer': true});
|
|
||||||
ga('send', {
|
|
||||||
'hitType': 'pageview',
|
|
||||||
'page': '/jiracardprinter/Bookmarklet.js'
|
|
||||||
});
|
|
||||||
|
|
||||||
open(issueKeyList);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function openPrintPreview(issueKeyList) {
|
||||||
function open(issueKeyList) {
|
|
||||||
|
|
||||||
jQuery(document).keyup(function(e) {
|
|
||||||
if (e.keyCode == 27) { // esc
|
|
||||||
close();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
jQuery("head").append(newPrintOverlayStyle);
|
jQuery("head").append(newPrintOverlayStyle);
|
||||||
jQuery("body").append(newPrintOverlayHTML);
|
jQuery("body").append(newPrintOverlayHTML);
|
||||||
@ -59,25 +64,24 @@ function open(issueKeyList) {
|
|||||||
jQuery("head", printDocument).append(newPrintPanelCardCSS());
|
jQuery("head", printDocument).append(newPrintPanelCardCSS());
|
||||||
|
|
||||||
console.logInfo("load " + issueKeyList.length + " issues...");
|
console.logInfo("load " + issueKeyList.length + " issues...");
|
||||||
jQuery("#card-print-dialog-title").text("Card Print - Loading... " + 0 + " / " + issueKeyList.length);
|
jQuery("#card-print-dialog-title").text("Card Print - Loading " + issueKeyList.length + " issues...");
|
||||||
var deferredList = [];
|
var deferredList = [];
|
||||||
|
|
||||||
issueKeyList.each(function(position, issueKey) {
|
issueKeyList.each(function(position, issueKey) {
|
||||||
var card = newCardHTML(issueKey);
|
var card = newCardHTML(issueKey);
|
||||||
card.hide();
|
card.hide();
|
||||||
jQuery("body", printDocument).append(card);
|
jQuery("body", printDocument).append(card);
|
||||||
var deferred = new jQuery.Deferred()
|
var deferred = addDeferred(deferredList);
|
||||||
deferredList.push(deferred);
|
|
||||||
loadCardDataJSON(issueKey, function(responseData) {
|
loadCardDataJSON(issueKey, function(responseData) {
|
||||||
fillCardWithJSONData(card, responseData);
|
fillCardWithJSONData(card, responseData);
|
||||||
card.show();
|
card.show();
|
||||||
resizeIframe(printFrame);
|
resizeIframe(printFrame);
|
||||||
jQuery("#card-print-dialog-title").text("Card Print - Loading... " + (position + 1) + " / " + issueKeyList.length);
|
|
||||||
deferred.resolve();
|
deferred.resolve();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
console.logInfo("wait for issues loaded...");
|
console.logInfo("wait for issues loaded...");
|
||||||
|
|
||||||
jQuery.when.apply(jQuery, deferredList).done(function() {
|
applyDeferred(deferredList,function() {
|
||||||
jQuery(printWindow).load(function(){
|
jQuery(printWindow).load(function(){
|
||||||
jQuery("#card-print-dialog-title").text("Card Print");
|
jQuery("#card-print-dialog-title").text("Card Print");
|
||||||
console.logInfo("everything loaded!");
|
console.logInfo("everything loaded!");
|
||||||
@ -88,7 +92,7 @@ function open(issueKeyList) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function close(){
|
function closePrintPreview(){
|
||||||
console.logInfo("close overlay");
|
console.logInfo("close overlay");
|
||||||
jQuery("#card-print-overlay").remove();
|
jQuery("#card-print-overlay").remove();
|
||||||
jQuery("#card-print-overlay-style").remove();
|
jQuery("#card-print-overlay-style").remove();
|
||||||
@ -145,7 +149,6 @@ function fillCardWithJSONData(card, data) {
|
|||||||
var avatarUrl = assignee.avatarUrls['48x48'];
|
var avatarUrl = assignee.avatarUrls['48x48'];
|
||||||
if(avatarUrl.indexOf("ownerId=") < 0){
|
if(avatarUrl.indexOf("ownerId=") < 0){
|
||||||
var displayName = assignee.displayName;
|
var displayName = assignee.displayName;
|
||||||
//card.find(".assignee").css("background", stringToColor(displayName));
|
|
||||||
card.find(".assignee").text(displayName[0]);
|
card.find(".assignee").text(displayName[0]);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@ -167,7 +170,7 @@ function fillCardWithJSONData(card, data) {
|
|||||||
|
|
||||||
//Attachment
|
//Attachment
|
||||||
var hasAttachment = false;
|
var hasAttachment = false;
|
||||||
var indexOfPrintScopeDeviderToken = ((description.indexOf(printScopeDeviderToken2) + 1) || (description.indexOf(printScopeDeviderToken1) + 1)) - 1;
|
var indexOfPrintScopeDeviderToken = description.indexOf(printScopeDeviderToken);
|
||||||
if (indexOfPrintScopeDeviderToken >= 0) {
|
if (indexOfPrintScopeDeviderToken >= 0) {
|
||||||
var descriptionWithoutAttachment = description.substring(0, indexOfPrintScopeDeviderToken);
|
var descriptionWithoutAttachment = description.substring(0, indexOfPrintScopeDeviderToken);
|
||||||
card.find('.description').html(descriptionWithoutAttachment);
|
card.find('.description').html(descriptionWithoutAttachment);
|
||||||
@ -233,8 +236,7 @@ function fillCardWithJSONDataLRS(card, data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function loadCardDataJSON(issueKey, callback, async) {
|
function loadCardDataJSON(issueKey, callback) {
|
||||||
async = firstNotNull(async, true);
|
|
||||||
|
|
||||||
//https://docs.atlassian.com/jira/REST/latest/
|
//https://docs.atlassian.com/jira/REST/latest/
|
||||||
var url = '/rest/api/2/issue/' + issueKey + '?expand=renderedFields,names';
|
var url = '/rest/api/2/issue/' + issueKey + '?expand=renderedFields,names';
|
||||||
@ -258,7 +260,6 @@ function loadCardDataJSON(issueKey, callback, async) {
|
|||||||
callback(responseData);
|
callback(responseData);
|
||||||
},
|
},
|
||||||
data: {},
|
data: {},
|
||||||
async: async
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -292,24 +293,36 @@ function newPrintOverlayHTML(){
|
|||||||
*/
|
*/
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
// print
|
||||||
|
|
||||||
result.find("#card-print-dialog-print")
|
result.find("#card-print-dialog-print")
|
||||||
.click(function(event){
|
.click(function(event){
|
||||||
jQuery('#card-print-dialog-content-iframe')[0].contentWindow.print();
|
jQuery('#card-print-dialog-content-iframe')[0].contentWindow.print();
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// closePrintPreview
|
||||||
|
|
||||||
result.find("#card-print-dialog-cancel")
|
result.find("#card-print-dialog-cancel")
|
||||||
.click(function(event){
|
.click(function(event){
|
||||||
close();
|
closePrintPreview();
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
result.click(function(event) {
|
result.click(function(event) {
|
||||||
if( event.target == this ){
|
if( event.target == this ){
|
||||||
close();
|
closePrintPreview();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
jQuery(document).keyup(function(e) {
|
||||||
|
if (e.keyCode == 27) { // esc
|
||||||
|
closePrintPreview();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// prevent background scrolling
|
||||||
result.scroll(function(event) {
|
result.scroll(function(event) {
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
@ -574,7 +587,6 @@ body {
|
|||||||
height: 3.2cm;
|
height: 3.2cm;
|
||||||
background: #d0d0d0;
|
background: #d0d0d0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.card {
|
.card {
|
||||||
position: relative;
|
position: relative;
|
||||||
min-width: 21.0cm;
|
min-width: 21.0cm;
|
||||||
@ -598,7 +610,6 @@ body {
|
|||||||
right:0.4cm;
|
right:0.4cm;
|
||||||
height: calc(100% - 4.0cm);
|
height: calc(100% - 4.0cm);
|
||||||
background: #ffffff;
|
background: #ffffff;
|
||||||
|
|
||||||
}
|
}
|
||||||
.card-header {
|
.card-header {
|
||||||
position: relative;
|
position: relative;
|
||||||
@ -655,7 +666,6 @@ body {
|
|||||||
background-position: center;
|
background-position: center;
|
||||||
z-index: 1;
|
z-index: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.card[type="story"] .type-icon {
|
.card[type="story"] .type-icon {
|
||||||
background-color: GOLD;
|
background-color: GOLD;
|
||||||
background-image: url(https://googledrive.com/host/0Bwgd0mVaLU_KU0N5b3JyRnJaNTA/resources/icons/Bulb.png);
|
background-image: url(https://googledrive.com/host/0Bwgd0mVaLU_KU0N5b3JyRnJaNTA/resources/icons/Bulb.png);
|
||||||
@ -668,7 +678,6 @@ body {
|
|||||||
background-color: ROYALBLUE;
|
background-color: ROYALBLUE;
|
||||||
background-image: url(https://googledrive.com/host/0Bwgd0mVaLU_KU0N5b3JyRnJaNTA/resources/icons/Flash.png);
|
background-image: url(https://googledrive.com/host/0Bwgd0mVaLU_KU0N5b3JyRnJaNTA/resources/icons/Flash.png);
|
||||||
}
|
}
|
||||||
|
|
||||||
.estimate {
|
.estimate {
|
||||||
position: relative;
|
position: relative;
|
||||||
float: left;
|
float: left;
|
||||||
@ -683,7 +692,6 @@ body {
|
|||||||
margin-top:1.5cm;
|
margin-top:1.5cm;
|
||||||
z-index: 999;
|
z-index: 999;
|
||||||
}
|
}
|
||||||
|
|
||||||
.due {
|
.due {
|
||||||
position: relative;
|
position: relative;
|
||||||
float: right;
|
float: right;
|
||||||
@ -731,7 +739,6 @@ body {
|
|||||||
-webkit-background-size: 70%;
|
-webkit-background-size: 70%;
|
||||||
background-size: 70%;
|
background-size: 70%;
|
||||||
background-position: center;
|
background-position: center;
|
||||||
|
|
||||||
}
|
}
|
||||||
.assignee {
|
.assignee {
|
||||||
position: relative;
|
position: relative;
|
||||||
@ -792,14 +799,16 @@ body {
|
|||||||
//############################################################################################################################
|
//############################################################################################################################
|
||||||
//############################################################################################################################
|
//############################################################################################################################
|
||||||
//############################################################################################################################
|
//############################################################################################################################
|
||||||
function loadScripts(load, callback){
|
|
||||||
|
|
||||||
load();
|
function getCORS(url, callback){
|
||||||
|
$.get('https://cors-anywhere.herokuapp.com/' + url, callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
function appendScript(url, callback){
|
||||||
|
|
||||||
var head = document.getElementsByTagName('head')[0];
|
var head = document.getElementsByTagName('head')[0];
|
||||||
var script = document.createElement('script');
|
var script = document.createElement('script');
|
||||||
script.src = "https://qoomon.github.io/void.js";
|
script.src = url;
|
||||||
script.async = false;
|
|
||||||
|
|
||||||
// Then bind the event to the callback function.
|
// Then bind the event to the callback function.
|
||||||
// There are several events for cross browser compatibility.
|
// There are several events for cross browser compatibility.
|
||||||
@ -809,23 +818,114 @@ function loadScripts(load, callback){
|
|||||||
head.appendChild(script);
|
head.appendChild(script);
|
||||||
}
|
}
|
||||||
|
|
||||||
function appendScript(src, async) {
|
//############################################################################################################################
|
||||||
var head = document.getElementsByTagName('head')[0];
|
//############################################################################################################################
|
||||||
console.log("add script " + src);
|
//############################################################################################################################
|
||||||
var script = document.createElement('script');
|
|
||||||
script.src = src;
|
function addDeferred(deferredList){
|
||||||
script.async = async;
|
var deferred = new jQuery.Deferred()
|
||||||
head.appendChild(script);
|
deferredList.push(deferred);
|
||||||
|
return deferred;
|
||||||
}
|
}
|
||||||
|
|
||||||
function init() {
|
function applyDeferred(deferredList, callback){
|
||||||
|
jQuery.when.apply(jQuery, deferredList).done(callback);
|
||||||
|
}
|
||||||
|
|
||||||
|
//############################################################################################################################
|
||||||
|
//############################################################################################################################
|
||||||
|
//############################################################################################################################
|
||||||
|
|
||||||
|
|
||||||
|
function addJQueryFunctions() {
|
||||||
//jQuery Extention
|
//jQuery Extention
|
||||||
jQuery.expr[':']['is'] = function(node, index, props){
|
jQuery.expr[':']['is'] = function(node, index, props){
|
||||||
return node.textContent == props[3];
|
return node.textContent == props[3];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
loadLoggingFunctions();
|
|
||||||
loadStringFunctions();
|
function addConsoleFunctions() {
|
||||||
|
|
||||||
|
console.ERROR = 0;
|
||||||
|
console.WARN = 1;
|
||||||
|
console.INFO = 2;
|
||||||
|
console.DEBUG = 3;
|
||||||
|
console.TRACE = 4;
|
||||||
|
|
||||||
|
console.logLevel = console.INFO ;
|
||||||
|
|
||||||
|
console.logError = function(msg){
|
||||||
|
if(console.logLevel >= console.ERROR ) {
|
||||||
|
console.log("ERROR: " + msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
console.logWarn = function(msg){
|
||||||
|
if(console.logLevel >= console.WARN ) {
|
||||||
|
console.log("WARN: " + msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
console.logInfo = function(msg){
|
||||||
|
if(console.logLevel >= console.INFO ) {
|
||||||
|
console.log("INFO: " + msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
console.logDebug = function(msg){
|
||||||
|
if(console.logLevel >= console.DEBUG ) {
|
||||||
|
console.log("DEBUG: " + msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
console.logTrace = function(msg){
|
||||||
|
if(console.logLevel >= console.TRACE ) {
|
||||||
|
console.log("TRACE: " + msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function addStringFunctions() {
|
||||||
|
|
||||||
|
//trim string - remove leading and trailing whitespaces
|
||||||
|
if (!String.prototype.trim) {
|
||||||
|
String.prototype.trim = function() {
|
||||||
|
return this.replace(/^\s+|\s+$/g, '');
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!String.prototype.startsWith) {
|
||||||
|
String.prototype.startsWith = function (str){
|
||||||
|
return this.slice(0, str.length) == str;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!String.prototype.endsWith) {
|
||||||
|
String.prototype.endsWith = function (str){
|
||||||
|
return this.slice(-str.length) == str;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!String.prototype.toCamelCase) {
|
||||||
|
String.prototype.toCamelCase = function() {
|
||||||
|
// remove all characters that should not be in a variable name
|
||||||
|
// as well underscores an numbers from the beginning of the string
|
||||||
|
var s = this.replace(/([^a-zA-Z0-9_\- ])|^[_0-9]+/g, "").trim().toLowerCase();
|
||||||
|
// uppercase letters preceeded by a hyphen or a space
|
||||||
|
s = s.replace(/([ -]+)([a-zA-Z0-9])/g, function(a,b,c) {
|
||||||
|
return c.toUpperCase();
|
||||||
|
});
|
||||||
|
// uppercase letters following numbers
|
||||||
|
s = s.replace(/([0-9]+)([a-zA-Z])/g, function(a,b,c) {
|
||||||
|
return b + c.toUpperCase();
|
||||||
|
});
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function addDateFunctions() {
|
||||||
|
|
||||||
Date.prototype.format = function(format) {
|
Date.prototype.format = function(format) {
|
||||||
var returnStr = '';
|
var returnStr = '';
|
||||||
@ -880,8 +980,7 @@ function init() {
|
|||||||
H: function() { return (this.getHours() < 10 ? '0' : '') + this.getHours(); },
|
H: function() { return (this.getHours() < 10 ? '0' : '') + this.getHours(); },
|
||||||
i: function() { return (this.getMinutes() < 10 ? '0' : '') + this.getMinutes(); },
|
i: function() { return (this.getMinutes() < 10 ? '0' : '') + this.getMinutes(); },
|
||||||
s: function() { return (this.getSeconds() < 10 ? '0' : '') + this.getSeconds(); },
|
s: function() { return (this.getSeconds() < 10 ? '0' : '') + this.getSeconds(); },
|
||||||
u: function() { var m = this.getMilliseconds(); return (m < 10 ? '00' : (m < 100 ?
|
u: function() { var m = this.getMilliseconds(); return (m < 10 ? '00' : (m < 100 ? '0' : '')) + m; },
|
||||||
'0' : '')) + m; },
|
|
||||||
// Timezone
|
// Timezone
|
||||||
e: function() { return "Not Yet Supported"; },
|
e: function() { return "Not Yet Supported"; },
|
||||||
I: function() {
|
I: function() {
|
||||||
@ -889,9 +988,9 @@ function init() {
|
|||||||
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) break;
|
else if (offset < DST) { DST = offset; break; }
|
||||||
|
else if (offset > DST) break;
|
||||||
}
|
}
|
||||||
return (this.getTimezoneOffset() == DST) | 0;
|
return (this.getTimezoneOffset() == DST) | 0;
|
||||||
},
|
},
|
||||||
@ -904,131 +1003,6 @@ function init() {
|
|||||||
r: function() { return this.toString(); },
|
r: function() { return this.toString(); },
|
||||||
U: function() { return this.getTimep() / 1000; }
|
U: function() { return this.getTimep() / 1000; }
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function addGoogleAnalytics() {
|
|
||||||
// Google Analytics
|
|
||||||
(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');
|
|
||||||
}
|
|
||||||
|
|
||||||
function loadLoggingFunctions() {
|
|
||||||
|
|
||||||
console.ERROR = 0;
|
|
||||||
console.WARN = 1;
|
|
||||||
console.INFO = 2;
|
|
||||||
console.DEBUG = 3;
|
|
||||||
console.TRACE = 4;
|
|
||||||
|
|
||||||
console.logLevel = console.INFO ;
|
|
||||||
|
|
||||||
console.logError = function(msg){
|
|
||||||
if(console.logLevel >= console.ERROR ) {
|
|
||||||
console.log("ERROR: " + msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
console.logWarn = function(msg){
|
|
||||||
if(console.logLevel >= console.WARN ) {
|
|
||||||
console.log("WARN: " + msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
console.logInfo = function(msg){
|
|
||||||
if(console.logLevel >= console.INFO ) {
|
|
||||||
console.log("INFO: " + msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
console.logDebug = function(msg){
|
|
||||||
if(console.logLevel >= console.DEBUG ) {
|
|
||||||
console.log("DEBUG: " + msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
console.logTrace = function(msg){
|
|
||||||
if(console.logLevel >= console.TRACE ) {
|
|
||||||
console.log("TRACE: " + msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function loadStringFunctions() {
|
|
||||||
|
|
||||||
//trim string - remove leading and trailing whitespaces
|
|
||||||
if (!String.prototype.trim) {
|
|
||||||
String.prototype.trim = function() {
|
|
||||||
return this.replace(/^\s+|\s+$/g, '');
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!String.prototype.startsWith) {
|
|
||||||
String.prototype.startsWith = function (str){
|
|
||||||
return this.slice(0, str.length) == str;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!String.prototype.endsWith) {
|
|
||||||
String.prototype.endsWith = function (str){
|
|
||||||
return this.slice(-str.length) == str;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!String.prototype.toCamelCase) {
|
|
||||||
String.prototype.toCamelCase = function() {
|
|
||||||
// remove all characters that should not be in a variable name
|
|
||||||
// as well underscores an numbers from the beginning of the string
|
|
||||||
var s = this.replace(/([^a-zA-Z0-9_\- ])|^[_0-9]+/g, "").trim().toLowerCase();
|
|
||||||
// uppercase letters preceeded by a hyphen or a space
|
|
||||||
s = s.replace(/([ -]+)([a-zA-Z0-9])/g, function(a,b,c) {
|
|
||||||
return c.toUpperCase();
|
|
||||||
});
|
|
||||||
// uppercase letters following numbers
|
|
||||||
s = s.replace(/([0-9]+)([a-zA-Z])/g, function(a,b,c) {
|
|
||||||
return b + c.toUpperCase();
|
|
||||||
});
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//############################################################################################################################
|
|
||||||
//############################################################################################################################
|
|
||||||
//############################################################################################################################
|
|
||||||
|
|
||||||
|
|
||||||
function firstNotNull(arg, def) {
|
|
||||||
return (arg != undefined && arg != null) ? arg : def;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function generateHTMLWithAbsolutePathes(html) {
|
|
||||||
var absoultePath = function(index, href) {
|
|
||||||
var link = link || document.createElement("a");
|
|
||||||
link.href = href;
|
|
||||||
return (link.protocol + "//" + link.host + link.pathname + link.search + link.hash);
|
|
||||||
};
|
|
||||||
|
|
||||||
jQuery(html).find('[href]').not('[href^="http"],[href^="https"],[href^="mailto:"],[href^="#"]').each(function() {
|
|
||||||
jQuery(this).attr('href', absoultePath);
|
|
||||||
});
|
|
||||||
jQuery(html).find('[src]').not('[src^="http"],[src^="https"]').each(function() {
|
|
||||||
jQuery(this).attr('src', absoultePath);
|
|
||||||
});
|
|
||||||
|
|
||||||
return html;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function multilineString(commentFunction) {
|
function multilineString(commentFunction) {
|
||||||
@ -1037,69 +1011,7 @@ function multilineString(commentFunction) {
|
|||||||
.replace(/\*\/[^\/]+$/, '');
|
.replace(/\*\/[^\/]+$/, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Retrieve nested item from object/array
|
|
||||||
* @param {Object|Array} obj
|
|
||||||
* @param {String} path dot separated
|
|
||||||
* @param {*} def default value ( if result undefined )
|
|
||||||
* @returns {*}
|
|
||||||
*/
|
|
||||||
function getProperty(obj, path, def){
|
|
||||||
for(var i = 0,path = path.split('.'),len = path.length; i < len; i++){
|
|
||||||
if(!obj || typeof obj !== 'object') return def;
|
|
||||||
obj = obj[path[i]];
|
|
||||||
}
|
|
||||||
|
|
||||||
if(obj === undefined) return def;
|
|
||||||
return obj;
|
|
||||||
}
|
|
||||||
|
|
||||||
function resizeIframe(iframe) {
|
function resizeIframe(iframe) {
|
||||||
iframe.height(iframe[0].contentWindow.document.body.scrollHeight);
|
iframe.height(iframe[0].contentWindow.document.body.scrollHeight);
|
||||||
}
|
}
|
||||||
|
|
||||||
/********************************************************
|
|
||||||
Name: str_to_color
|
|
||||||
Description: create a hash from a string then generates a color
|
|
||||||
Usage: alert('#'+str_to_color("Any string can be converted"));
|
|
||||||
author: Brandon Corbin [code@icorbin.com]
|
|
||||||
website: http://icorbin.com
|
|
||||||
********************************************************/
|
|
||||||
|
|
||||||
function stringToColor(str) {
|
|
||||||
'use strict';
|
|
||||||
// Generate a Hash for the String
|
|
||||||
var hash = function(word) {
|
|
||||||
var h = 0;
|
|
||||||
for (var i = 0; i < word.length; i++) {
|
|
||||||
h = word.charCodeAt(i) + ((h << 5) - h);
|
|
||||||
}
|
|
||||||
return h;
|
|
||||||
};
|
|
||||||
|
|
||||||
// Change the darkness or lightness
|
|
||||||
var shade = function(color, prc) {
|
|
||||||
var num = parseInt(color, 16),
|
|
||||||
amt = Math.round(2.55 * prc),
|
|
||||||
R = (num >> 16) + amt,
|
|
||||||
G = (num >> 8 & 0x00FF) + amt,
|
|
||||||
B = (num & 0x0000FF) + amt;
|
|
||||||
return (0x1000000 + (R < 255 ? R < 1 ? 0 : R : 255) * 0x10000 +
|
|
||||||
(G < 255 ? G < 1 ? 0 : G : 255) * 0x100 +
|
|
||||||
(B < 255 ? B < 1 ? 0 : B : 255))
|
|
||||||
.toString(16)
|
|
||||||
.slice(1);
|
|
||||||
|
|
||||||
};
|
|
||||||
// Convert init to an RGBA
|
|
||||||
var int_to_rgba = function(i) {
|
|
||||||
var color = ((i >> 24) & 0xFF).toString(16) +
|
|
||||||
((i >> 16) & 0xFF).toString(16) +
|
|
||||||
((i >> 8) & 0xFF).toString(16) +
|
|
||||||
(i & 0xFF).toString(16);
|
|
||||||
return color;
|
|
||||||
};
|
|
||||||
|
|
||||||
return '#'+shade(int_to_rgba(hash(str)), -10);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|||||||
12
index.html
12
index.html
@ -1 +1,11 @@
|
|||||||
qoomon.com
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Qoomon</title>
|
||||||
|
<meta http-equiv="refresh" content="1"; url="http://qoomon.blogspot.de/2014/01/jira-issue-card-printer-bookmarklet.html" />
|
||||||
|
<script language="javascript">
|
||||||
|
window.location = "http://qoomon.blogspot.de/2014/01/jira-issue-card-printer-bookmarklet.html";
|
||||||
|
</script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user