-
Notifications
You must be signed in to change notification settings - Fork 0
/
jira_task_printing.user.js
75 lines (74 loc) · 2.43 KB
/
jira_task_printing.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// ==UserScript==
// @name jira_task_printing
// @namespace aaron
// @include http://manjraprd01/secure/Print.jspa?*
// @version 1
// @grant none
// ==/UserScript==
(function(){
loadRS([
['http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js', function(){return typeof jQuery === 'undefined';}],
['http://code.jquery.com/ui/1.10.3/jquery-ui.js','http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css', function(){return typeof jQuery === 'undefined' || typeof jQuery.ui === 'undefined';}]
],function(){
var timeout = navigator && navigator.appName && navigator.appName.indexOf('icrosoft') != -1 ? 2000 : 100;
setTimeout(function(){
loadRS([
['https://rawgithub.com/kiinoo/utilities/master/jira_cards_printing_utils.js', function(){return typeof withjQuery !== 'function';}]
],function(){
if(jQuery('#menu').length == 0){
withjQuery(jQuery);
withjQueryUI(jQuery);
}
});
}, timeout);
});
function loadRS (resources, callback) {
var loader = function(src,handler){
var ext = src.split('.').pop().toLowerCase();
var rEL;
if(ext !== 'css') {
rEL = document.createElement('script');
rEL.src = src;
}else{
rEL = document.createElement('link');
rEL.href = src;
rEL.rel = 'stylesheet';
}
rEL.onload = rEL.onreadystatechange = function(){
console.log('loaded ' + src);
rEL.onreadystatechange = rEL.onload = null;
handler();
};
var head = document.getElementsByTagName('head')[0];
(head || document.body).appendChild( rEL );
};
var multiloader = function(item, next){
var fns = arguments;
if(typeof item === 'string'){
loader(item, next);
} else if(Object.prototype.toString.call(item) === '[object Array]'){
var predict = item[item.length - 1];
if(typeof predict === 'function'){
item.pop();
} else {
predict = null;
}
var shouldLoad = !predict || predict();
(function(){
if(item.length!=0 && shouldLoad){
loader(item.shift(), arguments.callee);
} else {
next && next();
}
})();
}
};
(function(){
if(resources.length!=0){
multiloader(resources.shift(),arguments.callee);
}else{
callback && callback();
}
})();
}
})();