<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>