-
Notifications
You must be signed in to change notification settings - Fork 0
/
octopus.js
101 lines (81 loc) · 2.9 KB
/
octopus.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
// Release note cache system
var notes = {};
function getNotes(url) {
if(!notes[url]) {
$.get(url, function( data ) {
var content = $($.parseHTML(data));
notes[url] = content.find(".release-header").html() + content.find(".markdown-body").html();
});
return "Loading notes...";
}
return notes[url];
}
function getProject(project) {
switch(project) {
case "Checkout.hub" :
return "checkout-hub";
break;
case "Gateway API" :
case "gateway-api" :
case "gateway-recurring-console" :
case "Gateway Recurring Console" :
return "checkout-merchant-api";
break;
default:
return project;
break;
}
}
var timerModal;
//Init method
function init() {
//wait for Octo to populate the tab
if($("table td[id*='Env']").length > 0) {
var temp = $("table td[id*='Env']");
// each packages
temp.each(function(i) {
var el = temp[i];
var project;
//get project name
if(window.location.hash.indexOf("projects") >= 0) {
project = getProject(window.location.hash.split("/")[window.location.hash.split("/").length - 1]);
}
else {
project = getProject($(el).parent().find("th .media-body").text());
}
// exclude "deploy" button and populated versions
if($(el).find(".version").length == 1 && $(el).find(".release").length == 0) {
//extract version, create URL
var v = $(el).find(".version").text().replace(/\s/g, "");
var url = "https://github.com/CKOTech/"+project+"/releases/tag/"+v.replace(/rc\.0+(\d)/, "rc.$1")
//Add informations
var notes = getNotes(url);
$(el).on("mouseover", function(e) {
var _url = url+"";
$('#cko-tooltip').html(getNotes(_url));
$('#cko-tooltip').show();
$('#cko-tooltip').css("top", $(this).offset().top + $(this).height() + 20);
$('#cko-tooltip').css("left", $(this).offset().left - $('#cko-tooltip').width() / 2 + $(this).width() / 2);
if(timerModal) clearTimeout(timerModal);
timerModal = setTimeout(function() {
$('#cko-tooltip').fadeOut();
}, 3000);
})
$(el).on("mouseout", function(e) {
$('#cko-tooltip').hide();
if(timerModal) clearTimeout(timerModal);
})
//create link
//$(el).append("<a class='release' href='"+url+"'>Release Notes</a>")
}
})
}
//We want to retry if the tab isn't populated, or start again if Octo refreshed the grid
setTimeout(init, 100);
}
init();
// Window modal
$("body").append("<div id='cko-tooltip'"+
" style='box-shadow: 0 19px 38px rgba(0,0,0,0.30), 0 15px 12px rgba(0,0,0,0.22); padding:30px;position:absolute;"+
" top:100px; left:0px; overflow : hidden; z-index:999999; min-width:300px; min-height:50px;max-width:600px; max-height:800px;border:1px silver solid; background:white; display:none;'"+
"></div>")