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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
<h3>{{lang_branchesHeading}}</h3>
<div class="clearfix"></div>
<div id="ibm-mainframe">
{{#branches}}
<a id="a-{{bid}}"></a>
<div class="panel panel-default" {{#color}}style="background:linear-gradient(90deg, {{color}} 0%, {{color}} 4px, rgba(255,255,255,0) 4px)"{{/color}}>
<div class="panel-heading">
<div class="pull-right slx-pointer" data-toggle="collapse" data-target="#{{bid}}">
{{sourceid}} {{branchid}} <b class="caret"></b>
</div>
<b>{{title}}</b>
</div>
<div class="collapse in branch-item" id="{{bid}}">
<div class="panel-body">
{{description}}
</div>
{{{versionlist}}}
</div>
</div>
{{/branches}}
</div>
<script>
document.addEventListener('DOMContentLoaded', function () {
var hash = window.location.hash.replaceAll('/', '-');
// Highlight
var $tr = $(hash);
if ($tr.length > 0) {
$tr.addClass('bg-info');
setTimeout(function () {
$tr[0].scrollIntoView();
}, 10);
}
// Remember collapsed state
var c = localStorage.getItem('ml-collapse');
if (c) {
c = JSON.parse(c);
for (var e in c) {
if (c.hasOwnProperty(e) && !hash.startsWith('#' + e.substring(4))) {
$('#' + e).collapse('hide');
}
}
} else {
c = {};
}
$('.branch-item').on('hide.bs.collapse', function() {
c[this.id] = true;
localStorage.setItem('ml-collapse', JSON.stringify(c));
}).on('show.bs.collapse', function() {
delete c[this.id];
localStorage.setItem('ml-collapse', JSON.stringify(c));
});
// Button magic
var addHandlers = function(parent) {
parent.find('.btn-verify').click(function() {
loadDetails($(this).data('version'), { show: "version", verify: 1 });
});
parent.find('.btn-download').click(function() {
loadDetails($(this).data('version'), { show: "download" });
$(this).remove();
});
};
var loadDetails = function(version, params) {
var c = $('.version-container[data-version="' + version + '"]');
c.show();
if (c.is(':empty')) {
c.html('<span class="glyphicon glyphicon-refresh slx-rotation"></span>');
} else {
c.addClass('slx-fade');
c.find('button, a').addClass('disabled').prop('disabled', true);
}
var data = { version: version, token: TOKEN };
$.extend(data, params);
c.load('?do=minilinux', data,
function () {
c.removeClass('slx-fade');
addHandlers(c);
c.find('button[data-confirm]').click(slxModalConfirmHandler);
tmInit();
});
};
$('.version-link').click(function(e) {
e.preventDefault();
var ver = $(this).data('version');
var c = $('.version-container[data-version="' + ver + '"]');
if (c.is(':visible')) {
c.hide();
} else if (c.is(':empty')) {
loadDetails(ver, {show: "version"});
} else {
c.show();
}
});
addHandlers($('#ibm-mainframe'));
$('[data-autoclick="true"]').click();
});
var taskDone = {};
var wasUnfinished = false;
var errors = {};
function dlTmCb(task) {
if (!task.data || !task.data.files)
return;
if (task.data.error) {
if (errors[task.id] !== task.data.error) {
errors[task.id] = task.data.error;
$('#error-' + task.id).text(errors[task.id]).show();
}
}
for (var i = 0; i < task.data.files.length; ++i) {
var f = task.data.files[i];
var id = task.id + f.id;
if (taskDone[id] === true)
continue;
var $div = $('#' + f.id);
if (f.error) {
$div.text(f.error).addClass('text-danger');
taskDone[id] = true;
} else {
var wasDone = (taskDone[id] === 100);
tmSetProgress($div, f.progress, wasDone ? 'TASK_FINISHED' : task.statusCode);
taskDone[id] = wasDone ? true : f.progress;
}
}
if (wasUnfinished && task.statusCode === 'TASK_FINISHED') location.reload(true);
if (task.statusCode !== 'TASK_FINISHED') wasUnfinished = true;
}
</script>
|